/* =========================================
   1. RESET & VARIABEL
   ========================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

:root {
    --brand: #10b981;
    --brand-hover: #059669;
    --brand-light: #ecfdf5;
    --bg: #f1f5f9;
    --surface: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --sidebar-w: 260px;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
}

body {
    background-color: var(--bg);
    color: var(--text);
}

/* =========================================
   2. LAYOUT UTAMA (FIX DEVTOOLS STUCK)
   ========================================= */
.app-container {
    display: flex;
    height: 100vh;
    height: 100dvh; /* Fallback modern untuk mobile address bar */
    width: 100%;    /* Ganti 100vw jadi 100% agar re-layout saat resize */
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.content-area {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

/* =========================================
   3. HEADER
   ========================================= */
.header {
    height: 70px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

#page-title {
    font-weight: 600;
    font-size: 18px;
    color: var(--text);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info-header {
    text-align: right;
}
.user-info-header #display-user {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
}
.user-info-header #display-role {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: capitalize;
}

.btn-logout {
    background: var(--danger-light);
    color: var(--danger);
    border: none;
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: 0.2s;
}
.btn-logout:hover {
    background: #fca5a5;
}

.hamburger {
    display: none;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}
.hamburger:hover {
    background: var(--brand-light);
    color: var(--brand);
    border-color: var(--brand);
}

/* =========================================
   4. SIDEBAR
   ========================================= */
.sidebar {
    width: var(--sidebar-w);
    background: var(--brand);
    color: white;
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: transform 0.3s ease;
    z-index: 100;
    flex-shrink: 0;
}

.sidebar-brand {
    padding: 20px;
    font-size: 20px;
    font-weight: bold;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-sidebar-btn {
    display: none;
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 5px;
    border-radius: 5px;
}
.close-sidebar-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.sidebar-menu {
    list-style: none;
    padding: 15px 10px;
    overflow-y: auto;
    flex: 1;
}

.menu-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 15px;
    cursor: pointer;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    transition: 0.2s;
}
.menu-title:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}
.menu-title-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.menu-title .arrow {
    transition: transform 0.3s ease;
    font-size: 10px;
}

/* =========================================
   5. SUBMENU (Animasi Stagger Kiri)
   ========================================= */
.submenu {
    list-style: none;
    padding-left: 20px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.submenu.open {
    max-height: 600px;
    margin-top: 5px;
    margin-bottom: 10px;
}

/* Default state: item tersembunyi */
.submenu li {
    opacity: 0;
    transform: translateX(-24px);
}

/* State saat submenu dibuka: animasi masuk bergelombang */
.submenu.open li {
    animation: submenuSlideIn 0.35s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}

@keyframes submenuSlideIn {
    0% {
        opacity: 0;
        transform: translateX(-24px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

.submenu a {
    display: block;
    padding: 10px 15px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    border-radius: 6px;
    cursor: pointer;
}
.submenu a:hover {
    color: white;
    background: rgba(255, 255, 255, 0.15);
}

/* =========================================
   6. MODAL (showAlert / showConfirm)
   ========================================= */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: 0.3s;
}
.modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}
.modal-box {
    background: white;
    padding: 25px;
    border-radius: 16px;
    width: 90%;
    max-width: 350px;
    text-align: center;
    transform: translateY(20px);
    transition: 0.3s;
}
.modal-overlay.show .modal-box {
    transform: translateY(0);
}
.modal-icon {
    font-size: 40px;
    margin-bottom: 10px;
}
.modal-box h3 {
    font-size: 18px;
    margin-bottom: 8px;
}
.modal-box p {
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.5;
}
.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}
.btn-modal-ok,
.btn-modal-cancel {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: bold;
    border: none;
    flex: 1;
    cursor: pointer;
    font-size: 13px;
}
.btn-modal-ok {
    background: var(--brand);
    color: white;
}
.btn-modal-ok:hover {
    background: var(--brand-hover);
}
.btn-modal-cancel {
    background: #e2e8f0;
    color: var(--text);
}

/* =========================================
   7. RESPONSIVE (Mobile)
   ========================================= */
@media (max-width: 768px) {
    /* Sidebar jadi overlay */
    .sidebar {
        position: fixed;
        height: 100dvh;
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }

    /* Tampilkan tombol mobile */
    .hamburger {
        display: flex;
    }
    .close-sidebar-btn {
        display: block;
    }

    /* Sembunyikan info user biar header lega */
    .user-info-header {
        display: none;
    }
    .header-right {
        gap: 10px;
    }

    /* Overlay gelap saat sidebar terbuka */
    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 99;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }
    .sidebar-overlay.open {
        opacity: 1;
        pointer-events: auto;
    }
}

/* =========================================
   MODAL SVG ICONS (Modern & Profesional)
   ========================================= */
.modal-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
}
.modal-icon svg {
    width: 48px;
    height: 48px;
    stroke-width: 2;
    stroke: currentColor;
    fill: none;
}
/* Warna default untuk tiap tipe */
.icon-warning { color: #f59e0b; } /* Kuning */
.icon-success { color: var(--brand); } /* Hijau */
.icon-danger  { color: var(--danger); } /* Merah */
.icon-info    { color: #3b82f6; } /* Biru */
.icon-question{ color: var(--text-muted); } /* Abu-abu */

/* =========================================
   OVERLAY TIMESTAMP & LOKASI KAMERA
   ========================================= */
.video-overlay-info {
    position: absolute;
    bottom: 12px;
    right: 12px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    pointer-events: none;
    z-index: 10;
}

.video-time {
    background: rgba(0, 0, 0, 0.7);
    color: #10b981; /* Hijau brand */
    font-family: monospace, sans-serif;
    font-size: 14px;
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 4px;
    letter-spacing: 1px;
    text-shadow: 0 0 4px rgba(16, 185, 129, 0.4);
}

.video-location {
    background: rgba(0, 0, 0, 0.6);
    color: #ffffff;
    font-family: sans-serif;
    font-size: 10px;
    padding: 3px 6px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.video-location svg {
    color: #10b981;
    flex-shrink: 0;
}

/* =========================================
   TOMBOL BACK (HEADER)
   ========================================= */
.btn-back {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: 0.2s;
    margin-right: 5px;
}
.btn-back:hover {
    background: var(--brand-light);
    color: var(--brand);
    border-color: var(--brand);
}

/* =========================================
   SIDEBAR FOOTER (Profil & Logout)
   ========================================= */
.sidebar-footer {
    padding: 15px;
    background: rgba(0, 0, 0, 0.15); /* Latar lebih gelap */
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.sidebar-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
}

.sidebar-user-avatar {
    width: 38px;
    height: 38px;
    background: var(--brand-light);
    color: var(--brand-hover);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 16px;
    flex-shrink: 0;
}

.sidebar-user-detail {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-user-detail #sidebar-user-name {
    color: white;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-detail #sidebar-user-role {
    color: rgba(255, 255, 255, 0.6);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-sidebar-logout {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
    flex-shrink: 0;
}

.btn-sidebar-logout:hover {
    background: var(--danger-light);
    color: var(--danger);
}

/* =========================================
   LOCKDOWN COUNTDOWN MODAL
   ========================================= */
.lockdown-overlay {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    display: flex; justify-content: center; align-items: center;
    z-index: 99999; opacity: 0; pointer-events: none; transition: 0.3s;
    padding: 20px;
}
.lockdown-overlay.show { opacity: 1; pointer-events: auto; }

.lockdown-box {
    background: #1e293b; /* Warna gelap elegan */
    border: 1px solid #334155;
    padding: 30px;
    border-radius: 16px;
    width: 100%; max-width: 380px;
    text-align: center;
    transform: translateY(20px); transition: 0.3s;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}
.lockdown-overlay.show .lockdown-box { transform: translateY(0); }

.lockdown-icon {
    color: #ef4444;
    margin-bottom: 15px;
    display: flex; justify-content: center;
    animation: pulse-red 1.5s infinite;
}
@keyframes pulse-red {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.7; }
    100% { transform: scale(1); opacity: 1; }
}

.lockdown-box h3 {
    color: #f8fafc;
    font-size: 20px;
    margin-bottom: 10px;
    letter-spacing: 1px;
}
.lockdown-box p {
    color: #94a3b8;
    font-size: 13px;
    line-height: 1.6;
    margin-bottom: 20px;
}
.lockdown-box p span {
    color: #ef4444;
    font-weight: 800;
    font-size: 16px;
}

.lockdown-progress-bg {
    width: 100%;
    height: 8px;
    background: #334155;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}
.lockdown-progress-bar {
    height: 100%;
    width: 100%;
    background: #ef4444;
    border-radius: 4px;
    transition: width 1s linear; /* Animasi halus */
}