/* ============================================================
   Airlanes Monitor — Clean, Minimal Interface
   ============================================================ */

:root {
    --bg: #fafbfc;
    --white: #ffffff;
    --text: #1a1a2e;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
    --border: #e5e7eb;
    --border-light: #f3f4f6;
    --radius: 16px;
    --radius-sm: 8px;
    --sidebar-width: 220px;
}

/* ---- Reset ---- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 14px;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: none; color: var(--accent-hover); }

/* ============================================================
   LAYOUT
   ============================================================ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--white);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 200;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 2rem 1.5rem 1.75rem;
}

.sidebar-brand-title {
    color: var(--text);
    font-size: 0.9375rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.sidebar-brand-sub {
    font-size: 0.6875rem;
    color: var(--text-tertiary);
    margin-top: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sidebar-nav {
    flex: 1;
    padding: 0 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.sidebar-nav a {
    display: block;
    padding: 0.5rem 0.75rem;
    border-left: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.12s ease;
    text-decoration: none;
}

.sidebar-nav a:hover {
    color: var(--text);
    text-decoration: none;
}

.sidebar-nav a.active {
    color: var(--accent);
    border-left-color: var(--accent);
    font-weight: 600;
}

.sidebar-footer {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border);
    font-size: 0.6875rem;
    color: var(--text-tertiary);
    line-height: 1.6;
}

/* ---- Main Content ---- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 52px;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.02em;
}

.topbar-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: var(--text-tertiary);
}

.topbar-breadcrumb a {
    color: var(--text-secondary);
}

.topbar-breadcrumb a:hover {
    color: var(--accent);
}

.topbar-breadcrumb .sep {
    color: var(--border);
    font-size: 0.625rem;
}

.content-area {
    flex: 1;
    padding: 2rem 2.5rem 3rem;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-header {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 1.25rem;
    letter-spacing: -0.02em;
}

/* ============================================================
   STAT CARDS
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.1;
    letter-spacing: -0.03em;
}

.stat-label {
    font-size: 0.6875rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.35rem;
    font-weight: 500;
}

/* ============================================================
   GRID LAYOUTS
   ============================================================ */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1.5rem;
}

.grid-65-35 {
    display: grid;
    grid-template-columns: 65fr 35fr;
    gap: 1.5rem;
}

/* ============================================================
   TABLES
   ============================================================ */
.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

thead th {
    color: var(--text-tertiary);
    font-weight: 500;
    text-transform: uppercase;
    font-size: 0.6875rem;
    letter-spacing: 0.05em;
    padding: 0 0.75rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
    color: var(--text);
}

tbody tr:hover td {
    background: var(--bg);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* ============================================================
   SCORE (plain colored number)
   ============================================================ */
.score {
    font-weight: 700;
    font-size: 0.875rem;
    font-variant-numeric: tabular-nums;
}

.score-high { color: var(--success); }
.score-mid { color: var(--warning); }
.score-low { color: var(--text-tertiary); }

/* Large score for detail page */
.score-large {
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1;
}

/* ============================================================
   BADGES (restrained - only for class & status)
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.badge-class {
    background: #f3f4f6;
    color: var(--text-secondary);
}

.badge-status {
    background: #f3f4f6;
    color: var(--text-secondary);
}

.badge-status.s-em_analise { background: #dbeafe; color: #1e40af; }
.badge-status.s-recomendado { background: #fef3c7; color: #92400e; }
.badge-status.s-aprovado { background: #d1fae5; color: #065f46; }
.badge-status.s-peticionado { background: #dbeafe; color: #1e40af; }
.badge-status.s-descartado { background: #fee2e2; color: #991b1b; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text-tertiary);
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-family: inherit;
    color: var(--text);
    background: var(--white);
    transition: border-color 0.15s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

/* ---- Filter Bar ---- */
.filters-bar {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
}

.filters-bar .form-group {
    margin-bottom: 0;
    flex: 1;
    min-width: 120px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.12s ease;
    font-family: inherit;
    line-height: 1.4;
}

.btn:hover { text-decoration: none; }

.btn-primary { background: var(--accent); color: var(--white); }
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary { background: var(--white); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-secondary:hover { background: #f9fafb; }

.btn-sm { padding: 0.3rem 0.75rem; font-size: 0.75rem; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    margin-top: 1.25rem;
    padding: 0.75rem;
}

.pagination a,
.pagination span {
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.pagination a:hover {
    background: var(--border-light);
}

.pagination .active {
    background: var(--accent);
    color: var(--white);
}

.pagination .disabled {
    color: var(--border);
    pointer-events: none;
}

/* ============================================================
   DETAIL PAGE
   ============================================================ */
.detail-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.02em;
    margin-bottom: 1rem;
}

.detail-meta {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.meta-pair {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.8125rem;
}

.meta-pair:last-child {
    border-bottom: none;
}

.meta-key {
    color: var(--text-tertiary);
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
    width: 140px;
}

.meta-val {
    color: var(--text);
    text-align: right;
    flex: 1;
}

.detail-text {
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1.25rem;
    font-size: 0.8125rem;
    line-height: 1.8;
    white-space: pre-wrap;
    max-height: 400px;
    overflow-y: auto;
    color: var(--text-secondary);
}

/* ============================================================
   LOG AREA
   ============================================================ */
.log-area {
    background: #0d1117;
    color: #7ee787;
    font-family: "Cascadia Code", "Fira Code", "Consolas", monospace;
    font-size: 0.75rem;
    padding: 1.25rem;
    border-radius: var(--radius-sm);
    height: 420px;
    overflow-y: auto;
    line-height: 1.6;
}

.log-area .log-error { color: #f85149; }
.log-area .log-warn { color: #d29922; }
.log-area .log-info { color: #58a6ff; }

/* ============================================================
   THEME LIST (simple text + count)
   ============================================================ */
.theme-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.theme-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.625rem 0.5rem;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.8125rem;
    border-radius: 6px;
    margin: 0 -0.5rem;
    transition: background 0.15s;
}

.theme-row:hover {
    background: var(--bg);
}

.theme-row:last-child {
    border-bottom: none;
}

.theme-name {
    color: var(--text);
    font-weight: 500;
}

.theme-count {
    color: var(--text-secondary);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* ============================================================
   REPORT ITEMS (simplified)
   ============================================================ */
.report-item {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.report-item-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
}

.report-item-desc {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.5;
    flex: 1;
}

/* ============================================================
   SECTION LABEL
   ============================================================ */
.section-label {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 2rem 0 1rem;
}

/* ============================================================
   UTILITY
   ============================================================ */
.truncate {
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.truncate-sm {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

a.case-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

a.case-link:hover {
    text-decoration: underline;
}

.text-muted { color: var(--text-tertiary); }
.text-sm { font-size: 0.75rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-tertiary);
}

.empty-state p {
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .grid-3 {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .content-area {
        padding: 1rem;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .grid-2, .grid-3, .grid-65-35 {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}
