:root {
    /* Apple Palette - Light Mode Default */
    --bg-primary: #f5f5f7;
    --bg-secondary: #ffffff;
    --glass-bg: rgba(255, 255, 255, 0.72);
    --glass-border: rgba(0, 0, 0, 0.05);
    --text-primary: #1d1d1f;
    --text-secondary: #86868b;
    --text-tertiary: #a1a1a6;
    
    --accent: #0071e3;
    --accent-hover: #0077ed;
    --accent-rgb: 0, 113, 227;
    
    --danger: #ff3b30;
    --danger-hover: #ff453a;
    --success: #34c759;
    --warning: #ff9500;
    
    --shadow-card: 0 8px 30px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
    --shadow-hover: 0 16px 40px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-modal: 0 30px 100px rgba(0, 0, 0, 0.12);
    
    --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 24px;
    --radius-pill: 9999px;
    
    --ease-apple: cubic-bezier(0.25, 0.8, 0.25, 1);
    --transition-fast: 150ms var(--ease-apple);
    --transition-base: 300ms var(--ease-apple);
    --transition-slow: 600ms var(--ease-apple);
}

/* Dark Mode Configuration */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #000000;
        --bg-secondary: #1c1c1e;
        --glass-bg: rgba(28, 28, 30, 0.75);
        --glass-border: rgba(255, 255, 255, 0.08);
        --text-primary: #f5f5f7;
        --text-secondary: #98989d;
        --text-tertiary: #48484a;
        --glass-border-active: rgba(255, 255, 255, 0.15);
        
        --shadow-card: 0 12px 40px rgba(0, 0, 0, 0.5), 0 2px 4px rgba(0, 0, 0, 0.3);
        --shadow-hover: 0 20px 50px rgba(0, 0, 0, 0.7), 0 4px 10px rgba(0, 0, 0, 0.5);
        --shadow-modal: 0 30px 100px rgba(0, 0, 0, 0.8);
    }
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    transition: background-color var(--transition-base), color var(--transition-base);
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--text-tertiary);
    border-radius: var(--radius-pill);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Animations */
.reveal {
    animation: fadeIn var(--transition-slow) forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Glassmorphism Card base */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    transition: transform var(--transition-base), box-shadow var(--transition-base), background var(--transition-base), border-color var(--transition-base);
}

/* ------------------- LOGIN VIEW ------------------- */
.login-body {
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at 10% 20%, rgba(0, 113, 227, 0.08) 0%, transparent 40%),
                radial-gradient(circle at 90% 80%, rgba(52, 199, 89, 0.05) 0%, transparent 40%),
                var(--bg-primary);
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.login-card {
    padding: 40px 30px;
}

.login-header {
    text-align: center;
    margin-bottom: 35px;
}

.logo-badge {
    width: 64px;
    height: 64px;
    background: rgba(0, 113, 227, 0.1);
    color: var(--accent);
    border-radius: var(--radius-md);
    display: inline-flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
    transition: transform var(--transition-base);
}

.logo-badge:hover {
    transform: scale(1.08) rotate(5deg);
}

.logo-icon {
    width: 32px;
    height: 32px;
}

.login-header h1 {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 8px;
    letter-spacing: -0.03em;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 15px;
}

/* Forms and Inputs */
.input-group {
    margin-bottom: 22px;
    display: flex;
    flex-direction: column;
}

.input-group label {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.input-field {
    width: 100%;
    padding: 14px 18px;
    border: 1.5px solid var(--glass-border);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 16px;
    font-family: var(--font-main);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    outline: none;
}

.input-field:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.15);
}

.input-field.disabled {
    background-color: var(--bg-primary);
    cursor: not-allowed;
    opacity: 0.7;
}

.input-help {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 6px;
}

.required {
    color: var(--danger);
}

/* Row utilities */
.row {
    display: flex;
    gap: 15px;
    margin-bottom: 22px;
}

.col-6 {
    flex: 1;
}

.input-group.col-6 {
    margin-bottom: 0;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    padding: 12px 24px;
    border-radius: var(--radius-pill);
    transition: background var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
    font-family: var(--font-main);
    text-decoration: none;
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn-primary {
    background: var(--accent);
    color: #ffffff;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: scale(1.015);
    box-shadow: 0 4px 15px rgba(0, 113, 227, 0.3);
}

.btn-primary:active {
    transform: scale(0.985);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
    background: var(--bg-primary);
    transform: scale(1.015);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.btn-secondary:active {
    transform: scale(0.985);
}

.btn-accent {
    background: rgba(0, 113, 227, 0.1);
    color: var(--accent);
}

.btn-accent:hover {
    background: rgba(0, 113, 227, 0.18);
    transform: scale(1.02);
}

.btn-accent:active {
    transform: scale(0.985);
}

.btn-danger {
    background: rgba(255, 59, 48, 0.1);
    color: var(--danger);
}

.btn-danger:hover {
    background: rgba(255, 59, 48, 0.2);
    transform: scale(1.02);
}

.btn-icon {
    padding: 10px;
    border-radius: var(--radius-md);
}

.btn-icon-round {
    padding: 12px;
    border-radius: 50%;
}

.btn-pill {
    padding: 10px 20px;
    border-radius: var(--radius-pill);
    font-size: 14px;
}

.icon {
    width: 20px;
    height: 20px;
}

.icon-play, .icon-refresh, .icon-fs, .icon-btn {
    width: 18px;
    height: 18px;
}

/* ------------------- DASHBOARD VIEW ------------------- */
.dashboard-body {
    min-height: 100vh;
    padding: 24px;
    gap: 24px;
}

/* Main Header */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 28px;
    height: 72px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-left h1 {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(142, 142, 147, 0.1);
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    font-size: 13px;
    font-weight: 500;
}

.status-badge.live {
    background: rgba(52, 199, 89, 0.12);
    color: var(--success);
}

.status-badge.live .dot {
    background-color: var(--success);
}

.status-badge.offline {
    background: rgba(255, 59, 48, 0.12);
    color: var(--danger);
}

.status-badge.offline .dot {
    background-color: var(--danger);
    animation: none;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-secondary);
}

.pulse {
    animation: pulseGlow 1.8s infinite ease-in-out;
}

@keyframes pulseGlow {
    0% {
        transform: scale(0.9);
        opacity: 0.6;
    }
    50% {
        transform: scale(1.2);
        opacity: 1;
        box-shadow: 0 0 10px currentColor;
    }
    100% {
        transform: scale(0.9);
        opacity: 0.6;
    }
}

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

.user-greeting {
    font-size: 15px;
    color: var(--text-secondary);
    margin-right: 10px;
}

/* Dashboard Content Grid */
.dashboard-content {
    display: grid;
    grid-template-columns: 1.8fr 1fr;
    gap: 24px;
    flex: 1;
}

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

/* Camera Card & Player */
.camera-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 16px;
}

.player-container {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background-color: #000;
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.feed-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: opacity var(--transition-base);
}

.feed-overlay {
    position: absolute;
    top: 15px;
    right: 15px;
    pointer-events: none;
}

.latency-badge {
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(10px);
    color: #fff;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
    font-family: monospace;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Controls */
.player-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 16px;
}

.divider {
    width: 1px;
    height: 24px;
    background-color: var(--glass-border);
}

.fps-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.fps-label {
    font-size: 14px;
    color: var(--text-secondary);
}

.fps-dropdown {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: var(--font-main);
    outline: none;
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

.fps-dropdown:focus {
    border-color: var(--accent);
}

.margin-left-auto {
    margin-left: auto;
}

/* Gallery Card */
.gallery-card {
    padding: 24px;
    display: flex;
    flex-direction: column;
    max-height: 700px;
}

.gallery-card h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 16px;
    letter-spacing: -0.02em;
}

.gallery-empty {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    flex: 1;
    gap: 16px;
    color: var(--text-secondary);
    text-align: center;
    padding: 40px 20px;
}

.empty-icon {
    width: 48px;
    height: 48px;
    color: var(--text-tertiary);
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 14px;
    overflow-y: auto;
    flex: 1;
    padding-right: 4px;
}

.gallery-item {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    aspect-ratio: 16/10;
    cursor: pointer;
    border: 1px solid var(--glass-border);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.gallery-item:hover {
    transform: scale(1.04);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-item-time {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    color: #fff;
    font-size: 10px;
    padding: 6px 8px;
    text-align: right;
    font-family: monospace;
}

.gallery-item-actions {
    position: absolute;
    top: 5px;
    right: 5px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.gallery-item:hover .gallery-item-actions {
    opacity: 1;
}

.gallery-action-btn {
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 4px;
    cursor: pointer;
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.gallery-action-btn:hover {
    background: #fff;
    color: #000;
}

.gallery-action-btn.delete:hover {
    background: var(--danger);
    color: #fff;
}

.gallery-action-btn svg {
    width: 14px;
    height: 14px;
}

/* ------------------- MODAL SYSTEM ------------------- */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity var(--transition-base);
}

.modal-container {
    width: 100%;
    max-width: 580px;
    padding: 30px;
    display: flex;
    flex-direction: column;
}

.animate-slide-up {
    animation: slideUp var(--transition-base) forwards;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h2 {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

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

.close-btn:hover {
    color: var(--text-primary);
}

.modal-tabs {
    display: flex;
    border-bottom: 1.5px solid var(--glass-border);
    margin-bottom: 24px;
    gap: 20px;
}

.tab-link {
    background: transparent;
    border: none;
    font-family: var(--font-main);
    font-size: 15px;
    font-weight: 500;
    padding: 10px 0;
    color: var(--text-secondary);
    cursor: pointer;
    position: relative;
    transition: color var(--transition-fast);
}

.tab-link:hover {
    color: var(--text-primary);
}

.tab-link.active {
    color: var(--accent);
}

.tab-link.active::after {
    content: '';
    position: absolute;
    bottom: -1.5px;
    left: 0;
    right: 0;
    height: 2px;
    background-color: var(--accent);
    border-radius: var(--radius-pill);
}

.modal-body {
    display: flex;
    flex-direction: column;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.tab-desc {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 15px;
    margin-top: 10px;
    border-top: 1.5px solid var(--glass-border);
}

.hidden {
    display: none !important;
}

/* ------------------- TOAST SYSTEM ------------------- */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    color: var(--text-primary);
    padding: 14px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    border-left: 4px solid var(--accent);
    border: 1px solid var(--glass-border);
    border-left-width: 4px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    transform: translateX(40px);
    opacity: 0;
    transition: transform var(--transition-base), opacity var(--transition-base);
    min-width: 250px;
    max-width: 380px;
}

.toast.visible {
    transform: translateX(0);
    opacity: 1;
}

.toast.success {
    border-left-color: var(--success);
}

.toast.error {
    border-left-color: var(--danger);
}

.toast.info {
    border-left-color: var(--accent);
}
