@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap');

:root {
    --bg-darkest: #020617;
    --bg-darker: #0b1329;
    --bg-card: rgba(30, 41, 59, 0.7);
    --border-glass: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(6, 182, 212, 0.2);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --accent-cyan: #06b6d4;
    --accent-green: #10b981;
    --accent-amber: #f59e0b;
    --accent-red: #ef4444;
    --accent-purple: #8b5cf6;
    
    --cyan-glow: 0 0 15px rgba(6, 182, 212, 0.4);
    --green-glow: 0 0 15px rgba(16, 185, 129, 0.4);
    --red-glow: 0 0 20px rgba(239, 68, 68, 0.6);
    --amber-glow: 0 0 15px rgba(245, 158, 11, 0.4);
    
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-darkest);
    color: var(--text-primary);
}

/* Hanya dashboard SPA — jangan terapkan ke landing page */
body.app-shell {
    overflow: hidden;
    height: 100vh;
    display: flex;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-darkest);
}
::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent-cyan);
}

/* Layout Shell */
.app-container {
    display: flex;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar Styling */
.sidebar {
    width: 280px;
    background-color: rgba(2, 6, 23, 0.85);
    border-right: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    backdrop-filter: blur(20px);
    z-index: 100;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-glass);
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-green));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--cyan-glow);
}

.logo-text h1 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, #fff, var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 0.5px;
}

.logo-text span {
    font-size: 0.75rem;
    color: var(--accent-cyan);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Nav Menu */
.nav-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-grow: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

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

.nav-item:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.03);
    border-color: var(--border-glass);
}

.nav-item.active {
    color: var(--text-primary);
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.15), rgba(16, 185, 129, 0.05));
    border-color: rgba(6, 182, 212, 0.3);
    box-shadow: 0 4px 20px rgba(6, 182, 212, 0.08);
}

.nav-item.active i {
    color: var(--accent-cyan);
    text-shadow: var(--cyan-glow);
}

/* Sidebar khusus role pengemudi */
.nav-section-label {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    padding: 0.25rem 1rem 0.15rem;
    margin-top: 0.25rem;
}

.sidebar-driver {
    border-right-color: rgba(6, 182, 212, 0.12);
}

body.role-pengemudi .main-content {
    /* fokus konten operasional */
}

body.role-pengemudi .nav-item.active {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.2), rgba(16, 185, 129, 0.08));
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border-glass);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--accent-cyan);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--bg-darkest);
    font-size: 0.85rem;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
}

.user-role {
    font-size: 0.7rem;
    color: var(--accent-green);
}

/* Main Content Area */
.main-content {
    flex-grow: 1;
    height: 100vh;
    overflow: hidden;
    background-color: var(--bg-darker);
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Views Wrapper */
.view-panel {
    display: none;
    flex: 1 1 auto;
    padding: 1.5rem;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    z-index: 1;
}

.view-panel.active {
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    position: sticky;
    top: 0;
    z-index: 1200;
    flex-shrink: 0;
    height: 70px;
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    background-color: rgba(2, 6, 23, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    overflow: visible;
}

.header-title h2 {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 600;
}

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

.header-user-menu {
    position: relative;
    z-index: 1210;
}

.header-user-trigger {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.35rem 0.55rem 0.35rem 0.35rem;
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    color: inherit;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
    outline: none;
}

.header-user-trigger:hover,
.header-user-menu.open .header-user-trigger {
    border-color: rgba(6, 182, 212, 0.35);
    background: rgba(6, 182, 212, 0.08);
}

.header-user-info {
    text-align: left;
    min-width: 0;
    max-width: 150px;
}

.header-user-info .user-name {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.2;
}

.header-user-info .user-role {
    display: block;
    font-size: 0.65rem;
    color: var(--text-secondary);
    line-height: 1.2;
}

.header-user-chevron {
    font-size: 0.65rem;
    color: var(--text-secondary);
    transition: transform 0.2s ease;
}

.header-user-menu.open .header-user-chevron {
    transform: rotate(180deg);
}

.header-user-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    width: 240px;
    padding: 0.85rem;
    border-radius: 14px;
    border: 1px solid var(--border-glass);
    background: rgba(15, 23, 42, 0.98);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
    z-index: 1220;
    pointer-events: none;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

body.light-mode .header-user-dropdown {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(15, 23, 42, 0.1);
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.12);
}

.header-user-menu.open .header-user-dropdown {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    pointer-events: auto;
    opacity: 1;
    transform: translateY(0);
}

.header-user-dropdown-profile {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding-bottom: 0.65rem;
    border-bottom: 1px solid var(--border-glass);
}

.header-user-dropdown-profile .user-name {
    font-size: 0.85rem;
    font-weight: 600;
}

.header-user-dropdown-profile .user-role {
    font-size: 0.68rem;
    color: var(--text-secondary);
}

.header-user-dropdown-btn {
    font-size: 0.72rem !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
}

.header-user-dropdown .btn-outline-danger {
    border-color: rgba(239, 68, 68, 0.25) !important;
}

.system-time {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    border-radius: 6px;
}

.header-view-site {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.4rem 0.8rem;
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    border-radius: 6px;
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.header-view-site:hover {
    color: var(--accent-cyan);
    border-color: rgba(6, 182, 212, 0.35);
    background: rgba(6, 182, 212, 0.08);
}

.header-view-site i {
    color: var(--accent-cyan);
    font-size: 0.9rem;
}

body.light-mode .header-view-site {
    background-color: rgba(255, 255, 255, 0.85);
}

body.light-mode .header-view-site:hover {
    color: #0891b2;
    background: rgba(6, 182, 212, 0.06);
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.btn-primary {
    background-color: var(--accent-cyan);
    color: var(--bg-darkest);
}

.btn-primary:hover {
    background-color: #22d3ee;
    box-shadow: var(--cyan-glow);
}

.btn-outline {
    background-color: transparent;
    border-color: var(--border-glass);
    color: var(--text-primary);
}

.btn-outline:hover {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: var(--text-secondary);
}

.btn-danger {
    background-color: var(--accent-red);
    color: white;
}

.btn-danger:hover {
    background-color: #f87171;
    box-shadow: var(--red-glow);
}

/* Card Styling - Glassmorphic */
.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 1.25rem;
    backdrop-filter: blur(12px) saturate(180%);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
    transition: border-color 0.3s ease;
}

.glass-card:hover {
    border-color: rgba(6, 182, 212, 0.15);
}

/* Stats Cards Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

.stat-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

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

.stat-value {
    font-family: var(--font-heading);
    font-size: 1.75rem;
    font-weight: 700;
}

.stat-change {
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.stat-change.up {
    color: var(--accent-green);
}

.stat-change.down {
    color: var(--accent-red);
}

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

.stat-icon.cyan { background-color: rgba(6, 182, 212, 0.1); color: var(--accent-cyan); }
.stat-icon.green { background-color: rgba(16, 185, 129, 0.1); color: var(--accent-green); }
.stat-icon.amber { background-color: rgba(245, 158, 11, 0.1); color: var(--accent-amber); }
.stat-icon.red { background-color: rgba(239, 68, 68, 0.1); color: var(--accent-red); }

/* Dashboard Grids */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.25rem;
    flex-grow: 1;
    min-height: 0; /* allows proper inner overflow */
}

/* Map Containers */
.map-container-wrapper {
    height: 100%;
    min-height: 400px;
    position: relative;
    border-radius: 12px;
    overflow: hidden;
}

.map-element {
    width: 100%;
    height: 100%;
    background-color: #111;
    z-index: 1;
}

/* CCTV Panel Grid */
.cctv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    grid-auto-rows: max-content;
    gap: 1rem;
    padding: 0.5rem 0;
}

.cctv-card {
    aspect-ratio: 16/9;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-glass);
    position: relative;
    background-color: #000;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cctv-card:hover {
    border-color: var(--accent-cyan);
    transform: scale(1.02);
}

.cctv-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.cctv-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, rgba(0,0,0,0.4) 0%, transparent 40%, transparent 60%, rgba(0,0,0,0.6) 100%);
    pointer-events: none;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    font-family: monospace;
    font-size: 0.7rem;
    color: #00ffcc;
    text-shadow: 1px 1px 2px #000;
}

.cctv-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cctv-tag {
    background-color: rgba(0, 0, 0, 0.6);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    border-left: 2px solid var(--accent-cyan);
}

.cctv-live-badge {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background-color: rgba(239, 68, 68, 0.8);
    color: white;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-weight: bold;
    animation: pulse 1s infinite alternate;
}

.cctv-bottom {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    background-color: rgba(0,0,0,0.5);
    padding: 0.25rem;
    border-radius: 3px;
}

.cctv-focus-view {
    position: fixed;
    top: 5%;
    left: 5%;
    width: 90%;
    height: 90%;
    z-index: 1000;
    background-color: #000;
    border: 2px solid var(--accent-cyan);
    box-shadow: 0 0 50px rgba(0,0,0,0.8), var(--cyan-glow);
    border-radius: 12px;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.cctv-focus-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background-color: rgba(11, 19, 41, 0.95);
    border-bottom: 1px solid var(--border-glass);
}

/* Panic Emergency Overlay & Alert */
.emergency-banner {
    background: linear-gradient(90deg, #ef4444, #b91c1c);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    display: none;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    box-shadow: var(--red-glow);
    border: 1px solid rgba(255,255,255,0.2);
    animation: flash-red 1s infinite alternate;
}

.emergency-banner-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
}

.emergency-banner-left i {
    font-size: 1.35rem;
}

/* Table Design */
.table-responsive {
    overflow-x: auto;
    width: 100%;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    text-align: left;
}

.custom-table th {
    padding: 0.75rem 1rem;
    background-color: rgba(255, 255, 255, 0.02);
    border-bottom: 2px solid var(--border-glass);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.custom-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-glass);
    color: var(--text-primary);
}

.custom-table tr:hover td {
    background-color: rgba(255, 255, 255, 0.01);
}

/* Badge Design */
.badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.badge-success { background-color: rgba(16, 185, 129, 0.1); color: var(--accent-green); border: 1px solid rgba(16, 185, 129, 0.2); }
.badge-warning { background-color: rgba(245, 158, 11, 0.1); color: var(--accent-amber); border: 1px solid rgba(245, 158, 11, 0.2); }
.badge-danger { background-color: rgba(239, 68, 68, 0.1); color: var(--accent-red); border: 1px solid rgba(239, 68, 68, 0.2); }
.badge-info { background-color: rgba(6, 182, 212, 0.1); color: var(--accent-cyan); border: 1px solid rgba(6, 182, 212, 0.2); }

/* TOB Validator Screen Design */
.tob-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1.5rem;
    flex-grow: 1;
}

.tob-device {
    width: 320px;
    background-color: #1e293b;
    border: 8px solid #0f172a;
    border-radius: 24px;
    padding: 1.5rem;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5), inset 0 2px 10px rgba(255,255,255,0.1);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    position: relative;
    border-top: 15px solid #0f172a;
    border-bottom: 25px solid #0f172a;
}

.tob-brand {
    text-align: center;
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--accent-cyan);
    letter-spacing: 1px;
    text-shadow: var(--cyan-glow);
}

.tob-screen {
    background-color: #000;
    border: 3px solid #334155;
    border-radius: 12px;
    height: 180px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.tob-screen.success {
    border-color: var(--accent-green);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.3);
}

.tob-screen.error {
    border-color: var(--accent-red);
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.3);
}

.tob-screen-state {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.tob-screen-amount {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--accent-cyan);
    margin-bottom: 0.25rem;
}

.tob-screen-message {
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
}

.tob-status-led {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: #334155;
    margin: 0 auto;
    transition: all 0.3s ease;
}

.tob-status-led.success { background-color: var(--accent-green); box-shadow: var(--green-glow); }
.tob-status-led.error { background-color: var(--accent-red); box-shadow: var(--red-glow); }

.tob-rfid-area {
    border: 2px dashed rgba(255,255,255,0.15);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tob-rfid-area:hover {
    border-color: var(--accent-cyan);
    background-color: rgba(6, 182, 212, 0.05);
}

.tob-rfid-icon {
    font-size: 2rem;
    color: var(--text-muted);
    transition: color 0.2s ease;
}

.tob-rfid-area:hover .tob-rfid-icon {
    color: var(--accent-cyan);
}

/* Management Tabs */
.tab-controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-glass);
    padding-bottom: 0.5rem;
}

.tab-btn {
    padding: 0.5rem 1.25rem;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.02);
}

.tab-btn.active {
    color: var(--text-primary);
    background-color: rgba(6, 182, 212, 0.1);
    border-color: rgba(6, 182, 212, 0.2);
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* Leaflet Map overrides for dark-mode */
.leaflet-container {
    background: #0b1329 !important;
}

.leaflet-bar {
    border: 1px solid var(--border-glass) !important;
}

.leaflet-bar a {
    background-color: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-bottom: 1px solid var(--border-glass) !important;
}

.leaflet-bar a:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
    color: var(--accent-cyan) !important;
}

.leaflet-popup-content-wrapper {
    background: rgba(15, 23, 42, 0.9) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-glass) !important;
    backdrop-filter: blur(10px) !important;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5) !important;
}

.leaflet-popup-tip {
    background: rgba(15, 23, 42, 0.9) !important;
    border: 1px solid var(--border-glass) !important;
}

/* Pulsing Leaflet Icon animation */
.pulsing-icon {
    border-radius: 50%;
    box-shadow: var(--cyan-glow);
    animation: marker-pulse 2s infinite;
}

.pulsing-icon-emergency {
    border-radius: 50%;
    box-shadow: var(--red-glow);
    animation: marker-pulse-emergency 1s infinite;
}

.pulsing-icon-speeding {
    border-radius: 50%;
    box-shadow: var(--amber-glow);
    animation: marker-pulse-speeding 1.5s infinite;
}

/* Halte & bus marker — tampilan familiar di peta nyata */
.custom-stop-marker {
    background: transparent !important;
    border: none !important;
}

.transit-stop-pin {
    position: relative;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.transit-stop-pin__ring {
    position: absolute;
    inset: 2px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.transit-stop-pin__ring::after {
    content: '';
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    border: 2.5px solid var(--route-color, #06b6d4);
}

.transit-stop-pin__dot {
    position: relative;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--route-color, #06b6d4);
}

.transit-bus-marker {
    position: relative;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.transit-bus-marker__pulse {
    position: absolute;
    inset: 0;
    border-radius: 8px;
    background: color-mix(in srgb, var(--alert-color, var(--route-color, #06b6d4)) 35%, transparent);
    animation: bus-marker-pulse 2s infinite;
}

.transit-bus-marker__body {
    position: relative;
    width: 24px;
    height: 18px;
    border-radius: 5px;
    background: #0f172a;
    border: 2px solid var(--alert-color, var(--route-color, #06b6d4));
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 9px;
}

.transit-bus-marker__body::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    right: 3px;
    height: 4px;
    border-radius: 2px;
    background: var(--alert-color, var(--route-color, #06b6d4));
}

.transit-bus-marker__badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 14px;
    height: 14px;
    padding: 0 2px;
    border-radius: 7px;
    background: #fff;
    color: #0f172a;
    border: 1.5px solid var(--alert-color, var(--route-color, #06b6d4));
    font-size: 7px;
    font-weight: 800;
    line-height: 11px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.transit-bus-marker__status {
    position: absolute;
    bottom: 2px;
    left: 2px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    border: 1.5px solid #fff;
}

.transit-bus-marker__status.is-live { background: #10b981; }
.transit-bus-marker__status.is-emergency { background: #ef4444; }
.transit-bus-marker__status.is-speeding { background: #f59e0b; }

@keyframes bus-marker-pulse {
    0% { transform: scale(0.92); opacity: 0.55; }
    70% { transform: scale(1.15); opacity: 0; }
    100% { transform: scale(0.92); opacity: 0; }
}

/* Animations */
@keyframes pulse {
    0% { opacity: 0.4; }
    100% { opacity: 1; }
}

@keyframes marker-pulse {
    0% { box-shadow: 0 0 0 0 rgba(6, 182, 212, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(6, 182, 212, 0); }
    100% { box-shadow: 0 0 0 0 rgba(6, 182, 212, 0); }
}

@keyframes marker-pulse-emergency {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.8); }
    70% { box-shadow: 0 0 0 15px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

@keyframes marker-pulse-speeding {
    0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7); }
    70% { box-shadow: 0 0 0 12px rgba(245, 158, 11, 0); }
    100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

@keyframes flash-red {
    0% { background-color: rgba(239, 68, 68, 1); }
    100% { background-color: rgba(185, 28, 28, 1); }
}

/* Modal styling for CRUD */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0,0,0,0.6);
    z-index: 1000;
    display: none;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: var(--bg-darker);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    width: 480px;
    max-width: 90%;
    padding: 1.5rem;
    box-shadow: 0 10px 40px rgba(0,0,0,0.6);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-glass);
}

.form-group {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-group label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.form-control {
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    color: #fff;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
}

.form-control:focus {
    border-color: var(--accent-cyan);
    outline: none;
    box-shadow: var(--border-glow);
}

/* Responsive Styles */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .sidebar {
        width: 70px;
        padding: 1rem 0.5rem;
        align-items: center;
    }
    .logo-text, .user-info, .nav-item span {
        display: none;
    }
    .logo-container {
        justify-content: center;
        width: 100%;
        margin-bottom: 1.5rem;
    }
    .nav-item {
        justify-content: center;
        padding: 0.75rem;
    }
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column !important;
    }
    .sidebar {
        width: 100% !important;
        height: auto !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        padding: 0.5rem 1rem !important;
        border-right: none !important;
        border-bottom: 1px solid var(--border-glass) !important;
        position: relative !important;
    }
    .logo-container {
        margin-bottom: 0 !important;
        justify-content: flex-start !important;
        width: auto !important;
        gap: 0.5rem !important;
    }
    .logo-icon {
        width: 32px !important;
        height: 32px !important;
    }
    .logo-text {
        display: block !important;
    }
    .logo-text h1 {
        font-size: 0.95rem !important;
    }
    .logo-text span {
        display: none !important;
    }
    .role-selector-container, .role-info-container {
        display: none !important; /* Sembunyikan selektor simulasi peran pada mobile */
    }
    .nav-menu {
        flex-direction: row !important;
        gap: 0.25rem !important;
        margin-top: 0 !important;
        overflow-x: auto !important;
        white-space: nowrap !important;
        scrollbar-width: none !important;
        flex-grow: 0 !important;
    }
    .nav-menu::-webkit-scrollbar {
        display: none !important;
    }
    .nav-item {
        justify-content: center !important;
        padding: 0.4rem 0.65rem !important;
        gap: 0.4rem !important;
    }
    .nav-item i {
        font-size: 0.95rem !important;
        width: auto !important;
    }
    .nav-item span {
        display: inline !important;
        font-size: 0.75rem !important;
    }
    .header-user-info,
    .header-user-chevron {
        display: none !important;
    }
    .header-user-trigger {
        padding: 0.25rem;
        border-radius: 50%;
        border-color: transparent;
        background: transparent;
    }
    .main-content {
        height: calc(100vh - 55px) !important;
    }
    .app-header {
        height: 48px !important;
        padding: 0 1rem !important;
    }
    .header-title h2 {
        font-size: 1rem !important;
    }
    .system-time {
        font-size: 0.7rem !important;
        padding: 0.2rem 0.4rem !important;
    }
    .header-view-site-label {
        display: none !important;
    }
    .header-view-site {
        font-size: 0.7rem !important;
        padding: 0.2rem 0.45rem !important;
    }
    .view-panel {
        padding: 0.75rem !important;
        min-height: 0 !important;
    }
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }
    .cctv-grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }
    .cctv-focus-grid {
        grid-template-columns: 1fr !important;
        padding: 1rem !important;
        gap: 0.75rem !important;
    }
    .cctv-focus-view {
        width: 96% !important;
        height: 96% !important;
        top: 2% !important;
        left: 2% !important;
    }
    .modal-content {
        width: 95% !important;
        padding: 1rem !important;
    }
}

/* ==========================================================================
   LIGHT MODE OVERRIDES
   ========================================================================== */
body.light-mode {
    --bg-darkest: #f1f5f9; /* Slate 100 */
    --bg-darker: #f8fafc; /* Slate 50 */
    --bg-card: rgba(255, 255, 255, 0.85);
    --border-glass: rgba(15, 23, 42, 0.08);
    --border-glow: rgba(6, 182, 212, 0.15);
    
    --text-primary: #0f172a; /* Slate 900 */
    --text-secondary: #475569; /* Slate 600 */
    --text-muted: #64748b; /* Slate 500 */
}

/* Sidebar Light Theme */
body.light-mode .sidebar {
    background-color: rgba(248, 250, 252, 0.9) !important;
}

body.light-mode .logo-text h1 {
    background: linear-gradient(135deg, #0f172a, var(--text-secondary)) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
}

/* Header Light Theme */
body.light-mode .app-header {
    background-color: rgba(255, 255, 255, 0.94) !important;
}

/* Nav Menu Hovers & Actives */
body.light-mode .nav-item:hover {
    background-color: rgba(0, 0, 0, 0.04) !important;
}
body.light-mode .nav-item.active {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.12), rgba(16, 185, 129, 0.06)) !important;
}

/* Form Controls with Inline Overrides */
body.light-mode .form-control,
body.light-mode select.form-control,
body.light-mode input.form-control,
body.light-mode textarea.form-control {
    background-color: rgba(255, 255, 255, 0.9) !important;
    color: #0f172a !important;
    border: 1px solid var(--border-glass) !important;
}

body.light-mode .form-control::placeholder {
    color: #94a3b8 !important;
}

/* Custom Table Hovers */
body.light-mode .custom-table tr:hover td {
    background-color: rgba(0, 0, 0, 0.02) !important;
}

/* Leaflet UI Light Customizations */
body.light-mode .leaflet-container {
    background: #f8fafc !important;
}

body.light-mode .leaflet-popup-content-wrapper {
    background: rgba(255, 255, 255, 0.95) !important;
    color: #0f172a !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1) !important;
}

body.light-mode .leaflet-popup-tip {
    background: rgba(255, 255, 255, 0.95) !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
}

body.light-mode .leaflet-bar a {
    background-color: #ffffff !important;
    color: #0f172a !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1) !important;
}

body.light-mode .leaflet-bar a:hover {
    background-color: #f1f5f9 !important;
    color: var(--accent-cyan) !important;
}

/* CCTV Dropdown Filter Overrides */
body.light-mode #ccCctvFilterBtn {
    background-color: rgba(255, 255, 255, 0.9) !important;
    color: #0f172a !important;
}

body.light-mode #ccCctvDropdownContent {
    background-color: #f8fafc !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1) !important;
}

body.light-mode #ccCctvDropdownContent label {
    color: #0f172a !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05) !important;
}

/* Floating Legend overrides */
body.light-mode .floating-legend {
    background: rgba(255, 255, 255, 0.95) !important;
    color: #0f172a !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1) !important;
}

body.light-mode .floating-legend div {
    border-bottom-color: rgba(0, 0, 0, 0.06) !important;
    border-top-color: rgba(0, 0, 0, 0.06) !important;
}

/* Mobile Drawer Styles */
.mobile-drawer {
    position: fixed;
    top: 0;
    right: -300px;
    width: 280px;
    height: 100vh;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-left: 1px solid var(--border-glass);
    z-index: 2500;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}
body.light-mode .mobile-drawer {
    background: rgba(248, 250, 252, 0.95);
    border-left: 1px solid rgba(15, 23, 42, 0.08);
}
.mobile-drawer.active {
    right: 0;
}
.mobile-drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 2400;
    display: none;
}
.mobile-drawer-overlay.active {
    display: block;
}
.mobile-drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-glass);
}
body.light-mode .mobile-drawer-header {
    border-bottom-color: rgba(15, 23, 42, 0.08);
}
.mobile-drawer-body {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    overflow-y: auto;
    flex-grow: 1;
}

/* Responsive Grid Containers */
.cc-standard-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 1.25rem;
    flex-grow: 1;
    min-height: 0;
}
.cc-vendor-grid {
    display: grid;
    grid-template-columns: 1.1fr 0.95fr 0.95fr;
    gap: 1.25rem;
    flex-grow: 1;
    min-height: 0;
}
.cc-dishub-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 1.25rem;
    flex-grow: 1;
    min-height: 0;
}
.treasurer-grid {
    display: grid;
    grid-template-columns: 1fr 1.3fr;
    gap: 1.25rem;
    flex-grow: 1;
    min-height: 0;
}
.card-filter-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 1rem;
}
.operations-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

@media (max-width: 1024px) {
    .cc-standard-grid, .cc-vendor-grid, .cc-dishub-grid, .treasurer-grid, .operations-grid {
        grid-template-columns: 1fr !important;
        height: auto !important;
        overflow-y: visible !important;
    }
}

/* Form grid supporting responsive layouts */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.form-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 768px) {
    .mobile-drawer-toggle {
        display: block !important;
    }
    
    .sidebar .nav-menu {
        display: none !important; /* Hide horizontal nav bar on mobile */
    }
    
    .tab-controls {
        overflow-x: auto !important;
        white-space: nowrap !important;
        scrollbar-width: none !important;
    }
    .tab-controls::-webkit-scrollbar {
        display: none !important;
    }
    .tab-controls .tab-btn {
        flex-shrink: 0 !important;
    }
    
    .form-grid, .form-grid-3 {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }
    
    .card-filter-grid {
        grid-template-columns: 1fr !important;
        gap: 0.5rem !important;
    }
    
    /* Make sure all roles forms, elements, and charts are comfortable on mobile */
    .view-panel {
        overflow-y: auto !important;
    }
    
    /* Adjust specific views styles for mobile */
    #command_center, #management_view, #reports_view, #bendahara_view, #tob_view {
        padding: 0.5rem !important;
    }
}
