/* ==============================================================================
   Design System & Styling for AI Multi-Vision Tracker
   Ultra Modern Dark Glassmorphism Cyberpunk Aesthetics
   ============================================================================== */

:root {
    --bg-primary: #0b0f19;
    --bg-secondary: #131b2e;
    --card-bg: rgba(19, 27, 46, 0.65);
    --card-border: rgba(255, 255, 255, 0.08);
    --accent-cyan: #00f2fe;
    --accent-blue: #4facfe;
    --accent-green: #00ff88;
    --accent-yellow: #ffb703;
    --accent-purple: #9d4edd;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;
    --shadow-glow: 0 0 25px rgba(0, 242, 254, 0.15);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Cairo', 'Outfit', sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Glowing Ambient Backgrounds */
.background-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    z-index: 0;
    pointer-events: none;
    opacity: 0.35;
}

.glow-1 {
    width: 450px;
    height: 450px;
    background: radial-gradient(circle, #00f2fe, #4facfe);
    top: -100px;
    right: -100px;
}

.glow-2 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, #7928ca, #ff0080);
    bottom: -100px;
    left: -100px;
}

.background-grid {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
                      linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 40px 40px;
    z-index: 0;
    pointer-events: none;
}

/* Main Container */
.app-container {
    position: relative;
    z-index: 1;
    max-width: 1440px;
    margin: 0 auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #000;
    box-shadow: 0 0 15px rgba(0, 242, 254, 0.4);
}

.logo-title {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: #fff;
}

.accent-text {
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: -2px;
}

.header-badges {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* Source Switcher */
.cam-source-selector {
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-full);
    padding: 3px;
    gap: 4px;
}

.source-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}

.source-btn.active {
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
    color: #000;
    box-shadow: 0 0 12px rgba(0, 242, 254, 0.4);
}

/* Network IP Badge */
.network-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(157, 78, 221, 0.12);
    border: 1px solid rgba(157, 78, 221, 0.3);
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 700;
    color: var(--accent-purple);
    cursor: pointer;
    transition: var(--transition);
    font-family: 'Outfit', sans-serif;
}

.network-badge:hover {
    background: rgba(157, 78, 221, 0.25);
    transform: translateY(-2px);
    box-shadow: 0 0 15px rgba(157, 78, 221, 0.4);
}

.network-badge .copy-icon {
    font-size: 11px;
    opacity: 0.7;
}

.fps-pill {
    background: rgba(0, 242, 254, 0.1);
    border: 1px solid rgba(0, 242, 254, 0.25);
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 700;
    color: var(--accent-cyan);
    font-family: 'Outfit', sans-serif;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 390px;
    gap: 20px;
    align-items: start;
}

@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* Glass Card */
.glass {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

.card {
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.card-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.06);
}

.section-title {
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
}

.section-title i {
    color: var(--accent-cyan);
}

/* Video Section */
.video-section {
    display: flex;
    flex-direction: column;
}

.video-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn {
    padding: 7px 14px;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.16);
    transform: translateY(-2px);
}

.btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.btn-icon:hover {
    background: var(--accent-cyan);
    color: #000;
    transform: translateY(-2px);
}

.video-viewport {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid rgba(0, 242, 254, 0.2);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.6);
}

.video-feed {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Futuristic Scanline Effect */
.stream-scanner-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent-cyan), transparent);
    box-shadow: 0 0 10px var(--accent-cyan);
    opacity: 0.6;
    animation: scan 4s linear infinite;
    pointer-events: none;
}

@keyframes scan {
    0% { top: 0%; }
    100% { top: 100%; }
}

.stream-overlay-badge {
    position: absolute;
    background: rgba(11, 15, 25, 0.85);
    border: 2px solid var(--accent-green);
    border-radius: var(--radius-md);
    padding: 10px 16px;
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.3);
    animation: fadeIn 0.3s ease;
}

.stream-overlay-badge.top-right {
    top: 16px;
    left: 16px;
}

.badge-label {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 600;
}

.badge-number {
    font-size: 36px;
    font-weight: 900;
    color: var(--accent-green);
    font-family: 'Outfit', sans-serif;
    line-height: 1;
    margin-top: 4px;
}

/* Sidebar Controls & Stats */
.controls-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Stats Row */
.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.stat-card {
    padding: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-3px);
    border-color: rgba(0, 242, 254, 0.3);
}

.stat-card.glow-border {
    border: 1px solid rgba(0, 255, 136, 0.3);
    background: rgba(0, 255, 136, 0.04);
}

.stat-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.finger-icon {
    background: rgba(0, 255, 136, 0.15);
    color: var(--accent-green);
}

.face-icon {
    background: rgba(0, 242, 254, 0.15);
    color: var(--accent-cyan);
}

.hand-icon {
    background: rgba(157, 78, 221, 0.15);
    color: var(--accent-purple);
}

.stat-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
}

.stat-value {
    font-size: 24px;
    font-weight: 800;
    color: #fff;
    font-family: 'Outfit', sans-serif;
    line-height: 1;
}

/* Objects Tags Container */
.objects-card {
    min-height: 120px;
}

.count-badge {
    background: rgba(0, 242, 254, 0.15);
    color: var(--accent-cyan);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
}

.objects-tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 48px;
    align-items: center;
}

.empty-hint {
    font-size: 12px;
    color: var(--text-muted);
}

.obj-tag {
    background: rgba(255, 183, 3, 0.12);
    border: 1px solid rgba(255, 183, 3, 0.3);
    color: var(--accent-yellow);
    padding: 5px 12px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    animation: tagAppear 0.3s ease;
}

@keyframes tagAppear {
    from { opacity: 0; transform: scale(0.85); }
    to { opacity: 1; transform: scale(1); }
}

/* Toggles List */
.toggles-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toggle-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.toggle-item:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);
}

.toggle-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.toggle-title {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.accent-color { color: var(--accent-cyan); }
.warning-color { color: var(--accent-yellow); }
.success-color { color: var(--accent-green); }
.info-color { color: var(--accent-blue); }

.toggle-desc {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Custom iOS / Cyber Switch Toggle */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.15);
    transition: var(--transition);
    border-radius: 34px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: var(--transition);
    border-radius: 50%;
}

input:checked + .slider {
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
    border-color: transparent;
    box-shadow: 0 0 12px rgba(0, 242, 254, 0.5);
}

input:checked + .slider:before {
    transform: translateX(20px);
    background-color: #000;
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(19, 27, 46, 0.95);
    border: 1px solid var(--accent-cyan);
    color: #fff;
    padding: 12px 24px;
    border-radius: var(--radius-full);
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
    z-index: 1000;
    pointer-events: none;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Primary Accent Button */
.btn-primary-accent {
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
    color: #000;
    font-weight: 700;
    box-shadow: 0 0 15px rgba(0, 242, 254, 0.35);
}

.btn-primary-accent:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 20px rgba(0, 242, 254, 0.6);
}

/* Modal Backdrop & Dialog */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.25s ease;
}

.modal-card {
    width: 100%;
    max-width: 440px;
    background: var(--bg-secondary);
    border: 1px solid rgba(0, 242, 254, 0.3);
    border-radius: var(--radius-lg);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.8), 0 0 30px rgba(0, 242, 254, 0.2);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 12px;
}

.modal-header h3 {
    font-size: 17px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    transition: var(--transition);
}

.btn-close:hover {
    color: #fff;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    font-size: 13px;
    color: var(--text-secondary);
}

.modal-input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-md);
    color: #fff;
    font-size: 14px;
    outline: none;
    transition: var(--transition);
}

.modal-input:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 15px rgba(0, 242, 254, 0.3);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 8px;
}
