/**
 * @fileoverview Styles cho External Sort Visualizer Dashboard
 * @description Theme sáng/tối với bố cục 3 cột chuyên nghiệp
 * @version 3.0.0
 */

/* ========== CSS Variables - Light Theme ========== */
:root,
[data-theme="light"] {
    --bg-primary: #dbeafe;
    --bg-gradient: linear-gradient(180deg, #B3E5FC 0%, #c8edfb 20%, #daf3ff 45%, #e8f4fd 70%, #f0f7ff 100%);
    --bg-secondary: #ffffff;
    --bg-tertiary: #f8f9fa;
    --bg-hover: #e8eaed;

    --text-primary: #1a1d23;
    --text-secondary: #5f6368;
    --text-muted: #9aa0a6;

    --border-color: #e0e3e8;
    --border-light: #eef0f3;

    --accent: #4a7c6f;
    --accent-light: #5a9a8a;
    --accent-bg: #e8f5f0;
    --accent-text: #fff;

    --viz-default: #8fbcad;
    --viz-comparing: #e8725a;
    --viz-merging: #f59e0b;
    --viz-sorted: #4a7c6f;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.1);

    --header-bg: #ffffff;
    --sidebar-bg: #ffffff;
    --card-bg: #ffffff;
    --footer-bg: #f8f9fa;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-full: 50px;
}

/* ========== Dark Theme ========== */
[data-theme="dark"] {
    --bg-primary: #0d1117;
    --bg-gradient: linear-gradient(180deg, #0d1b2a 0%, #131f30 25%, #182640 50%, #1a2342 75%, #1e2550 100%);
    --bg-secondary: #1a1d24;
    --bg-tertiary: #22252d;
    --bg-hover: #2a2d36;

    --text-primary: #e8eaed;
    --text-secondary: #9aa0a6;
    --text-muted: #6b7075;

    --border-color: #2d3038;
    --border-light: #252830;

    --accent: #5a9a8a;
    --accent-light: #6fb5a3;
    --accent-bg: #1e3a32;

    --viz-default: #5a8a7d;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.5);

    --header-bg: #1a1d24;
    --sidebar-bg: #1a1d24;
    --card-bg: #1e2128;
    --footer-bg: #15171c;
}

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

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-gradient, var(--bg-primary));
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ========== HEADER ========== */
.app-header {
    display: flex;
    align-items: center;
    padding: 0 20px;
    height: 56px;
    background: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    z-index: 100;
    gap: 16px;
}

.header-left {
    flex: 0 0 auto;
}

.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
}

.header-right {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Logo */
.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    font-size: 1.8rem;
}

.logo-title {
    font-weight: 700;
    font-size: 1.35rem;
    color: var(--text-primary);
}

.logo-subtitle {
    display: block;
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* Step Nav */
.step-nav {
    display: flex;
    gap: 4px;
    background: var(--bg-tertiary);
    padding: 4px;
    border-radius: var(--radius-full);
}

.step-nav-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 18px;
    border: none;
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.step-nav-btn:hover {
    background: var(--bg-hover);
}

.step-nav-btn.active {
    background: var(--accent);
    color: var(--accent-text);
}

.step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    font-size: 0.72rem;
    font-weight: 700;
}

.step-nav-btn:not(.active) .step-num {
    background: var(--border-color);
    color: var(--text-muted);
}

/* Theme Switch */
.theme-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 30px;
    cursor: pointer;
}

.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.theme-slider {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, #4FC3F7 0%, #81D4FA 50%, #B3E5FC 100%);
    border-radius: 30px;
    transition: background 0.5s;
    overflow: hidden;
}

/* ---- Clouds (light mode) ---- */
.theme-clouds {
    position: absolute;
    inset: 0;
    transition: opacity 0.4s;
}

.cloud {
    position: absolute;
    background: #fff;
    border-radius: 50%;
    opacity: 0.9;
}

@keyframes cloud-float-right {

    0%,
    100% {
        transform: translateX(0);
    }

    50% {
        transform: translateX(-20px);
    }
}

@keyframes cloud-float-left {

    0%,
    100% {
        transform: translateX(0);
    }

    50% {
        transform: translateX(-14px);
    }
}

@keyframes cloud-float-gentle {

    0%,
    100% {
        transform: translateX(0);
    }

    50% {
        transform: translateX(8px);
    }
}

/* Fluffy cloud 1 - top right */
.cloud.c1 {
    width: 8px;
    height: 6px;
    right: 8px;
    top: 7px;
    border-radius: 50%;
    box-shadow:
        5px 0 0 1px #fff,
        -4px 1px 0 0px #fff,
        2px -2px 0 1px #fff,
        7px 1px 0 -1px rgba(255, 255, 255, 0.8);
    animation: cloud-float-right 8s ease-in-out infinite;
}

/* Fluffy cloud 2 - bottom right */
.cloud.c2 {
    width: 6px;
    height: 5px;
    right: 5px;
    bottom: 5px;
    box-shadow:
        4px 0 0 0px #fff,
        -3px 0 0 0px #fff,
        1px -2px 0 1px #fff;
    animation: cloud-float-left 10s ease-in-out infinite;
}

/* Fluffy cloud 3 - mid right */
.cloud.c3 {
    width: 7px;
    height: 5px;
    right: 21px;
    top: 12px;
    opacity: 0.8;
    border-radius: 50%;
    box-shadow:
        4px 0 0 1px #fff,
        -3px 1px 0 0px #fff,
        1px -2px 0 1px #fff;
    animation: cloud-float-gentle 8s ease-in-out infinite;
}

/* ---- Stars (dark mode) ---- */
.theme-stars {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 0.4s;
}

.star {
    position: absolute;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 0 3px 1px rgba(255, 255, 255, 0.6);
}

/* Twinkling animation */
@keyframes twinkle {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

.star.s1 {
    width: 2px;
    height: 2px;
    left: 10px;
    top: 6px;
    animation: twinkle 2s ease-in-out infinite;
}

.star.s2 {
    width: 3px;
    height: 3px;
    left: 18px;
    top: 17px;
    animation: twinkle 3s ease-in-out 0.5s infinite;
    box-shadow: 0 0 4px 2px rgba(255, 255, 255, 0.5);
}

.star.s3 {
    width: 2px;
    height: 2px;
    left: 7px;
    bottom: 6px;
    animation: twinkle 2.5s ease-in-out 1s infinite;
}

.star.s4 {
    width: 2px;
    height: 2px;
    left: 22px;
    top: 9px;
    animation: twinkle 1.8s ease-in-out 0.3s infinite;
}

.star.s5 {
    width: 1px;
    height: 1px;
    left: 14px;
    top: 4px;
    animation: twinkle 2.2s ease-in-out 0.8s infinite;
}

.star.s6 {
    width: 2px;
    height: 2px;
    left: 5px;
    top: 13px;
    animation: twinkle 2.8s ease-in-out 1.5s infinite;
}

/* ---- Icon thumb (no white bg) ---- */
.theme-icon-sun,
.theme-icon-moon {
    position: absolute;
    top: 0;
    left: 1px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    border-radius: 50%;
    background: transparent;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s;
    z-index: 2;
    line-height: 1;
}

.theme-icon-sun {
    filter:
        drop-shadow(0 0 3px #FFD700) drop-shadow(0 0 6px #FFD700) drop-shadow(0 0 10px rgba(255, 215, 0, 0.4));
}

.theme-icon-moon {
    filter:
        drop-shadow(0 0 3px #fff) drop-shadow(0 0 6px rgba(255, 255, 255, 0.5));
}

/* Light mode (unchecked): sun on left */
.theme-icon-sun {
    opacity: 1;
    transform: translateX(0);
}

.theme-icon-moon {
    opacity: 0;
    transform: translateX(0);
}

/* ---- Dark mode (checked) ---- */
.theme-switch input:checked+.theme-slider {
    background: linear-gradient(180deg, #0d1b2a 0%, #1b2838 50%, #2d2b55 100%);
}

.theme-switch input:checked+.theme-slider .theme-clouds {
    opacity: 0;
}

.theme-switch input:checked+.theme-slider .theme-stars {
    opacity: 1;
}

.theme-switch input:checked+.theme-slider .theme-icon-sun {
    opacity: 0;
    transform: translateX(30px);
}

.theme-switch input:checked+.theme-slider .theme-icon-moon {
    opacity: 1;
    transform: translateX(30px);
}

.btn-new-session {
    padding: 6px 16px;
    border: none;
    border-radius: var(--radius-full);
    background: var(--accent);
    color: #fff;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-new-session:hover {
    background: var(--accent-light);
    transform: translateY(-1px);
}

/* ========== MAIN LAYOUT ========== */
.app-main {
    display: flex;
    flex: 1;
    overflow: hidden;
    height: calc(100vh - 56px - 32px);
}

/* ========== SIDEBARS ========== */
.sidebar {
    width: 320px;
    flex-shrink: 0;
    padding: 14px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
}

.sidebar-right {
    border-right: none;
    border-left: 1px solid var(--border-color);
}

/* ========== CARDS ========== */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

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

.card-title {
    flex: 1;
    text-transform: uppercase;
}

.card-body {
    padding: 14px;
}

/* Badge */
.badge {
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-green {
    background: var(--accent-bg);
    color: var(--accent);
}

/* File Info */
.file-name {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.file-meta {
    display: flex;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* Input Tabs */
.input-tabs {
    margin-top: 12px;
}

.input-tab-buttons {
    display: flex;
    gap: 2px;
    margin-bottom: 10px;
}

.input-tab-btn {
    flex: 1;
    padding: 5px 4px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s;
}

.input-tab-btn:hover {
    background: var(--bg-hover);
}

.input-tab-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.input-tab-content {
    display: none;
}

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

/* Mini Form */
.mini-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mini-form label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.mini-form input[type="number"] {
    width: 80px;
    padding: 4px 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    text-align: center;
}

.mini-form input:focus {
    outline: none;
    border-color: var(--accent);
}

.mini-form textarea,
#manualInput {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    resize: vertical;
}

.mini-form textarea:focus,
#manualInput:focus {
    outline: none;
    border-color: var(--accent);
}

/* Upload Zone Mini */
.upload-zone-mini {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: center;
    transition: all 0.2s;
    cursor: pointer;
}

.upload-zone-mini:hover,
.upload-zone-mini.dragover {
    border-color: var(--accent);
    background: var(--accent-bg);
}

.upload-zone-mini p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.upload-zone-mini small {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.upload-link {
    color: var(--accent);
    cursor: pointer;
    text-decoration: underline;
    font-weight: 600;
}

/* ========== STATS ========== */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
}

.stat-item {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 2px;
}

.stat-value {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-highlight {
    color: var(--accent);
}

.stat-minmax {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 10px;
    border-top: 1px solid var(--border-light);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ========== BUTTONS ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn:hover {
    background: var(--bg-hover);
}

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

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

.btn-primary:hover {
    background: var(--accent-light);
    border-color: var(--accent-light);
}

.btn-secondary {
    background: var(--bg-tertiary);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 12px 28px;
    font-size: 1rem;
    font-weight: 600;
}

.btn-result {
    width: 100%;
    justify-content: flex-start;
    padding: 10px 14px;
    margin-bottom: 6px;
    border-radius: var(--radius-md);
    font-weight: 500;
}

.btn-result:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-link {
    background: none;
    border: none;
    color: var(--accent);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-link:hover {
    text-decoration: underline;
}

/* ========== CENTER AREA ========== */
.center-area {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    background: var(--bg-primary);
}

/* Tab Panels */
.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
    animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.panel-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-primary);
}

/* ========== CONFIG PANEL ========== */
.config-container {
    max-width: 720px;
    margin: 0 auto;
}

.data-preview-box {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 14px;
    margin-bottom: 16px;
}

.data-preview-box h3 {
    font-size: 0.95rem;
    margin-bottom: 10px;
}

.data-display {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    max-height: 100px;
    overflow-y: auto;
    padding: 10px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

.data-item {
    padding: 2px 8px;
    background: var(--accent-bg);
    color: var(--accent);
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-family: 'Courier New', monospace;
    font-weight: 600;
}

.config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 16px;
}

.config-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px;
}

.config-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.config-icon {
    font-size: 1.1rem;
}

.config-title {
    flex: 1;
    font-weight: 600;
    font-size: 0.9rem;
}

.config-badge {
    background: var(--accent);
    color: #fff;
    padding: 2px 10px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 1rem;
}

.config-unit {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.config-slider {
    width: 100%;
    height: 6px;
    border-radius: var(--radius-full);
    background: var(--bg-hover);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    margin-bottom: 8px;
}

.config-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    transition: transform 0.15s;
}

.config-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.config-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.4;
}

/* Estimation */
.estimation-box {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 14px;
    margin-bottom: 16px;
}

.estimation-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.estimation-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.estimation-item {
    background: var(--bg-tertiary);
    padding: 12px;
    border-radius: var(--radius-md);
    text-align: center;
}

.estimation-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

.estimation-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
}

.config-actions {
    text-align: center;
}

/* ========== SIMULATION PANEL ========== */
.viz-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 14px;
}

.viz-header-left {
    flex: 1;
}

.viz-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.viz-header-right {
    display: flex;
    gap: 4px;
}

.viz-view-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
}

.viz-view-btn:hover,
.viz-view-btn.active {
    background: var(--accent-bg);
    border-color: var(--accent);
}

/* Step Info */
.step-info {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    margin-bottom: 14px;
}

.step-badge {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    padding: 2px 10px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    margin-right: 8px;
}

.step-phase {
    font-weight: 600;
    color: var(--accent);
}

.step-detail {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 4px;
    line-height: 1.5;
}

/* Viz Container */
.viz-container {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    min-height: 260px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 2px;
    overflow-x: auto;
    margin-bottom: 14px;
}

/* Viz Bars */
.viz-bar {
    min-width: 8px;
    background: var(--viz-default);
    border-radius: 3px 3px 0 0;
    transition: all 0.15s ease;
    position: relative;
    cursor: pointer;
}

.viz-bar:hover {
    filter: brightness(1.15);
}

.viz-bar.comparing {
    background: var(--viz-comparing);
    box-shadow: 0 0 8px var(--viz-comparing);
}

.viz-bar.merging {
    background: var(--viz-merging);
    box-shadow: 0 0 8px var(--viz-merging);
}

.viz-bar.sorted {
    background: var(--viz-sorted);
}

.viz-bar-value {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem;
    font-weight: 600;
    white-space: nowrap;
    padding: 1px 4px;
    background: var(--text-primary);
    color: var(--bg-secondary);
    border-radius: 3px;
    margin-bottom: 3px;
    opacity: 0.9;
}

/* Playback Controls */
.playback-controls {
    display: flex;
    align-items: center;
    gap: 20px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 12px 20px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.playback-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
}

.play-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.control-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover {
    background: var(--bg-hover);
}

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

.speed-control {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 200px;
    flex-wrap: wrap;
}

.speed-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.speed-slider {
    flex: 1;
    height: 5px;
    border-radius: var(--radius-full);
    background: var(--bg-hover);
    -webkit-appearance: none;
    appearance: none;
    outline: none;
    min-width: 100px;
}

.speed-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
}

.speed-value {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent);
    min-width: 50px;
}

.speed-range-labels {
    width: 100%;
    display: flex;
    justify-content: space-between;
    margin-top: -4px;
}

.speed-range-labels small {
    font-size: 0.6rem;
    color: var(--text-muted);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
}

.status-dot.processing {
    background: #ef4444;
    animation: pulse-dot 1s infinite;
}

@keyframes pulse-dot {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

.status-text {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Viz Legend */
.viz-legend {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.legend-color {
    width: 14px;
    height: 14px;
    border-radius: 3px;
}

.legend-color.default {
    background: var(--viz-default);
}

.legend-color.comparing {
    background: var(--viz-comparing);
}

.legend-color.merging {
    background: var(--viz-merging);
}

.legend-color.sorted {
    background: var(--viz-sorted);
}

/* ========== RESULT PANEL ========== */
.result-container {
    max-width: 700px;
    margin: 0 auto;
    text-align: center;
}

.result-check-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
}

.checkmark {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: block;
    stroke-width: 2;
    stroke: #4CAF50;
    stroke-miterlimit: 10;
    animation: checkmark-fill 0.4s ease-in-out 0.4s forwards, checkmark-scale 0.3s ease-in-out 0.9s both;
}

.checkmark-circle {
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    stroke-width: 2;
    stroke: #4CAF50;
    fill: none;
    animation: checkmark-stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.checkmark-check {
    transform-origin: 50% 50%;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    stroke: #4CAF50;
    stroke-width: 3;
    animation: checkmark-stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
}

@keyframes checkmark-stroke {
    100% {
        stroke-dashoffset: 0;
    }
}

@keyframes checkmark-scale {

    0%,
    100% {
        transform: none;
    }

    50% {
        transform: scale3d(1.1, 1.1, 1);
    }
}

@keyframes checkmark-fill {
    100% {
        box-shadow: inset 0 0 0 40px rgba(76, 175, 80, 0.1);
    }
}

.result-subtitle {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.result-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.r-stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    text-align: center;
}

.r-stat-icon {
    font-size: 1.2rem;
    margin-bottom: 4px;
}

.r-stat-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 4px;
}

.r-stat-value {
    font-size: 1.2rem;
    font-weight: 700;
}

.result-preview {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 14px;
    margin-bottom: 16px;
    text-align: left;
}

.result-preview h4 {
    margin-bottom: 10px;
    font-size: 0.95rem;
}

.result-data {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    max-height: 100px;
    overflow-y: auto;
    margin-bottom: 12px;
}

.result-minmax {
    display: flex;
    gap: 10px;
}

.minmax-box {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.85rem;
    color: #fff;
}

.minmax-box.min {
    background: linear-gradient(135deg, #10b981, #059669);
}

.minmax-box.max {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.minmax-value {
    font-size: 1.1rem;
    font-family: 'Courier New', monospace;
}

.result-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ========== RIGHT SIDEBAR ========== */
.algo-select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    margin-bottom: 10px;
    cursor: pointer;
}

.algo-select:focus {
    outline: none;
    border-color: var(--accent);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
}

/* History */
.history-list {
    max-height: 200px;
    overflow-y: auto;
}

.history-empty {
    font-size: 0.82rem;
    color: var(--text-muted);
    text-align: center;
    padding: 16px 0;
}

.history-item {
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 6px;
    transition: background 0.2s;
}

.history-item:hover {
    background: var(--bg-hover);
}

.history-item-title {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 2px;
}

.history-item-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.history-item-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    color: var(--accent);
    font-weight: 600;
}

/* Info Accordion */
.info-accordion details {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 6px;
    overflow: hidden;
}

.info-accordion summary {
    padding: 8px 12px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    background: var(--bg-tertiary);
    transition: background 0.2s;
}

.info-accordion summary:hover {
    background: var(--bg-hover);
}

.info-content {
    padding: 10px 12px;
    font-size: 0.82rem;
    line-height: 1.6;
    color: var(--text-secondary);
}

.info-content p {
    margin-bottom: 4px;
}

/* Card scrollable */
.card-scrollable .card-body {
    max-height: 400px;
    overflow-y: auto;
}

/* Info boxes */
.info-box {
    padding: 10px 12px;
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    border-left: 3px solid var(--border-color);
}

.info-box:last-child {
    margin-bottom: 0;
}

.info-box ul {
    padding-left: 16px;
    margin-top: 6px;
}

.info-box ul li {
    margin-bottom: 4px;
    font-size: 0.82rem;
    line-height: 1.5;
}

.info-box code {
    background: var(--accent-bg);
    color: var(--accent);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.82rem;
    font-weight: 600;
}

.info-box-example {
    background: rgba(74, 124, 111, 0.08);
    border-left-color: var(--accent);
}

.info-box-warning {
    background: rgba(245, 158, 11, 0.08);
    border-left-color: #f59e0b;
}

.info-box-tip {
    background: rgba(59, 130, 246, 0.08);
    border-left-color: #3b82f6;
}

.text-green {
    color: #10b981;
}

.text-blue {
    color: #3b82f6;
}

/* ========== FOOTER ========== */
.app-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 32px;
    background: var(--footer-bg);
    border-top: 1px solid var(--border-color);
    font-size: 0.7rem;
    color: var(--text-muted);
}

.footer-left,
.footer-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.footer-center {
    text-align: center;
}

.footer-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
}

.footer-dot.green {
    background: #10b981;
}

.footer-label {
    font-weight: 600;
    letter-spacing: 0.3px;
}

.mini-bars {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 16px;
}

.mini-bars span {
    width: 4px;
    background: var(--accent);
    border-radius: 1px;
    animation: bar-dance 1.5s ease-in-out infinite;
}

.mini-bars span:nth-child(1) {
    height: 6px;
    animation-delay: 0s;
}

.mini-bars span:nth-child(2) {
    height: 10px;
    animation-delay: 0.2s;
}

.mini-bars span:nth-child(3) {
    height: 14px;
    animation-delay: 0.4s;
}

.mini-bars span:nth-child(4) {
    height: 8px;
    animation-delay: 0.6s;
}

.mini-bars span:nth-child(5) {
    height: 12px;
    animation-delay: 0.8s;
}

@keyframes bar-dance {

    0%,
    100% {
        transform: scaleY(1);
    }

    50% {
        transform: scaleY(0.4);
    }
}

/* ========== UTILITY ========== */
.hidden {
    display: none !important;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 1200px) {
    .sidebar {
        width: 280px;
    }
}

@media (max-width: 900px) {
    .app-main {
        flex-direction: column;
        height: auto;
        overflow-y: auto;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .sidebar-right {
        border-left: none;
        border-top: 1px solid var(--border-color);
    }

    body {
        overflow: auto;
    }

    .app-header {
        flex-wrap: wrap;
        height: auto;
        padding: 10px 16px;
        gap: 8px;
    }

    .header-center {
        order: 3;
        width: 100%;
    }

    .step-nav {
        width: 100%;
        justify-content: center;
    }

    .config-grid {
        grid-template-columns: 1fr;
    }

    .result-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}