/* ============================================
   CCTV Monitor - Modern Startup Style CSS
   ============================================ */

:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --accent-start: #3b82f6;
    --accent-end: #8b5cf6;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 80px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

/* ============================================
   LOGIN PAGE
   ============================================ */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--bg-primary) 0%, #1a1f3a 100%);
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.login-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input {
    padding: 12px 16px;
    background: var(--bg-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    transition: var(--transition);
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-start);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-group input::placeholder {
    color: var(--text-secondary);
}

/* ============================================
   APP CONTAINER
   ============================================ */

.app-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

/* ============================================
   SIDEBAR
   ============================================ */

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    z-index: 1000;
    overflow-y: auto;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo {
    font-size: 18px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    transition: var(--transition);
}

.sidebar.collapsed .sidebar-logo {
    opacity: 0;
    width: 0;
}

.sidebar-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: var(--transition);
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-toggle span {
    width: 20px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: var(--transition);
}

.sidebar-nav {
    flex: 1;
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    transition: var(--transition);
    white-space: nowrap;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    transform: translateX(4px);
}

.nav-item.active {
    background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
    color: white;
}

.nav-icon {
    font-size: 20px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.nav-text {
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
}

.sidebar.collapsed .nav-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

/* Sub Menu Styles */
.nav-item-submenu {
    display: flex;
    flex-direction: column;
}

.nav-item-parent {
    cursor: pointer;
    position: relative;
}

.nav-arrow {
    margin-left: auto;
    font-size: 10px;
    transition: var(--transition);
}

.nav-item-submenu.active .nav-arrow {
    transform: rotate(180deg);
}

.nav-submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    padding-left: 0;
}

.nav-item-submenu.active .nav-submenu {
    max-height: 500px;
    padding-left: 12px;
}

.nav-item-child {
    padding-left: 48px;
    font-size: 13px;
}

.nav-item-child .nav-icon {
    font-size: 16px;
}

.sidebar.collapsed .nav-submenu {
    display: none;
}

/* ============================================
   MAIN CONTENT
   ============================================ */

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: var(--transition);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

.sidebar.collapsed ~ .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

/* ============================================
   TOPBAR
   ============================================ */

.topbar {
    background: var(--bg-secondary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: var(--transition);
}

.mobile-menu-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

.mobile-menu-toggle span {
    width: 20px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.user-role {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================
   CONTENT AREA
   ============================================ */

.content {
    flex: 1;
    padding: 24px;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* ============================================
   FLASH MESSAGES
   ============================================ */

.flash-messages {
    padding: 16px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.flash-message {
    padding: 12px 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: slideIn 0.3s ease-out;
}

.flash-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--success);
}

.flash-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--error);
}

.flash-info {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: var(--accent-start);
}

.flash-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: var(--transition);
}

.flash-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   DASHBOARD
   ============================================ */

.dashboard-container {
    width: 100%;
}

.camera-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

.camera-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: var(--transition);
    position: relative;
}

.camera-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.2);
    border-color: var(--accent-start);
}

.camera-header {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.camera-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.camera-video {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    background: #000;
    overflow: hidden;
}

.camera-error {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.8);
    color: var(--text-secondary);
    z-index: 10;
}

.stream-mode-badge {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.7);
    padding: 4px 8px;
    border-radius: 4px;
    z-index: 5;
}

.stream-mode-badge small {
    color: var(--text-secondary);
    font-size: 10px;
}

.camera-stream-mjpeg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.error-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.error-text {
    font-size: 12px;
    text-align: center;
    padding: 0 16px;
}

.camera-stream {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

.camera-card:hover .camera-stream {
    transform: scale(1.05);
}

/* ============================================
   EMPTY STATE
   ============================================ */

.empty-state {
    text-align: center;
    padding: 80px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.empty-icon {
    font-size: 64px;
    opacity: 0.5;
}

.empty-state h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.empty-state p {
    font-size: 16px;
    color: var(--text-secondary);
    max-width: 400px;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover {
    background: var(--bg-secondary);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-block {
    width: 100%;
}

/* ============================================
   CAMERAS MANAGEMENT
   ============================================ */

.cameras-container {
    width: 100%;
}

.page-header {
    margin-bottom: 24px;
    display: flex;
    justify-content: flex-end;
}

.cameras-table-container {
    background: var(--bg-secondary);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.cameras-table {
    width: 100%;
    border-collapse: collapse;
}

.cameras-table thead {
    background: var(--bg-tertiary);
}

.cameras-table th {
    padding: 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cameras-table td {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    font-size: 14px;
}

.cameras-table tbody tr {
    transition: var(--transition);
}

.cameras-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

.url-cell code {
    background: var(--bg-primary);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    color: var(--text-secondary);
    font-family: 'Courier New', monospace;
}

.inline-form {
    display: inline;
}

/* ============================================
   FORM CONTAINER
   ============================================ */

.form-container {
    max-width: 600px;
    margin: 0 auto;
}

.form-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 32px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.camera-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.form-control {
    padding: 12px 16px;
    background: var(--bg-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    width: 100%;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-start);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-help {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 8px;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 1024px) {
    .camera-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
    }
    
    .content {
        width: 100%;
        max-width: 100%;
        padding: 16px;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    
    .analytics-dashboard {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    
    .mobile-menu-toggle {
        display: flex;
    }
    
    .camera-grid {
        grid-template-columns: 1fr;
    }
    
    .topbar {
        padding: 12px 16px;
    }
    
    .page-title {
        font-size: 20px;
    }
    
    /* Analytics Dashboard Mobile */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .stat-card {
        padding: 16px;
    }
    
    .stat-icon {
        font-size: 36px;
        width: 60px;
        height: 60px;
    }
    
    .stat-value {
        font-size: 24px;
    }
    
    .charts-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .chart-body {
        height: 250px;
    }
    
    .system-status-grid {
        grid-template-columns: 1fr;
    }
    
    .quick-actions {
        flex-direction: column;
    }
    
    .action-btn {
        min-width: 100%;
    }
    
    .cameras-table-container {
        overflow-x: auto;
    }
    
    .cameras-table {
        min-width: 600px;
    }
}

@media (max-width: 480px) {
    .login-card {
        padding: 24px;
    }
    
    .form-card {
        padding: 20px;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions .btn {
        width: 100%;
    }
}

/* ============================================
   PTZ CONTROLS
   ============================================ */

.camera-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ptz-toggle-btn {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: var(--accent-start);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    transition: var(--transition);
}

.ptz-toggle-btn:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: var(--accent-start);
}

.ptz-panel {
    background: var(--bg-tertiary);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 16px;
    margin-top: 8px;
    border-radius: 0 0 8px 8px;
}

.ptz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.ptz-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: var(--transition);
}

.ptz-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.ptz-controls {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ptz-direction {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    justify-items: center;
}

.ptz-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    width: 100%;
    max-width: 200px;
}

.ptz-btn {
    background: var(--bg-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    transition: var(--transition);
    min-width: 50px;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ptz-btn:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: var(--accent-start);
    transform: scale(1.05);
}

.ptz-btn:active {
    transform: scale(0.95);
    background: rgba(59, 130, 246, 0.3);
}

.ptz-zoom,
.ptz-focus,
.ptz-iris {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.ptz-zoom .ptz-btn,
.ptz-focus .ptz-btn,
.ptz-iris .ptz-btn {
    flex: 1;
    max-width: 120px;
    font-size: 16px;
}

.ptz-speed {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
}

.ptz-speed label {
    font-size: 12px;
    color: var(--text-secondary);
    min-width: 80px;
}

.ptz-speed span {
    color: var(--accent-start);
    font-weight: 600;
    min-width: 20px;
    display: inline-block;
}

.speed-slider {
    flex: 1;
    height: 6px;
    background: var(--bg-primary);
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

.speed-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--accent-start);
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
}

.speed-slider::-webkit-slider-thumb:hover {
    background: var(--accent-end);
    transform: scale(1.2);
}

.speed-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--accent-start);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    transition: var(--transition);
}

.speed-slider::-moz-range-thumb:hover {
    background: var(--accent-end);
    transform: scale(1.2);
}

.ptz-preset {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
}

.ptz-preset label {
    font-size: 12px;
    color: var(--text-secondary);
    min-width: 60px;
}

.preset-select {
    background: var(--bg-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.preset-select:hover {
    border-color: var(--accent-start);
}

.preset-select:focus {
    outline: none;
    border-color: var(--accent-start);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.ptz-btn-small {
    background: var(--bg-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: var(--transition);
}

.ptz-btn-small:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: var(--accent-start);
}

@media (max-width: 768px) {
    .ptz-panel {
        padding: 12px;
    }
    
    .ptz-btn {
        min-width: 40px;
        min-height: 40px;
        font-size: 16px;
        padding: 8px 12px;
    }
    
    .ptz-row {
        max-width: 160px;
    }
}

/* ============================================
   ANALYTICS DASHBOARD
   ============================================ */

.analytics-dashboard {
    display: flex;
    flex-direction: column;
    gap: 24px;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr));
    gap: 20px;
    margin-bottom: 24px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--accent-start);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.2);
}

.stat-card.stat-primary::before {
    background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
}

.stat-card.stat-success::before {
    background: var(--success);
}

.stat-card.stat-warning::before {
    background: var(--warning);
}

.stat-card.stat-error::before {
    background: var(--error);
}

.stat-icon {
    font-size: 48px;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    flex-shrink: 0;
}

.stat-content {
    flex: 1;
}

.stat-label {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 4px;
}

.stat-percentage {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(400px, 100%), 1fr));
    gap: 24px;
    margin-bottom: 24px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.chart-card {
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 24px;
    transition: var(--transition);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.chart-card:hover {
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.chart-header {
    margin-bottom: 20px;
}

.chart-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.chart-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
}

.chart-body {
    height: 300px;
    position: relative;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.chart-body canvas {
    max-width: 100% !important;
    height: auto !important;
}

/* Progress Section */
.progress-section {
    margin-bottom: 24px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.progress-card {
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 24px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.progress-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
}

.progress-items {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.progress-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}

.progress-value {
    color: var(--text-secondary);
    font-weight: 600;
}

.progress-bar {
    width: 100%;
    height: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.6s ease;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

.progress-success {
    background: linear-gradient(90deg, var(--success), #34d399);
}

.progress-warning {
    background: linear-gradient(90deg, var(--warning), #fbbf24);
}

.progress-error {
    background: linear-gradient(90deg, var(--error), #f87171);
}

/* System Status */
.system-status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr));
    gap: 20px;
    margin-bottom: 24px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.status-card {
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 24px;
    transition: var(--transition);
}

.status-card:hover {
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.status-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.status-body {
    display: flex;
    align-items: center;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.status-online .status-dot {
    background: var(--success);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
}

.status-offline .status-dot {
    background: var(--error);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
}

.status-loading .status-dot {
    background: var(--warning);
    animation: pulse 1.2s infinite;
}

.status-loading .status-text {
    color: var(--warning);
}

.stats-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
    color: var(--text-secondary);
    font-size: 13px;
}

.health-refresh-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    font-size: 12px;
    font-weight: 600;
}

.health-refresh-badge.is-loading {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.source-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.source-summary-card {
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 18px 20px;
}

.source-summary-title {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 8px;
}

.source-summary-value {
    color: var(--text-primary);
    font-size: 28px;
    font-weight: 700;
    line-height: 1.1;
}

.source-summary-detail {
    margin-top: 8px;
    color: var(--text-secondary);
    font-size: 12px;
}

.error-list-card {
    margin-bottom: 24px;
}

.error-list-body {
    padding: 0 20px 20px;
}

.error-list-empty {
    padding: 20px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    text-align: center;
}

.error-list-empty.success {
    color: var(--success);
}

.error-list-table {
    width: 100%;
    border-collapse: collapse;
}

.error-list-table th,
.error-list-table td {
    padding: 12px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    text-align: left;
    font-size: 13px;
}

.error-list-table th {
    color: var(--text-secondary);
    font-weight: 600;
}

.error-status-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.error-status-error {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

.error-status-offline,
.error-status-pending {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

.status-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.status-online .status-text {
    color: var(--success);
}

.status-offline .status-text {
    color: var(--error);
}

/* Quick Actions */
.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 24px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
    flex: 1;
    min-width: 200px;
    justify-content: center;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.2);
}

.action-btn.action-primary {
    background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
    border: none;
    color: white;
}

.action-btn.action-primary:hover {
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.4);
}

.action-icon {
    font-size: 20px;
}

.action-text {
    font-size: 14px;
}

/* Responsive - Mobile */
@media (max-width: 768px) {
    .analytics-dashboard {
        gap: 16px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        margin-bottom: 16px;
    }
    
    .stat-card {
        padding: 16px;
        gap: 16px;
    }
    
    .stat-icon {
        font-size: 36px;
        width: 60px;
        height: 60px;
    }
    
    .stat-value {
        font-size: 24px;
    }
    
    .stat-label {
        font-size: 12px;
    }
    
    .stat-percentage {
        font-size: 12px;
    }
    
    .charts-grid {
        grid-template-columns: 1fr;
        gap: 16px;
        margin-bottom: 16px;
        min-width: 0;
    }
    
    .chart-card {
        padding: 16px;
    }
    
    .chart-header h3 {
        font-size: 16px;
    }
    
    .chart-subtitle {
        font-size: 11px;
    }
    
    .chart-body {
        height: 250px;
    }
    
    .progress-section {
        margin-bottom: 16px;
    }
    
    .progress-card {
        padding: 16px;
    }
    
    .progress-header h3 {
        font-size: 16px;
        margin-bottom: 16px;
    }
    
    .progress-items {
        gap: 16px;
    }
    
    .progress-label {
        font-size: 13px;
    }
    
    .progress-bar {
        height: 10px;
    }
    
    .system-status-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        margin-bottom: 16px;
    }
    
    .status-card {
        padding: 16px;
    }
    
    .status-header h3 {
        font-size: 14px;
        margin-bottom: 12px;
    }
    
    .quick-actions {
        flex-direction: column;
        gap: 12px;
    }
    
    .action-btn {
        min-width: 100%;
        padding: 14px 20px;
    }
    
    .action-icon {
        font-size: 18px;
    }
    
    .action-text {
        font-size: 13px;
    }
}

/* Responsive - Small Mobile */
@media (max-width: 480px) {
    .analytics-dashboard {
        gap: 12px;
    }
    
    .stats-grid {
        gap: 10px;
    }
    
    .stat-card {
        padding: 12px;
        gap: 12px;
        flex-direction: column;
        align-items: flex-start;
    }
    
    .stat-icon {
        font-size: 32px;
        width: 50px;
        height: 50px;
    }
    
    .stat-value {
        font-size: 20px;
    }
    
    .chart-card {
        padding: 12px;
    }
    
    .chart-body {
        height: 200px;
    }
    
    .progress-card {
        padding: 12px;
    }
    
    .status-card {
        padding: 12px;
    }
    
    .action-btn {
        padding: 12px 16px;
    }
}

/* ============================================
   CAMERA MODAL POPUP
   ============================================ */

.camera-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.camera-modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    width: 90%;
    max-width: 1400px;
    height: 90%;
    max-height: 90vh;
    background: var(--bg-secondary);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    z-index: 10000;
}

.camera-modal.active .modal-content {
    transform: scale(1);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-tertiary);
}

.modal-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.modal-close-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 20px;
    transition: var(--transition);
}

.modal-close-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--error);
    color: var(--error);
    transform: rotate(90deg);
}

.modal-body {
    flex: 1;
    padding: 0;
    overflow: hidden;
    position: relative;
}

.modal-video-container {
    width: 100%;
    height: 100%;
    position: relative;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: var(--text-secondary);
    font-size: 14px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent-start);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.modal-video-container video,
.modal-video-container img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

/* Responsive Modal */
@media (max-width: 768px) {
    .modal-content {
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .modal-header {
        padding: 16px 20px;
    }
    
    .modal-title {
        font-size: 18px;
    }
    
    .modal-close-btn {
        width: 32px;
        height: 32px;
        font-size: 18px;
    }
}

@media (max-width: 480px) {
    .modal-header {
        padding: 12px 16px;
    }
    
    .modal-title {
        font-size: 16px;
    }
}
