:root {
    --bg-main: #F9FAFB;
    --card-bg: #FFFFFF;
    --card-border: #F3F4F6;
    --accent-primary: #7C3AED; /* Purple */
    --accent-secondary: #F59E0B; /* Orange */
    --accent-light: rgba(124, 58, 237, 0.1);
    --danger: #EF4444;
    --text-primary: #111827;
    --text-secondary: #6B7280;
    --text-muted: #9CA3AF;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

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

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

.dashboard {
    display: grid;
    grid-template-columns: 1fr 420px;
    grid-template-rows: auto auto 1fr;
    height: 100vh;
    padding: 16px;
    gap: 16px;
    position: relative;
    z-index: 1;
    overflow: hidden;
}

header {
    grid-column: 1 / 3;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 24px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
}

.title h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.title h1 i {
    color: var(--accent-primary);
}

.top-stats {
    grid-column: 1 / 3;
}

.top-stats .stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.camera-tabs {
    grid-column: 1 / 3;
    margin-top: -8px;
}

.tabs-list {
    display: flex;
    gap: 12px;
    padding-bottom: 8px;
    overflow-x: auto;
}

.camera-tab {
    padding: 10px 24px;
    background: #FFFFFF;
    border: 1px solid var(--card-border);
    border-radius: 12px;
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-sm);
}

.camera-tab i {
    color: var(--text-muted);
}

.camera-tab:hover {
    background: #F9FAFB;
    transform: translateY(-1px);
}

.camera-tab.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.camera-tab.active i {
    color: white;
}

.main-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 0; /* Important for flex child in grid */
}

.video-container {
    position: relative;
    background: #000;
    border-radius: 20px;
    overflow: hidden;
    flex: 1;
    min-height: 0;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--card-border);
}

#video-feed {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.controls {
    display: flex;
    gap: 8px;
    background: var(--card-bg);
    padding: 12px;
    border-radius: 16px;
    border: 1px solid var(--card-border);
    box-shadow: var(--shadow-md);
    flex-shrink: 0;
}

button {
    padding: 8px 16px;
    border-radius: 12px;
    border: 1px solid #E5E7EB;
    background: #FFFFFF;
    color: var(--text-primary);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

button:hover {
    background: #F9FAFB;
    border-color: #D1D5DB;
    transform: translateY(-1px);
}

button.primary {
    background: var(--accent-primary);
    color: white;
    border: none;
}

button.primary:hover {
    background: #6D28D9;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

button.warning {
    background: var(--accent-secondary);
    color: white;
    border: none;
}

button.warning:hover {
    background: #D97706;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

button.danger {
    background: var(--danger);
    color: white;
    border: none;
}

.analytics-panel {
    background: var(--card-bg);
    border-radius: 24px;
    padding: 32px;
    border: 1px solid var(--card-border);
    box-shadow: var(--shadow-md);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background: #FFFFFF;
    padding: 12px 20px;
    border-radius: 16px;
    text-align: left;
    border: 1px solid var(--card-border);
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-card .label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-card .value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-card:nth-child(1) .value { color: var(--accent-primary); }
.stat-card:nth-child(2) .value { color: var(--accent-secondary); }
.stat-card:nth-child(3) .value { color: var(--accent-secondary); }

.side-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
    padding-right: 4px;
    min-height: 0;
}

.analytics-chart-side {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 16px;
    border: 1px solid var(--card-border);
    box-shadow: var(--shadow-md);
    flex-shrink: 0;
}

.chart-filters {
    display: flex;
    gap: 8px;
    align-items: center;
}

.chart-filters select {
    padding: 4px 8px;
    border-radius: 8px;
    border: 1px solid var(--card-border);
    background: #F9FAFB;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    outline: none;
}

.chart-filters select:hover {
    border-color: var(--accent-primary);
    background: #FFFFFF;
}

.chart-filters select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-light);
}

.media-manager {
    flex: 1;
    background: var(--card-bg);
    border-radius: 20px;
    padding: 20px;
    border: 1px solid var(--card-border);
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: var(--shadow-md);
    min-height: 0;
}

.media-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-right: 8px;
}

.media-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: #F9FAFB;
    border-radius: 16px;
    font-size: 0.95rem;
    border: 1px solid var(--card-border);
    transition: all 0.2s ease;
}

.media-item:hover {
    background: #F3F4F6;
    border-color: #E5E7EB;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.media-controls {
    display: flex;
    gap: 15px;
    align-items: center;
}

.select-all-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.8rem;
}

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

.media-info span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.media-checkbox {
    cursor: pointer;
    accent-color: var(--accent);
}

.media-item:hover {
    background: rgba(255,255,255,0.1);
}

.media-item .actions {
    display: flex;
    gap: 5px;
}

.media-item button {
    padding: 5px;
    background: transparent;
}

.system-status {
    display: flex;
    align-items: center;
    gap: 20px;
}

.settings-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.settings-link:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

#fps-counter {
    font-family: monospace;
    font-size: 0.85rem;
    color: var(--accent-secondary);
    background: rgba(6, 182, 212, 0.1);
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid rgba(6, 182, 212, 0.2);
}

.media-placeholder {
    padding: 40px;
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    border: 1px dashed var(--card-border);
}

.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.tabs button {
    flex: 1;
    padding: 10px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    font-size: 0.85rem;
}

.tabs button.active {
    background: var(--accent-gradient);
    box-shadow: 0 4px 15px var(--accent-glow);
}

/* Decorative Elements */
.dashboard header { animation: none; }
.main-content { animation: none; }
.side-panel { animation: none; }

@keyframes blink {
    0% { opacity: 1; }
    50% { opacity: 0; }
    100% { opacity: 1; }
}

.recording-indicator {
    position: absolute;
    top: 24px;
    right: 24px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.9);
    padding: 8px 16px;
    border-radius: 30px;
    color: var(--danger);
    font-weight: 700;
    font-size: 0.85rem;
    pointer-events: none;
    border: 1px solid rgba(239, 68, 68, 0.2);
    box-shadow: var(--shadow-md);
}

.dot {
    width: 12px;
    height: 12px;
    background: var(--danger);
    border-radius: 50%;
    animation: blink 1s infinite;
    box-shadow: 0 0 10px var(--danger);
}

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    border: 2px solid transparent;
    background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
    background-clip: content-box;
}

/* ==========================================================================
   CCTV DASHBOARD ENHANCEMENTS (WALL, PLAYBACK, ANALYTICS)
   ========================================================================== */

/* Navigation buttons styling */
.nav-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}
.nav-btn {
    padding: 8px 16px;
    border-radius: 10px;
    border: 1px solid var(--card-border);
    background: #F9FAFB;
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
}
.nav-btn:hover {
    background: #E5E7EB;
    color: var(--text-primary);
    transform: translateY(-1px);
}
.nav-btn.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.25);
}

.hidden-view {
    display: none !important;
}

/* Media Modal styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(17, 24, 39, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.modal-container {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 24px;
    max-width: 800px;
    width: 90%;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    gap: 16px;
    animation: zoomIn 0.3s ease-out;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--card-border);
}
.modal-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}
.modal-close-btn {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}
.modal-close-btn:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}
.modal-body video, .modal-body img {
    width: 100%;
    max-height: 480px;
    border-radius: 12px;
    background: #000;
    object-fit: contain;
}

@keyframes zoomIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Video Wall View Container */
#video-wall-view-container {
    grid-column: 1 / 3;
    height: 100%;
    overflow-y: auto;
    padding-right: 4px;
}
.video-wall-grid {
    display: grid;
    gap: 16px;
    height: 100%;
}
.video-wall-cell {
    position: relative;
    background: #000;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--card-border);
    aspect-ratio: 16/9;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.video-wall-cell:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-primary);
}
.video-wall-cell img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.video-wall-overlay {
    position: absolute;
    bottom: 12px;
    left: 12px;
    background: rgba(17, 24, 39, 0.85);
    color: white;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 8px;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255,255,255,0.05);
}

/* Analytics View Container */
#analytics-view-container {
    grid-column: 1 / 3;
    height: 100%;
    overflow-y: auto;
    padding-right: 4px;
}
.analytics-view {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding-bottom: 24px;
}
.analytics-summary-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}
.analytics-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 20px;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform 0.2s;
}
.analytics-card:hover {
    transform: translateY(-1px);
}
.analytics-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(124, 58, 237, 0.1);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.4rem;
    color: var(--accent-primary);
}
.analytics-card-icon.orange {
    background: rgba(245, 158, 11, 0.1);
    color: var(--accent-secondary);
}
.analytics-card-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.analytics-card-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
}
.analytics-card-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 600;
}
.analytics-main-chart {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 24px;
    box-shadow: var(--shadow-md);
    height: 420px;
}

