/* ========================================
   ScreenSync - Modern Glassmorphism UI
   ======================================== */

:root {
    /* Colors */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a25;
    --bg-glass: rgba(255, 255, 255, 0.03);
    --bg-glass-hover: rgba(255, 255, 255, 0.06);
    
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-tertiary: rgba(255, 255, 255, 0.4);
    
    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
    
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(99, 102, 241, 0.3);
    
    /* Sizing */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s ease;
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* App Container */
.app {
    position: relative;
    min-height: 100vh;
}

/* Animated Background */
.color-bg {
    position: fixed;
    inset: 0;
    opacity: 0.15;
    transition: background-color 0.3s ease;
    pointer-events: none;
    z-index: 0;
}

.color-bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% 0%, transparent 0%, var(--bg-primary) 70%);
}

/* Container */
.container {
    position: relative;
    z-index: 1;
    max-width: 480px;
    margin: 0 auto;
    padding: 24px 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

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

.logo-icon {
    font-size: 28px;
    filter: drop-shadow(0 0 8px rgba(99, 102, 241, 0.5));
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Status Badge */
.status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: 100px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--warning);
    animation: pulse 2s infinite;
}

.status.connected .status-dot {
    background: var(--success);
}

.status.error .status-dot {
    background: var(--error);
    animation: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Main Content */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Preview Section */
.preview-section {
    width: 100%;
}

.preview-container {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 
        0 4px 24px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.preview-container video,
.preview-container canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.preview-container video {
    display: none;
}

.preview-container.active video {
    display: block;
}

.preview-container.active .preview-placeholder {
    display: none;
}

.preview-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--text-tertiary);
}

.placeholder-icon {
    font-size: 48px;
    opacity: 0.5;
}

.preview-placeholder p {
    font-size: 0.9rem;
}

/* Color Section */
.color-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(20px);
}

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

.color-swatch {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    background: #000;
    border: 2px solid var(--border-color);
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    transition: background-color 0.1s ease, box-shadow 0.3s ease;
}

.color-swatch.active {
    box-shadow: 
        0 4px 20px rgba(var(--current-color-rgb, 0, 0, 0), 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.color-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.color-value {
    font-size: 1.1rem;
    font-weight: 600;
    font-family: 'SF Mono', 'Consolas', monospace;
    letter-spacing: 0.5px;
}

.color-hsl {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    font-family: 'SF Mono', 'Consolas', monospace;
}

/* Stats */
.stats {
    display: flex;
    gap: 20px;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-primary);
    font-family: 'SF Mono', 'Consolas', monospace;
}

.stat-label {
    font-size: 0.65rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Controls */
.controls-section {
    display: flex;
    gap: 12px;
}

.btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-icon {
    font-size: 1rem;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(99, 102, 241, 0.4);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

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

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-glass-hover);
    border-color: var(--border-glow);
}

/* Settings */
.settings-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

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

.setting label {
    flex: 0 0 100px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.setting input[type="range"] {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-tertiary);
    border-radius: 2px;
    outline: none;
}

.setting input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-primary);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
    transition: transform var(--transition-fast);
}

.setting input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.setting-value {
    flex: 0 0 60px;
    font-size: 0.8rem;
    color: var(--text-tertiary);
    text-align: right;
    font-family: 'SF Mono', 'Consolas', monospace;
}

/* Footer */
.footer {
    margin-top: auto;
    padding-top: 24px;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 0.75rem;
}

.footer span {
    color: var(--accent-primary);
    font-family: 'SF Mono', 'Consolas', monospace;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.main > * {
    animation: fadeIn 0.5s ease backwards;
}

.main > *:nth-child(1) { animation-delay: 0.1s; }
.main > *:nth-child(2) { animation-delay: 0.2s; }
.main > *:nth-child(3) { animation-delay: 0.3s; }
.main > *:nth-child(4) { animation-delay: 0.4s; }

/* Responsive */
@media (max-width: 480px) {
    .container {
        padding: 16px;
    }
    
    .color-section {
        flex-direction: column;
        gap: 20px;
    }
    
    .color-display {
        width: 100%;
    }
    
    .stats {
        width: 100%;
        justify-content: center;
    }
}
