:root {
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --accent-primary: #3b82f6;
    --accent-secondary: #0ea5e9;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #eab308;

    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.05);
}

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

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

.app-container {
    display: grid;
    grid-template-columns: 260px 1fr;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    min-width: 260px;
    /* Force width */
    background: var(--bg-card);
    border-right: 1px solid var(--glass-border);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    /* Prevent shrinking */
}

.logo {
    margin-bottom: 3rem;
    font-weight: 700;
    font-size: 1.5rem;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo small {
    font-size: 0.7rem;
    color: var(--accent-primary);
    display: block;
    font-weight: 400;
}

.nav-links {
    list-style: none;
    flex-grow: 1;
}

.nav-links li {
    margin-bottom: 0.5rem;
}

.nav-links a {
    display: block;
    padding: 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 12px;
    transition: all 0.3s ease;
    font-weight: 500;
}

.nav-links li.active a,
.nav-links a:hover {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-primary);
}

.status-panel {
    background: rgba(0, 0, 0, 0.2);
    padding: 1rem;
    border-radius: 12px;
}

.status-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
}

.status-item .label {
    color: var(--text-muted);
}

.status-item .value.online {
    color: var(--success);
}

.status-item .value.offline {
    color: var(--danger);
}

/* Model Selector Panel */
.model-panel {
    margin-top: 1.5rem;
    padding: 1rem;
    background: rgba(30, 41, 59, 0.5);
    border-radius: 12px;
}

.model-panel h4 {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.75rem;
}

.model-panel select {
    width: 100%;
    padding: 0.5rem;
    background: var(--bg-dark);
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
}

.model-panel select:focus {
    outline: none;
    border-color: var(--accent);
}

.model-panel #world-classes-container {
    margin-top: 0.75rem;
}

.model-panel input[type="text"] {
    width: 100%;
    padding: 0.5rem;
    background: var(--bg-dark);
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.model-panel input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
}

.model-panel button {
    width: 100%;
    padding: 0.5rem;
    background: linear-gradient(135deg, var(--accent), #06b6d4);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: transform 0.2s;
}

.model-panel button:hover {
    transform: scale(1.02);
}

.model-status {
    display: block;
    margin-top: 0.75rem;
    font-size: 0.75rem;
    color: var(--accent);
    text-align: center;
}

.model-summary-row {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 0.4rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.model-summary-row strong {
    overflow: hidden;
    color: var(--text-main);
    font-weight: 600;
    text-align: right;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Main Content */
.main-content {
    padding: 2rem;
    overflow-y: auto;
    background: radial-gradient(circle at top right, #1e293b 0%, #0f172a 40%);
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

h1 {
    font-weight: 600;
}

.time-display {
    font-family: monospace;
    font-size: 1.2rem;
    color: var(--accent-secondary);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 2rem;
    height: calc(100vh - 120px);
}

/* Cards */
.card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.video-card {
    display: flex;
    flex-direction: column;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.live-badge {
    background: var(--danger);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    animation: pulse 2s infinite;
}

.video-container {
    flex-grow: 1;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-container img,
.video-container video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.ai-overlay-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.stats-column {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.stat-card h3 {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
}

.stat-card .big-number {
    font-size: 3.5rem;
    font-weight: 700;
    color: var(--success);
}

.stat-card.secondary .big-number {
    color: var(--text-main);
}

.progress-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    margin: 1rem 0 0.5rem 0;
    overflow: hidden;
}

.progress-bar .fill {
    height: 100%;
    background: var(--success);
    transition: width 0.5s ease;
}

.subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.log-card {
    flex-grow: 1;
    overflow-y: auto;
}

.log-card ul {
    list-style: none;
    font-size: 0.8rem;
}

.log-card li {
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
}

.log-card .time {
    color: var(--accent-secondary);
    margin-right: 8px;
}

/* Loader */
.overlay-loader {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.overlay-loader.active {
    opacity: 1;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-left-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

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

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

/* ======================
   RESPONSIVE BREAKPOINTS
   ====================== */

/* Tablet (< 1024px) */
@media (max-width: 1024px) {
    .app-container {
        grid-template-columns: 200px 1fr;
    }

    .sidebar {
        padding: 1.5rem 1rem;
    }

    .logo {
        font-size: 1.2rem;
        margin-bottom: 2rem;
    }

    .nav-links a {
        padding: 0.75rem;
        font-size: 0.9rem;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .stats-column {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 1rem;
    }

    .stat-card {
        flex: 1;
        min-width: 140px;
    }

    .stat-card .big-number {
        font-size: 2.5rem;
    }
}

/* Mobile (< 768px) */
@media (max-width: 768px) {
    .app-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .sidebar {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 260px;
        height: 100vh;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.active {
        display: flex;
        transform: translateX(0);
    }

    .main-content {
        padding: 1rem;
    }

    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        margin-bottom: 1rem;
    }

    header h1 {
        font-size: 1.3rem;
    }

    .dashboard-grid {
        height: auto;
        min-height: calc(100vh - 100px);
    }

    .video-card {
        min-height: 250px;
    }

    .card {
        padding: 1rem;
        border-radius: 12px;
    }

    .stat-card .big-number {
        font-size: 2rem;
    }

    .log-card {
        max-height: 200px;
    }

    .live-badge {
        font-size: 0.6rem;
        padding: 3px 8px;
    }
}

/* Small Mobile (< 480px) */
@media (max-width: 480px) {
    .main-content {
        padding: 0.75rem;
    }

    .stats-column {
        flex-direction: column;
    }

    .stat-card {
        min-width: 100%;
    }

    header h1 {
        font-size: 1.1rem;
    }

    .time-display {
        font-size: 1rem;
    }
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #333;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
}

input:checked+.slider {
    background-color: var(--accent-primary);
}

input:focus+.slider {
    box-shadow: 0 0 1px var(--accent-primary);
}

input:checked+.slider:before {
    transform: translateX(20px);
}

/* Rounded sliders */
.slider.round {
    border-radius: 20px;
}

.slider.round:before {
    border-radius: 50%;
}
