/* ============================================================
   SIP Caleg - Custom Styles
   ============================================================ */

/* --- Root Variables --- */
:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 0px;
    --sidebar-bg: #1e2a3a;
    --sidebar-hover: #2c3e50;
    --sidebar-active: #3498db;
    --topbar-height: 60px;
    --primary-color: #3498db;
    --transition-speed: 0.3s;
}

[data-bs-theme="dark"] {
    --sidebar-bg: #0f1a2e;
    --sidebar-hover: #1a2a40;
}

/* --- Login Page --- */
.login-page {
    background: linear-gradient(135deg, #003D7B 0%, #0066CC 50%, #4D94FF 100%);
    min-height: 100vh;
}

.login-page .card {
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.98);
}

[data-bs-theme="dark"] .login-page .card {
    background: rgba(30, 30, 30, 0.98);
}

.login-icon {
    width: 70px;
    height: 70px;
    line-height: 70px;
    border-radius: 50%;
    background: linear-gradient(135deg, #003D7B 0%, #0066CC 100%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

/* --- Wrapper & Sidebar --- */
#wrapper {
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    z-index: 1040;
    overflow-y: auto;
    transition: transform var(--transition-speed) ease;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-user {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-nav {
    list-style: none;
    padding: 0.5rem 0;
    margin: 0;
    flex: 1;
}

.sidebar-nav .nav-item {
    padding: 0 0.75rem;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    color: rgba(255,255,255,0.7);
    border-radius: 0.5rem;
    text-decoration: none;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.sidebar-nav .nav-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.sidebar-nav .nav-link.active {
    background: var(--sidebar-active);
    color: #fff;
    font-weight: 500;
}

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

/* --- Avatar Circle --- */
.avatar-circle {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--primary-color);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.avatar-sm {
    width: 30px;
    height: 30px;
    font-size: 0.75rem;
}

/* --- Main Content --- */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left var(--transition-speed) ease;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: transparent;
    min-height: var(--topbar-height);
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

[data-bs-theme="dark"] .topbar {
    border-bottom-color: rgba(255,255,255,0.05);
}

.topbar .navbar-text {
    color: var(--bs-body-color);
}

.sidebar-toggle {
    color: var(--bs-body-color);
    padding: 0.25rem;
}

/* --- Overlay untuk mobile --- */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1035;
}

/* --- Stat Cards --- */
.stat-card {
    border-radius: 0.75rem;
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--bs-secondary-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-weight: 700;
    font-size: 1.75rem;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

/* --- Activity Dot --- */
.activity-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary-color);
    flex-shrink: 0;
}

/* --- Progress Bars --- */
.progress {
    border-radius: 10px;
    background: var(--bs-tertiary-bg);
}

/* --- Sidebar Toggle on Mobile --- */
@media (max-width: 767.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .sidebar-overlay.show {
        display: block;
    }

    .main-content {
        margin-left: 0;
    }
}

/* --- Desktop sidebar always visible --- */
@media (min-width: 768px) {
    .sidebar {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: none !important;
    }
}

/* --- Dark Mode Adjustments --- */
[data-bs-theme="dark"] .card {
    background: var(--bs-body-bg);
    border-color: rgba(255,255,255,0.1);
}

[data-bs-theme="dark"] .list-group-item {
    background: transparent;
    border-color: rgba(255,255,255,0.05);
}

[data-bs-theme="dark"] .table {
    --bs-table-bg: transparent;
}

[data-bs-theme="dark"] .progress {
    background: rgba(255,255,255,0.1);
}

[data-bs-theme="dark"] .stat-card {
    background: var(--bs-body-bg);
}

/* --- Upload Area --- */
.upload-area {
    border: 2px dashed var(--bs-border-color);
    border-radius: 0.75rem;
    padding: 2rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: var(--bs-tertiary-bg);
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: rgba(52, 152, 219, 0.05);
}

.upload-icon {
    font-size: 2.5rem;
    color: var(--primary-color);
    display: block;
    margin-bottom: 0.5rem;
}

.stat-card-sm {
    border-radius: 0.75rem;
    transition: transform 0.2s;
}

.stat-card-sm:hover {
    transform: translateY(-2px);
}

.stat-icon-sm {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

/* --- KTP Scan Guide --- */
.ktp-guide::after {
    bottom: -2px;
    right: -2px;
    border-width: 0 3px 3px 0;
}

.ktp-guide::before,
.ktp-guide::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-color: #4CAF50;
    border-style: solid;
}

.ktp-guide {
    width: 85%;
    height: 55%;
    border: 2px dashed rgba(255,255,255,0.6);
    border-radius: 8px;
    position: relative;
}

/* --- Scrollbar --- */
.sidebar::-webkit-scrollbar {
    width: 5px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 10px;
}

/* --- GIS Map --- */
#map {
    z-index: 1;
    border-radius: 0.5rem;
}

#map .leaflet-popup-content {
    font-size: 0.85rem;
}

#map .leaflet-popup-content hr {
    margin: 4px 0;
}

#mapLegend {
    font-size: 0.7rem;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(0,0,0,0.05);
}

#panelKecamatan::-webkit-scrollbar,
#panelPrioritas::-webkit-scrollbar {
    width: 4px;
}

#panelKecamatan::-webkit-scrollbar-thumb,
#panelPrioritas::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.15);
    border-radius: 4px;
}

[data-bs-theme="dark"] #mapLegend {
    background: rgba(30,30,30,0.9) !important;
    border-color: rgba(255,255,255,0.1);
}

[data-bs-theme="dark"] .leaflet-container {
    background: #1a1a2e;
}

/* Leaflet dark mode tile fix */
[data-bs-theme="dark"] .leaflet-control-attribution {
    background: rgba(0,0,0,0.6);
    color: rgba(255,255,255,0.6);
}

[data-bs-theme="dark"] .leaflet-control-attribution a {
    color: rgba(255,255,255,0.6);
}

/* Layer toggle buttons */
#map + .position-absolute .btn.active {
    background: var(--bs-primary);
    color: #fff;
    border-color: var(--bs-primary);
}

#map + .position-absolute .btn {
    border-radius: 0;
    padding: 0.35rem 0.5rem;
    font-size: 0.85rem;
}

#map + .position-absolute .btn:first-child {
    border-radius: 0.375rem 0 0 0.375rem;
}

#map + .position-absolute .btn:last-child {
    border-radius: 0 0.375rem 0.375rem 0;
}
