/* ===== CSS Variables ===== */
:root {
    --primary: #1a365d;
    --primary-light: #2c5282;
    --secondary: #38a169;
    --accent: #ed8936;
    --danger: #e53e3e;
    --warning: #ecc94b;
    --success: #48bb78;
    --gray-50: #f7fafc;
    --gray-100: #edf2f7;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e0;
    --gray-400: #a0aec0;
    --gray-500: #718096;
    --gray-600: #4a5568;
    --gray-700: #2d3748;
    --gray-800: #1a202c;
    --sidebar-width: 250px;
    --sidebar-collapsed: 60px;
    --top-bar-height: 60px;
    --border-radius: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.15);
}

/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--gray-100);
    color: var(--gray-700);
    display: flex;
    min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--primary);
    color: white;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    transition: width 0.3s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar.collapsed .nav-text,
.sidebar.collapsed .subtitle {
    display: none;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    text-align: center;
}

.sidebar-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

.sidebar-header .subtitle {
    font-size: 0.85rem;
    opacity: 0.7;
    margin-top: 4px;
}

.nav-menu {
    list-style: none;
    flex: 1;
    padding: 10px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: rgba(255,255,255,0.1);
}

.nav-item.active {
    background: rgba(255,255,255,0.15);
    border-left-color: var(--secondary);
}

.nav-icon {
    font-size: 1.25rem;
    margin-right: 12px;
    width: 24px;
    text-align: center;
}

.nav-text {
    font-size: 0.95rem;
}

/* ===== Main Content ===== */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    transition: margin-left 0.3s ease;
}

.sidebar.collapsed + .main-content {
    margin-left: var(--sidebar-collapsed);
}

.top-bar {
    height: var(--top-bar-height);
    background: white;
    display: flex;
    align-items: center;
    padding: 0 24px;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.menu-toggle {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    margin-right: 16px;
    color: var(--gray-600);
}

.top-bar h1 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-800);
    flex: 1;
}

.user-info {
    color: var(--gray-500);
    font-size: 0.9rem;
}

.content-area {
    padding: 24px;
    min-height: calc(100vh - var(--top-bar-height));
}

/* ===== Cards ===== */
.card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--gray-200);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-800);
}

/* ===== Stats Grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-icon.blue { background: #ebf4ff; }
.stat-icon.green { background: #e6fffa; }
.stat-icon.orange { background: #fffaf0; }
.stat-icon.red { background: #fff5f5; }
.stat-icon.purple { background: #faf5ff; }

.stat-content h3 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-800);
}

.stat-content p {
    font-size: 0.85rem;
    color: var(--gray-500);
    margin-top: 2px;
}

/* ===== Tables ===== */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-700);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

tr:hover {
    background: var(--gray-50);
}

/* ===== Badges ===== */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success { background: #c6f6d5; color: #276749; }
.badge-warning { background: #fefcbf; color: #975a16; }
.badge-danger { background: #fed7d7; color: #c53030; }
.badge-info { background: #bee3f8; color: #2b6cb0; }
.badge-secondary { background: var(--gray-200); color: var(--gray-600); }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.btn-primary:hover {
    background: var(--primary-light);
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* ===== Forms ===== */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--gray-700);
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 0.95rem;
    transition: border-color 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 54, 93, 0.1);
}

select.form-control {
    background: white;
}

/* ===== Filters ===== */
.filters-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.filters-bar .form-control {
    width: auto;
    min-width: 150px;
}

.search-box {
    position: relative;
    flex: 1;
    max-width: 300px;
}

.search-box input {
    padding-left: 36px;
}

.search-box::before {
    content: '🔍';
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.9rem;
}

/* ===== Grid Layouts ===== */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

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

@media (max-width: 768px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ===== Charts (Placeholder) ===== */
.chart-container {
    height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-50);
    border-radius: var(--border-radius);
    color: var(--gray-500);
}

/* Simple Bar Chart */
.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 200px;
    padding: 20px 0;
}

.bar-chart .bar {
    flex: 1;
    background: var(--primary);
    border-radius: 4px 4px 0 0;
    min-width: 30px;
    max-width: 60px;
    transition: height 0.3s ease;
    position: relative;
}

.bar-chart .bar:hover {
    background: var(--primary-light);
}

.bar-chart .bar::after {
    content: attr(data-value);
    position: absolute;
    top: -24px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-700);
}

.bar-chart .bar-label {
    position: absolute;
    bottom: -24px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: var(--gray-500);
    white-space: nowrap;
}

/* Pie Chart (CSS only) */
.pie-chart {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    position: relative;
}

.pie-legend {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-left: 24px;
}

.pie-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
}

.pie-legend-color {
    width: 14px;
    height: 14px;
    border-radius: 3px;
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-500);
    line-height: 1;
}

.modal-close:hover {
    color: var(--gray-700);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

/* ===== Progress Bar ===== */
.progress-bar {
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar .progress {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-bar .progress.green { background: var(--success); }
.progress-bar .progress.orange { background: var(--accent); }
.progress-bar .progress.red { background: var(--danger); }
.progress-bar .progress.blue { background: var(--primary); }

/* ===== Tabs ===== */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--gray-200);
    margin-bottom: 20px;
}

.tab {
    padding: 12px 20px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    font-weight: 500;
    color: var(--gray-500);
    transition: all 0.2s ease;
}

.tab:hover {
    color: var(--gray-700);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ===== Attendance Status ===== */
.attendance-cell {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

.attendance-cell.present { background: #c6f6d5; }
.attendance-cell.absent { background: #fed7d7; }
.attendance-cell.leave { background: #fefcbf; }
.attendance-cell.no-sitting { background: var(--gray-200); }

/* ===== Electoral Map Placeholder ===== */
.electoral-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
}

.state-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.state-card h4 {
    font-size: 1rem;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--gray-200);
}

.party-bar {
    display: flex;
    height: 24px;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.party-bar .segment {
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
}

.party-bar .bn { background: #2563eb; }
.party-bar .pas { background: #16a34a; }
.party-bar .dap { background: #dc2626; }
.party-bar .pkr { background: #0891b2; }
.party-bar .others { background: var(--gray-400); }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .sidebar {
        width: var(--sidebar-collapsed);
    }

    .sidebar .nav-text,
    .sidebar .subtitle {
        display: none;
    }

    .main-content {
        margin-left: var(--sidebar-collapsed);
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

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

    .filters-bar .form-control,
    .search-box {
        width: 100%;
        max-width: none;
    }
}

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

    .stat-card {
        padding: 16px;
    }
}

/* ===== Utility Classes ===== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-500); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: #d69e2e; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
