/* ══════════════════════════════════════════════
   MEGADADOS 2.0 — Design System
   ══════════════════════════════════════════════ */

:root {
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --brand: #0B1D32;
    --brand-light: #112B47;
    --brand-accent: #4FC0D0;
    --brand-accent-hover: #6DD5E3;
    --surface: #F7F8FA;
    --card: #FFFFFF;
    --text-primary: #1A2332;
    --text-secondary: #5F6D7E;
    --text-muted: #97A3B6;
    --border: #E4E7EC;
    --border-light: #F0F2F5;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
    --shadow: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; }
body {
    font-family: 'DM Sans', -apple-system, sans-serif;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--surface);
    margin: 0;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-accent); text-decoration: none; }
a:hover { color: var(--brand-accent-hover); }

/* ── Layout ── */
.app-layout {
    display: flex;
    min-height: 100vh;
}
.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.app-content {
    padding: 24px;
    flex: 1;
}

/* ── Sidebar ── */
.app-sidebar {
    width: var(--sidebar-width);
    background: var(--brand);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition);
    overflow-y: auto;
    overflow-x: hidden;
}
.app-sidebar::-webkit-scrollbar { width: 4px; }
.app-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.brand-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--brand-accent), #1B6B93);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    color: #fff;
    letter-spacing: -0.5px;
}
.brand-name {
    font-weight: 700;
    font-size: 15px;
    color: #fff;
    letter-spacing: 1px;
}
.brand-version {
    font-size: 11px;
    color: rgba(255,255,255,0.4);
    font-weight: 500;
}

.sidebar-nav {
    flex: 1;
    padding: 8px 0;
}
.nav-section {
    padding: 4px 0;
}
.nav-label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: rgba(255,255,255,0.3);
    padding: 12px 20px 6px;
}
.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    color: rgba(255,255,255,0.6);
    font-size: 13.5px;
    font-weight: 450;
    transition: all var(--transition);
    border-left: 3px solid transparent;
    text-decoration: none;
}
.nav-link:hover {
    color: #fff;
    background: rgba(255,255,255,0.06);
}
.nav-link.active {
    color: #fff;
    background: rgba(79,192,208,0.12);
    border-left-color: var(--brand-accent);
}
.nav-link i, .nav-link [data-lucide] {
    width: 18px;
    height: 18px;
    opacity: 0.7;
    flex-shrink: 0;
}
.nav-link.active i, .nav-link.active [data-lucide] {
    opacity: 1;
    color: var(--brand-accent);
}
.nav-badge {
    margin-left: auto;
    background: rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.7);
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    font-family: 'JetBrains Mono', monospace;
}

.sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.4);
    font-size: 12px;
}
.status-dot {
    width: 7px;
    height: 7px;
    background: #27AE60;
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(39,174,96,0.5);
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1035;
    display: none;
}
.btn-close-sidebar {
    background: none;
    border: none;
    margin-left: auto;
    padding: 4px;
    cursor: pointer;
    line-height: 0;
}
.border-dashed { border-style: dashed !important; }

/* ── Topbar ── */
.app-topbar {
    height: var(--topbar-height);
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}
.topbar-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}
.topbar-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0;
}
.topbar-search {
    position: relative;
}
.topbar-search svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}
.topbar-search input {
    width: 280px;
    padding: 8px 12px 8px 36px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    background: var(--surface);
    transition: all var(--transition);
}
.topbar-search input:focus {
    outline: none;
    border-color: var(--brand-accent);
    box-shadow: 0 0 0 3px rgba(79,192,208,0.15);
    background: #fff;
}
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: none;
    max-height: 320px;
    overflow-y: auto;
    margin-top: 4px;
    z-index: 200;
}
.search-results.show { display: block; }
.search-result-item {
    padding: 10px 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background var(--transition);
    border-bottom: 1px solid var(--border-light);
}
.search-result-item:hover { background: var(--surface); }

.avatar-sm {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--brand-accent), #1B6B93);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
}

.topbar-user .btn {
    border: none;
    background: none;
    padding: 4px 8px;
    color: var(--text-primary);
    font-size: 13px;
}

/* ── Cards ── */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    background: var(--card);
}
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-light);
    padding: 16px 20px;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-body { padding: 20px; }
.card-footer {
    background: transparent;
    border-top: 1px solid var(--border-light);
    padding: 12px 20px;
}

/* ── Stats Cards ── */
.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: all var(--transition);
    box-shadow: var(--shadow-sm);
}
.stat-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}
.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.stat-icon [data-lucide], .stat-icon svg { width: 22px; height: 22px; }
.stat-icon.blue { background: rgba(79,192,208,0.12); color: #4FC0D0; }
.stat-icon.green { background: rgba(39,174,96,0.12); color: #27AE60; }
.stat-icon.orange { background: rgba(242,153,74,0.12); color: #F2994A; }
.stat-icon.purple { background: rgba(130,87,229,0.12); color: #8257E5; }
.stat-icon.red { background: rgba(235,87,87,0.12); color: #EB5757; }
.stat-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.1;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
}
.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
    font-weight: 500;
}
.stat-change {
    font-size: 11px;
    font-weight: 600;
    margin-top: 4px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 6px;
    border-radius: 4px;
}
.stat-change.up { color: #27AE60; background: rgba(39,174,96,0.1); }
.stat-change.down { color: #EB5757; background: rgba(235,87,87,0.1); }

/* ── Tables ── */
.table {
    font-size: 13px;
}
.table thead th {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    padding: 10px 14px;
    white-space: nowrap;
    background: var(--surface);
}
.table tbody td {
    padding: 12px 14px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
}
.table tbody tr:hover { background: rgba(79,192,208,0.03); }
.table-link {
    color: var(--text-primary);
    font-weight: 500;
    text-decoration: none;
}
.table-link:hover { color: var(--brand-accent); }

/* ── Buttons ── */
.btn {
    font-family: inherit;
    font-weight: 500;
    font-size: 13px;
    border-radius: 8px;
    padding: 8px 16px;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn [data-lucide], .btn svg { width: 16px; height: 16px; }
.btn-primary {
    background: var(--brand-accent);
    border-color: var(--brand-accent);
    color: var(--brand);
    font-weight: 600;
}
.btn-primary:hover {
    background: var(--brand-accent-hover);
    border-color: var(--brand-accent-hover);
    color: var(--brand);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79,192,208,0.3);
}
.btn-outline-secondary {
    border-color: var(--border);
    color: var(--text-secondary);
}
.btn-outline-secondary:hover {
    background: var(--surface);
    border-color: var(--text-muted);
    color: var(--text-primary);
}
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-sm [data-lucide], .btn-sm svg { width: 14px; height: 14px; }

/* ── Badges ── */
.badge {
    font-family: inherit;
    font-weight: 600;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 5px;
}

/* ── Forms ── */
.form-control, .form-select {
    font-family: inherit;
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 12px;
    transition: all var(--transition);
    color: var(--text-primary);
}
.form-control:focus, .form-select:focus {
    border-color: var(--brand-accent);
    box-shadow: 0 0 0 3px rgba(79,192,208,0.15);
}
.form-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 4px;
}

/* ── Alerts ── */
.alert {
    border-radius: var(--radius);
    font-size: 13px;
    border: none;
    padding: 12px 16px;
}

/* ── Pagination ── */
.page-link {
    font-size: 13px;
    color: var(--text-secondary);
    border-color: var(--border);
    padding: 6px 12px;
    display: flex;
    align-items: center;
}
.page-item.active .page-link {
    background: var(--brand-accent);
    border-color: var(--brand-accent);
    color: var(--brand);
}

/* ── Empty State ── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state [data-lucide], .empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
    opacity: 0.3;
}
.empty-state h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.empty-state p { font-size: 13px; }

/* ── Tags ── */
.tag-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}
.tag-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ── Score Bar ── */
.score-bar {
    width: 60px;
    height: 6px;
    background: var(--border-light);
    border-radius: 3px;
    overflow: hidden;
    display: inline-block;
    vertical-align: middle;
}
.score-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

/* ── Chart Container ── */
.chart-container {
    position: relative;
    width: 100%;
}

/* ── Login Page ── */
.login-page {
    min-height: 100vh;
    display: flex;
    background: var(--brand);
}
.login-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    background: linear-gradient(135deg, var(--brand) 0%, #112B47 100%);
    color: #fff;
}
.login-right {
    width: 480px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    padding: 40px;
}
.login-box { width: 100%; max-width: 360px; }
.login-box h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text-primary);
}
.login-box p {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 28px;
}
.login-left h1 {
    font-size: 42px;
    font-weight: 700;
    letter-spacing: -1px;
}
.login-left .tagline {
    font-size: 16px;
    opacity: 0.6;
    margin-top: 8px;
    max-width: 360px;
    text-align: center;
    line-height: 1.6;
}
.login-features {
    margin-top: 40px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.login-feature {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    opacity: 0.7;
}
.login-feature-icon {
    width: 36px;
    height: 36px;
    background: rgba(79,192,208,0.2);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ── Utilities ── */
.text-mono { font-family: 'JetBrains Mono', monospace; }
.gap-row { row-gap: 16px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }

/* ── Responsive ── */
@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
    }
    .app-sidebar.show {
        transform: translateX(0);
    }
    .app-sidebar.show ~ .sidebar-overlay {
        display: block;
    }
    .app-main {
        margin-left: 0;
    }
    .app-content {
        padding: 16px;
    }
    .login-left { display: none; }
    .login-right { width: 100%; }
}

@media (max-width: 575.98px) {
    .stat-value { font-size: 22px; }
    .topbar-title { font-size: 15px; }
}
