/* Design System & CSS Variables */
:root {
    /* Color Palette - Deep Space Theme */
    --color-bg-primary: hsl(230, 35%, 7%);
    --color-bg-secondary: hsl(230, 25%, 12%);
    --color-bg-tertiary: hsl(230, 20%, 18%);
    
    --color-accent-primary: hsl(280, 85%, 65%);
    --color-accent-secondary: hsl(200, 90%, 55%);
    --color-accent-glow: hsla(280, 85%, 65%, 0.4);
    
    --color-text-primary: hsl(0, 0%, 95%);
    --color-text-secondary: hsl(0, 0%, 70%);
    --color-text-muted: hsl(0, 0%, 50%);
    
    --color-border: hsla(0, 0%, 100%, 0.1);
    --color-border-focus: hsla(280, 85%, 65%, 0.5);
    
    /* Gradients */
    --gradient-primary: linear-gradient(135deg, hsl(280, 85%, 65%), hsl(200, 90%, 55%));
    --gradient-overlay: linear-gradient(180deg, 
        hsla(230, 35%, 7%, 0) 0%, 
        hsla(230, 35%, 7%, 0.8) 100%);
    
    /* Spacing */
    --space-xs: 0.5rem;
    --space-sm: 0.75rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    
    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.5rem;
    --font-size-2xl: 2rem;
    
    /* Borders & Radius */
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-full: 9999px;
    
    /* Shadows */
    --shadow-sm: 0 2px 8px hsla(0, 0%, 0%, 0.2);
    --shadow-md: 0 4px 16px hsla(0, 0%, 0%, 0.3);
    --shadow-lg: 0 8px 32px hsla(0, 0%, 0%, 0.4);
    --shadow-glow: 0 0 20px var(--color-accent-glow);
    
    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background: var(--color-bg-primary);
    color: var(--color-text-primary);
    line-height: 1.6;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Container */
.container {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    padding: var(--space-lg) var(--space-xl);
    background: var(--color-bg-secondary);
    border-bottom: 1px solid var(--color-border);
    position: relative;
    z-index: 10;
}

header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--gradient-primary);
    opacity: 0.6;
}

h1 {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: var(--space-xs);
}

.subtitle {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    font-weight: 300;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    position: relative;
    overflow: hidden;
}

/* Canvas Container */
.canvas-container {
    flex: 1;
    position: relative;
    background: var(--color-bg-primary);
    overflow: hidden;
}

#flockCanvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

/* Stats Display */
.stats {
    position: absolute;
    top: var(--space-lg);
    left: var(--space-lg);
    background: hsla(230, 25%, 12%, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    display: flex;
    gap: var(--space-lg);
    box-shadow: var(--shadow-md);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.stat-label {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    font-weight: 400;
}

.stat-value {
    font-size: var(--font-size-lg);
    color: var(--color-accent-secondary);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* Controls Panel */
.controls-panel {
    width: 320px;
    background: var(--color-bg-secondary);
    border-left: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    position: relative;
    transition: transform var(--transition-base);
    z-index: 20;
}

.controls-panel.collapsed {
    transform: translateX(320px);
}

.toggle-controls {
    position: absolute;
    left: -48px;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-right: none;
    border-radius: var(--radius-md) 0 0 var(--radius-md);
    color: var(--color-text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base);
}

.toggle-controls:hover {
    background: var(--color-bg-tertiary);
    box-shadow: var(--shadow-sm);
}

.toggle-controls svg {
    transition: transform var(--transition-base);
}

.controls-panel.collapsed .toggle-controls svg {
    transform: rotate(180deg);
}

.controls-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-xl);
}

.controls-content::-webkit-scrollbar {
    width: 8px;
}

.controls-content::-webkit-scrollbar-track {
    background: var(--color-bg-primary);
}

.controls-content::-webkit-scrollbar-thumb {
    background: var(--color-bg-tertiary);
    border-radius: var(--radius-full);
}

.controls-content::-webkit-scrollbar-thumb:hover {
    background: hsla(0, 0%, 100%, 0.2);
}

.controls-content h2 {
    font-size: var(--font-size-xl);
    font-weight: 700;
    margin-bottom: var(--space-xl);
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Control Sections */
.control-section {
    margin-bottom: var(--space-xl);
}

.control-section h3 {
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: var(--space-md);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: var(--font-size-sm);
}

.control-group {
    margin-bottom: var(--space-lg);
}

.control-group label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-sm);
    font-size: var(--font-size-sm);
    color: var(--color-text-primary);
}

.control-group label .value {
    color: var(--color-accent-secondary);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    min-width: 3rem;
    text-align: right;
}

/* Range Inputs */
input[type="range"] {
    width: 100%;
    height: 6px;
    background: var(--color-bg-tertiary);
    border-radius: var(--radius-full);
    outline: none;
    -webkit-appearance: none;
    cursor: pointer;
    position: relative;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--gradient-primary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px hsla(280, 85%, 65%, 0.4);
    transition: all var(--transition-fast);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--gradient-primary);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px hsla(280, 85%, 65%, 0.4);
    transition: all var(--transition-fast);
}

input[type="range"]:hover::-webkit-slider-thumb {
    transform: scale(1.2);
    box-shadow: 0 4px 12px hsla(280, 85%, 65%, 0.6), var(--shadow-glow);
}

input[type="range"]:hover::-moz-range-thumb {
    transform: scale(1.2);
    box-shadow: 0 4px 12px hsla(280, 85%, 65%, 0.6), var(--shadow-glow);
}

input[type="range"]:focus {
    outline: 2px solid var(--color-border-focus);
    outline-offset: 2px;
}

/* Checkbox */
.checkbox-group {
    display: flex;
    align-items: center;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
    user-select: none;
}

input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--color-accent-primary);
}

/* Reset Button */
.reset-button {
    width: 100%;
    padding: var(--space-md) var(--space-lg);
    background: var(--gradient-primary);
    color: var(--color-text-primary);
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-sm);
    font-family: var(--font-family);
}

.reset-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md), var(--shadow-glow);
}

.reset-button:active {
    transform: translateY(0);
}

.reset-button:focus {
    outline: 2px solid var(--color-border-focus);
    outline-offset: 2px;
}

/* Responsive Design */
@media (max-width: 768px) {
    header {
        padding: var(--space-md) var(--space-lg);
    }
    
    h1 {
        font-size: var(--font-size-xl);
    }
    
    .controls-panel {
        width: 280px;
    }
    
    .controls-panel.collapsed {
        transform: translateX(280px);
    }
    
    .stats {
        flex-direction: column;
        gap: var(--space-sm);
    }
}

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

.control-section {
    animation: fadeIn var(--transition-slow) ease-out backwards;
}

.control-section:nth-child(1) { animation-delay: 50ms; }
.control-section:nth-child(2) { animation-delay: 100ms; }
.control-section:nth-child(3) { animation-delay: 150ms; }
.control-section:nth-child(4) { animation-delay: 200ms; }
.control-section:nth-child(5) { animation-delay: 250ms; }
