/* ==========================================================================
   HIKVISION iVMS-4200 Cloud NVR — Mobile & Desktop Theme (cctvku.pages.dev)
   ========================================================================== */

:root {
    --hik-bg-chassis: #0a0b0e;
    --hik-bg-panel: #13171f;
    --hik-bg-card: #181d27;
    --hik-bg-tile: #0f1218;
    --hik-border: #222938;
    --hik-border-hover: #3b4458;
    --hik-border-active: #d71920;
    --hik-red: #d71920;
    --hik-red-glow: rgba(215, 25, 32, 0.45);
    --hik-red-hover: #ef232c;
    --hik-cyan: #00bcd4;
    --hik-blue: #0284c7;
    --hik-green: #10b981;
    --hik-yellow: #f59e0b;
    --hik-text-main: #f8fafc;
    --hik-text-muted: #94a3b8;
    --hik-text-dim: #64748b;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--hik-bg-chassis);
    color: var(--hik-text-main);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    user-select: none;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}
::-webkit-scrollbar-track {
    background: #0d0f14;
}
::-webkit-scrollbar-thumb {
    background: #2a3140;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--hik-red);
}

.tab-pane:not(.active) {
    display: none !important;
}

/* ================= TOP NAVBAR ================= */
.hik-navbar {
    background: linear-gradient(180deg, #181c25 0%, #101319 100%);
    border-bottom: 1px solid var(--hik-border);
    padding: 6px 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
    position: sticky;
    top: 0;
    z-index: 1020;
}

.hik-brand-badge {
    background-color: var(--hik-red);
    color: #fff;
    font-weight: 900;
    letter-spacing: 1.5px;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 0.88rem;
    display: inline-block;
    box-shadow: 0 0 10px var(--hik-red-glow);
}

.hik-brand-title {
    font-weight: 700;
    font-size: 1rem;
    color: #ffffff;
    letter-spacing: 0.5px;
    line-height: 1.2;
}

.hik-brand-sub {
    font-size: 0.68rem;
    color: var(--hik-cyan);
    font-family: monospace;
}

/* Desktop Navigation Tabs */
.hik-nav-tabs {
    border-bottom: none;
    gap: 4px;
}

.hik-nav-tabs .nav-link {
    background: transparent;
    color: var(--hik-text-muted);
    border: 1px solid transparent;
    border-bottom: 3px solid transparent;
    border-radius: 4px 4px 0 0;
    padding: 6px 12px;
    font-size: 0.82rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.hik-nav-tabs .nav-link:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.05);
}

.hik-nav-tabs .nav-link.active {
    color: #ffffff;
    background-color: var(--hik-bg-panel);
    border-color: var(--hik-border) var(--hik-border) transparent;
    border-bottom: 3px solid var(--hik-red);
}

/* Top Stat Pills */
.hik-stat-pill {
    background-color: #121620;
    border: 1px solid var(--hik-border);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.74rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--hik-text-muted);
}

.hik-stat-val {
    font-weight: 700;
    color: #ffffff;
    font-family: monospace;
}

.hik-clock {
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.78rem;
    color: var(--hik-cyan);
    background-color: #0b0d13;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #1a2233;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

/* ================= PANELS & CARDS ================= */
.hik-sidebar {
    background-color: var(--hik-bg-panel);
    border: 1px solid var(--hik-border);
    border-radius: 6px;
    padding: 10px;
    height: 100%;
}

.hik-card {
    background-color: var(--hik-bg-card);
    border: 1px solid var(--hik-border);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.hik-section-header {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--hik-text-muted);
    border-bottom: 1px solid var(--hik-border);
    padding-bottom: 6px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ================= CHANNEL LIST ================= */
.hik-channel-item {
    padding: 7px 10px;
    border-radius: 4px;
    margin-bottom: 3px;
    cursor: pointer;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.15s ease;
    border: 1px solid transparent;
}

.hik-channel-item:hover {
    background-color: #1f2533;
}

.hik-channel-item.active {
    background-color: #24161b;
    border-color: var(--hik-red);
    color: #ffffff;
    font-weight: 600;
}

/* ================= SURVEILLANCE MATRIX ================= */
.hik-matrix-toolbar {
    background-color: var(--hik-bg-panel);
    border: 1px solid var(--hik-border);
    border-radius: 6px;
    padding: 6px 12px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.hik-matrix-grid {
    display: grid;
    gap: 8px;
    transition: all 0.3s ease;
}

.hik-matrix-grid.layout-3x2 {
    grid-template-columns: repeat(3, 1fr);
}

.hik-matrix-grid.layout-2x2 {
    grid-template-columns: repeat(2, 1fr);
}

.hik-matrix-grid.layout-1x1 {
    grid-template-columns: 1fr;
}

/* ================= CAMERA TILE ================= */
.hik-cam-tile {
    background-color: var(--hik-bg-tile);
    border: 1.5px solid var(--hik-border);
    border-radius: 6px;
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hik-cam-tile:hover {
    border-color: var(--hik-border-hover);
}

.hik-cam-tile.selected {
    border-color: var(--hik-red) !important;
    box-shadow: 0 0 14px var(--hik-red-glow);
}

.hik-cam-tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    background-color: #050608;
    transition: filter 0.2s;
}

.hik-cam-tile.loading img {
    filter: brightness(0.6);
}

/* OSD Overlays */
.hik-osd-top {
    position: absolute;
    top: 6px;
    left: 8px;
    right: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
    z-index: 5;
}

.hik-osd-bottom {
    position: absolute;
    bottom: 6px;
    left: 8px;
    right: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
    z-index: 5;
}

.hik-osd-badge {
    background: rgba(10, 12, 16, 0.78);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 3px;
    padding: 2px 6px;
    font-size: 0.72rem;
    font-family: "JetBrains Mono", Consolas, monospace;
    color: #e2e8f0;
}

.hik-osd-live-tag {
    background-color: var(--hik-red);
    color: #fff;
    font-weight: 800;
    font-size: 0.65rem;
    padding: 2px 5px;
    border-radius: 2px;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    animation: livePulse 2s infinite;
}

@keyframes livePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

.hik-cam-actions {
    position: absolute;
    top: 6px;
    right: 8px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 10;
}

.hik-cam-tile:hover .hik-cam-actions,
.hik-cam-tile.selected .hik-cam-actions {
    opacity: 1;
}

.hik-btn-cam {
    background: rgba(15, 20, 28, 0.85);
    border: 1px solid var(--hik-border);
    color: #ffffff;
    width: 26px;
    height: 26px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.hik-btn-cam:hover {
    background-color: var(--hik-red);
    border-color: var(--hik-red);
}

/* ================= PTZ DOME CONTROLLER ================= */
.hik-ptz-dome {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #2a3244, #121622 75%);
    border: 3px solid #2d3648;
    position: relative;
    margin: 8px auto;
    box-shadow: inset 0 4px 10px rgba(0, 0, 0, 0.8), 0 4px 15px rgba(0, 0, 0, 0.6);
}

.hik-ptz-btn {
    position: absolute;
    width: 32px;
    height: 32px;
    background: #1b212f;
    border: 1px solid #364157;
    color: #94a3b8;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 0.8rem;
    touch-action: manipulation;
}

.hik-ptz-btn:hover,
.hik-ptz-btn:active {
    background: var(--hik-red);
    color: #ffffff;
    border-color: var(--hik-red);
    transform: scale(1.1);
    box-shadow: 0 0 10px var(--hik-red-glow);
}

.hik-ptz-up    { top: 6px; left: 50%; transform: translateX(-50%); }
.hik-ptz-down  { bottom: 6px; left: 50%; transform: translateX(-50%); }
.hik-ptz-left  { left: 6px; top: 50%; transform: translateY(-50%); }
.hik-ptz-right { right: 6px; top: 50%; transform: translateY(-50%); }
.hik-ptz-center {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 36px;
    height: 36px;
    background: #0f121a;
    border: 2px solid var(--hik-red);
    color: var(--hik-red);
}
.hik-ptz-center:hover {
    background: var(--hik-red);
    color: #ffffff;
    transform: translate(-50%, -50%) scale(1.05);
}

/* ================= 24-HOUR TIMELINE BAR ================= */
.hik-timeline-container {
    background-color: var(--hik-bg-panel);
    border: 1px solid var(--hik-border);
    border-radius: 6px;
    padding: 10px 12px;
    margin-top: 10px;
}

.hik-timeline-ruler {
    display: flex;
    justify-content: space-between;
    font-family: "JetBrains Mono", Consolas, monospace;
    font-size: 0.68rem;
    color: var(--hik-text-dim);
    padding: 0 4px;
    margin-bottom: 4px;
    border-bottom: 1px solid #1a2233;
}

.hik-timeline-wrapper {
    position: relative;
    height: 70px;
    background-color: #090c12;
    border: 1px solid #1f2738;
    border-radius: 4px;
    overflow: hidden;
    cursor: crosshair;
    touch-action: none;
}

.hik-timeline-tracks {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    padding: 4px 0;
}

.hik-timeline-track {
    position: relative;
    height: 7px;
    background-color: rgba(255, 255, 255, 0.03);
    margin: 1px 0;
}

.hik-seg-block {
    position: absolute;
    top: 0;
    bottom: 0;
    border-radius: 1px;
    cursor: pointer;
    transition: opacity 0.15s;
}

.hik-seg-block:hover {
    opacity: 0.85;
    outline: 1px solid #fff;
}

.hik-seg-continuous {
    background-color: #0284c7; /* Blue for STB continuous */
}

.hik-seg-gdrive {
    background-color: #10b981; /* Green for GDrive archive */
}

.hik-timeline-needle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: var(--hik-red);
    box-shadow: 0 0 8px var(--hik-red-glow);
    z-index: 10;
    pointer-events: none;
    transition: left 0.1s linear;
}

.hik-timeline-needle-badge {
    position: absolute;
    top: 2px;
    left: 5px;
    background-color: var(--hik-red);
    color: #ffffff;
    font-family: monospace;
    font-size: 0.65rem;
    padding: 1px 4px;
    border-radius: 2px;
    white-space: nowrap;
}

/* ================= TABLES ================= */
.hik-table {
    width: 100%;
    font-size: 0.78rem;
    color: var(--hik-text-main);
    border-collapse: collapse;
}

.hik-table th {
    background-color: #161c28;
    color: var(--hik-text-muted);
    font-weight: 600;
    padding: 8px 10px;
    border-bottom: 1px solid var(--hik-border);
    text-align: left;
}

.hik-table td {
    padding: 7px 10px;
    border-bottom: 1px solid #1a202d;
    vertical-align: middle;
}

.hik-table tr:hover td {
    background-color: #1a2233;
}

/* ================= MOBILE BOTTOM NAVIGATION ================= */
.hik-mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(180deg, #181d28 0%, #0d1017 100%);
    border-top: 1px solid var(--hik-border);
    padding: 6px 12px calc(6px + var(--safe-bottom));
    z-index: 2000;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.6);
}

.hik-bottom-nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--hik-text-muted);
    padding: 4px 0;
    font-size: 0.68rem;
    font-weight: 600;
    gap: 3px;
    transition: all 0.15s ease;
    cursor: pointer;
    touch-action: manipulation;
}

.hik-bottom-nav-btn i {
    font-size: 1.15rem;
    transition: transform 0.15s ease;
}

.hik-bottom-nav-btn.active {
    color: #ffffff;
}

.hik-bottom-nav-btn.active i {
    color: var(--hik-red);
    transform: translateY(-2px);
}

/* ================= FULLSCREEN MODAL ================= */
.fullscreen-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #000000;
    z-index: 9999;
    display: flex;
    flex-direction: column;
}

.fullscreen-header {
    background: rgba(15, 18, 24, 0.95);
    border-bottom: 1px solid var(--hik-border);
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.fullscreen-img-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #000000;
    position: relative;
    overflow: hidden;
}

.fullscreen-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    user-select: none;
}

.fullscreen-footer {
    background: rgba(15, 18, 24, 0.95);
    border-top: 1px solid var(--hik-border);
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.78rem;
    color: var(--hik-text-muted);
}

/* ================= RESPONSIVE MEDIA QUERIES ================= */

@media (max-width: 991px) {
    .hik-matrix-grid.layout-3x2 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    body {
        padding-bottom: 70px; /* Space for bottom navbar */
    }

    .hik-nav-tabs {
        display: none !important; /* Replaced by bottom nav */
    }

    .hik-mobile-bottom-nav {
        display: flex;
    }

    .hik-matrix-grid.layout-3x2,
    .hik-matrix-grid.layout-2x2 {
        grid-template-columns: 1fr; /* 1 column full width on smartphones */
    }

    .hik-stat-pill {
        font-size: 0.68rem;
        padding: 2px 6px;
    }

    .hik-clock {
        font-size: 0.7rem;
        padding: 2px 6px;
    }

    .hik-timeline-wrapper {
        height: 55px;
    }
}

@media (max-width: 480px) {
    .hik-brand-sub {
        display: none;
    }

    .hik-brand-badge {
        font-size: 0.78rem;
        padding: 2px 6px;
    }

    .hik-brand-title {
        font-size: 0.88rem;
    }
}
