/* ============================================================
   style.css — Design System for Processo Jurídico Parser
   Colors: Deep blue (#0B1437), White, Accent blue (#2563EB)
   Font: Inter (Google Fonts)
   ============================================================ */

/* ── CSS Variables ──────────────────────────────────────────── */
:root {
    --bg: #f0f4ff;
    --sidebar-bg: #0B1437;
    --panel-bg: #ffffff;
    --accent: #2563EB;
    --accent-hover: #1d4ed8;
    --accent-light: #eff6ff;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .08), 0 1px 2px rgba(0, 0, 0, .06);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, .10);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, .15);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --transition: 0.18s ease;
    --sidebar-w: 280px;
}

/* ── Reset ────────────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--sidebar-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 0 0 24px;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 28px 24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 8px;
}

.sidebar-logo .logo-icon {
    width: 40px;
    height: 40px;
    background: var(--accent);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-logo .logo-icon svg {
    color: #fff;
}

.sidebar-logo h1 {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
}

.sidebar-logo p {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.45);
    margin-top: 2px;
}

.sidebar-section {
    padding: 0 16px;
    margin-bottom: 6px;
}

.sidebar-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.35);
    padding: 16px 8px 8px;
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed rgba(255, 255, 255, 0.18);
    border-radius: var(--radius);
    padding: 24px 16px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: rgba(255, 255, 255, 0.04);
    margin-bottom: 8px;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--accent);
    background: rgba(37, 99, 235, 0.12);
}

.drop-zone .drop-icon {
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 10px;
}

.drop-zone h3 {
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
}

.drop-zone p {
    color: rgba(255, 255, 255, 0.4);
    font-size: 11px;
}

.drop-zone input[type="file"] {
    display: none;
}

.file-name {
    font-size: 11px;
    color: var(--success);
    display: none;
    padding: 6px 0 0;
    word-break: break-all;
    line-height: 1.4;
}

.file-name.visible {
    display: block;
}

/* Filter Form */
.filter-group {
    margin-bottom: 14px;
}

.filter-group label {
    font-size: 11px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.55);
    display: block;
    margin-bottom: 5px;
    letter-spacing: 0.02em;
}

.filter-group select,
.filter-group input[type="date"],
.filter-group input[type="number"],
.filter-group input[type="text"] {
    width: 100%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-xs);
    color: #fff;
    font-size: 12px;
    padding: 8px 10px;
    outline: none;
    transition: var(--transition);
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
}

.filter-group select:focus,
.filter-group input:focus {
    border-color: var(--accent);
    background: rgba(37, 99, 235, 0.15);
}

.filter-group select option {
    background: #0B1437;
    color: #fff;
}

.filter-row {
    display: flex;
    gap: 8px;
}

.filter-row .filter-group {
    flex: 1;
}

/* Sidebar Buttons */
.btn-primary {
    width: 100%;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
    margin-top: 4px;
    letter-spacing: 0.01em;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-ghost {
    width: 100%;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    padding: 9px 16px;
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: var(--transition);
    margin-top: 8px;
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.2);
}

/* ── Main Content ─────────────────────────────────────────── */
.main {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Topbar */
.topbar {
    background: var(--panel-bg);
    border-bottom: 1px solid var(--border);
    padding: 0 32px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

.topbar h2 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.topbar p {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 1px;
}

/* Counter Stats */
.stats-row {
    display: flex;
    gap: 16px;
    padding: 24px 32px 0;
    flex-wrap: wrap;
}

.stat-card {
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    flex: 1;
    min-width: 140px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon--blue {
    background: #eff6ff;
    color: var(--accent);
}

.stat-icon--green {
    background: #ecfdf5;
    color: var(--success);
}

.stat-icon--orange {
    background: #fffbeb;
    color: var(--warning);
}

.stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}

.stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
    font-weight: 500;
}

/* Progress */
.progress-wrap {
    margin: 20px 32px 0;
    display: none;
}

.progress-track {
    height: 8px;
    background: var(--border);
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #60a5fa);
    border-radius: 999px;
    width: 0%;
    transition: width 0.3s ease;
}

.progress-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 6px;
    text-align: right;
}

/* ── Content Area ─────────────────────────────────────────── */
.content {
    padding: 20px 32px 40px;
    flex: 1;
}

/* Export bar */
.export-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.export-bar span {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-right: 4px;
}

/* Search Bar */
.search-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0 14px;
    height: 40px;
    width: 100%;
    max-width: 400px;
    transition: var(--transition);
}

.search-wrap:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-wrap svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-wrap input {
    border: none;
    outline: none;
    background: transparent;
    font-size: 13px;
    color: var(--text-primary);
    width: 100%;
    font-family: inherit;
}

.btn-export {
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}

.btn-export:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

.btn-export:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}



/* Table */
.table-section {
    display: none;
}

.table-card {
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.table-scroll {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

thead th {
    background: #f8fafc;
    padding: 12px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    color: var(--text-primary);
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: var(--accent-light);
}

.td-processo {
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 11px;
    color: var(--accent);
    font-weight: 600;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.td-tribunal {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.badge-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    background: var(--accent-light);
    color: var(--accent);
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
}

.badge-age {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 8px;
    background: #ecfdf5;
    color: var(--success);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

/* Preview button */
.btn-preview {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    width: 32px;
    height: 32px;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-preview:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-light);
}

/* Empty State */
#empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 32px;
    text-align: center;
    gap: 16px;
}

#empty-state .empty-icon {
    color: var(--text-muted);
    opacity: 0.4;
}

#empty-state h3 {
    font-size: 16px;
    color: var(--text-secondary);
    font-weight: 600;
}

#empty-state p {
    font-size: 13px;
    color: var(--text-muted);
    max-width: 380px;
    line-height: 1.6;
}

/* Logs */
#logs-section {
    display: none;
    margin-top: 24px;
}

.logs-card {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: var(--radius);
    overflow: hidden;
}

.logs-header {
    padding: 14px 20px;
    border-bottom: 1px solid #fde68a;
    font-size: 13px;
    font-weight: 700;
    color: #92400e;
    display: flex;
    align-items: center;
    gap: 8px;
}

.logs-list {
    list-style: none;
    max-height: 220px;
    overflow-y: auto;
}

.log-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 20px;
    font-size: 12px;
    border-bottom: 1px solid #fde68a;
}

.log-item:last-child {
    border-bottom: none;
}

.log-idx {
    color: var(--warning);
    font-weight: 700;
    min-width: 32px;
}

.log-proc {
    color: var(--text-primary);
    font-weight: 600;
    min-width: 120px;
}

.log-warnings {
    color: #92400e;
    flex: 1;
}

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(11, 20, 55, 0.65);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    padding: 24px;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal-box {
    background: var(--panel-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-width: 680px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    transform: scale(0.96);
    transition: transform 0.2s ease;
}

.modal-overlay.active .modal-box {
    transform: scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--panel-bg);
    z-index: 1;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: 1px solid var(--border);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-xs);
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    line-height: 1;
    transition: var(--transition);
}

.modal-close:hover {
    background: #fee2e2;
    color: var(--danger);
    border-color: var(--danger);
}

#modal-content {
    padding: 24px;
}

/* Preview grid */
.preview-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.preview-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: var(--bg);
    border-radius: var(--radius-xs);
    padding: 12px 14px;
}

.preview-field--full {
    grid-column: 1 / -1;
}

.preview-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.preview-value {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 500;
    word-break: break-word;
}

.preview-value a {
    color: var(--accent);
    text-decoration: none;
}

.preview-value a:hover {
    text-decoration: underline;
}

.preview-divider {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent);
    margin-top: 4px;
}

.preview-divider::before,
.preview-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* ── Toast ────────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    background: var(--text-primary);
    color: #fff;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    max-width: 340px;
    line-height: 1.4;
    transform: translateY(80px);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    pointer-events: none;
}

.toast--visible {
    transform: translateY(0);
    opacity: 1;
}

.toast--success {
    background: var(--success);
}

.toast--error {
    background: var(--danger);
}

.toast--info {
    background: var(--info);
}

/* ── Spinner ──────────────────────────────────────────────── */
.btn-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 900px) {
    .sidebar {
        position: relative;
        width: 100%;
        min-width: unset;
        min-height: unset;
        flex-direction: row;
        flex-wrap: wrap;
        padding: 12px;
    }

    .main {
        margin-left: 0;
    }

    body {
        flex-direction: column;
    }

    .stats-row {
        padding: 16px 16px 0;
        gap: 10px;
    }

    .content {
        padding: 16px 16px 40px;
    }

    .topbar {
        padding: 0 16px;
    }

    .progress-wrap {
        margin: 14px 16px 0;
    }
}

@media (max-width: 600px) {
    .preview-grid {
        grid-template-columns: 1fr;
    }

    .stat-card {
        min-width: 100%;
    }
}