/* Dashboard Pantau KB — Tableau-style */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: #f0f2f5;
    color: #1a1a2e;
    min-height: 100vh;
}

/* Header */
.dashboard-header {
    background: linear-gradient(135deg, #0c4a6e 0%, #075985 50%, #0369a1 100%);
    color: white;
    padding: 20px 32px;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-text h1 {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.header-text h2 {
    font-size: 14px;
    font-weight: 500;
    opacity: 0.9;
    margin-top: 4px;
}

.header-text h3 {
    font-size: 13px;
    font-weight: 500;
    opacity: 0.8;
    margin-top: 2px;
}

.header-logo img {
    height: 56px;
}

/* Summary Cards */
.summary-section {
    max-width: 1400px;
    margin: 16px auto;
    padding: 0 32px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.summary-card {
    background: white;
    border-radius: 10px;
    padding: 16px 20px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    border-top: 4px solid transparent;
}

.summary-card h4 {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    color: #475569;
}

.card-pb {
    border-top-color: #0ea5e9;
}

.card-pb h4 {
    color: #0369a1;
}

.card-mkjp {
    border-top-color: #8b5cf6;
}

.card-mkjp h4 {
    color: #6d28d9;
}

.card-kbpp {
    border-top-color: #10b981;
}

.card-kbpp h4 {
    color: #059669;
}

.summary-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

.summary-row .label {
    color: #64748b;
    font-weight: 500;
}

.summary-row .value {
    font-weight: 700;
    color: #1e293b;
    font-size: 14px;
}

.summary-row .value.highlight {
    color: #0369a1;
}

.card-mkjp .summary-row .value.highlight {
    color: #6d28d9;
}

.card-kbpp .summary-row .value.highlight {
    color: #059669;
}

/* Update bar */
.update-bar {
    max-width: 1400px;
    margin: 0 auto;
    padding: 8px 32px;
    text-align: right;
    font-size: 11px;
    color: #64748b;
    font-weight: 600;
}

/* Ranking Cards */
.ranking-section {
    max-width: 1400px;
    margin: 0 auto 16px;
    padding: 0 32px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.ranking-card {
    background: white;
    border-radius: 10px;
    padding: 16px 20px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    gap: 14px;
    border-left: 5px solid #cbd5e1;
}

.rank-pb {
    border-left-color: #0ea5e9;
}

.rank-mkjp {
    border-left-color: #8b5cf6;
}

.rank-kbpp {
    border-left-color: #10b981;
}

.rank-icon {
    font-size: 32px;
}

.rank-info {
    display: flex;
    flex-direction: column;
}

.rank-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #64748b;
}

.rank-number {
    font-size: 28px;
    font-weight: 800;
    color: #1e293b;
    line-height: 1.1;
}

.rank-detail {
    font-size: 11px;
    color: #94a3b8;
    font-weight: 500;
}

/* Main Content */
.main-content {
    max-width: 1400px;
    margin: 0 auto 16px;
    padding: 0 32px;
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 16px;
    align-items: start;
}

/* Map */
.map-section {
    background: white;
    border-radius: 10px;
    padding: 16px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

#map {
    height: 380px;
    border-radius: 8px;
}

.map-legend {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 11px;
    color: #64748b;
    flex-wrap: wrap;
}

.legend-title {
    font-weight: 600;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.legend-color {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    display: inline-block;
}

/* Table */
.table-section {
    background: white;
    border-radius: 10px;
    padding: 16px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.table-section .table-wrapper {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 420px;
}

.section-title {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #0369a1;
    margin-bottom: 12px;
}

/* Filter */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.filter-bar label {
    font-size: 12px;
    font-weight: 600;
    color: #475569;
}

.filter-bar select {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    color: #334155;
    outline: none;
}

.filter-bar select:focus {
    border-color: #3b82f6;
}

/* Data Table */
.table-wrapper {
    flex: 1;
    overflow-y: auto;
    max-height: 320px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.data-table thead th {
    background: #f1f5f9;
    padding: 8px 10px;
    text-align: left;
    font-weight: 700;
    color: #475569;
    font-size: 11px;
    letter-spacing: 0.3px;
    border-bottom: 2px solid #e2e8f0;
    position: sticky;
    top: 0;
}

.data-table tbody td {
    padding: 7px 10px;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
}

.data-table tbody tr:hover {
    background: #f8fafc;
}

.data-table tbody tr.highlight-row {
    background: #eff6ff;
    font-weight: 600;
}

/* Kab/Kota Section */
.kabkota-section {
    max-width: 1400px;
    margin: 16px auto;
    padding: 0 32px;
}

.kabkota-section .card {
    background: white;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

/* Charts Section */
.charts-section {
    max-width: 1400px;
    margin: 16px auto 24px;
    padding: 0 32px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.chart-card {
    background: white;
    border-radius: 10px;
    padding: 16px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.bar-chart {
    height: 200px;
    overflow-y: auto;
    margin-top: 8px;
}

.bar-item {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 3px;
    font-size: 10px;
}

.bar-item .bar-label {
    width: 100px;
    text-align: right;
    color: #64748b;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

.bar-item .bar-fill-wrapper {
    flex: 1;
    background: #f1f5f9;
    border-radius: 3px;
    height: 12px;
    overflow: hidden;
}

.bar-item .bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

.bar-item .bar-fill.pb {
    background: #c0392b;
}

.bar-item .bar-fill.mkjp {
    background: #8b5cf6;
}

.bar-item .bar-fill.kbpp {
    background: #10b981;
}

.bar-item .bar-value {
    width: 50px;
    font-weight: 600;
    color: #334155;
    font-size: 10px;
}

/* Kecamatan Section (BNBA) */
.kecamatan-section {
    max-width: 1400px;
    margin: 16px auto 24px;
    padding: 0 32px;
}

.kecamatan-section .table-wrapper {
    background: white;
    border-radius: 10px;
    padding: 16px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    overflow-x: auto;
    max-height: 600px;
    overflow-y: auto;
}

.kecamatan-section .section-title {
    margin-bottom: 16px;
}

.kec-kab-first td {
    border-top: 2px solid #e2e8f0 !important;
}

/* Footer */
.dashboard-footer {
    text-align: center;
    padding: 16px;
    font-size: 12px;
    color: #94a3b8;
}

/* Custom tooltip */
.leaflet-tooltip-custom {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 12px;
    font-family: 'Inter', sans-serif;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.leaflet-tooltip-custom .tt-name {
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 4px;
}

.leaflet-tooltip-custom .tt-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 11px;
}

.leaflet-tooltip-custom .tt-label {
    color: #64748b;
}

.leaflet-tooltip-custom .tt-val {
    font-weight: 600;
    color: #1e293b;
}

/* No data state */
.no-data {
    text-align: center;
    padding: 40px;
    color: #94a3b8;
}

.no-data .icon {
    font-size: 48px;
    margin-bottom: 12px;
}

/* Trend Chart */
.trend-chart-wrapper {
    height: 280px;
    position: relative;
}

/* Ranking Modal */
.ranking-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.ranking-modal {
    background: white;
    border-radius: 12px;
    width: 520px;
    max-width: 90vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
    animation: slideUp 0.2s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.ranking-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
}

.ranking-modal-header h4 {
    font-size: 14px;
    font-weight: 700;
    color: #0369a1;
    letter-spacing: 0.5px;
}

.ranking-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #94a3b8;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}

.ranking-modal-close:hover {
    color: #1e293b;
}

.ranking-modal-body {
    overflow-y: auto;
    padding: 0;
    max-height: 60vh;
}

.ranking-modal-body .data-table {
    margin: 0;
    border-radius: 0;
}

.ranking-modal-body .data-table th {
    position: sticky;
    top: 0;
    z-index: 2;
}

.ranking-row-highlight {
    background: #dbeafe !important;
    font-weight: 700;
}

.ranking-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    transform: translateY(-1px);
    transition: all 0.2s ease;
}

/* Responsive — Tablet */
@media (max-width: 1024px) {

    .summary-section,
    .ranking-section {
        grid-template-columns: 1fr 1fr;
    }

    .main-content {
        grid-template-columns: 1fr;
    }

    .charts-section {
        grid-template-columns: 1fr;
    }

    .dashboard-header {
        padding: 16px;
    }

    .summary-section,
    .ranking-section,
    .main-content,
    .charts-section,
    .kabkota-section,
    .kecamatan-section {
        padding: 0 16px;
    }
}

/* Responsive — Mobile */
@media (max-width: 640px) {
    .dashboard-header {
        padding: 12px;
    }

    .header-content {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }

    .header-text h1 {
        font-size: 14px;
        line-height: 1.3;
    }

    .header-text h2 {
        font-size: 11px;
    }

    .header-text h3 {
        font-size: 10px;
    }

    .header-logo img {
        height: 40px;
    }

    .summary-section,
    .ranking-section {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 0 10px;
        margin: 10px auto;
    }

    .summary-card {
        padding: 12px 14px;
    }

    .summary-card h4 {
        font-size: 11px;
        margin-bottom: 8px;
    }

    .summary-row {
        font-size: 12px;
    }

    .summary-row .value {
        font-size: 12px;
    }

    .ranking-card {
        padding: 12px 14px;
        gap: 10px;
    }

    .rank-icon {
        font-size: 24px;
    }

    .rank-number {
        font-size: 22px;
    }

    .rank-label {
        font-size: 9px;
    }

    .rank-detail {
        font-size: 10px;
    }

    .update-bar {
        padding: 6px 10px;
        font-size: 10px;
        text-align: center;
    }

    .main-content {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 0 10px;
    }

    #map {
        height: 260px;
    }

    .map-section {
        padding: 10px;
    }

    .map-legend {
        font-size: 9px;
        gap: 6px;
    }

    .table-section {
        padding: 10px;
    }

    .section-title {
        font-size: 11px;
    }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }

    .data-table {
        font-size: 10px;
    }

    .data-table thead th {
        padding: 6px 6px;
        font-size: 9px;
    }

    .data-table tbody td {
        padding: 5px 6px;
    }

    .charts-section {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 0 10px;
    }

    .chart-card {
        padding: 10px;
    }

    .trend-chart-wrapper {
        height: 220px;
    }

    .bar-chart {
        height: 160px;
    }

    .bar-item .bar-label {
        width: 70px;
        font-size: 9px;
    }

    .bar-item .bar-value {
        width: 40px;
        font-size: 9px;
    }

    .kabkota-section {
        padding: 0 10px;
        margin: 10px auto;
    }

    .dashboard-footer {
        padding: 12px 10px;
        font-size: 10px;
    }

    .ranking-modal {
        width: 95vw;
        max-height: 85vh;
    }

    .ranking-modal-header {
        padding: 12px 14px;
    }

    .ranking-modal-header h4 {
        font-size: 12px;
    }
}