/* Enhanced Dashboard Styles */
/* Modern Color Palette */
:root {
    --primary-color: #128f8a;
    --primary-dark: #0d6b67;
    --secondary-color: #16B3AC;
    --accent-color: #45C2BD;
    --dark-bg: #232A32;
    --card-bg: #ffffff;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --border-color: #e0e6ed;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.15);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Global Improvements */
body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: #f5f7fa;
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Enhanced Container */
.home-page {
    padding: 20px;
    max-width: 100%;
    margin: 0 auto;
}

@media (min-width: 1400px) {
    .home-page {
        max-width: 1920px;
    }
}

/* Header/Information Bar */
.accent {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    margin-bottom: 20px;
    overflow: hidden;
}

.information {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.left-side-information,
.right-side-information {
    display: flex;
    align-items: center;
    gap: 15px;
    color: #ffffff;
    font-size: 14px;
}

.left-side-information {
    width: auto;
    margin-top: 0;
}

.right-side-information {
    position: static;
    width: auto;
    margin: 0;
}

.btn-rotate {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.btn-rotate:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(180deg);
}

.btn-rotate img {
    filter: brightness(0) invert(1);
}

/* Enhanced Chart Cards */
.row-chart {
    margin-top: 20px;
    margin-bottom: 20px;
}

.chart {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: var(--transition);
    min-height: auto;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.chart:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.chart-title {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 2px solid var(--primary-color);
    padding: 18px 24px;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 0;
}

.chart-title select {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    font-size: 14px;
    font-weight: 400;
    background: white;
    cursor: pointer;
    transition: var(--transition);
}

.chart-title select:hover {
    border-color: var(--primary-color);
}

.content-chart {
    padding: 24px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Enhanced Tables */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-sm);
}

.table-chart {
    width: 100%;
    margin: 0;
    font-size: 14px;
    border-collapse: separate;
    border-spacing: 0;
}

.table-chart thead th {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    font-weight: 600;
    padding: 14px 16px;
    text-align: center;
    border: none;
    position: sticky;
    top: 0;
    z-index: 10;
}

.table-chart thead th:first-child {
    text-align: left;
}

.table-chart tbody tr {
    transition: var(--transition);
    background: white;
}

.table-chart tbody tr:nth-child(even) {
    background: #f8f9fa;
}

.table-chart tbody tr:hover {
    background: #e3f2fd;
    transform: scale(1.01);
}

.table-chart tbody td {
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.table-chart tbody td.text-left {
    font-weight: 500;
}

/* Filter Sidebar */
.filter-sidebar {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: 24px;
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.filter-section {
    margin-bottom: 20px;
}

.filter-label {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 8px;
    display: block;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: var(--transition);
    background: white;
}

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

.form-control:hover {
    border-color: var(--secondary-color);
}

/* Enhanced Buttons */
.btn {
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14px;
    transition: var(--transition);
    border: none;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Chart Total Count */
.year-total-count {
    font-size: 56px !important;
    font-weight: 800;
    color: var(--primary-color);
    text-align: center;
    padding: 40px 20px 20px !important;
    font-family: 'Nunito', sans-serif;
}

/* Legend Container */
#chart-legend-container {
    background: #f8f9fa;
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 24px;
}

#chart-legend-container > div:first-child,
#chart-legend-container > div:nth-child(2) {
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
}

#chart-legend-container > div:not(:first-child):not(:nth-child(2)) {
    display: flex;
    align-items: center;
    padding: 6px 0;
    font-size: 14px;
}

#chart-legend-container > div:not(:first-child):not(:nth-child(2)) > div:first-child {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    margin-right: 10px;
    flex-shrink: 0;
}

/* Loading States */
.chart-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    color: var(--text-secondary);
}

.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 64px;
    margin-bottom: 20px;
    color: var(--border-color);
}

.empty-state p {
    font-size: 16px;
    margin: 0;
}

/* Maps Container */
#maps {
    min-height: 400px;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    overflow: hidden;
}

/* Responsive Grid Improvements */
@media (max-width: 1199px) {
    .home-page {
        padding: 15px;
        left: 0 !important;
        width: 100% !important;
    }

    .chart-title {
        font-size: 16px;
        padding: 14px 18px;
    }

    .year-total-count {
        font-size: 42px !important;
        padding: 30px 15px 15px !important;
    }
}

@media (max-width: 991px) {
    .filter-sidebar {
        position: static;
        margin-bottom: 20px;
    }

    .row-chart {
        margin-left: 0;
        margin-right: 0;
    }

    .information {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .left-side-information,
    .right-side-information {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 767px) {
    .home-page {
        padding: 10px;
    }

    .chart {
        margin-bottom: 15px;
    }

    .chart-title {
        font-size: 14px;
        padding: 12px 16px;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .chart-title select {
        width: 100%;
    }

    .content-chart {
        padding: 16px;
    }

    .year-total-count {
        font-size: 36px !important;
        padding: 20px 10px 10px !important;
    }

    .table-chart {
        font-size: 12px;
    }

    .table-chart thead th,
    .table-chart tbody td {
        padding: 8px 10px;
    }

    .btn {
        width: 100%;
        padding: 14px 20px;
    }

    .accent {
        border-radius: var(--radius-md);
    }

    .information {
        padding: 15px;
        border-radius: var(--radius-md) var(--radius-md) 0 0;
    }
}

@media (max-width: 575px) {
    .chart-title {
        font-size: 13px;
        padding: 10px 12px;
    }

    .table-chart {
        font-size: 11px;
    }

    .table-chart thead th,
    .table-chart tbody td {
        padding: 6px 8px;
    }
}

/* Scrollbar Styling */
.table-responsive::-webkit-scrollbar {
    height: 8px;
}

.table-responsive::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* Print Styles */
@media print {
    .btn-rotate,
    .filter-sidebar,
    .btn {
        display: none;
    }

    .chart {
        page-break-inside: avoid;
        box-shadow: none;
    }
}

/* Accessibility */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Focus Styles */
button:focus,
select:focus,
input:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .chart {
        border: 2px solid var(--text-primary);
    }

    .btn-primary {
        border: 2px solid var(--primary-dark);
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ─── KPI Summary Cards ─────────────────────────────────────────────────── */
.kpi-row {
    margin-bottom: 4px;
}
.kpi-card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 24px 20px;
    box-shadow: var(--shadow-md);
    text-align: center;
    border-left: 4px solid var(--primary-color);
    height: 100%;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.kpi-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}
.kpi-icon {
    font-size: 30px;
    margin-bottom: 8px;
    line-height: 1;
}
.kpi-value {
    font-size: 34px;
    font-weight: 800;
    color: var(--primary-color);
    line-height: 1.1;
    letter-spacing: -0.5px;
}
.kpi-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 8px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ─── KPI Today Card ────────────────────────────────────────────────────── */
.kpi-card-today {
    border-left-color: #128f8a;
    align-items: stretch;
}
.kpi-today-top {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start;
    width: 100%;
}
.kpi-today-number {
    font-size: 2.4rem;
    font-weight: 800;
    color: #128f8a;
    line-height: 1.1;
    letter-spacing: -0.5px;
}
.kpi-trend {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 7px;
    border-radius: 12px;
    color: #fff;
    white-space: nowrap;
    margin-top: 2px;
}
.kpi-trend-up   { background: #20c997; }
.kpi-trend-down { background: #e74c3c; }
.kpi-today-sub {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
    text-align: left;
    width: 100%;
}

/* ─── Status Distribution Bar ───────────────────────────────────────────── */
.stat-dist-body {
    padding: 14px 20px 16px;
    flex: 1;
}
.stat-dist-bar-wrap {
    display: flex;
    flex-direction: row;
    height: 30px;
    border-radius: 6px;
    overflow: hidden;
    width: 100%;
    margin-bottom: 12px;
}
.stat-dist-seg {
    height: 100%;
    min-width: 1px;
    cursor: pointer;
    transition: filter 0.2s;
    flex-shrink: 0;
}
.stat-dist-seg:hover { filter: brightness(0.85); }
.stat-dist-legend {
    display: flex;
    flex-wrap: wrap;
    column-gap: 14px;
    row-gap: 8px;
}
.stat-dist-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
}
.stat-dist-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.stat-dist-name  { font-size: 12px; font-weight: 600; color: var(--text-primary); }
.stat-dist-pct   { font-size: 11px; color: var(--text-secondary); }

/* ─── BTKL Mini Cards ───────────────────────────────────────────────────── */
.btkl-mini-card {
    height: 100%;
}
.btkl-mini-body {
    padding: 10px 16px 14px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 9px;
}
.btkl-mini-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
    gap: 8px;
    min-width: 0;
}
.btkl-mini-name {
    width: 110px;
    min-width: 110px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}
.btkl-mini-bar-wrap {
    flex: 1;
    min-width: 30px;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}
.btkl-mini-bar-fill {
    height: 100%;
    min-width: 2px;
    background: #128f8a;
    border-radius: 4px;
    transition: width 0.6s ease;
}
.btkl-mini-total {
    width: 46px;
    min-width: 46px;
    text-align: right;
    font-weight: 700;
    font-size: 12px;
    color: var(--text-primary);
    flex-shrink: 0;
}

/* ---- Level Process Boxes ---- */
.level-box {
    display: flex;
    gap: 16px;
    padding: 18px 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.09);
    height: 100%;
    align-items: flex-start;
    min-height: 120px;
    cursor: default;
    transition: box-shadow .2s, transform .2s;
}
.level-box:hover {
    box-shadow: 0 6px 18px rgba(0,0,0,.13);
    transform: translateY(-3px);
}
.level-box-label {
    font-size: 13px;
    color: #666;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 4px;
}
.level-box-icon-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 12px;
    flex-shrink: 0;
    font-size: 24px;
    margin-top: 2px;
}
.level-box-content {
    flex: 1;
    min-width: 0;
}
/* Comparison row */
.level-box-compare {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 10px;
    margin-top: 4px;
    margin-bottom: 8px;
}
.lb-done {
    font-size: 24px;
    font-weight: 800;
    line-height: 1.1;
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
}
.lb-notdone {
    font-size: 16px;
    font-weight: 600;
    color: #9e9e9e;
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
}
.lb-tag {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 8px;
    text-transform: uppercase;
    letter-spacing: .3px;
    line-height: 1.4;
}
.lb-tag-done {
    background: rgba(0,0,0,.08);
    color: inherit;
}
.lb-tag-not {
    background: #f0f0f0;
    color: #999;
}
/* Total line below progress bar */
.lb-total {
    font-size: 12px;
    color: #aaa;
    margin-top: 6px;
    font-weight: 500;
    white-space: nowrap;
}

/* Progress bar inside level box */
.lb-bar-wrap {
    height: 6px;
    background: rgba(0,0,0,.08);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 2px;
}
.lb-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width .5s ease;
    min-width: 2px;
}

/* ---- Scope indicator badge ---- */
.scope-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 20px;
    padding: 5px 14px;
    font-size: 13px;
    color: #7a5c00;
}

/* ---- Floating Action Button (FAB) ---- */
.dash-fab {
    position: fixed !important;
    bottom: 100px !important;
    right: 32px !important;
    width: 52px !important;
    height: 52px !important;
    border-radius: 50% !important;
    background: #128f8a !important;
    background-image: none !important;
    color: #fff !important;
    border: none !important;
    outline: none !important;
    padding: 0 !important;
    margin: 0 !important;
    font-size: 22px !important;
    line-height: 1 !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    font-weight: normal !important;
    box-shadow: 0 4px 18px rgba(18,143,138,.55) !important;
    cursor: pointer !important;
    z-index: 2147483647 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background .2s, transform .15s;
}
.dash-fab:hover,
.dash-fab:focus,
.dash-fab:active {
    background: #0d6b67 !important;
    background-image: none !important;
    color: #fff !important;
    outline: none !important;
    box-shadow: 0 6px 22px rgba(18,143,138,.65) !important;
    transform: scale(1.08);
}
.dash-fab-dot {
    position: absolute;
    top: 7px;
    right: 7px;
    width: 10px;
    height: 10px;
    background: #ffc107;
    border-radius: 50%;
    border: 2px solid #fff;
    pointer-events: none;
}

/* ---- FAB overlay ---- */
.dash-fab-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.35);
    z-index: 2147483646;
}
.dash-fab-overlay.open { display: block; }

/* ---- FAB slide-in panel ---- */
.dash-fab-panel {
    position: fixed;
    top: 0;
    right: -340px;
    width: 320px;
    height: 100%;
    background: #fff;
    z-index: 2147483647;
    box-shadow: -4px 0 20px rgba(0,0,0,.15);
    transition: right .28s cubic-bezier(.4,0,.2,1);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}
.dash-fab-panel.open { right: 0; }

.dash-fab-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: #128f8a;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    flex-shrink: 0;
}
.dash-fab-close {
    background: none !important;
    background-image: none !important;
    border: none !important;
    color: #fff !important;
    font-size: 18px !important;
    cursor: pointer !important;
    padding: 0 4px !important;
    line-height: 1 !important;
    text-transform: none !important;
    box-shadow: none !important;
    outline: none !important;
}
.dash-fab-close:hover,
.dash-fab-close:focus { opacity: .8; outline: none !important; background: none !important; color: #fff !important; }
.dash-fab-form {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0;
}
.dash-fab-group {
    margin-bottom: 16px;
}
.dash-fab-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    letter-spacing: .4px;
    margin-bottom: 5px;
}
.dash-fab-actions {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid #eee;
}
/* Override global .btn bleed inside FAB panel */
.dash-fab-form .btn {
    padding: 8px 16px !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    font-size: 13px !important;
    width: 100% !important;
    display: block !important;
    text-align: center !important;
}
.dash-fab-form .btn-primary {
    background: linear-gradient(135deg, #128f8a 0%, #0d6b67 100%) !important;
    color: #fff !important;
    border: none !important;
    box-shadow: 0 2px 8px rgba(18,143,138,.35) !important;
}
.dash-fab-form .btn-primary:hover,
.dash-fab-form .btn-primary:focus {
    background: linear-gradient(135deg, #0d6b67 0%, #095754 100%) !important;
    color: #fff !important;
    box-shadow: 0 4px 12px rgba(18,143,138,.5) !important;
}
.dash-fab-form .btn-outline-secondary {
    background: transparent !important;
    background-image: none !important;
    color: #555 !important;
    border: 1px solid #ccc !important;
    box-shadow: none !important;
}
.dash-fab-form .btn-outline-secondary:hover,
.dash-fab-form .btn-outline-secondary:focus {
    background: #f5f5f5 !important;
    color: #333 !important;
    border-color: #aaa !important;
}
.dash-fab-form .mt-1 { margin-top: 8px !important; }

/* ---- KPI Icon Circle ---- */
.kpi-icon-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    margin-bottom: 12px;
    font-size: 24px;
    flex-shrink: 0;
}
.kpi-icon-circle i { line-height: 1; }
