/* ========================================
   OAuth Flow Simulator — Premium Dark Theme
   ======================================== */

:root {
    /* Colors */
    --primary: #6C63FF;
    --primary-light: #8B83FF;
    --primary-dark: #4F46E5;
    --secondary: #10B981;
    --accent: #F59E0B;
    --danger: #EF4444;
    --bg-primary: #0F0A1A;
    --bg-secondary: #1A1330;
    --bg-card: #221B35;
    --bg-card-hover: #2D2345;
    --surface: rgba(255, 255, 255, 0.05);
    --surface-hover: rgba(255, 255, 255, 0.08);
    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    --text-primary: #F1F0F5;
    --text-secondary: #9B95AD;
    --text-muted: #6B6580;
    --glass: rgba(255, 255, 255, 0.04);
    --glass-border: rgba(255, 255, 255, 0.1);
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --mono: 'JetBrains Mono', 'Fira Code', monospace;
}

[data-theme="light"] {
    --bg-primary: #F8F7FC;
    --bg-secondary: #EFEDF5;
    --bg-card: #FFFFFF;
    --bg-card-hover: #F3F1FA;
    --surface: rgba(108, 99, 255, 0.04);
    --surface-hover: rgba(108, 99, 255, 0.08);
    --border: rgba(0, 0, 0, 0.08);
    --border-hover: rgba(0, 0, 0, 0.15);
    --text-primary: #1A1330;
    --text-secondary: #5E5776;
    --text-muted: #9B95AD;
    --glass: rgba(108, 99, 255, 0.03);
    --glass-border: rgba(0, 0, 0, 0.08);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ========== Theme Toggle ========== */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    width: 44px;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--bg-card);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    backdrop-filter: blur(12px);
}

.theme-toggle:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
    transform: scale(1.08);
}

/* ========== Hero ========== */
.hero {
    position: relative;
    padding: 100px 0 60px;
    text-align: center;
    overflow: hidden;
}

.hero-bg {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 80% 50% at 50% -10%, rgba(108, 99, 255, 0.2) 0%, transparent 60%),
        radial-gradient(ellipse 60% 40% at 80% 60%, rgba(16, 185, 129, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

.hero-badge {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 100px;
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
    letter-spacing: 0.02em;
}

.hero h1 {
    font-size: clamp(2rem, 5vw, 3.2rem);
    font-weight: 800;
    line-height: 1.15;
    margin-bottom: 16px;
}

.gradient-text {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 540px;
    margin: 0 auto;
}

/* ========== Flow Selector ========== */
.flow-selector {
    padding: 40px 0;
}

.flow-selector h2 {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 28px;
}

.flow-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.flow-card {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    text-align: left;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    color: var(--text-primary);
    font-size: 1rem;
}

.flow-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
    transform: translateY(-4px);
    box-shadow: var(--shadow);
}

.flow-card.active {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(108, 99, 255, 0.08), rgba(16, 185, 129, 0.04));
    box-shadow: 0 0 24px rgba(108, 99, 255, 0.15);
}

.flow-card-icon {
    font-size: 2rem;
    margin-bottom: 12px;
}

.flow-card h3 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.flow-card p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.flow-tag {
    display: inline-block;
    margin-top: 12px;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.tag-recommended {
    background: rgba(16, 185, 129, 0.15);
    color: var(--secondary);
}

.tag-legacy {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent);
}

.tag-m2m {
    background: rgba(108, 99, 255, 0.15);
    color: var(--primary-light);
}

/* ========== Simulation ========== */
.simulation {
    padding: 40px 0;
}

/* Progress Tracker */
.progress-tracker {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 32px;
    flex-wrap: wrap;
}

.progress-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--surface);
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: var(--transition);
}

.progress-dot.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 0 12px rgba(108, 99, 255, 0.4);
}

.progress-dot.done {
    background: var(--secondary);
    border-color: var(--secondary);
    color: #fff;
}

.progress-line {
    width: 24px;
    height: 2px;
    background: var(--border);
    transition: var(--transition);
}

.progress-line.done {
    background: var(--secondary);
}

/* Actors Row */
.actors-row {
    display: flex;
    justify-content: space-around;
    gap: 16px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.actor {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
    transition: var(--transition);
    min-width: 90px;
    opacity: 0.5;
}

.actor.active {
    opacity: 1;
    border-color: var(--primary);
    box-shadow: 0 0 16px rgba(108, 99, 255, 0.15);
}

.actor-icon {
    font-size: 1.6rem;
}

.actor-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Step Display */
.step-display {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    margin-bottom: 24px;
    min-height: 220px;
    transition: var(--transition);
}

.step-header {
    margin-bottom: 16px;
}

.step-number {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 100px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
}

.step-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
}

.step-description {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 20px;
}

/* Arrow Container */
.arrow-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 16px 0;
    min-height: 60px;
}

.arrow-box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius-xs);
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    animation: arrow-in 0.5s ease;
}

.arrow-box .arrow-emoji {
    font-size: 1.2rem;
}

@keyframes arrow-in {
    from {
        opacity: 0;
        transform: translateX(-12px);
    }

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

/* HTTP Preview */
.http-preview {
    margin-top: 20px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
}

.http-tab-bar {
    display: flex;
    background: var(--surface);
}

.http-tab {
    flex: 1;
    padding: 8px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.http-tab.active {
    color: var(--primary);
    background: var(--bg-card);
}

.http-code {
    padding: 16px;
    background: var(--bg-secondary);
    font-family: var(--mono);
    font-size: 0.82rem;
    line-height: 1.7;
    color: var(--text-primary);
    overflow-x: auto;
    white-space: pre;
    margin: 0;
}

/* Tooltips */
.tooltips {
    margin-top: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tooltip-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 100px;
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: help;
    position: relative;
    transition: var(--transition);
}

.tooltip-chip:hover {
    background: var(--surface-hover);
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.tooltip-chip .tip-icon {
    font-size: 0.9rem;
}

.tooltip-popup {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: 240px;
    padding: 12px;
    border-radius: var(--radius-xs);
    background: var(--bg-card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    font-size: 0.78rem;
    line-height: 1.5;
    color: var(--text-secondary);
    z-index: 100;
}

.tooltip-chip:hover .tooltip-popup {
    display: block;
}

/* Navigation */
.step-nav {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.btn {
    padding: 10px 24px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border-color: var(--primary);
}

.btn-primary:hover:not(:disabled) {
    filter: brightness(1.15);
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--surface-hover);
}

.btn-reset {
    background: transparent;
    color: var(--text-muted);
    border-color: transparent;
}

.btn-reset:hover {
    color: var(--danger);
}

/* ========== Error Section ========== */
.error-section {
    padding: 60px 0;
}

.error-section h2 {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.section-subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 28px;
}

.error-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.error-card {
    padding: 20px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
}

.error-card:hover {
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.04);
    transform: translateY(-2px);
}

.error-card h4 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--danger);
}

.error-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.error-card .error-fix {
    display: none;
    margin-top: 12px;
    padding: 10px;
    border-radius: var(--radius-xs);
    background: rgba(16, 185, 129, 0.06);
    border: 1px solid rgba(16, 185, 129, 0.15);
    font-size: 0.82rem;
    color: var(--secondary);
}

.error-card.expanded .error-fix {
    display: block;
}

/* ========== FAQ ========== */
.faq-section {
    padding: 60px 0 80px;
}

.faq-section h2 {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 28px;
}

.faq-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    overflow: hidden;
    transition: var(--transition);
}

.faq-question {
    padding: 16px 20px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 0.95rem;
}

.faq-question::after {
    content: '+';
    font-size: 1.3rem;
    color: var(--text-muted);
    transition: var(--transition);
}

.faq-item.open .faq-question::after {
    content: '−';
    color: var(--primary);
}

.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.faq-answer-inner {
    padding: 0 20px 16px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.7;
}

.faq-item.open .faq-answer {
    max-height: 300px;
}

/* ========== Footer ========== */
.footer {
    padding: 32px 0;
    text-align: center;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ========== Responsive ========== */
@media (max-width: 640px) {
    .hero {
        padding: 80px 0 40px;
    }

    .flow-cards {
        grid-template-columns: 1fr;
    }

    .actors-row {
        gap: 8px;
    }

    .actor {
        min-width: 70px;
        padding: 8px 10px;
    }

    .actor-icon {
        font-size: 1.2rem;
    }

    .actor-label {
        font-size: 0.7rem;
    }

    .step-display {
        padding: 20px;
    }

    .btn {
        padding: 8px 16px;
        font-size: 0.85rem;
    }
}