/* === LAYOUT STRUCTURE === */
#app-container {
    display: flex;
    width: 100vw;
    min-height: 100vh;
}

/* SIDEBAR - Premium Dark Glassmorphism */
aside {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.85) 0%, rgba(11, 15, 25, 0.95) 100%);
    backdrop-filter: blur(20px);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 5px 0 30px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: var(--transition-smooth);
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
}

.sidebar-header {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}
.sidebar-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 10%;
    width: 80%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(6, 182, 212, 0.3), transparent);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #0ea5e9 0%, #6366f1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 4px 12px rgba(14, 165, 233, 0.2);
}

.brand-icon {
    font-size: 1.5rem;
    filter: drop-shadow(0 2px 8px rgba(6, 182, 212, 0.4));
}

/* ── ISP SWITCHER DROPDOWN ─────────────────────────── */
.isp-switcher-container {
    padding: 1rem 1.25rem;
    position: relative;
}
.isp-switcher-container::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 1.25rem;
    right: 1.25rem;
    height: 1px;
    background: rgba(255, 255, 255, 0.04);
}

.isp-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    color: #64748b;
    margin-bottom: 0.6rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.isp-label::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 8px var(--primary);
    flex-shrink: 0;
}

.isp-select-wrapper {
    position: relative;
}

/* Custom chevron via background SVG */
.isp-select-wrapper::after {
    content: '';
    position: absolute;
    right: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2306b6d4' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: contain;
    pointer-events: none;
    transition: transform 0.3s ease;
}

.isp-select {
    width: 100%;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    padding: 0.75rem 2.4rem 0.75rem 1rem;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.isp-select option {
    background: #0f1729;
    color: var(--text-primary);
    font-weight: 600;
    padding: 0.5rem;
}

.isp-select:hover {
    border-color: rgba(6, 182, 212, 0.3);
    background: rgba(30, 41, 59, 0.7);
}

.isp-select:focus {
    border-color: var(--primary);
    background: rgba(15, 23, 42, 0.8);
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* SIDEBAR NAVIGATION */
.sidebar-nav {
    flex: 1;
    padding: 1.5rem 1rem;
    overflow-y: auto;
}
.sidebar-nav::-webkit-scrollbar {
    display: none;
}

.nav-group-title {
    font-size: 0.68rem;
    text-transform: uppercase;
    color: #64748b;
    font-weight: 800;
    margin: 1.5rem 0.75rem 0.75rem;
    letter-spacing: 1.5px;
}
.nav-group-title:first-child {
    margin-top: 0;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1.25rem;
    border-radius: 12px;
    color: #94a3b8;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.35rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.nav-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 0;
    background: var(--primary);
    border-radius: 0 4px 4px 0;
    transition: height 0.3s ease;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.03);
    color: #e2e8f0;
    transform: translateX(4px);
}

.nav-link.active {
    background: linear-gradient(90deg, rgba(6, 182, 212, 0.1) 0%, rgba(6, 182, 212, 0) 100%);
    color: #38bdf8;
    border-color: rgba(6, 182, 212, 0.1);
}

.nav-link.active::before {
    height: 60%;
}

.nav-icon {
    font-size: 1.25rem;
    width: 20px;
    text-align: center;
    transition: transform 0.3s ease;
}

.nav-link:hover .nav-icon {
    transform: scale(1.1) rotate(-3deg);
}
.nav-link.active .nav-icon {
    transform: scale(1.1);
    filter: drop-shadow(0 0 6px rgba(56, 189, 248, 0.5));
}

/* PROFILE / ROLE SWITCHER SIMULATOR */
.profile-footer {
    padding: 1.25rem;
    background: rgba(15, 23, 42, 0.6);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    backdrop-filter: blur(10px);
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.65rem;
    border-radius: 14px;
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.04);
    transition: all 0.3s ease;
}

.user-badge:hover {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.user-avatar {
    width: 42px;
    height: 42px;
    min-width: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.9rem;
    color: white;
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
    letter-spacing: 0.02em;
}

.user-info {
    flex: 1;
    overflow: hidden;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 700;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    color: #f1f5f9;
}

.user-role {
    font-size: 0.7rem;
    color: #38bdf8;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-top: 2px;
}

.btn-switch-role, .btn-logout {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #ef4444;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.65rem;
    border-radius: 12px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-logout:hover {
    background: #ef4444;
    color: #fff;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
    transform: translateY(-2px);
}

/* MAIN CONTENT AREA */
main {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: var(--transition-smooth);
}

/* TOP HEADER / MOBILE BAR */
header {
    background: var(--bg-surface);
    backdrop-filter: blur(var(--glass-blur));
    border-bottom: 1px solid var(--border-glass);
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 90;
}

.mobile-menu-toggle {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-title i {
    width: 24px;
    height: 24px;
    color: var(--primary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.isp-brand-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    padding: 0.5rem 1rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 700;
}

.isp-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--primary);
    box-shadow: 0 0 8px var(--primary);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.9); opacity: 0.6; }
    50% { transform: scale(1.1); opacity: 1; box-shadow: 0 0 12px var(--primary); }
    100% { transform: scale(0.9); opacity: 0.6; }
}

/* PAGE WRAPPER & ANIMATED VIEWPORT */
.content-wrapper {
    flex: 1;
    padding: 2rem;
    position: relative;
}

/* Semua section disembunyikan secara default */
.view-section {
    display: none;
}

.view-section.active {
    display: block;
    animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* KHUSUS map-view: gunakan visibility agar Leaflet selalu bisa menghitung ukuran container */
/* Leaflet gagal render jika containernya display:none saat diinisialisasi */
#map-view {
    display: block !important;
    visibility: hidden;
    pointer-events: none;
    position: fixed;
    width: 100vw;
    height: 100vh;
    top: -200vh;
    left: 0;
    opacity: 0;
    overflow: hidden;
    z-index: -1;
}

#map-view.active {
    visibility: visible;
    pointer-events: auto;
    position: relative;
    width: auto;
    height: auto;
    top: auto;
    left: auto;
    opacity: 1;
    overflow: visible;
    z-index: auto;
    animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === DATABASE OFFLINE ALERT BANNER === */
.db-offline-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.25);
    backdrop-filter: blur(12px);
    color: #ef4444;
    padding: 14px 20px;
    border-radius: 12px;
    margin: 16px 20px 0 20px;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.08);
    animation: slideDown 0.3s ease;
}
.db-offline-banner .banner-content {
    display: flex;
    align-items: center;
    gap: 12px;
}
.db-offline-banner .btn-reconnect {
    background: #ef4444;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}
.db-offline-banner .btn-reconnect:hover {
    background: #dc2626;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.4);
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === COLLAPSIBLE ARCHIVE SIDEBAR === */
.archive-sidebar {
    position: fixed;
    top: 0;
    right: -400px; /* Sembunyikan awal */
    width: 400px;
    height: 100vh;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.archive-sidebar.active {
    right: 0;
}
.archive-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.archive-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #22d3ee;
    display: flex;
    align-items: center;
    gap: 8px;
}
.btn-close-archive {
    background: transparent;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 50%;
}
.btn-close-archive:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}
.archive-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.archive-tabs {
    display: flex;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.2);
}
.archive-tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    padding: 12px;
    color: #9ca3af;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
}
.archive-tab-btn.active {
    color: #22d3ee;
    border-bottom-color: #22d3ee;
    background: rgba(34, 211, 238, 0.03);
}
.archive-tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}
.archive-tab-content.active {
    display: block;
}
.archive-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.archive-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    padding: 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    transition: all 0.2s;
}
.archive-item:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(34, 211, 238, 0.15);
}
.archive-item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 0.75rem;
    color: #9ca3af;
}
.archive-item-time {
    color: #6b7280;
}
.archive-item-title {
    font-weight: 600;
    color: #fff;
    margin-bottom: 4px;
}
.archive-item-desc {
    color: #9ca3af;
    line-height: 1.4;
}
.archive-badge {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
}
.archive-badge-create { background: rgba(16, 185, 129, 0.1); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.2); }
.archive-badge-delete { background: rgba(239, 68, 68, 0.1); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.2); }
.archive-badge-update { background: rgba(245, 158, 11, 0.1); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.2); }
.archive-badge-restore { background: rgba(59, 130, 246, 0.1); color: #3b82f6; border: 1px solid rgba(59, 130, 246, 0.2); }
