/* ==========================================================================
   1. Theme Variables & Base Setup (Minimalist SaaS / Designer Theme)
   ========================================================================== */
:root {
    --bg-base: #f8fafc;
    /* Clean light slate background */
    --bg-surface: #ffffff;
    /* Pure white card panels */
    --border-standard: #e2e8f0;
    /* Very thin, elegant slate borders */
    --border-focus: #94a3b8;
    /* Slate for active outlines */

    --text-primary: #0f172a;
    /* Deep slate for highly readable text */
    --text-secondary: #475569;
    /* Medium slate for labels and descriptions */
    --text-muted: #94a3b8;
    /* Light slate for helpers and instructions */

    --accent: #0f172a;
    /* Clean, minimalist black/dark slate accent */
    --accent-hover: #1e293b;
    --accent-light: #f1f5f9;

    --error: #ef4444;
    --error-bg: #fef2f2;
    --success: #10b981;
    --success-bg: #ecfdf5;
    --warning: #f59e0b;
    --warning-bg: #fffbeb;

    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;

    --color-u: #ffffff;
    --border-u: #cbd5e1;
    --color-l: #f97316;
    --color-f: #10b981;
    --color-r: #ef4444;
    --color-b: #2563eb;
    --color-d: #ffea00;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* ==========================================================================
   2. Main Layout Structure (Responsive)
   ========================================================================== */
.app-container {
    width: 100%;
    max-width: 1100px;
    padding: 60px 20px;
    display: flex;
    flex-direction: column;
    gap: 40px;
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-standard);
    padding-bottom: 20px;
}

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

.logo-icon {
    color: var(--accent);
}

.navbar h1 {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-primary);
    margin: 0;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 20px;
}

.nav-item {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: color 0.15s ease, transform 0.15s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-item:hover {
    color: var(--text-primary);
    transform: translateY(-1.5px);
}

.github-link svg {
    fill: currentColor;
}

.lang-select {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-standard);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    outline: none;
    font-family: inherit;
}

.lang-select:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.lang-select option {
    background-color: var(--bg-surface);
    color: var(--text-primary);
}

@media (max-width: 576px) {
    .navbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    .nav-links {
        width: 100%;
        flex-wrap: wrap;
        gap: 12px;
    }
    .nav-item span {
        display: none;
    }
    .navbar h1 {
        font-size: 1.4rem;
        white-space: nowrap;
    }
    .logo-icon {
        width: 24px;
        height: 24px;
    }
}

.subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    max-width: 700px;
    line-height: 1.5;
}

/* Responsive Single Column Layout */
.workspace {
    display: grid;
    grid-template-columns: 1fr;
    gap: 32px;
    align-items: stretch;
    width: 100%;
}

@media (max-width: 968px) {
    .app-container {
        padding: 30px 15px;
    }
}

/* ==========================================================================
   3. Panel & Cards Design
   ========================================================================== */
.panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-standard);
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 10px 20px -5px rgba(0, 0, 0, 0.02);
    display: flex;
    flex-direction: column;
    gap: 28px;
    min-width: 0;
    /* Prevents grid/flex items from expanding past their columns */
    min-height: 500px;
    height: auto;
}

/* Explicit class for the 3D visualizer to lock its dimensions */
.visualizer-panel {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}



.panel-desc {
    font-size: 0.88rem;
    color: var(--text-secondary);
}

/* ==========================================================================
   4. Left Panel: 2D Editor & Palette
   ========================================================================== */

/* Interactive Palette */
.palette-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.palette-container label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.palette {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.color-btn {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    border: 1px solid var(--border-standard);
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

.color-btn.active {
    transform: translateY(-2px);
    border-color: var(--accent);
    outline: 2px solid var(--text-primary);
    outline-offset: 2px;
}

/* Theme Custom Color Configurator */
.theme-config-panel {
    background-color: var(--accent-light);
    border: 1px solid var(--border-standard);
    border-radius: 12px;
    padding: 14px;
    margin-top: 15px;
    margin-bottom: 15px;
    transition: all 0.2s ease;
}

.theme-config-panel.hidden {
    display: none;
}

.config-title-row h4 {
    margin: 0 0 10px 0;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
}

.config-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

@media (max-width: 480px) {
    .config-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.config-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-surface);
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid var(--border-standard);
}

.config-item span {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.config-item .color-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    border: 1px solid rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.config-item input[type="color"] {
    -webkit-appearance: none;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    background: none;
    margin-left: auto;
    padding: 0;
    flex-shrink: 0;
}

.config-item input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.config-item input[type="color"]::-webkit-color-swatch {
    border: 1px solid var(--border-standard);
    border-radius: 4px;
}

.main-actions {
    display: flex;
    gap: 12px;
    width: 100%;
}

.main-actions > button {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 48px; /* Force equal height */
    padding: 0 10px;
}

.btn-secondary {
    flex: 1;
    background: var(--bg-surface);
    border: 1px solid var(--border-standard);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
}

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

/* Validation status alert boxes (Floating over 3D Canvas) */
.validation-box {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.4;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 1px solid transparent;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    max-width: 90%;
    text-align: center;
    transition: all 0.3s ease;
}

.validation-box.warning {
    background: rgba(245, 158, 11, 0.85);
    border-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.validation-box.error {
    background: rgba(239, 68, 68, 0.85);
    border-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.validation-box.success {
    background: rgba(16, 185, 129, 0.85);
    border-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

/* Clean, Minimalist Slate Primary Action Button */
.btn-primary {
    position: relative;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
}

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

/* Loader spinner inside button */
.loader {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.hidden {
    display: none !important;
}

/* ==========================================================================
   5. Right Panel: 3D Canvas
   ========================================================================== */
.canvas-container {
    width: 100%;
    flex: 1 1 auto;
    /* Grow and shrink dynamically inside the visualizer panel */
    min-height: 550px;
    border-radius: 12px;
    background: #0f172a;
    /* Clean slate-900 background for 3D model contrast */
    border: 1px solid var(--border-standard);
    overflow: hidden;
    position: relative;
    cursor: grab;
}

.canvas-container:active {
    cursor: grabbing;
}


.player-panel {
    display: flex;
    flex-direction: column;
    width: 100%;
    margin-top: auto;
    /* Push to the very bottom of the card */
    padding-top: 16px;
    animation: fadeIn 0.4s ease forwards;
}

/* Horizontally scrollable timeline card */
.timeline-container {
    width: 100%;
    background: transparent;
    /* Seamless blend */
    border: none;
    /* Removed inner rectangle border outline! */
    padding: 12px 0;
    overflow-x: auto;
    position: relative;
}

/* Custom Scrollbar for horizontal timeline */
.timeline-container::-webkit-scrollbar {
    height: 6px;
}

.timeline-container::-webkit-scrollbar-track {
    background: transparent;
}

.timeline-container::-webkit-scrollbar-thumb {
    background: var(--border-standard);
    border-radius: 3px;
}

.timeline-container::-webkit-scrollbar-thumb:hover {
    background: var(--border-focus);
}

.moves-timeline {
    display: flex;
    align-items: center;
    gap: 22px;
    width: max-content;
    padding: 6px 16px;
    /* Generous 16px padding on left/right to prevent any active halo shadow cutoff! */
    position: relative;
}

/* Horizontal connecting track line behind the step circles */
.moves-timeline::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 35px;
    /* Aligns perfectly with the center of the first circle (16px padding + 19px half-width) */
    right: 35px;
    /* Aligns perfectly with the center of the last circle (16px padding + 19px half-width) */
    height: 3px;
    background: var(--border-standard);
    transform: translateY(-50%);
    z-index: 1;
    border-radius: 1.5px;
    transition: background 0.3s ease;
}

.step-node {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--bg-surface);
    border: 2px solid var(--border-standard);
    color: var(--text-secondary);
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.88rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 2;
    user-select: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.step-node:hover {
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.12);
}

/* Completed Steps: Glowing border and background */
.step-node.completed {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

/* Active Step: Vibrant premium circular badge with custom accent ring */
.step-node.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    box-shadow: 0 0 0 4px var(--accent-light), 0 4px 12px rgba(99, 102, 241, 0.25);
    transform: scale(1.15) translateY(-1px);
}


/* ==========================================================================
   7. Footer & Animations
   ========================================================================== */
footer {
    text-align: left;
    font-size: 0.75rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-standard);
    padding-top: 20px;
    margin-top: 16px;
}

.app-version {
    font-weight: 600;
    color: var(--text-secondary);
}

.footer-credit {
    margin-top: 6px;
    color: var(--text-secondary);
}

.footer-credit a {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s ease;
}

.footer-credit a:hover {
    color: var(--accent);
    text-decoration: underline;
}

/* Mobile & Tablet Adjustments */
@media (max-width: 968px) {
    .canvas-container {
        height: 380px;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.98);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}