/* ============================================
   RUBIK'S CUBE 3D SOLVER — STYLES
   ============================================ */

:root {
    --bg-primary: #0a0a14;
    --bg-secondary: #12121f;
    --bg-panel: rgba(18, 18, 35, 0.75);
    --bg-panel-solid: #16162a;
    --border-panel: rgba(120, 100, 255, 0.15);
    --text-primary: #eaeaff;
    --text-secondary: #8888aa;
    --text-muted: #555570;
    --accent-primary: #7c5cfc;
    --accent-secondary: #5a3de8;
    --accent-glow: rgba(124, 92, 252, 0.35);
    --accent-hint: #fbbf24;
    --accent-success: #34d399;
    --danger: #ef4444;
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.5);
    --shadow-glow: 0 0 30px var(--accent-glow);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

/* ---- App Container ---- */
#app {
    position: relative;
    width: 100%;
    height: 100%;
}

#cube-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

/* ---- Background Gradient ---- */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(124, 92, 252, 0.08) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 20%, rgba(90, 61, 232, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(52, 211, 153, 0.04) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* ---- Panels (Glassmorphism) ---- */
.panel {
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-panel);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 16px;
}

/* ---- Header ---- */
#header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: linear-gradient(180deg, rgba(10,10,20,0.85) 0%, transparent 100%);
    pointer-events: none;
}

#header > * {
    pointer-events: auto;
}

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

.logo-icon {
    font-size: 1.4rem;
    color: var(--accent-primary);
    filter: drop-shadow(0 0 6px var(--accent-glow));
    animation: logoSpin 8s linear infinite;
}

@keyframes logoSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#stats {
    display: flex;
    gap: 12px;
}

.stat-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-panel);
    border-radius: var(--radius-md);
    padding: 6px 14px;
    min-width: 64px;
}

.stat-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}

/* ---- Main Controls ---- */
#controls {
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    max-width: 580px;
    width: calc(100% - 32px);
}

.controls-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* ---- Buttons ---- */
.btn {
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    user-select: none;
    position: relative;
    overflow: hidden;
    white-space: nowrap;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at var(--x, 50%) var(--y, 50%), rgba(255,255,255,0.12) 0%, transparent 60%);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}
.btn:hover::after { opacity: 1; }

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    color: #fff;
    border-color: rgba(255,255,255,0.1);
    box-shadow: 0 2px 12px var(--accent-glow);
}
.btn-primary:hover {
    box-shadow: 0 4px 20px var(--accent-glow);
    transform: translateY(-1px);
}
.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 1px 6px var(--accent-glow);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-panel);
}
.btn-secondary:hover {
    background: #1e1e36;
    border-color: rgba(120,100,255,0.3);
}

.btn-accent {
    background: linear-gradient(135deg, #34d399 0%, #059669 100%);
    color: #fff;
    border-color: rgba(255,255,255,0.1);
    box-shadow: 0 2px 12px rgba(52,211,153,0.3);
}
.btn-accent:hover {
    box-shadow: 0 4px 20px rgba(52,211,153,0.4);
    transform: translateY(-1px);
}

.btn-hint {
    background: linear-gradient(135deg, #fbbf24 0%, #d97706 100%);
    color: #1a1a2e;
    border-color: rgba(255,255,255,0.1);
    box-shadow: 0 2px 12px rgba(251,191,36,0.25);
}
.btn-hint:hover {
    box-shadow: 0 4px 20px rgba(251,191,36,0.35);
    transform: translateY(-1px);
}

.btn-input {
    background: linear-gradient(135deg, #38bdf8 0%, #0284c7 100%);
    color: #fff;
    border-color: rgba(255,255,255,0.1);
    box-shadow: 0 2px 12px rgba(56,189,248,0.25);
}
.btn-input:hover {
    box-shadow: 0 4px 20px rgba(56,189,248,0.4);
    transform: translateY(-1px);
}

.btn-icon-only {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-panel);
    padding: 8px 12px;
    font-size: 1rem;
}
.btn-icon-only:hover {
    background: #1e1e36;
    border-color: rgba(120,100,255,0.3);
}

.btn-sm {
    font-size: 0.78rem;
    padding: 6px 12px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-panel);
}
.btn-sm:hover {
    background: #1e1e36;
}
.btn-sm.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: #fff;
}

.btn-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1rem;
    padding: 4px 8px;
}
.btn-close:hover { color: var(--text-primary); }

.btn:disabled {
    opacity: 0.4;
    pointer-events: none;
}

.btn-icon {
    font-size: 1em;
}

/* Move Buttons */
.move-buttons {
    gap: 4px;
}

.btn-move {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-panel);
    padding: 6px 10px;
    font-size: 0.78rem;
    font-weight: 700;
    font-family: 'Inter', monospace;
    min-width: 36px;
    justify-content: center;
}
.btn-move:hover {
    background: var(--accent-primary);
    color: #fff;
    border-color: var(--accent-primary);
    box-shadow: 0 0 12px var(--accent-glow);
}

/* ---- Solver Loading ---- */
.solver-loading {
    position: absolute;
    top: 72px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-panel);
    border-radius: var(--radius-md);
    padding: 10px 20px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    animation: fadeIn 0.3s ease-out;
}

.solver-loading-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--text-muted);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ---- Explanation Panel (Left Side) ---- */
.explanation-panel {
    position: absolute;
    top: 80px;
    left: 20px;
    z-index: 15;
    width: 320px;
    max-height: calc(100vh - 200px);
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.explanation-panel.hidden {
    opacity: 0;
    transform: translateX(-20px);
    pointer-events: none;
}

.explanation-header {
    border-bottom: 1px solid var(--border-panel);
    padding-bottom: 8px;
}
.explanation-header h2 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--accent-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.explanation-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    padding-right: 4px;
}

#exp-step-title {
    font-size: 1.1rem;
    color: var(--text-primary);
    font-weight: 600;
}

#exp-step-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.explanation-moves {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

/* ---- Solver Panel ---- */
.solver-panel {
    position: absolute;
    top: 80px;
    right: 20px;
    z-index: 15;
    width: 280px;
    max-height: calc(100vh - 200px);
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.solver-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.solver-header h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent-success);
}

.solver-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
#solver-step-label {
    font-size: 0.82rem;
    color: var(--text-secondary);
}
#solver-move-label {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.solver-moves {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    max-height: 180px;
    overflow-y: auto;
    padding: 8px;
    background: rgba(0,0,0,0.25);
    border-radius: var(--radius-sm);
}

.solver-moves .sol-move {
    font-family: 'Inter', monospace;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 7px;
    border-radius: 4px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid transparent;
    transition: all var(--transition);
}
.solver-moves .sol-move.active {
    background: var(--accent-primary);
    color: #fff;
    border-color: rgba(255,255,255,0.2);
    box-shadow: 0 0 8px var(--accent-glow);
}
.solver-moves .sol-move.done {
    color: var(--accent-success);
    border-color: rgba(52,211,153,0.3);
}

.solver-controls {
    display: flex;
    gap: 6px;
    justify-content: center;
}

/* ---- Hint Toast ---- */
.hint-toast {
    position: absolute;
    top: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    z-index: 20;
    background: linear-gradient(135deg, rgba(251,191,36,0.95), rgba(217,119,6,0.95));
    color: #1a1a2e;
    font-weight: 700;
    font-size: 1.2rem;
    padding: 12px 28px;
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 24px rgba(251,191,36,0.3);
    opacity: 1;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}
.hint-toast.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
}

/* ---- Instructions Bar ---- */
.instructions-bar {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    white-space: nowrap;
}
.instructions-bar p {
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

/* ---- Solved Overlay ---- */
.solved-overlay {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 20, 0.7);
    backdrop-filter: blur(8px);
    animation: fadeIn 0.4s ease-out;
}

.solved-content {
    text-align: center;
    padding: 40px 48px;
    background: var(--bg-panel);
    border: 1px solid var(--border-panel);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.solved-content h2 {
    font-size: 2rem;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--accent-success), #a7f3d0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.solved-content p {
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-size: 0.9rem;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes popIn {
    from { opacity: 0; transform: scale(0.85); }
    to { opacity: 1; transform: scale(1); }
}

/* ============================================
   CUBE INPUT MODAL
   ============================================ */

.input-modal-overlay {
    position: absolute;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 20, 0.85);
    backdrop-filter: blur(12px);
    animation: fadeIn 0.3s ease-out;
}

.input-modal {
    background: var(--bg-panel-solid);
    border: 1px solid var(--border-panel);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    padding: 28px 32px;
    max-width: 620px;
    width: calc(100% - 32px);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.input-modal-header {
    position: relative;
    text-align: center;
}

.input-modal-header h2 {
    font-size: 1.3rem;
    font-weight: 700;
    background: linear-gradient(135deg, #38bdf8, #7c5cfc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.input-modal-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.input-modal-header .btn-close {
    position: absolute;
    top: -4px;
    right: -8px;
}

.input-modal-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

/* ---- Color Palette ---- */
.color-palette {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.palette-color {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    border: 2px solid rgba(255,255,255,0.1);
    background: var(--swatch);
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
}

.palette-color:hover {
    transform: scale(1.1);
    border-color: rgba(255,255,255,0.4);
}

.palette-color.active {
    border-color: #fff;
    box-shadow: 0 0 16px rgba(255,255,255,0.3), 0 0 4px rgba(255,255,255,0.5);
    transform: scale(1.12);
}

.palette-color.active::after {
    content: '✓';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 700;
    color: rgba(0,0,0,0.6);
    text-shadow: 0 0 4px rgba(255,255,255,0.5);
}

/* ---- Color Counters ---- */
.color-counters {
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-wrap: wrap;
}

.color-counter {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 4px;
    background: rgba(0,0,0,0.25);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: color var(--transition);
}

.color-counter .counter-swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.color-counter.complete {
    color: var(--accent-success);
}

.color-counter.over {
    color: var(--danger);
}

/* ---- 2D Cube Net ---- */
.cube-net {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.net-row {
    display: flex;
    gap: 2px;
}

.net-spacer {
    width: 120px;
    height: 120px;
}

.net-face {
    position: relative;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 3px;
    width: 120px;
    height: 120px;
    padding: 4px;
    background: rgba(0,0,0,0.35);
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.06);
}

.net-face-label {
    position: absolute;
    top: -16px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.net-sticker {
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1.5px solid rgba(255,255,255,0.08);
    position: relative;
}

.net-sticker:hover {
    transform: scale(1.08);
    border-color: rgba(255,255,255,0.3);
    z-index: 1;
}

.net-sticker.center {
    cursor: default;
    opacity: 0.9;
}

.net-sticker.center::after {
    content: '●';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.5rem;
    color: rgba(0,0,0,0.3);
}

/* Sticker colors */
.net-sticker[data-color="U"] { background: #ffffff; }
.net-sticker[data-color="D"] { background: #ffd500; }
.net-sticker[data-color="F"] { background: #009b48; }
.net-sticker[data-color="B"] { background: #0046ad; }
.net-sticker[data-color="R"] { background: #b71234; }
.net-sticker[data-color="L"] { background: #ff5800; }
.net-sticker[data-color=""] { background: rgba(50,50,70,0.6); }

/* ---- Validation Message ---- */
.input-validation {
    font-size: 0.8rem;
    min-height: 1.2em;
    text-align: center;
    transition: color var(--transition);
}

.input-validation.error {
    color: var(--danger);
}

.input-validation.success {
    color: var(--accent-success);
}

/* ---- Modal Footer ---- */
.input-modal-footer {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ---- Hidden Utility ---- */
.hidden {
    display: none !important;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 4px; }

/* ---- Responsive ---- */
@media (max-width: 600px) {
    #controls {
        bottom: 50px;
        padding: 12px;
    }
    .solver-panel {
        top: auto;
        bottom: 50px;
        right: 10px;
        left: 10px;
        width: auto;
    }
    .btn { padding: 6px 12px; font-size: 0.78rem; }
    .btn-move { padding: 5px 8px; min-width: 30px; font-size: 0.7rem; }
    .logo h1 { font-size: 1rem; }

    .net-spacer,
    .net-face {
        width: 85px;
        height: 85px;
    }
    .input-modal {
        padding: 20px 16px;
    }
    .palette-color {
        width: 34px;
        height: 34px;
    }
}
