/*
   CalcImov - Premium Real Estate Theme
   Design System variables
*/
:root {
    --color-bg: #090a0f;
    --color-surface: rgba(26, 29, 41, 0.4);
    --color-surface-border: rgba(255, 255, 255, 0.08);
    --color-primary: #3b82f6;
    --color-primary-hover: #2563eb;
    --color-accent: #10b981;
    --color-text: #f8fafc;
    --color-text-muted: #94a3b8;
    --color-input-bg: rgba(15, 23, 42, 0.6);
    --color-input-border: rgba(59, 130, 246, 0.2);
    --color-input-focus: rgba(59, 130, 246, 0.5);

    --radius-lg: 16px;
    --radius-md: 10px;
    --radius-sm: 6px;

    --transition-fast: 0.2s ease;
    --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Base Reset & Typography */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: linear-gradient(135deg, #0a0e1a 0%, #0f1729 40%, #111827 70%, #0d1117 100%);
    color: var(--color-text);
    font-family: var(--font-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow-x: hidden;
}

/* Background Grid Texture */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(59, 130, 246, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(59, 130, 246, 0.03) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
    z-index: 0;
}

/* Container & Layout */
.container {
    width: 100%;
    max-width: 800px;
    padding: 2rem;
    position: relative;
    z-index: 1;
}

.hero {
    text-align: center;
    margin-bottom: 2.5rem;
}

.hero h1 {
    font-size: 3.5rem;
    font-weight: 700;
    letter-spacing: -1px;
    margin-bottom: 0.5rem;
    text-shadow: 0 0 40px rgba(59, 130, 246, 0.4);
}

.hero h1 .highlight {
    background: linear-gradient(135deg, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero p {
    color: var(--color-text-muted);
    font-size: 1.1rem;
    font-weight: 300;
}

/* Glassmorphism Form */
.glass-form {
    background: var(--color-surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--color-surface-border);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-group.row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-text);
    margin-left: 0.2rem;
}

input, select {
    background: var(--color-input-bg);
    border: 1px solid var(--color-input-border);
    color: var(--color-text);
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: var(--transition-smooth);
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
}

select:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

input:focus, select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px var(--color-input-focus);
    background: rgba(15, 23, 42, 0.8);
}

input::placeholder {
    color: var(--color-text-muted);
    opacity: 0.5;
}

/* Button & Action Area */
.action-row {
    margin-top: 1rem;
    display: flex;
    justify-content: center;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary), #2563eb);
    color: white;
    border: none;
    padding: 1.1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    width: 100%;
    transition: var(--transition-smooth);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    overflow: hidden;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -10px rgba(59, 130, 246, 0.5);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary.loading .btn-text {
    opacity: 0;
}

.btn-primary.loading .loader-spinner {
    display: block !important;
}

/* Animated Spinner */
.loader-spinner {
    position: absolute;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* NBR Disclaimer */
.nbr-text {
    font-size: 0.78rem;
    color: var(--color-text-muted);
    text-align: center;
    padding: 0 1rem;
    line-height: 1.4;
    opacity: 0.7;
}

/* Status Message */
.status-message {
    text-align: center;
    font-size: 0.9rem;
    font-weight: 500;
    min-height: 20px;
    margin-top: 0.5rem;
    opacity: 0;
    transition: var(--transition-fast);
}

.status-message.success {
    color: var(--color-accent);
    opacity: 1;
}

.status-message.error {
    color: #ef4444;
    opacity: 1;
}

.status-message.loading {
    color: var(--color-text-muted);
    opacity: 1;
}

.required-asterisk {
    color: #ef4444;
    font-weight: bold;
    margin-left: 0.1rem;
}

/* Responsive constraints */
@media (max-width: 768px) {
    .form-group.row {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .glass-form {
        padding: 1.5rem;
    }
}

/* Download Section */
.download-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1.25rem;
    padding: 1.25rem;
    border-radius: var(--radius-md);
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.25);
    animation: fadeInUp 0.4s ease forwards;
}

.samples-count {
    font-size: 0.85rem;
    color: var(--color-accent);
    font-weight: 500;
}

.btn-download {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.5rem;
    background: var(--color-accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-main);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.btn-download:hover {
    background: #059669;
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.35);
}

.btn-download:active {
    transform: translateY(0);
}

.btn-cancel {
    padding: 0.45rem 1.2rem;
    background: rgba(239, 68, 68, 0.12);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-md);
    font-family: var(--font-main);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.btn-cancel:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: rgba(239, 68, 68, 0.5);
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* TD-05: Progress Steps — track horizontal com pulse animation */
.progress-steps {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 0;
    padding: 1rem 0.5rem 0.75rem;
    background: rgba(59, 130, 246, 0.05);
    border: 1px solid rgba(59, 130, 246, 0.12);
    border-radius: var(--radius-md);
    animation: fadeInUp 0.3s ease forwards;
    overflow: visible;
}

.progress-step {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    gap: 0.4rem;
    transition: var(--transition-fast);
}

/* Linha conectora entre etapas */
.progress-step:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 7px;
    left: 50%;
    width: 100%;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    z-index: 0;
    transition: background var(--transition-smooth);
}

.progress-step.done:not(:last-child)::after {
    background: rgba(16, 185, 129, 0.5);
}

/* Ícone circular de cada etapa */
.step-icon {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.04);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.55rem;
    font-weight: 700;
    color: var(--color-text-muted);
    flex-shrink: 0;
    position: relative;
    z-index: 1;
    margin: 0 auto;
    transition: var(--transition-smooth);
}

.progress-step.done .step-icon {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: #fff;
}

.progress-step.active .step-icon {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
    animation: step-pulse 1.8s ease-in-out infinite;
}

@keyframes step-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.5); }
    50%       { box-shadow: 0 0 0 5px rgba(59, 130, 246, 0); }
}

/* Labels de cada etapa */
.step-label {
    font-size: 0.62rem;
    color: var(--color-text-muted);
    opacity: 0.45;
    line-height: 1.3;
    transition: var(--transition-fast);
    padding: 0 0.1rem;
}

.progress-step.done .step-label {
    color: var(--color-accent);
    opacity: 0.75;
}

.progress-step.active .step-label {
    color: var(--color-primary);
    opacity: 1;
    font-weight: 500;
}

/* Mobile: voltar para lista vertical */
@media (max-width: 520px) {
    .progress-steps {
        flex-direction: column;
        gap: 0.3rem;
        padding: 0.75rem 1rem;
    }

    .progress-step {
        flex-direction: row;
        text-align: left;
        align-items: center;
        gap: 0.6rem;
    }

    .progress-step:not(:last-child)::after {
        display: none;
    }

    .step-label {
        opacity: 1;
    }
}

/* TD-06: Histórico de pesquisas */
.history-section {
    margin-top: 1.5rem;
    background: var(--color-surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--color-surface-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    animation: fadeInUp 0.4s ease forwards;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.history-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
}

.btn-history-toggle {
    background: none;
    border: 1px solid var(--color-surface-border);
    color: var(--color-text-muted);
    padding: 0.3rem 0.75rem;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-history-toggle:hover {
    border-color: var(--color-primary);
    color: var(--color-text);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.history-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--color-surface-border);
    gap: 1rem;
    flex-wrap: wrap;
}

.history-card.status-done {
    border-color: rgba(16, 185, 129, 0.2);
}

.history-card.status-error {
    border-color: rgba(239, 68, 68, 0.2);
}

.history-card-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.history-location {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-text);
}

.history-meta {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.history-card-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.history-status {
    font-size: 0.78rem;
    color: var(--color-text-muted);
}

.history-card.status-done .history-status {
    color: var(--color-accent);
}

.history-card.status-error .history-status {
    color: #ef4444;
}

.btn-history-download {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.75rem;
    background: var(--color-accent);
    color: #fff;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition-fast);
}

.btn-history-download:hover {
    background: #059669;
}
