/* ==========================================================================
   FILE: style.css
   SISTEM INFORMASI REKAPITULASI PEMILU DPR RI 2024 - DAPIL JAWA TIMUR IX
   ========================================================================== */
:root {
    --bg-main: #f1f5f9;
    --bg-card: #ffffff;
    --navy-900: #0f172a;
    --navy-800: #1e293b;
    --navy-700: #1f3864;
    --blue-600: #2563eb;
    --blue-500: #3b82f6;
    --blue-50: #eff6ff;
    --emerald-600: #059669;
    --emerald-100: #d1fae5;
    --amber-600: #d97706;
    --amber-100: #fef3c7;
    --rose-600: #e11d48;
    --rose-100: #ffe4e6;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
    --radius-md: 10px;
    --radius-lg: 14px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    display: flex;
    min-height: 100vh;
}

/* Sidebar Navigation */
.sidebar {
    width: 270px;
    background: linear-gradient(180deg, var(--navy-900) 0%, var(--navy-700) 100%);
    color: #fff;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    box-shadow: 4px 0 16px rgba(15, 23, 42, 0.15);
}

.sidebar-brand {
    padding: 22px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand .badge-kpu {
    display: inline-block;
    background: rgba(59, 130, 246, 0.25);
    border: 1px solid rgba(96, 165, 250, 0.4);
    color: #93c5fd;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 99px;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.sidebar-brand h1 {
    font-size: 16px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.35;
}

.sidebar-brand p {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 4px;
}

.nav-menu {
    list-style: none;
    padding: 16px 12px;
    flex: 1;
}

.nav-item {
    margin-bottom: 6px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.nav-link.active {
    background: var(--blue-600);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 11.5px;
    color: #94a3b8;
}

/* Main Content Wrapper */
.main-content {
    margin-left: 270px;
    flex: 1;
    padding: 26px 32px 48px;
    max-width: calc(100vw - 270px);
}

/* Top Header Bar */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    padding: 18px 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.top-bar-title h2 {
    font-size: 19px;
    font-weight: 700;
    color: var(--navy-900);
}

.top-bar-title p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.top-bar-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.18s ease;
    text-decoration: none;
}

.btn-primary {
    background: var(--blue-600);
    color: #ffffff;
}

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-outline {
    background: #ffffff;
    border-color: var(--border-color);
    color: var(--text-primary);
}

.btn-outline:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

/* KPI Metric Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    background: var(--bg-card);
    padding: 18px 20px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--blue-600);
}

.kpi-card.emerald::before { background: var(--emerald-600); }
.kpi-card.amber::before { background: var(--amber-600); }
.kpi-card.rose::before { background: var(--rose-600); }

.kpi-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
}

.kpi-value {
    font-size: 24px;
    font-weight: 800;
    color: var(--navy-900);
    margin: 6px 0 4px;
}

.kpi-sub {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Tab Sections */
.tab-section {
    display: none;
}

.tab-section.active {
    display: block;
    animation: fadeIn 0.25s ease;
}

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

/* Cards & Containers */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    overflow: hidden;
}

.card-header {
    padding: 16px 22px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
    flex-wrap: wrap;
    gap: 10px;
}

.card-header h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--navy-800);
}

.card-body {
    padding: 20px 22px;
}

/* Cascading Filter Panel (Modul Pencarian Berjenjang) */
.cascading-panel {
    background: linear-gradient(135deg, #f8fafc 0%, #eff6ff 100%);
    border: 1px solid #bfdbfe;
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
}

.cascading-steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(195px, 1fr));
    gap: 14px;
    align-items: end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-group label {
    font-size: 12px;
    font-weight: 700;
    color: var(--navy-800);
    display: flex;
    align-items: center;
    gap: 6px;
}

.step-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--blue-600);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
}

.form-control {
    padding: 9px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-primary);
    background: #ffffff;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    width: 100%;
}

.form-control:focus {
    border-color: var(--blue-600);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.range-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

/* Tables */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table thead th {
    background: var(--navy-700);
    color: #ffffff;
    font-weight: 600;
    text-align: left;
    padding: 11px 14px;
    border: 1px solid #2e4a7d;
    white-space: nowrap;
}

.data-table thead th.text-right,
.data-table tbody td.text-right,
.data-table tfoot td.text-right {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.data-table thead th.text-center,
.data-table tbody td.text-center {
    text-align: center;
}

.data-table tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.data-table tbody tr:hover {
    background-color: #f1f5f9;
}

.data-table tr.row-partai {
    background-color: #f1f5f9;
    font-weight: 700;
}

.data-table tr.row-subtotal {
    background-color: #e2e8f0;
    font-weight: 700;
}

.data-table tr.row-total,
.data-table tfoot tr {
    background-color: #dcfce7;
    font-weight: 800;
    color: #064e3b;
    border-top: 2px solid #059669;
    border-bottom: 3px double #059669;
}

.data-table tr.row-section td {
    background-color: #dbeafe;
    color: var(--navy-700);
    font-weight: 800;
    font-size: 13.5px;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 6px;
}

.badge-a1 {
    background: #dbeafe;
    color: #1e40af;
}

.badge-a2 {
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #cbd5e1;
}

.badge-win {
    background: var(--emerald-100);
    color: var(--emerald-600);
    border: 1px solid #6ee7b7;
}

.badge-fail {
    background: var(--rose-100);
    color: var(--rose-600);
}

.highlight-col {
    background-color: #fef9c3 !important;
    font-weight: 700;
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

@media (max-width: 1024px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
    .sidebar {
        position: static;
        width: 100%;
    }
    body {
        flex-direction: column;
    }
    .main-content {
        margin-left: 0;
        max-width: 100%;
        padding: 16px;
    }
}

@media print {
    .sidebar, .top-bar-actions, .cascading-panel {
        display: none !important;
    }
    .main-content {
        margin-left: 0 !important;
        max-width: 100% !important;
        padding: 0 !important;
    }
    .tab-section {
        display: block !important;
        page-break-after: always;
    }
}