/* ==========================================================================
   MVP OMR — Design System
   Fonte: Inter (Google Fonts)
   Paleta: Dark mode com acento azul-violeta
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Reset & Custom Properties
   -------------------------------------------------------------------------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Cores base */
    --bg-page:        #0d0f14;
    --bg-surface:     #141720;
    --bg-surface-2:   #1c2030;
    --bg-surface-3:   #222840;

    /* Acento */
    --accent:         #6366f1;
    --accent-hover:   #4f52d9;
    --accent-glow:    rgba(99, 102, 241, 0.25);
    --accent-light:   rgba(99, 102, 241, 0.12);

    /* Sucesso */
    --success:        #22c55e;
    --success-light:  rgba(34, 197, 94, 0.12);

    /* Erro */
    --error:          #ef4444;
    --error-light:    rgba(239, 68, 68, 0.12);

    /* Aviso */
    --warning:        #f59e0b;

    /* Texto */
    --text-primary:   #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted:     #475569;

    /* Bordas */
    --border:         rgba(255, 255, 255, 0.08);
    --border-focus:   rgba(99, 102, 241, 0.6);

    /* Dimensões */
    --radius-sm:      6px;
    --radius-md:      12px;
    --radius-lg:      18px;
    --radius-xl:      24px;

    /* Sombras */
    --shadow-card:    0 4px 32px rgba(0, 0, 0, 0.4);
    --shadow-glow:    0 0 40px var(--accent-glow);

    /* Tipografia */
    --font:           'Inter', system-ui, sans-serif;
}

/* --------------------------------------------------------------------------
   2. Base
   -------------------------------------------------------------------------- */
body {
    font-family: var(--font);
    background-color: var(--bg-page);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* Gradiente de fundo sutil */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 50% at 20% -10%, rgba(99, 102, 241, 0.08) 0%, transparent 60%),
        radial-gradient(ellipse 60% 40% at 80% 110%, rgba(99, 102, 241, 0.06) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

/* --------------------------------------------------------------------------
   3. Layout
   -------------------------------------------------------------------------- */
.page-wrapper {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main {
    flex: 1;
    max-width: 780px;
    width: 100%;
    margin: 0 auto;
    padding: 24px 16px 48px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* --------------------------------------------------------------------------
   4. Header
   -------------------------------------------------------------------------- */
.header {
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(10px);
    background: rgba(13, 15, 20, 0.7);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 780px;
    margin: 0 auto;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    color: var(--text-secondary);
}

.logo-icon {
    font-size: 22px;
    color: var(--accent);
    filter: drop-shadow(0 0 8px var(--accent));
}

.logo-text strong {
    color: var(--text-primary);
}

.badge {
    font-size: 12px;
    font-weight: 500;
    padding: 4px 12px;
    border-radius: 999px;
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    color: var(--text-muted);
    transition: all 0.4s ease;
}

.badge.online {
    color: var(--success);
    border-color: rgba(34, 197, 94, 0.3);
    background: var(--success-light);
}

.badge.offline {
    color: var(--error);
    border-color: rgba(239, 68, 68, 0.3);
    background: var(--error-light);
}

/* --------------------------------------------------------------------------
   5. Cards
   -------------------------------------------------------------------------- */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 32px;
    box-shadow: var(--shadow-card);
    transition: border-color 0.3s ease;
}

.card-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.card-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 28px;
}

/* --------------------------------------------------------------------------
   6. Drop Zone / Upload
   -------------------------------------------------------------------------- */
.drop-zone {
    position: relative;
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    min-height: 220px;
    cursor: pointer;
    transition: border-color 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.drop-zone:hover,
.drop-zone:focus-visible {
    border-color: var(--accent);
    background: var(--accent-light);
    box-shadow: var(--shadow-glow);
    outline: none;
}

.drop-zone.drag-over {
    border-color: var(--accent);
    background: var(--accent-light);
    box-shadow: var(--shadow-glow);
    transform: scale(1.01);
}

.drop-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

/* Idle state */
.drop-zone-idle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 32px;
    pointer-events: none;
    text-align: center;
}

.drop-icon {
    font-size: 48px;
    margin-bottom: 8px;
    filter: grayscale(0.3);
}

.drop-text {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.drop-hint {
    font-size: 13px;
    color: var(--text-secondary);
}

.drop-formats {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 8px;
    letter-spacing: 0.05em;
}

/* Preview state */
.drop-zone-preview {
    width: 100%;
    height: 100%;
    position: relative;
}

.drop-zone-preview img {
    width: 100%;
    max-height: 320px;
    object-fit: contain;
    display: block;
    border-radius: var(--radius-md);
}

.preview-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 16px;
    background: linear-gradient(transparent, rgba(13, 15, 20, 0.9));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.preview-filename {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.preview-change-btn {
    font-family: var(--font);
    font-size: 12px;
    font-weight: 500;
    color: var(--accent);
    background: none;
    border: 1px solid rgba(99, 102, 241, 0.4);
    border-radius: var(--radius-sm);
    padding: 4px 10px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.preview-change-btn:hover {
    background: var(--accent-light);
    border-color: var(--accent);
}

/* --------------------------------------------------------------------------
   7. Botão Processar
   -------------------------------------------------------------------------- */
.btn-process {
    margin-top: 20px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: none;
    border-radius: var(--radius-md);
    background: var(--accent);
    color: white;
    font-family: var(--font);
    font-size: 15px;
    font-weight: 600;
    padding: 14px 24px;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
    letter-spacing: 0.02em;
}

.btn-process:hover:not(:disabled) {
    background: var(--accent-hover);
    box-shadow: 0 0 20px var(--accent-glow);
    transform: translateY(-1px);
}

.btn-process:active:not(:disabled) {
    transform: translateY(0);
}

.btn-process:disabled {
    background: var(--bg-surface-3);
    color: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
}

/* Spinner dentro do botão */
.btn-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
}

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

/* --------------------------------------------------------------------------
   8. Resultado
   -------------------------------------------------------------------------- */
.result-card {
    animation: slideUp 0.35s ease both;
}

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

.result-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.result-title {
    font-size: 18px;
    font-weight: 700;
}

.result-filename {
    font-size: 12px;
    color: var(--text-muted);
    font-family: monospace;
    background: var(--bg-surface-2);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

/* Stats bar */
.stats-bar {
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.stat-item {
    flex: 1;
    min-width: 120px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-winner {
    align-items: center;
    text-align: center;
}

.stat-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.stat-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.stat-unit {
    font-size: 11px;
    color: var(--text-muted);
}

.stat-badge {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-light);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 999px;
    padding: 4px 12px;
}

.stat-divider {
    width: 1px;
    height: 40px;
    background: var(--border);
    flex-shrink: 0;
}

.result-nota {
    font-size: 13px;
    color: var(--text-secondary);
    background: var(--bg-surface-2);
    border-left: 3px solid var(--accent);
    padding: 10px 14px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin-bottom: 20px;
    line-height: 1.5;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}

.tab {
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 10px 16px;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
    margin-bottom: -1px;
}

.tab:hover {
    color: var(--text-secondary);
}

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* Texto do resultado */
.result-text {
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    line-height: 1.7;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-word;
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    max-height: 420px;
    overflow-y: auto;
}

.result-text::-webkit-scrollbar {
    width: 6px;
}

.result-text::-webkit-scrollbar-track {
    background: transparent;
}

.result-text::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

/* --------------------------------------------------------------------------
   9. Error Banner
   -------------------------------------------------------------------------- */
.error-banner {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--error-light);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    animation: slideUp 0.3s ease both;
}

.error-icon {
    font-size: 18px;
    flex-shrink: 0;
    color: var(--error);
}

.error-message {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* --------------------------------------------------------------------------
   10. Footer
   -------------------------------------------------------------------------- */
.footer {
    text-align: center;
    padding: 16px;
    font-size: 12px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}

/* --------------------------------------------------------------------------
   11. Responsividade
   -------------------------------------------------------------------------- */
@media (max-width: 600px) {
    .card {
        padding: 20px;
    }

    .card-title {
        font-size: 18px;
    }

    .stats-bar {
        flex-direction: column;
    }

    .stat-divider {
        width: 100%;
        height: 1px;
    }

    .result-header {
        flex-direction: column;
    }

    .header-inner {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }
}