/* === Algorithm Visualizer Shared Theme === */

:root {
    /* Light mode (default) */
    --accent: #3498db;
    --accent-hover: #2980b9;
    --bg-primary: #f5f5f5;
    --bg-card: #ffffff;
    --bg-code: #2c3e50;
    --bg-highlight: #f8f9fa;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-muted: #7f8c8d;
    --text-code: #ecf0f1;
    --border-color: #e0e0e0;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.15);

    /* State colors */
    --color-comparing: #f39c12;
    --color-swapping: #e74c3c;
    --color-sorted: #27ae60;
    --color-active: #3498db;
    --color-visited: #9b59b6;
    --color-highlight: #f1c40f;

    /* Sizing */
    --radius: 8px;
    --radius-sm: 4px;
    --spacing: 20px;
    --font-mono: 'Monaco', 'Menlo', 'Consolas', monospace;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Dark mode */
[data-theme="dark"] {
    --bg-primary: #1a1a2e;
    --bg-card: #16213e;
    --bg-code: #0f0f23;
    --bg-highlight: #1a1a3e;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --text-muted: #808080;
    --text-code: #e0e0e0;
    --border-color: #2a2a4a;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.4);
}

/* === Theme Toggle Button === */
.theme-toggle {
    position: fixed;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 18px;
    cursor: pointer;
    box-shadow: var(--shadow);
    z-index: 1000;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    transform: scale(1.1);
}

/* === Algo Control Bar === */
.algo-control-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: var(--spacing);
    flex-wrap: wrap;
}

.algo-control-bar button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
    background: var(--bg-highlight);
    color: var(--text-primary);
}

.algo-control-bar button:hover {
    background: var(--accent);
    color: white;
}

.algo-control-bar button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.algo-control-bar button:disabled:hover {
    background: var(--bg-highlight);
    color: var(--text-primary);
}

.algo-control-bar .btn-play {
    background: var(--accent);
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 18px;
}

.algo-control-bar .btn-play:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
}

.algo-control-bar .speed-control {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    font-size: 13px;
    color: var(--text-muted);
}

.algo-control-bar .speed-control input[type="range"] {
    width: 80px;
    accent-color: var(--accent);
}

.algo-control-bar .progress-info {
    font-size: 13px;
    color: var(--text-secondary);
    min-width: 80px;
    text-align: center;
}

/* Progress bar */
.algo-progress-bar {
    width: 100%;
    height: 4px;
    background: var(--bg-highlight);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 4px;
}

.algo-progress-bar .fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.15s ease;
}

/* === Pseudocode Panel === */
.pseudocode-panel {
    background: var(--bg-code);
    color: var(--text-code);
    padding: 16px;
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.8;
    margin-bottom: var(--spacing);
    overflow-x: auto;
}

.pseudocode-panel .panel-title {
    font-size: 14px;
    font-weight: bold;
    color: var(--accent);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.pseudocode-panel .code-line {
    display: flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.pseudocode-panel .code-line.active {
    background: rgba(241, 196, 15, 0.25);
    border-left: 3px solid var(--color-highlight);
}

.pseudocode-panel .line-number {
    color: rgba(255, 255, 255, 0.3);
    min-width: 30px;
    text-align: right;
    margin-right: 12px;
    user-select: none;
    font-size: 12px;
}

.pseudocode-panel .line-content {
    white-space: pre;
}

/* Syntax colors */
.pseudocode-panel .kw { color: #c678dd; }     /* keyword */
.pseudocode-panel .fn { color: #61afef; }     /* function */
.pseudocode-panel .num { color: #d19a66; }    /* number */
.pseudocode-panel .str { color: #98c379; }    /* string */
.pseudocode-panel .cmt { color: #5c6370; font-style: italic; } /* comment */

/* === Video Recording Mode (9:16) === */
@media (max-width: 450px), (max-aspect-ratio: 10/16) {
    body.video-mode {
        max-width: 405px;
        margin: 0 auto;
        padding: 10px;
    }

    body.video-mode .nav-link,
    body.video-mode .theme-toggle {
        display: none;
    }

    body.video-mode .pseudocode-panel {
        font-size: 12px;
    }
}

body.video-mode {
    max-width: 405px;
    margin: 0 auto;
}

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

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

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

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

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 5px var(--accent); }
    50% { box-shadow: 0 0 20px var(--accent); }
}
