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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f0f2f5;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

h1 {
    color: #1a237e;
    margin-bottom: 20px;
}

h2 {
    color: #333;
    margin-bottom: 15px;
    font-size: 18px;
}

/* Navigation */
.nav-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.nav-tabs a {
    padding: 10px 20px;
    background: #fff;
    color: #333;
    text-decoration: none;
    border-radius: 5px;
    border: 1px solid #ddd;
    transition: all 0.3s;
}

.nav-tabs a:hover {
    background: #e3f2fd;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.nav-tabs a.active {
    background: #1a237e;
    color: #fff;
    border-color: #1a237e;
}

/* ============================================
   USER BAR (dipakai semua halaman via includes/layout.php)
   ============================================ */
.user-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    background: #fff;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.user-bar .user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.user-bar .user-info .name {
    font-weight: 600;
}

.user-bar .user-info .role-badge {
    padding: 3px 12px;
    border-radius: 12px;
    font-size: 12px;
    color: #fff;
}

.user-bar .user-info .role-badge.admin { background: #1a237e; }
.user-bar .user-info .role-badge.timses { background: #ff9800; }
.user-bar .user-info .role-badge.viewer { background: #6c757d; }

.user-bar .user-actions a {
    padding: 5px 15px;
    font-size: 13px;
    text-decoration: none;
    margin-left: 10px;
}

.user-bar .user-actions .logout { color: #dc3545; }
.user-bar .user-actions .change-pass { color: #1a237e; }
.user-bar .user-actions .users { color: #1a237e; }

/* Tag wilayah */
.wilayah-tag {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 11px;
    background: #e3f2fd;
    color: #1a237e;
    border: 1px solid #bbdefb;
    margin: 2px;
}

/* Badge filter aktif */
.filter-active-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 11px;
    background: #e3f2fd;
    color: #1a237e;
    border: 1px solid #bbdefb;
    margin: 0 3px;
}

/* ============================================
   FILTER RW / RT BERTINGKAT
   ============================================ */
.filter-bar-rwrt {
    background: #fff;
    padding: 12px 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.filter-bar-rwrt .filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.filter-bar-rwrt .filter-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-bar-rwrt .filter-group label {
    font-size: 13px;
    font-weight: 600;
    color: #555;
    white-space: nowrap;
}

.filter-bar-rwrt .filter-group select,
.filter-bar-rwrt .filter-group input {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    background: #fff;
}

.filter-bar-rwrt .filter-group select:focus,
.filter-bar-rwrt .filter-group input:focus {
    outline: none;
    border-color: #1a237e;
}

/* ============================================
   BULK EDIT (pilih banyak baris sekaligus)
   ============================================ */
.bulk-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    background: #e8eaf6;
    border: 1px solid #c5cae9;
    border-radius: 6px;
    padding: 10px 15px;
    margin-bottom: 12px;
}

.bulk-toolbar .bulk-count {
    font-size: 13px;
    font-weight: 600;
    color: #1a237e;
    min-width: 110px;
}

.bulk-toolbar .bulk-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.bulk-toolbar .bulk-group label {
    font-size: 12px;
    font-weight: 600;
    color: #555;
    white-space: nowrap;
}

.bulk-toolbar .bulk-group select,
.bulk-toolbar .bulk-group input {
    padding: 5px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    background: #fff;
}

.btn-bulk-apply {
    padding: 6px 16px;
    background: #1a237e;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

.btn-bulk-apply:hover { background: #0d1642; }

.btn-bulk-danger {
    padding: 6px 16px;
    background: #dc3545;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

.btn-bulk-danger:hover { background: #b02a37; }

.btn-bulk-clear {
    padding: 6px 14px;
    background: #6c757d;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    text-decoration: none;
}

.btn-bulk-clear:hover { background: #5a6268; }

.checkbox-cell {
    width: 36px;
    text-align: center;
}

.checkbox-cell input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

tr.row-selected {
    background: #e3f2fd !important;
}

/* Stats Cards */
.stats {
    margin-bottom: 20px;
}

.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
}

.stat-card {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    text-align: center;
    transition: transform 0.3s;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.stat-card h3 {
    color: #666;
    font-size: 13px;
    margin-bottom: 8px;
}

.stat-card p {
    font-size: 28px;
    font-weight: bold;
    color: #1a237e;
}

/* Forms */
.form-section {
    background: #fff;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    color: #333;
    font-size: 13px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #1a237e;
    box-shadow: 0 0 5px rgba(26, 35, 126, 0.2);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.form-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
}

/* Buttons */
.btn {
    padding: 8px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: #1a237e;
    color: #fff;
}

.btn-primary:hover {
    background: #0d1642;
}

.btn-success {
    background: #2e7d32;
    color: #fff;
}

.btn-success:hover {
    background: #1b5e20;
}

.btn-secondary {
    background: #6c757d;
    color: #fff;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

/* Tables */
.table-section {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    overflow-x: auto;
}

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

.table th {
    background: #1a237e;
    color: #fff;
    padding: 10px;
    text-align: left;
    white-space: nowrap;
}

.table td {
    padding: 8px 10px;
    border-bottom: 1px solid #eee;
}

.table tr:hover {
    background: #f5f5f5;
}

/* Badge Status */
.status-badge {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge.pemilih {
    background: #d4edda;
    color: #155724;
}

.status-badge.ragu {
    background: #fff3cd;
    color: #856404;
}

.status-badge.calon_lain {
    background: #f8d7da;
    color: #721c24;
}

.status-badge.Belum {
    background: #e2e3e5;
    color: #383d41;
}

/* Alerts */
.alert {
    padding: 15px 20px;
    border-radius: 4px;
    margin-bottom: 20px;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Info Box */
.info-box {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid #1a237e;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.info-box h3 {
    color: #1a237e;
    margin-bottom: 10px;
}

.info-box ul, .info-box ol {
    padding-left: 20px;
    line-height: 1.8;
}

/* Upload Box */
.upload-box {
    background: #fff;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.upload-box input[type="file"] {
    width: 100%;
    padding: 15px;
    border: 2px dashed #ddd;
    border-radius: 4px;
    cursor: pointer;
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 22px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    min-width: 100px;
}

.progress-fill {
    height: 100%;
    background: #1a237e;
    color: #fff;
    text-align: center;
    line-height: 22px;
    font-size: 12px;
    transition: width 0.5s;
    white-space: nowrap;
}

/* Filter Bar */
.filter-bar {
    margin-bottom: 15px;
}

.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.filter-form input,
.filter-form select {
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.filter-form input {
    flex: 1;
    min-width: 150px;
}

/* Status Summary */
.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin-top: 15px;
}

.status-item {
    padding: 10px;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.status-item.pemilih {
    background: #d4edda;
}

.status-item.ragu {
    background: #fff3cd;
}

.status-item.calon_lain {
    background: #f8d7da;
}

.status-label {
    font-weight: 600;
}

.status-total {
    font-weight: bold;
}

/* Chart */
.chart-section {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.chart-container {
    max-width: 400px;
    margin: 0 auto;
}

.chart-section h2 {
    text-align: center;
}

/* Analisis */
.analisis-box {
    background: #fff;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.prediksi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.prediksi-card {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 4px;
}

.prediksi-card h3 {
    font-size: 13px;
    color: #666;
    margin-bottom: 5px;
}

.prediksi-card p {
    font-size: 24px;
    font-weight: bold;
    margin: 5px 0;
}

.prediksi-card small {
    color: #666;
}

.prediksi-result {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-top: 15px;
}

.prediksi-result h3 {
    margin-bottom: 15px;
    color: #1a237e;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.result-item {
    display: flex;
    flex-direction: column;
}

.result-item span {
    color: #666;
    font-size: 13px;
}

.result-item strong {
    font-size: 20px;
    margin: 3px 0;
}

.progress-container {
    margin-top: 10px;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    margin-bottom: 5px;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .stat-cards {
        grid-template-columns: 1fr 1fr;
    }
    
    .prediksi-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .result-grid {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .nav-tabs a {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .user-bar {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
    
    .user-bar .user-actions {
        width: 100%;
        text-align: center;
    }
    
    .user-bar .user-actions a {
        margin: 0 4px;
    }
    
    .filter-bar-rwrt .filter-form,
    .bulk-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .table {
        font-size: 12px;
    }
    
    .table th, .table td {
        padding: 5px 8px;
    }
}

@media (max-width: 480px) {
    .stat-cards {
        grid-template-columns: 1fr;
    }
    
    .prediksi-grid {
        grid-template-columns: 1fr;
    }
    
    .filter-form {
        flex-direction: column;
    }
    
    .filter-form input,
    .filter-form select {
        width: 100%;
    }
}

/* Utility */
.text-center {
    text-align: center;
}