@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary: #e97216;
    --primary-dark: #c75f0e;
    --primary-light: #f5a623;
    --secondary: #ff8c38;
    --accent: #e97216;
    --success: #27ae60;
    --danger: #e74c3c;
    --warning: #f39c12;
    --info: #3498db;
    --bg-body: #f4f6f9;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #fef7f0;
    --text-primary: #2c3e50;
    --text-secondary: #636e72;
    --text-muted: #95a5a6;
    --border-color: #e8e8e8;
    --sidebar-width: 260px;
    --gradient-1: linear-gradient(135deg, #e97216 0%, #f5a623 100%);
    --gradient-2: linear-gradient(135deg, #ff8c38 0%, #ffb347 100%);
    --gradient-3: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    --gradient-4: linear-gradient(135deg, #3498db 0%, #5dade2 100%);
    --gradient-5: linear-gradient(135deg, #e74c3c 0%, #ec7063 100%);
    --shadow-card: 0 2px 12px rgba(0,0,0,0.06);
    --shadow-glow: 0 4px 20px rgba(233,114,22,0.15);
}

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

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform .3s ease;
    box-shadow: 2px 0 8px rgba(0,0,0,0.04);
}

.sidebar-brand {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    text-align: center;
    background: var(--gradient-1);
}

.sidebar-brand h4 {
    color: #fff;
    font-weight: 800;
    font-size: 1.1rem;
    letter-spacing: .5px;
}

.sidebar-brand small {
    color: rgba(255,255,255,.8);
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.sidebar-menu .menu-label {
    padding: .5rem 1.5rem;
    font-size: .65rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-muted);
    font-weight: 600;
}

.sidebar-menu .nav-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .7rem 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: .85rem;
    font-weight: 500;
    transition: all .2s;
    border-left: 3px solid transparent;
    margin: 2px 0;
}

.sidebar-menu .nav-link:hover {
    color: var(--primary);
    background: #fef7f0;
    border-left-color: var(--primary-light);
}

.sidebar-menu .nav-link.active {
    color: var(--primary);
    background: #fef0e0;
    border-left-color: var(--primary);
    font-weight: 600;
}

.sidebar-menu .nav-link i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background: #fafafa;
}

.sidebar-footer .user-info {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.sidebar-footer .user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--gradient-1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .8rem;
    color: #fff;
}

.sidebar-footer .user-name { font-size: .8rem; font-weight: 600; color: var(--text-primary); }
.sidebar-footer .user-role { font-size: .65rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    padding: 2rem;
}

.page-header {
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.page-header .breadcrumb-text {
    font-size: .8rem;
    color: var(--text-muted);
}

/* ===== STAT CARDS ===== */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    transition: all .3s ease;
    box-shadow: var(--shadow-card);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-card), var(--shadow-glow);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 4px;
}

.stat-card.gradient-1::before { background: var(--gradient-1); }
.stat-card.gradient-2::before { background: var(--gradient-2); }
.stat-card.gradient-3::before { background: var(--gradient-3); }
.stat-card.gradient-4::before { background: var(--gradient-4); }
.stat-card.gradient-5::before { background: var(--gradient-5); }

.stat-card .stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: #fff;
    margin-bottom: 1rem;
}

.stat-card .stat-icon.gi-1 { background: var(--gradient-1); }
.stat-card .stat-icon.gi-2 { background: var(--gradient-2); }
.stat-card .stat-icon.gi-3 { background: var(--gradient-3); }
.stat-card .stat-icon.gi-4 { background: var(--gradient-4); }
.stat-card .stat-icon.gi-5 { background: var(--gradient-5); }

.stat-card .stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: .25rem;
    color: var(--text-primary);
}

.stat-card .stat-label {
    font-size: .75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

/* ===== CHART CARD ===== */
.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--shadow-card);
    margin-bottom: 1.5rem;
}

.chart-card .card-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: .5rem;
    color: var(--text-primary);
}

.chart-card .card-title i {
    color: var(--primary);
}

/* ===== TABLE ===== */
.table-custom {
    background: transparent;
    color: var(--text-primary);
    font-size: .82rem;
}

.table-custom thead th {
    background: #fef0e0;
    border-bottom: 2px solid var(--primary);
    color: var(--primary-dark);
    font-weight: 600;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: .75rem;
    white-space: nowrap;
}

.table-custom tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background .2s;
}

.table-custom tbody tr:hover {
    background: #fef7f0;
}

.table-custom td {
    padding: .65rem .75rem;
    vertical-align: middle;
    border: none;
}

/* ===== BADGE ===== */
.badge-rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px; height: 26px;
    border-radius: 8px;
    font-size: .7rem;
    font-weight: 700;
    color: #fff;
}

.badge-rank.gold { background: linear-gradient(135deg, #f39c12, #e67e22); }
.badge-rank.silver { background: linear-gradient(135deg, #bdc3c7, #95a5a6); }
.badge-rank.bronze { background: linear-gradient(135deg, #e67e22, #d35400); }
.badge-rank.normal { background: #dfe6e9; color: var(--text-secondary); }

/* ===== LOGIN PAGE ===== */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e97216 0%, #f5a623 50%, #fff8f0 100%);
    position: relative;
}

.login-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 3rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 8px 40px rgba(0,0,0,.1);
    position: relative;
    z-index: 1;
}

.login-card h3 {
    text-align: center;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: .25rem;
}

.login-card .subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: .82rem;
    margin-bottom: 2rem;
}

.form-floating-dark .form-control {
    background: #fafafa;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 12px;
    padding: .75rem 1rem;
    font-size: .85rem;
    transition: border-color .3s, box-shadow .3s;
}

.form-floating-dark .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(233,114,22,.15);
    background: #fff;
}

.form-floating-dark label {
    color: var(--text-muted);
    font-size: .82rem;
}

.btn-primary-gradient {
    background: var(--gradient-1);
    border: none;
    color: #fff;
    font-weight: 600;
    padding: .75rem;
    border-radius: 12px;
    font-size: .9rem;
    transition: all .3s;
    letter-spacing: .5px;
}

.btn-primary-gradient:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(233,114,22,.35);
    color: #fff;
}

/* ===== TABS ===== */
.nav-tabs-custom {
    border: none;
    gap: .5rem;
    margin-bottom: 1.5rem;
}

.nav-tabs-custom .nav-link {
    background: #fef0e0;
    border: 1px solid #f5d6b0;
    border-radius: 12px;
    color: var(--primary-dark);
    font-size: .8rem;
    font-weight: 600;
    padding: .6rem 1.2rem;
    transition: all .2s;
}

.nav-tabs-custom .nav-link:hover {
    background: #fce4c8;
    border-color: var(--primary);
}

.nav-tabs-custom .nav-link.active {
    background: var(--gradient-1);
    border-color: transparent;
    color: #fff;
}

/* ===== PROGRESS BAR ===== */
.progress-bar-custom {
    height: 8px;
    background: #eee;
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-custom .bar {
    height: 100%;
    border-radius: 4px;
}

/* ===== RESPONSIVE ===== */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 1rem; left: 1rem;
    z-index: 1100;
    background: #fff;
    border: 1px solid var(--border-color);
    color: var(--primary);
    width: 40px; height: 40px;
    border-radius: 10px;
    font-size: 1.1rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-card);
}

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .main-content { margin-left: 0; padding: 1rem; padding-top: 4rem; }
    .sidebar-toggle { display: flex; }
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.4);
        z-index: 999;
        display: none;
    }
    .sidebar-overlay.show { display: block; }
}

/* ===== HTML BAR CHART ===== */
.html-bar-chart {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.html-bar-chart .bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.html-bar-chart .bar-label {
    width: 110px;
    min-width: 110px;
    font-size: .72rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.html-bar-chart .bar-track {
    flex: 1;
    height: 18px;
    background: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
}

.html-bar-chart .bar-fill {
    height: 100%;
    border-radius: 4px;
}

.html-bar-chart .bar-value {
    width: 110px;
    min-width: 110px;
    font-size: .72rem;
    font-weight: 600;
    color: #000; /* Updated to black for better visibility */
    white-space: nowrap;
}

.html-bar-chart .bar-value small {
    color: #333; /* Darker grey for percentage */
    font-weight: 400;
}

/* ===== DAPIL STACKED CHART ===== */
.dapil-chart {
    padding-top: .5rem;
}

.dapil-stacked {
    display: flex;
    height: 32px;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.dapil-stacked .dapil-seg {
    height: 100%;
    cursor: default;
}

.dapil-legend {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem .75rem;
}

.dapil-legend .dapil-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .75rem;
    color: var(--text-secondary);
}

.dapil-legend .dapil-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    display: inline-block;
    flex-shrink: 0;
}

.dapil-legend .dapil-item strong {
    color: var(--text-primary);
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #f4f6f9; }
::-webkit-scrollbar-thumb { background: #ddd; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #bbb; }

/* ===== HIGHLIGHTS ===== */
.highlight-pks {
    background: #fff0e6 !important;
}
.highlight-pks td {
    font-weight: 600;
}
.bar-row-highlight {
    background: #fff0e6;
    border-radius: 4px;
}

/* ===== TABLE COMPACT ===== */
.table-compact th, .table-compact td {
    padding: 0.2rem 0.4rem;
    font-size: 0.75rem;
}
