:root {
    --bg-dark: #0f172a;
    --bg-panel: #1e293b;
    --bg-card: #334155;
    --accent: #3b82f6;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --green: #22c55e;
    --red: #ef4444;
}

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

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

.app {
    display: flex;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-dark);
    border-right: 1px solid #334155;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    transition: transform 0.3s ease;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 2rem;
    color: var(--text-primary);
}

.brand-icon {
    color: var(--accent);
}

.menu {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    transition: 0.2s;
}

.menu-item:hover {
    background: #334155;
    color: white;
}

.menu-item.active {
    background: #1e40af;
    color: #60a5fa;
}

.badge {
    background: var(--red);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    margin-left: auto;
}

.bottom-menu {
    margin-top: auto;
    border-top: 1px solid #334155;
    padding-top: 10px;
}

/* Camera List */
.camera-list-panel {
    width: 320px;
    background: var(--bg-panel);
    border-right: 1px solid #334155;
    display: flex;
    flex-direction: column;
}

.panel-header {
    padding: 1.5rem;
    border-bottom: 1px solid #334155;
}

.panel-header h2 {
    font-size: 1rem;
    margin-bottom: 1rem;
    font-weight: 500;
}

.search-box {
    background: var(--bg-card);
    padding: 10px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    border: 1px solid #475569;
}

.search-box input {
    background: transparent;
    border: none;
    color: white;
    width: 100%;
    outline: none;
}

.camera-list {
    overflow-y: auto;
    flex: 1;
    padding: 10px;
}

.camera-list::-webkit-scrollbar {
    width: 6px;
}

.camera-list::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 3px;
}

.camera-card {
    background: var(--bg-card);
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: 0.2s;
    position: relative;
}

.camera-card:hover {
    border-color: #64748b;
}

.camera-card.active {
    border-color: var(--accent);
    background: #1e3a8a;
}

.camera-card h3 {
    font-size: 0.9rem;
    margin-bottom: 5px;
    color: white;
}

.camera-card p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 5px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #64748b;
    /* Default Grey */
    border-radius: 50%;
    position: absolute;
    right: 15px;
    top: 15px;
    transition: all 0.3s ease;
}

.status-dot.online {
    background: var(--green);
    box-shadow: 0 0 5px var(--green);
}

.status-dot.idle {
    background: #64748b;
    box-shadow: none;
}

.status-dot.offline {
    background: var(--red);
    box-shadow: 0 0 5px var(--red);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: black;
}

/* Desktop: Map takes priority */
.video-container {
    height: 40%;
    position: relative;
    background: #000;
    overflow: hidden;
}

iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

.live-badge {
    position: absolute;
    top: 20px;
    left: 20px;
    background: var(--red);
    color: white;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 10;
}

.dot {
    width: 6px;
    height: 6px;
    background: white;
    border-radius: 50%;
    animation: pulse 1s infinite;
}

.video-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 30px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9), transparent);
    pointer-events: none;
}

.video-overlay h1 {
    font-size: 1.8rem;
    margin-bottom: 8px;
    font-weight: 600;
}

.cam-meta {
    display: flex;
    gap: 20px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    align-items: center;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
}

.text-green {
    color: var(--green);
    font-weight: 500;
}

.map-container {
    flex: 1;
    background: #222;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

/* Mobile Reponsive */
.mobile-header {
    display: none;
}

@media (max-width: 768px) {
    body {
        overflow: auto;
        height: auto;
    }

    .app {
        flex-direction: column;
        height: auto;
    }

    /* Mobile Header */
    .mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 10px 15px;
        background: var(--bg-panel);
        border-bottom: 1px solid #334155;
        position: sticky;
        top: 0;
        z-index: 1001;
    }

    .mobile-header h3 {
        color: white;
        font-weight: 600;
        display: flex;
        align-items: center;
        gap: 8px;
        font-size: 1rem;
    }

    #menuToggle {
        background: none;
        border: none;
        color: white;
        cursor: pointer;
    }

    /* Sidebar - Hidden drawer */
    .sidebar {
        position: fixed;
        top: 50px;
        left: 0;
        bottom: 0;
        z-index: 1000;
        width: 100%;
        transform: translateX(-100%);
        padding-top: 0;
    }

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

    .sidebar .brand {
        display: none;
    }

    /* REORDERING MAGIC using display: contents */
    /* This allows us to interleave main-content children with camera-list */
    .main-content {
        display: contents;
    }

    /* 1. Video (Top) */
    .video-container {
        order: 1;
        height: 200px;
        width: 100%;
        flex: none;
    }

    /* 2. Map (Middle - BIG PRIORITY) */
    .map-container {
        order: 2;
        height: 50vh;
        /* 50% of screen height */
        width: 100%;
        flex: none;
        display: block;
    }

    /* 3. Camera List (Bottom - Compact) */
    .camera-list-panel {
        order: 3;
        width: 100%;
        height: 200px;
        /* Limit height */
        border-right: none;
        border-top: 4px solid #1e293b;
    }

    .panel-header {
        padding: 10px;
    }

    .panel-header h2 {
        font-size: 0.9rem;
        margin-bottom: 5px;
    }

    .search-box {
        padding: 6px;
    }
}