/* ========================================
   BAR CHART RACE - Premium Dark Theme
   ======================================== */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=Outfit:wght@400;500;600;700;800&display=swap');

/* CSS Variables */
:root {
    /* Colors - Dark Theme */
    --bg-primary: #0a0a1a;
    --bg-secondary: #12122a;
    --bg-tertiary: #1a1a3a;
    --bg-glass: rgba(30, 30, 60, 0.7);
    --bg-glass-light: rgba(50, 50, 90, 0.5);

    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
    --accent-glow: 0 0 30px rgba(99, 102, 241, 0.4);

    --text-primary: #ffffff;
    --text-secondary: #a5a5c0;
    --text-muted: #6b6b8a;

    --border-color: rgba(99, 102, 241, 0.2);
    --border-glow: rgba(99, 102, 241, 0.5);

    /* Sizing */
    --header-height: 50px;
    --sidebar-width: 220px;
    --control-height: 50px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* Light Theme */
body.light-mode {
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8ecf1;
    --bg-glass: rgba(255, 255, 255, 0.7);
    --bg-glass-light: rgba(232, 236, 241, 0.5);

    --accent-primary: #4f46e5;
    --accent-secondary: #7c3aed;
    --accent-gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #9333ea 100%);
    --accent-glow: 0 0 30px rgba(79, 70, 229, 0.2);

    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;

    --border-color: rgba(79, 70, 229, 0.15);
    --border-glow: rgba(79, 70, 229, 0.3);
}

/* Reset & Base */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: auto;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

/* Animated Background */
.app-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(139, 92, 246, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(168, 85, 247, 0.05) 0%, transparent 70%),
        var(--bg-primary);
    animation: backgroundPulse 15s ease-in-out infinite alternate;
}
}

@keyframes backgroundPulse {
    0% {
        opacity: 1;
    }

    100% {
        opacity: 0.8;
    }
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

/* ========================================
   HEADER
   ======================================== */
.header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: var(--bg-glass);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    position: relative;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: var(--accent-gradient);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    box-shadow: var(--accent-glow);
}

.logo-text {
    font-family: 'Outfit', sans-serif;
    font-size: 20px;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
}

.title-input {
    background: transparent;
    border: none;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
    min-width: 300px;
    padding: 8px 16px;
    border-radius: 8px;
    transition: var(--transition-fast);
}

.title-input:hover {
    background: var(--bg-glass-light);
}

.title-input:focus {
    outline: none;
    background: var(--bg-tertiary);
    box-shadow: 0 0 0 2px var(--accent-primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    outline: 2px solid transparent;
    outline-offset: 2px;
}

.btn:focus {
    outline: 2px solid var(--accent-primary);
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 10px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-icon:hover {
    background: var(--bg-glass-light);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

.btn-icon:focus {
    outline: 2px solid var(--accent-primary);
    outline-offset: 1px;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.5);
}

.btn-primary:focus {
    outline: 2px solid var(--accent-primary);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-glass-light);
    border-color: var(--accent-primary);
}

.btn-secondary:focus {
    outline: 2px solid var(--accent-primary);
}

/* ========================================
   MAIN CONTENT
   ======================================== */
.main-content {
    flex: 1;
    display: flex;
    overflow: auto;
}

/* ========================================
   VISUALIZATION AREA
   ======================================== */
.visualization-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 16px;
    overflow: visible;
}

.chart-container {
    flex: 1;
    background: var(--bg-glass);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    border: 1px solid var(--border-color);
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow-y: auto;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* Year Display */
.year-display {
    position: absolute;
    bottom: 80px;
    right: 30px;
    font-family: 'Outfit', sans-serif;
    font-size: 80px;
    font-weight: 800;
    color: white;
    line-height: 1;
    pointer-events: none;
    -webkit-user-select: none;
    user-select: none;
    transition: var(--transition-normal);
    z-index: 10;
}
}

.year-display.animating {
    animation: yearPulse 0.3s ease;
}

/* Total Display */
.chart-total {
    position: absolute;
    bottom: 20px;
    right: 30px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-glass);
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    pointer-events: none;
    -webkit-user-select: none;
    user-select: none;
}
}

@keyframes yearPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.02);
    }
}

/* Chart Title */
.chart-title {
    font-family: 'Outfit', sans-serif;
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.chart-subtitle {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Axis Scale */
.axis-scale {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    padding: 0 30px;
    position: relative;
    height: 20px;
}

.scale-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
    flex: 1;
    font-weight: 500;
}

.scale-label:first-child {
    text-align: left;
}

.scale-label:last-child {
    text-align: right;
}

/* Bars Container */
.bars-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    position: relative;
    overflow: visible;
    min-height: 420px;
}

/* Single Bar */
.bar-row {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 38px;
    position: absolute;
    left: 0;
    right: 0;
    will-change: transform, opacity;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.3s ease;
}

.bar-row:hover {
    opacity: 1 !important;
}

.bar-row:hover .bar {
    filter: brightness(1.1);
}

/* Leader Highlight */
.bar-row.leader .bar {
    box-shadow:
        0 0 20px rgba(99, 102, 241, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.bar-row.leader .bar-rank {
    color: var(--accent-primary);
    font-weight: 800;
}

.bar-rank {
    width: 30px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    text-align: center;
    flex-shrink: 0;
}

.bar-flag {
    width: 32px;
    height: 24px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Icon/Flag outside bar */
.bar-icon {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Emoji icon styles - Shared */
.bar-icon-emoji {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    flex-shrink: 0;
}

/* Specific size for outside emoji */
.bar-icon-emoji:not(.inside) {
    width: 32px;
    height: 32px;
    font-size: 20px;
    background: rgba(99, 102, 241, 0.15);
    border-radius: 4px;
}

.bar-name {
    width: 140px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bar-wrapper {
    flex: 1;
    height: 28px;
    position: relative;
    border-radius: 6px;
    overflow: visible;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    padding-right: 120px;
}

.bar {
    height: 100%;
    border-radius: 6px;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s ease, filter 0.2s ease;
    position: relative;
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: flex-start;
    padding-left: 4px;
    padding-right: 4px;
    min-width: 0;
}

.bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.2), transparent);
    border-radius: 6px 6px 0 0;
    pointer-events: none;
}

/* Icon inside bar */
.bar-icon-flag {
    width: 20px;
    height: 16px;
    border-radius: 2px;
    object-fit: cover;
    flex-shrink: 0;
    display: block;
}

/* Emoji inside bar */
.bar-icon-emoji.inside {
    width: 20px;
    height: 20px;
    font-size: 14px;
}

/* Value displayed after bar */
.bar-value {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    white-space: nowrap;
    margin-left: 12px;
    z-index: 10;
    position: relative;
    /* Stays in flow for flex positioning */
    background: linear-gradient(90deg, transparent 0%, var(--bg-secondary) 20%, var(--bg-secondary) 80%, transparent 100%);
    padding: 2px 8px;
    border-radius: 4px;
    min-width: 80px;
    text-align: right;
    font-family: 'Courier New', monospace;
}

/* Handle overflow for very small bars if needed */
.bar-value.outside {
    /* No special handling needed in flex layout unless specific override */
    position: relative;
    left: auto;
    top: auto;
    transform: none;
}

/* ========================================
   CONTROLS
   ======================================== */
.controls-container {
    padding: 0 24px 24px;
}

.controls {
    background: var(--bg-glass);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    padding: 10px 14px;
    margin-top: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.playback-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.play-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent-gradient);
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--accent-glow);
    transition: var(--transition-fast);
}

.play-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.6);
}

.play-btn:active {
    transform: scale(0.95);
}

.control-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.control-btn:hover {
    background: var(--bg-glass-light);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

/* Timeline */
.timeline-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.timeline-labels {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
    padding: 0 4px;
}

/* Help Button */
.help-btn {
    position: absolute;
    bottom: 16px;
    left: 16px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent-gradient);
    color: white;
    border: none;
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: var(--accent-glow);
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.help-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.5);
}

.help-btn:focus {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

.timeline-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: linear-gradient(to right,
            var(--accent-primary) 0%,
            var(--accent-primary) var(--progress, 0%),
            var(--bg-tertiary) var(--progress, 0%),
            var(--bg-tertiary) 100%);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    position: relative;
}

.timeline-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: var(--accent-gradient);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--accent-glow);
    transition: var(--transition-fast);
}

.timeline-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.timeline-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: var(--accent-gradient);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: var(--accent-glow);
}

/* Current Year Badge */
.current-year-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--accent-gradient);
    border-radius: 12px;
    box-shadow: var(--accent-glow);
}

.current-year-badge span:first-child {
    font-size: 12px;
    font-weight: 500;
    opacity: 0.8;
}

.current-year-badge span:last-child {
    font-family: 'Outfit', sans-serif;
    font-size: 24px;
    font-weight: 700;
}

/* Speed Control */
.speed-control {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 100px;
}

.speed-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.speed-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 80px;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.speed-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent-secondary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.5);
}

.speed-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

/* ========================================
   SIDEBAR
   ======================================== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-glass);
}

.sidebar-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    background: var(--bg-secondary);
}

/* Settings Panel */
.settings-panel {
    margin-bottom: 8px;
    background: var(--bg-tertiary);
    border-radius: 10px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: var(--transition-fast);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    cursor: pointer;
    transition: var(--transition-fast);
    background: var(--bg-tertiary);
}

.panel-header:hover {
    background: var(--bg-glass-light);
}

.panel-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-title .icon {
    font-size: 14px;
    opacity: 0.7;
}

.panel-toggle {
    color: var(--text-muted);
    font-size: 12px;
    transition: var(--transition-fast);
}

.settings-panel.open .panel-toggle {
    transform: rotate(180deg);
}

.panel-content {
    padding: 0 12px 12px;
    display: none;
    background: var(--bg-secondary);
}

.settings-panel.open .panel-content {
    display: block;
}

/* Setting Row */
.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.setting-row:last-child {
    border-bottom: none;
}

.setting-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.setting-value {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Custom Inputs */
.input-number {
    width: 50px;
    padding: 4px 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 12px;
    text-align: center;
}

.input-number:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

/* Search Input */
.search-input {
    width: 100%;
    padding: 6px 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 12px;
    margin-bottom: 10px;
    transition: var(--transition-fast);
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
    background: var(--bg-secondary);
}

/* Toggle Switch */
.toggle {
    position: relative;
    width: 40px;
    height: 22px;
    background: var(--bg-primary);
    border-radius: 11px;
    cursor: pointer;
    border: 1px solid var(--border-color);
    transition: var(--transition-fast);
}

.toggle.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    transition: var(--transition-fast);
}

.toggle.active::after {
    left: 20px;
}

/* Select Dropdown */
.select-wrapper {
    position: relative;
}

.select-input {
    padding: 5px 24px 5px 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 12px;
    cursor: pointer;
    appearance: none;
}

.select-wrapper::after {
    content: '▼';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 8px;
    color: var(--text-muted);
    pointer-events: none;
}

/* ========================================
   FULLSCREEN MODE
   ======================================== */
.app-container.fullscreen .header,
.app-container.fullscreen .sidebar {
    display: none;
}

/* Hide global header in fullscreen */
.app-container.fullscreen ~ .global-header,
body.fullscreen .global-header {
    opacity: 0 !important;
    visibility: hidden !important;
    transform: translateY(-100%) !important;
    pointer-events: none !important;
    height: 0 !important;
}

.app-container.fullscreen .visualization-area {
    padding: 8px;
    height: 100vh;
    overflow: hidden;
}

.app-container.fullscreen .chart-container {
    border-radius: 12px;
    height: 100%;
    padding: 8px;
    display: flex;
    flex-direction: column;
}

.app-container.fullscreen .bars-container {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.app-container.fullscreen .bar-row {
    height: 28px;
    gap: 6px;
}

.app-container.fullscreen .bar-rank {
    width: 24px;
    font-size: 12px;
}

.app-container.fullscreen .bar-name {
    width: 100px;
    font-size: 12px;
}

.app-container.fullscreen .bar-value {
    font-size: 11px;
    min-width: 60px;
}

.app-container.fullscreen .chart-title {
    font-size: 20px;
}

.app-container.fullscreen .chart-subtitle {
    font-size: 13px;
}

.app-container.fullscreen .speed-control {
    display: none;
}

.app-container.fullscreen .help-btn {
    display: none;
}


/* ========================================
   ANIMATIONS
   ======================================== */
@keyframes glowPulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(100, 150, 255, 0.4);
        border-color: rgba(100, 150, 255, 0.4);
    }

    50% {
        box-shadow: 0 0 15px 5px rgba(100, 150, 255, 0.2);
        border-color: rgba(100, 150, 255, 0.7);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.bar-row {
    animation: fadeIn 0.5s ease-out;
}

/* ========================================
   SCROLLBAR
   ======================================== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

::-webkit-scrollbar-thumb {
    background: var(--accent-primary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-secondary);
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 1200px) {
    .sidebar {
        display: none;
    }
}

/* Tablet devices (landscape) */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 180px;
    }

    .sidebar {
        width: 180px;
    }

    .main-content {
        margin-left: 180px;
    }
}

/* Tablet devices (portrait) and larger phones */
@media (max-width: 768px) {
    :root {
        --header-height: 60px;
        --sidebar-width: 0;
    }

    .app-background {
        animation: none;
    }

    .header {
        padding: 0 12px;
        height: 60px;
        gap: 8px;
        flex-wrap: wrap;
    }

    .header-left,
    .header-center,
    .header-right {
        flex: 0 0 auto;
    }

    .logo-text {
        display: none;
    }

    .header-center {
        flex: 1;
        min-width: 0;
        order: 3;
        width: 100%;
    }

    .title-input {
        min-width: 150px;
        font-size: 13px;
        padding: 6px 8px;
        width: 100%;
    }

    .header-right {
        display: flex;
        gap: 4px;
        order: 2;
    }

    .btn-secondary span,
    .btn-primary span {
        display: none;
    }

    .btn {
        padding: 8px 10px;
        font-size: 16px;
    }

    .app-container {
        flex-direction: column;
    }

    .main-content {
        margin-left: 0;
        display: flex;
        flex-direction: column;
    }

    .visualization-area {
        padding: 12px;
        flex: 1;
        display: flex;
        flex-direction: column;
        order: 1;
    }

    .chart-container {
        padding: 12px;
        flex: 1;
        display: flex;
        flex-direction: column;
    }

    .bars-container {
        flex: 1;
        overflow-y: auto;
        max-height: 60vh;
    }

    .year-display {
        font-size: 48px;
        right: 12px;
        bottom: 12px;
    }

    .chart-title {
        font-size: 18px;
        margin-bottom: 4px;
    }

    .chart-subtitle {
        font-size: 12px;
        margin-bottom: 8px;
    }

    .bar-rank {
        min-width: 20px;
        font-size: 12px;
    }

    .bar-name {
        width: 70px;
        font-size: 11px;
    }

    .bar-value {
        font-size: 11px;
    }

    .controls {
        flex-wrap: wrap;
        gap: 12px;
        padding: 12px;
        order: 2;
    }

    .timeline-container {
        order: 3;
        width: 100%;
    }

    .speed-control {
        min-width: auto;
    }

    .settings-panel {
        width: 100% !important;
        position: static !important;
        max-height: 400px;
        overflow-y: auto;
    }

    aside {
        position: fixed;
        right: -100%;
        top: 60px;
        width: 100%;
        height: calc(100% - 60px);
        background: var(--bg-secondary);
        z-index: 900;
        transition: right 0.3s ease;
        overflow-y: auto;
        border-left: 1px solid var(--border-color);
    }

    aside.open {
        right: 0;
    }
}

/* Small phones (landscape) */
@media (max-width: 600px) {
    :root {
        --header-height: 50px;
        --control-height: 40px;
    }

    .header {
        padding: 0 8px;
        height: 50px;
        gap: 4px;
    }

    .logo {
        width: 30px;
        height: 30px;
    }

    .logo-icon {
        font-size: 20px;
    }

    .title-input {
        min-width: 100px;
        font-size: 12px;
        padding: 4px 6px;
    }

    .btn {
        padding: 6px 8px;
        font-size: 14px;
        min-width: auto;
    }

    .btn-icon {
        width: 36px;
        height: 36px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .visualization-area {
        padding: 8px;
    }

    .chart-container {
        padding: 8px;
    }

    .bars-container {
        max-height: 50vh;
    }

    .year-display {
        font-size: 36px;
        right: 8px;
        bottom: 8px;
    }

    .chart-title {
        font-size: 16px;
        margin-bottom: 2px;
    }

    .chart-subtitle {
        font-size: 11px;
        margin-bottom: 6px;
    }

    .bar-row {
        min-height: 28px;
        gap: 4px;
        padding: 0 4px;
    }

    .bar-rank {
        min-width: 16px;
        font-size: 10px;
    }

    .bar-name {
        width: 60px;
        font-size: 10px;
    }

    .bar-value {
        font-size: 10px;
        min-width: 50px;
    }

    .bar {
        min-height: 20px;
    }

    .controls {
        gap: 8px;
        padding: 8px;
        flex-direction: column;
    }

    .btn-link {
        width: 100%;
        text-align: center;
    }

    .speed-control,
    .play-controls {
        width: 100%;
    }

    .input-number,
    .select-input {
        font-size: 13px;
        padding: 6px 8px;
    }

    .panel-content {
        max-height: 300px;
    }

    .setting-row {
        padding: 8px;
    }

    .chart-tooltip {
        max-width: 250px;
        font-size: 12px;
        padding: 12px !important;
    }

    .stats-panel {
        bottom: 50px !important;
        right: 10px !important;
        min-width: 200px !important;
    }
}

/* Shortcut Description */
.shortcut-desc {
    font-size: 12px;
    color: var(--text-muted);
}

/* Dataset Select */
.dataset-select {
    width: 140px;
}

/* ========================================
   NOTIFICATION ANIMATIONS
   ======================================== */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(100px);
    }
}

/* Skip Link for Accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--accent-primary);
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    border-radius: 0 0 8px 0;
    z-index: 10000;
}

.skip-link:focus {
    top: 0;
}

/* Enhanced Bar Hover Effects */
.bar-row {
    cursor: pointer;
}

.bar-row:hover {
    z-index: 100 !important;
}

.bar-row:hover .bar {
    filter: brightness(1.2) saturate(1.1);
    transform: scaleY(1.05);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

/* Smooth Theme Transition */
body {
    transition: background-color 0.3s ease;
}

body * {
    transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

/* Loading State */
@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.loading {
    animation: pulse 1.5s ease-in-out infinite;
}