/* ══════════════════════════════════════════════
   Admin View — Refined Clinical Luxe
   ══════════════════════════════════════════════ */

.admin-container {
    display: flex;
    min-height: calc(100vh - 80px);
    gap: var(--space-8);
    animation: fadeIn var(--duration-slow) var(--ease-out);
}

/* ── Sidebar ── */
.sidebar {
    width: 240px;
    flex-shrink: 0;
    position: sticky;
    top: 80px;
    align-self: flex-start;
    padding-top: var(--space-4);
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-menu li {
    padding: 11px 16px;
    cursor: pointer;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.875rem;
    transition: all var(--duration-fast) var(--ease-out);
    position: relative;
    overflow: hidden;
}

.sidebar-menu li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    background: var(--primary);
    border-radius: 0 var(--radius-full) var(--radius-full) 0;
    transition: height var(--duration-normal) var(--ease-spring);
}

.sidebar-menu li:hover {
    background: var(--bg-sunken);
    color: var(--text-primary);
}

.sidebar-menu li.active {
    background: var(--primary-subtle);
    color: var(--primary);
    font-weight: 600;
}

.sidebar-menu li.active::before {
    height: 60%;
}

.main-content {
    flex: 1;
    padding: 0 0 var(--space-12) 0;
    overflow-y: auto;
    min-width: 0;
}

/* ── Dashboard Cards ── */
.card-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-5);
    margin-bottom: var(--space-8);
}

.card-container > .card {
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    padding: var(--space-5) var(--space-6);
    border-left: none;
    position: relative;
    overflow: hidden;
}

.card-container > .card::after {
    content: '';
    position: absolute;
    top: -20px;
    right: -20px;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.06), transparent);
    pointer-events: none;
}

.card-container > .card h3 {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    line-height: 1.4;
}

.card .value {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-top: var(--space-3);
    line-height: 1;
    letter-spacing: -0.04em;
    font-variant-numeric: tabular-nums;
}

/* ── Chart ── */
.chart-row {
    display: flex;
    gap: var(--space-5);
    margin-bottom: var(--space-6);
    flex-wrap: wrap;
}

.chart-container {
    background: var(--bg-raised);
    padding: var(--space-6);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    flex: 1;
    min-width: 320px;
    transition: all var(--duration-normal) var(--ease-out);
}

.chart-container:hover {
    box-shadow: var(--shadow-md);
}

.chart-container h3 {
    margin: 0 0 var(--space-5) 0;
    font-size: 0.9375rem;
    color: var(--text-primary);
    font-weight: 700;
    letter-spacing: -0.01em;
}

/* ── Data Tables ── */
.table-container {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-raised);
    box-shadow: var(--shadow-xs);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-raised);
    font-size: 0.85rem;
}

.data-table th, .data-table td {
    padding: 14px 20px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}

.data-table th {
    background: var(--bg-sunken);
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.6875rem;
    letter-spacing: 0.06em;
    position: sticky;
    top: 0;
    z-index: 1;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr {
    transition: background var(--duration-fast) ease;
}

.data-table tbody tr:hover td {
    background: var(--bg-sunken);
}

/* ── Table Action Buttons ── */
.btn-small {
    padding: 5px 12px;
    font-size: 0.75rem;
    margin-left: var(--space-2);
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border);
    cursor: pointer;
    font-weight: 600;
    font-family: inherit;
    background: var(--bg-raised);
    color: var(--text-secondary);
    transition: all var(--duration-fast) ease;
}

.btn-small:hover {
    background: var(--bg-sunken);
    color: var(--text-primary);
    border-color: var(--text-tertiary);
    transform: translateY(-1px);
}

.btn-edit {
    color: var(--primary);
    border-color: rgba(79, 70, 229, 0.2);
    background: var(--primary-subtle);
}
.btn-edit:hover {
    background: rgba(79, 70, 229, 0.12);
    color: var(--primary-dark);
}

/* ── Status Indicators ── */
.status-active {
    color: var(--success);
    font-weight: 700;
}
.status-inactive {
    color: var(--danger);
    font-weight: 700;
}

/* ── Section Headers ── */
.main-content h2 {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.main-content h3 {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text-secondary);
}

/* ── Heatmap cells ── */
#heatmap-container > div {
    border-radius: 3px;
    transition: transform var(--duration-fast) ease;
}

#heatmap-container > div:hover {
    transform: scale(1.3);
    z-index: 2;
    position: relative;
}
/* ============================================================
   PATCH: admin.css — Estilos corrigidos para seção OCR
   ============================================================
   PROBLEMAS CORRIGIDOS:
     1. Layout quebrado do card de upload (elementos sobrepostos)
     2. Botão "Processar" fora do card
     3. Nome do arquivo sobrepondo a drop zone
     4. Adicionados estilos faltantes para resultados OCR
     5. Melhorada responsividade
   ============================================================
   INSTRUÇÕES: Substituir toda a seção OCR no admin.css
   (de .ocr-layout até o final dos estilos OCR)
   ============================================================ */

/* ── OCR Page Description ── */
.ocr-page-desc {
    font-size: 0.9rem;
    color: var(--text-tertiary, #64748b);
    margin: 4px 0 0 0;
}

/* ── OCR Layout Grid ── */
.ocr-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-6, 24px);
    align-items: start;
    animation: fadeInUp 400ms var(--ease-out) both;
    max-width: 1200px;
}

.ocr-layout.has-results {
    grid-template-columns: 400px 1fr;
}

@media (max-width: 900px) {
    .ocr-layout,
    .ocr-layout.has-results {
        grid-template-columns: 1fr;
    }
}

/* ── Upload Card ── */
.ocr-upload-card {
    background: var(--bg-raised, #ffffff);
    padding: 28px;
    border-radius: var(--radius-lg, 16px);
    box-shadow: var(--shadow-sm, 0 1px 3px rgba(0, 0, 0, 0.08));
    border: 1px solid var(--border, #e2e8f0);
    height: fit-content;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* ── Upload Card Header ── */
.ocr-upload-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
}

.ocr-icon-wrapper {
    width: 44px;
    height: 44px;
    background: var(--primary-subtle, rgba(79, 70, 229, 0.08));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ocr-section-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0 0 2px 0;
    color: var(--text-primary, #1e293b);
    line-height: 1.3;
}

.ocr-hint {
    font-size: 0.8rem;
    color: var(--text-tertiary, #64748b);
    margin: 0;
    line-height: 1.3;
}

/* ── Drop Zone ── */
.ocr-file-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 36px 24px;
    border: 2px dashed var(--border-light, #cbd5e1);
    border-radius: var(--radius-lg, 12px);
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--bg-sunken, #f8fafc);
    text-align: center;
    margin-bottom: 16px;
}

.ocr-file-label:hover,
.ocr-drop-active {
    border-color: var(--primary, #4f46e5);
    background: var(--primary-subtle, rgba(79, 70, 229, 0.04));
}

.ocr-file-icon {
    font-size: 2.2rem;
    color: var(--primary-light, #818cf8);
    transition: transform 0.2s, color 0.2s;
}

.ocr-file-label:hover .ocr-file-icon,
.ocr-drop-active .ocr-file-icon {
    color: var(--primary, #4f46e5);
    transform: translateY(-3px);
}

.ocr-file-text {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
    margin: 0;
}

.ocr-file-sub {
    font-size: 0.78rem;
    color: var(--text-tertiary, #64748b);
    margin: 0;
}

/* ── File Name Indicator ── */
.ocr-file-name {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    margin-bottom: 16px;
    background: var(--success-subtle, rgba(16, 185, 129, 0.08));
    color: var(--success-dark, #065f46);
    border-radius: var(--radius-md, 8px);
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid rgba(16, 185, 129, 0.2);
    gap: 8px;
    word-break: break-all;
}

/* ── Process Button ── */
.ocr-process-btn {
    width: 100%;
    padding: 13px 20px;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: var(--radius-md, 8px);
    font-weight: 600;
    transition: all 0.2s ease;
}

.ocr-process-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ── Results Card ── */
.ocr-results-card {
    background: var(--bg-raised, #ffffff);
    padding: 28px;
    border-radius: var(--radius-lg, 16px);
    box-shadow: var(--shadow-sm, 0 1px 3px rgba(0, 0, 0, 0.08));
    border: 1px solid var(--border, #e2e8f0);
    min-width: 0;
}

/* ── Results Header ── */
.ocr-results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.ocr-results-header h3 {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary, #1e293b);
}

/* ── Results Subtitle ── */
.ocr-results-subtitle {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-tertiary, #64748b);
    margin: 20px 0 10px 0;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-light, #e2e8f0);
}

/* ── Extracted Fields Grid ── */
.ocr-fields-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 8px;
}

@media (max-width: 600px) {
    .ocr-fields-grid {
        grid-template-columns: 1fr;
    }
}

.ocr-field {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 10px 12px;
    background: var(--bg-sunken, #f8fafc);
    border-radius: var(--radius-sm, 6px);
    border: 1px solid var(--border-light, #e2e8f0);
}

.ocr-field-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary, #64748b);
}

.ocr-field-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
    word-break: break-word;
}

/* ── No CIDs message ── */
.ocr-no-cids {
    font-size: 0.85rem;
    color: var(--text-tertiary, #94a3b8);
    font-style: italic;
    padding: 12px 0;
    margin: 0;
}

/* ── Raw Text Details ── */
.ocr-raw-details {
    margin-top: 20px;
    border: 1px solid var(--border-light, #e2e8f0);
    border-radius: var(--radius-md, 8px);
    overflow: hidden;
}

.ocr-raw-details summary {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary, #475569);
    background: var(--bg-sunken, #f8fafc);
    user-select: none;
    transition: background 0.15s;
}

.ocr-raw-details summary:hover {
    background: var(--bg-sunken, #f1f5f9);
}

.ocr-raw-details[open] summary {
    border-bottom: 1px solid var(--border-light, #e2e8f0);
}

.ocr-raw-text {
    padding: 14px;
    margin: 0;
    font-size: 0.78rem;
    line-height: 1.6;
    color: var(--text-secondary, #475569);
    background: var(--bg-raised, #ffffff);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 300px;
    overflow-y: auto;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}