/* ============================================================
   DEVICE RECOMMENDATION ASSISTANT — STYLES
   Apple-esque dark mode with dynamic vibe theming,
   glassmorphism, and micro-animations.
   ============================================================ */

:root {
    /* Base Palette */
    --bg-dark: #09090b;
    --bg-surface: rgba(24, 24, 27, 0.65);
    --bg-surface-hover: rgba(39, 39, 42, 0.8);
    --bg-surface-solid: #18181b;

    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted: #52525b;

    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-glow: rgba(99, 102, 241, 0.35);

    --border-subtle: rgba(255, 255, 255, 0.07);
    --border-active: rgba(99, 102, 241, 0.5);

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

    /* Animation */
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --transition-fast: 0.15s ease-out;
    --transition-normal: 0.3s var(--ease-out-expo);
    --transition-slow: 0.6s var(--ease-out-expo);
}

/* ---- Dynamic Vibe Theming ---- */
body.vibe-gaming { --accent-primary: #22c55e; --accent-secondary: #16a34a; --accent-glow: rgba(34,197,94,0.3); }
body.vibe-creative { --accent-primary: #a855f7; --accent-secondary: #7c3aed; --accent-glow: rgba(168,85,247,0.3); }
body.vibe-coding { --accent-primary: #3b82f6; --accent-secondary: #2563eb; --accent-glow: rgba(59,130,246,0.3); }
body.vibe-student { --accent-primary: #f59e0b; --accent-secondary: #d97706; --accent-glow: rgba(245,158,11,0.3); }
body.vibe-casual { --accent-primary: #ec4899; --accent-secondary: #db2777; --accent-glow: rgba(236,72,153,0.3); }

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: --accent-primary 0.8s, --accent-secondary 0.8s;
}

/* ---- Background Mesh ---- */
.background-mesh {
    position: fixed; inset: 0;
    z-index: -1;
    overflow: hidden;
    background: radial-gradient(ellipse at 50% 0%, #111116, var(--bg-dark));
}

.mesh-gradient-1, .mesh-gradient-2, .mesh-gradient-3 {
    position: absolute;
    border-radius: 50%;
    filter: blur(140px);
    opacity: 0.12;
    animation: meshFloat 25s infinite alternate var(--ease-out-expo);
    will-change: transform;
}

.mesh-gradient-1 { top: -15%; left: -10%; width: 55vw; height: 55vw; background: var(--accent-primary); }
.mesh-gradient-2 { bottom: -20%; right: -10%; width: 60vw; height: 60vw; background: var(--accent-secondary); animation-delay: -7s; }
.mesh-gradient-3 { top: 35%; left: 45%; width: 35vw; height: 35vw; background: #3b82f6; animation-delay: -12s; opacity: 0.08; }

@keyframes meshFloat {
    0%   { transform: translate(0, 0) scale(1); }
    100% { transform: translate(8%, 8%) scale(1.08); }
}

/* ---- Layout ---- */
.app-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
}

/* ---- View Management ---- */
.view {
    display: none;
    opacity: 0;
    transform: translateY(24px);
    transition: opacity var(--transition-slow), transform var(--transition-slow);
}

.view.active {
    display: flex;
    flex-direction: column;
    opacity: 1;
    transform: translateY(0);
}

.hidden { display: none !important; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.75rem;
    border-radius: 99px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: none;
    font-family: inherit;
    letter-spacing: -0.01em;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    box-shadow: 0 4px 20px var(--accent-glow);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px var(--accent-glow);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
    background: rgba(255,255,255,0.05);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
}
.btn-secondary:hover { background: rgba(255,255,255,0.1); }

/* ============================================================
   LANDING VIEW
   ============================================================ */
#view-landing {
    align-items: center;
    text-align: center;
    padding-top: 4rem;
}

.header {
    position: absolute;
    top: 2rem;
    left: 2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-secondary);
}
.header-icon { font-size: 1.5rem; color: var(--accent-primary); }

.hero { max-width: 780px; margin: 0 auto; }

.hero-badge {
    display: inline-block;
    padding: 0.3rem 0.85rem;
    border-radius: 99px;
    background: rgba(99, 102, 241, 0.08);
    color: var(--accent-primary);
    border: 1px solid rgba(99, 102, 241, 0.15);
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 1.5rem;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.hero-title {
    font-size: clamp(2.5rem, 5vw, 4.25rem);
    font-weight: 700;
    letter-spacing: -0.04em;
    line-height: 1.08;
    margin-bottom: 1.5rem;
}
.hero-title span {
    background: linear-gradient(135deg, #e4e4e7, #71717a);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: block;
}

.hero-subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
    max-width: 560px;
    margin: 0 auto 2.5rem auto;
    line-height: 1.7;
}

/* ============================================================
   QUIZ VIEW
   ============================================================ */
.quiz-container {
    max-width: 680px;
    margin: 0 auto;
    width: 100%;
}

.quiz-progress {
    height: 3px;
    background: var(--bg-surface-solid);
    border-radius: 2px;
    margin-bottom: 3rem;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    width: 0%;
    transition: width 0.6s var(--ease-out-expo);
    border-radius: 2px;
}

.quiz-question-container {
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.question-title {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    letter-spacing: -0.03em;
}
.question-desc {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 1.05rem;
}

/* Option Cards */
.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.875rem;
}

.option-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    padding: 1.5rem 1.25rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    user-select: none;
}
.option-card:hover {
    background: var(--bg-surface-hover);
    border-color: var(--border-active);
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.option-card.selected {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 1px var(--accent-primary), 0 8px 24px var(--accent-glow);
}
.option-card.disabled {
    opacity: 0.3;
    pointer-events: none;
    cursor: not-allowed;
}

.option-icon { font-size: 1.75rem; color: var(--text-secondary); }
.option-card.selected .option-icon { color: var(--accent-primary); }
.option-label { font-weight: 500; font-size: 1rem; }

/* Fluid Slider */
.slider-container { padding: 1.5rem 0 0; }
.slider-val {
    color: var(--accent-primary);
    font-size: 2.5rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 1.5rem;
    letter-spacing: -0.04em;
    transition: color 0.3s;
}
.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.slider-track-wrap {
    position: relative;
    width: 100%;
    height: 40px;
    display: flex;
    align-items: center;
}

/* The visible styled track behind the real input */
.slider-track {
    position: absolute;
    left: 0; right: 0;
    height: 8px;
    background: var(--bg-surface-solid);
    border-radius: 99px;
    overflow: hidden;
    pointer-events: none;
}

.slider-track-fill {
    height: 100%;
    width: 50%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 99px;
    transition: width 0.05s linear;
    box-shadow: 0 0 12px var(--accent-glow);
}

input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 40px;
    background: transparent;
    position: relative;
    z-index: 2;
    cursor: pointer;
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 8px;
    background: transparent;
    border-radius: 99px;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 28px;
    width: 28px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #fff, var(--accent-primary));
    cursor: grab;
    margin-top: -10px;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15), 0 2px 12px var(--accent-glow);
    transition: transform 0.15s ease, box-shadow 0.2s ease;
    border: 2px solid var(--accent-primary);
}

input[type=range]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 0 0 6px rgba(99, 102, 241, 0.2), 0 4px 20px var(--accent-glow);
}

input[type=range]::-webkit-slider-thumb:active {
    transform: scale(1.05);
    cursor: grabbing;
}

/* Firefox */
input[type=range]::-moz-range-track {
    height: 8px;
    background: transparent;
    border-radius: 99px;
}
input[type=range]::-moz-range-thumb {
    height: 28px; width: 28px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #fff, var(--accent-primary));
    border: 2px solid var(--accent-primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15), 0 2px 12px var(--accent-glow);
    cursor: grab;
}
input[type=range]::-moz-range-thumb:hover { transform: scale(1.15); }
input[type=range]::-moz-range-thumb:active { cursor: grabbing; }

.quiz-navigation {
    margin-top: 2rem;
    display: flex;
    justify-content: flex-start;
}

/* ============================================================
   LOADING VIEW
   ============================================================ */
#view-loading {
    align-items: center;
    text-align: center;
    padding-top: 6rem;
}

.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

.spinner-container { position: relative; width: 72px; height: 72px; }
.spinner {
    width: 100%;
    height: 100%;
    border: 3px solid var(--border-subtle);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-title {
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.loading-steps {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.loading-step {
    opacity: 0.25;
    transition: opacity 0.5s, color 0.5s;
    font-size: 1rem;
    color: var(--text-secondary);
}
.loading-step.active { opacity: 1; color: var(--text-primary); }
.loading-step.done { opacity: 0.5; color: var(--accent-primary); }

/* ============================================================
   RESULTS VIEW
   ============================================================ */
#view-results { padding-top: 2rem; }

.results-header {
    text-align: center;
    margin-bottom: 3rem;
}
.results-header h2 {
    font-size: clamp(2rem, 4vw, 2.5rem);
    font-weight: 700;
    margin-bottom: 0.5rem;
    letter-spacing: -0.03em;
}
.results-header p {
    color: var(--text-secondary);
    font-size: 1.05rem;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

/* Result Card */
.result-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 20px;
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    animation: cardSlideIn 0.5s var(--ease-out-expo) both;
    transition: transform var(--transition-normal), border-color var(--transition-normal);
}
.result-card:hover {
    transform: translateY(-4px);
    border-color: rgba(255,255,255,0.12);
}

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

/* Badges */
.result-badge {
    align-self: flex-start;
    padding: 0.25rem 0.7rem;
    border-radius: 99px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
}
.card-perfect .result-badge  { background: rgba(250,204,21,0.1); color: #facc15; border: 1px solid rgba(250,204,21,0.2); }
.card-powerhouse .result-badge { background: rgba(239,68,68,0.1); color: #ef4444; border: 1px solid rgba(239,68,68,0.2); }
.card-sensible .result-badge { background: rgba(16,185,129,0.1); color: #10b981; border: 1px solid rgba(16,185,129,0.2); }

/* Card Header */
.result-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.25rem;
}
.result-title { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.02em; }
.result-price { font-size: 1.1rem; color: var(--text-secondary); margin-top: 0.15rem; }

/* Fit Score Ring */
.fit-score { position: relative; width: 52px; height: 52px; flex-shrink: 0; }
.fit-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.fit-ring-bg {
    fill: none;
    stroke: var(--bg-surface-solid);
    stroke-width: 3;
}
.fit-ring-fill {
    fill: none;
    stroke: var(--accent-primary);
    stroke-width: 3;
    stroke-linecap: round;
    transition: stroke-dasharray 1s var(--ease-out-expo);
}
.fit-score-val {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Spec Tags */
.result-specs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1.25rem;
}
.spec-tag {
    background: var(--bg-surface-solid);
    padding: 0.25rem 0.55rem;
    border-radius: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}
.spec-tag i { font-size: 0.85rem; }

/* Accordion Sections */
.result-section { border-top: 1px solid var(--border-subtle); }
.result-section:last-child { border-bottom: none; }

.accordion-toggle {
    width: 100%;
    background: none;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.85rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: color var(--transition-fast);
}
.accordion-toggle:hover { color: var(--accent-primary); }
.accordion-toggle i {
    transition: transform 0.3s;
    font-size: 1rem;
}
.accordion-toggle.active i { transform: rotate(180deg); }

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s var(--ease-out-expo), padding 0.3s;
    padding: 0;
}
.accordion-content.open {
    max-height: 400px;
    padding-bottom: 1rem;
}
.accordion-content p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.7;
}

/* Pros & Cons */
.pros-cons-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}
.pros-list, .cons-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.pros-list li, .cons-list li {
    font-size: 0.85rem;
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    line-height: 1.4;
}
.pros-list li { color: #4ade80; }
.pros-list li i { color: #22c55e; flex-shrink: 0; margin-top: 2px; }
.cons-list li { color: #f87171; }
.cons-list li i { color: #ef4444; flex-shrink: 0; margin-top: 2px; }

/* Results Actions */
.results-actions {
    display: flex;
    justify-content: center;
    padding-bottom: 3rem;
}

/* ============================================================
   API KEY SECTION
   ============================================================ */
.api-key-section {
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.api-key-toggle {
    background: none;
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.85rem;
    padding: 0.5rem 1rem;
    border-radius: 99px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: all var(--transition-fast);
}
.api-key-toggle:hover {
    color: var(--text-secondary);
    border-color: rgba(255,255,255,0.15);
}
.api-key-toggle.connected {
    color: #22c55e;
    border-color: rgba(34, 197, 94, 0.3);
}

.api-key-input-wrap {
    display: flex;
    gap: 0.5rem;
    width: 100%;
    max-width: 420px;
}

.api-key-input {
    flex: 1;
    background: var(--bg-surface-solid);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 0.65rem 1rem;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: border-color var(--transition-fast);
}
.api-key-input:focus {
    border-color: var(--accent-primary);
}
.api-key-input::placeholder {
    color: var(--text-muted);
}

.api-key-save {
    padding: 0.65rem 1.25rem;
    font-size: 0.85rem;
    border-radius: 12px;
}

.api-key-status {
    font-size: 0.8rem;
    color: var(--text-muted);
    transition: color 0.3s;
}
.api-key-status.connected {
    color: #22c55e;
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 0.75rem 1.25rem;
    border-radius: 12px;
    font-size: 0.9rem;
    font-family: var(--font-sans);
    color: var(--text-primary);
    background: var(--bg-surface-solid);
    border: 1px solid var(--border-subtle);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.3s, transform 0.3s;
}
.toast.show {
    opacity: 1;
    transform: translateY(0);
}
.toast-success { border-color: rgba(34, 197, 94, 0.3); }
.toast-warning { border-color: rgba(245, 158, 11, 0.3); }
.toast-error   { border-color: rgba(239, 68, 68, 0.3); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .app-container { padding: 1.25rem; }
    .hero-title { font-size: 2.25rem; }
    .question-title { font-size: 1.5rem; }
    .options-grid { grid-template-columns: 1fr 1fr; gap: 0.75rem; }
    .results-grid { grid-template-columns: 1fr; }
    .pros-cons-grid { grid-template-columns: 1fr; }
    .header { position: relative; top: 0; left: 0; margin-bottom: 2rem; }
    .result-card-header { flex-direction: column; gap: 0.75rem; }
    .fit-score { align-self: flex-end; margin-top: -3rem; }
    .toast-container { bottom: 1rem; right: 1rem; left: 1rem; }
    .api-key-input-wrap { flex-direction: column; }
}

@media (max-width: 480px) {
    .options-grid { grid-template-columns: 1fr; }
    .option-card { flex-direction: row; align-items: center; padding: 1rem; }
    .option-icon { font-size: 1.5rem; }
}
