/* ========================================
   AST Generator - Main Stylesheet
   Compiler Design Project
   ======================================== */

/* ----- CSS Variables / Design Tokens ----- */
:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #111118;
    --bg-card: #16161e;
    --bg-card-hover: #1c1c27;
    --bg-elevated: #1e1e2a;

    --text-primary: #f0f0f5;
    --text-secondary: #9898b0;
    --text-muted: #5a5a78;

    --accent-primary: #6366f1;
    --accent-secondary: #a855f7;
    --accent-gradient: linear-gradient(135deg, #6366f1, #a855f7);
    --accent-gradient-hover: linear-gradient(135deg, #7c7ff7, #b96ff9);

    --green: #10b981;
    --yellow: #f59e0b;
    --red: #ef4444;
    --pink: #ec4899;
    --cyan: #06b6d4;

    --border-color: #2a2a3d;
    --border-glow: rgba(99, 102, 241, 0.3);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.15);

    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
    overflow-x: hidden;
    max-width: 100vw;
}

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

::selection {
    background: rgba(99, 102, 241, 0.4);
    color: white;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}

/* ----- Background Effects ----- */
.bg-grid {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(rgba(99, 102, 241, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(99, 102, 241, 0.03) 1px, transparent 1px);
    background-size: 60px 60px;
    z-index: 0;
    pointer-events: none;
}

.bg-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.4;
    z-index: 0;
    pointer-events: none;
    animation: glowFloat 12s ease-in-out infinite;
}

.bg-glow-1 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.15), transparent);
    top: -100px;
    right: -100px;
    animation-delay: 0s;
}

.bg-glow-2 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(168, 85, 247, 0.12), transparent);
    bottom: -50px;
    left: -100px;
    animation-delay: -4s;
}

.bg-glow-3 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(6, 182, 212, 0.1), transparent);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -8s;
}

@keyframes glowFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(30px, -20px) scale(1.05); }
    50% { transform: translate(-20px, 30px) scale(0.95); }
    75% { transform: translate(20px, 20px) scale(1.02); }
}

/* Floating particles */
.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.particle {
    position: absolute;
    width: 3px;
    height: 3px;
    background: var(--accent-primary);
    border-radius: 50%;
    opacity: 0;
    animation: particleFloat 8s ease-in-out infinite;
}

@keyframes particleFloat {
    0% { opacity: 0; transform: translateY(100vh) scale(0); }
    10% { opacity: 0.6; }
    90% { opacity: 0.6; }
    100% { opacity: 0; transform: translateY(-10vh) scale(1); }
}

/* ----- Navbar ----- */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    height: 64px;
    background: rgba(10, 10, 15, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
}

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

.nav-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.nav-title {
    font-size: 1.1rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
}

.nav-links {
    display: flex;
    gap: 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition-normal);
    position: relative;
}

.nav-link:hover {
    color: var(--text-primary);
    background: rgba(99, 102, 241, 0.08);
}

.nav-link.active {
    color: var(--text-primary);
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.nav-link-icon {
    font-size: 1rem;
}

.nav-badge {
    padding: 6px 14px;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 100px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--accent-primary);
    letter-spacing: 0.03em;
}

/* ----- Main Container ----- */
.main-container {
    position: relative;
    z-index: 1;
    max-width: 960px;
    margin: 0 auto;
    padding: 40px 24px 60px;
}

/* ----- Hero Section ----- */
.hero-section {
    text-align: center;
    margin-bottom: 48px;
    animation: fadeInUp 0.6s ease;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 100px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--accent-primary);
    margin-bottom: 24px;
    letter-spacing: 0.04em;
}

.hero-badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

.hero-title {
    font-size: 3rem;
    font-weight: 900;
    line-height: 1.1;
    letter-spacing: -0.03em;
    margin-bottom: 16px;
}

.hero-title-gradient {
    display: block;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 3.4rem;
}

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

.hero-subtitle strong {
    color: var(--accent-primary);
    font-weight: 600;
}

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

/* ----- Pipeline Section ----- */
.pipeline-section {
    margin-bottom: 48px;
    animation: fadeInUp 0.6s ease 0.1s both;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 20px;
    text-align: center;
}

.pipeline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 24px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.pipeline-step {
    text-align: center;
    padding: 16px 20px;
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    transition: all var(--transition-normal);
    min-width: 120px;
}

.pipeline-step:hover,
.pipeline-step.active {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.08);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

.pipeline-icon {
    font-size: 1.6rem;
    margin-bottom: 8px;
}

.pipeline-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
}

.pipeline-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.pipeline-arrow {
    font-size: 1.4rem;
    color: var(--accent-primary);
    font-weight: 700;
}

/* ----- Editor Card ----- */
.input-section {
    animation: fadeInUp 0.6s ease 0.2s both;
}

.editor-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    transition: all var(--transition-normal);
}

.editor-card:focus-within {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-color);
}

.editor-header.compact {
    padding: 10px 16px;
}

.editor-dots {
    display: flex;
    gap: 7px;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.dot.red { background: #ff5f57; }
.dot.yellow { background: #ffbd2e; }
.dot.green { background: #28c840; }

.editor-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-weight: 500;
}

.editor-file-icon {
    font-size: 0.9rem;
}

.editor-actions {
    display: flex;
    gap: 4px;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.editor-body {
    display: flex;
    min-height: 280px;
    max-height: 400px;
}

.line-numbers {
    padding: 16px 0;
    min-width: 48px;
    background: rgba(0, 0, 0, 0.2);
    text-align: right;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.65;
    user-select: none;
    border-right: 1px solid var(--border-color);
    padding-right: 12px;
    padding-left: 12px;
    overflow: hidden;
    white-space: pre-wrap;
}

.code-editor {
    flex: 1;
    padding: 16px;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.88rem;
    line-height: 1.65;
    resize: none;
    tab-size: 2;
    overflow-y: auto;
}

.code-editor::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

/* ----- Snippet Section ----- */
.snippets-section {
    margin-top: 24px;
}

.snippets-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.snippets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

.snippet-btn {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    text-align: left;
    transition: all var(--transition-normal);
    color: var(--text-primary);
}

.snippet-btn:hover {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.06);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

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

.snippet-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
}

.snippet-code {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.3);
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ----- Action Section ----- */
.action-section {
    text-align: center;
    margin-top: 32px;
}

.btn-generate {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: var(--radius-md);
    overflow: hidden;
    font-family: var(--font-body);
}

.btn-generate-bg {
    position: absolute;
    inset: 0;
    background: var(--accent-gradient);
    border-radius: var(--radius-md);
    transition: all var(--transition-normal);
}

.btn-generate:hover .btn-generate-bg {
    background: var(--accent-gradient-hover);
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.4);
}

.btn-generate-content {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 36px;
    font-size: 1rem;
    font-weight: 700;
    color: white;
    letter-spacing: 0.02em;
}

.btn-generate:active .btn-generate-bg {
    transform: scale(0.97);
}

.action-hint {
    margin-top: 12px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.action-hint kbd {
    padding: 2px 7px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
}

/* ----- Error Container ----- */
.error-container {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    margin-top: 20px;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-md);
    animation: shakeIn 0.4s ease;
}

@keyframes shakeIn {
    0% { transform: translateX(-8px); opacity: 0; }
    25% { transform: translateX(6px); }
    50% { transform: translateX(-4px); }
    75% { transform: translateX(2px); }
    100% { transform: translateX(0); opacity: 1; }
}

.error-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
}

.error-content {
    flex: 1;
}

.error-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--red);
    margin-bottom: 4px;
}

.error-message {
    font-size: 0.84rem;
    color: rgba(239, 68, 68, 0.85);
    font-family: var(--font-mono);
}

.error-close {
    background: none;
    border: none;
    color: var(--red);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 4px;
    opacity: 0.6;
    transition: opacity var(--transition-fast);
}

.error-close:hover {
    opacity: 1;
}

/* ----- Features Section ----- */
.features-section {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-top: 56px;
    animation: fadeInUp 0.6s ease 0.3s both;
}

.feature-card {
    padding: 28px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    text-align: center;
    transition: all var(--transition-normal);
}

.feature-card:hover {
    border-color: var(--accent-primary);
    transform: translateY(-3px);
    box-shadow: var(--shadow-glow);
}

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

.feature-title {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.feature-desc {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ----- Footer ----- */
.footer {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 32px 24px;
    border-top: 1px solid var(--border-color);
    margin-top: 40px;
}

.footer-content p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.footer-sub {
    font-size: 0.78rem !important;
    color: var(--text-muted) !important;
    margin-top: 4px;
}

/* ----- Responsive ----- */
@media (max-width: 768px) {
    .navbar {
        padding: 0 12px;
    }

    .nav-brand {
        gap: 8px;
    }

    .nav-title {
        display: none; /* Hide AST Generator text to save room */
    }

    .nav-badge {
        display: none;
    }

    .nav-link {
        padding: 6px 12px;
        font-size: 0.85rem;
        gap: 6px;
    }

    .hero-title {
        font-size: 2rem;
    }

    .hero-title-gradient {
        font-size: 2.3rem;
    }

    .pipeline {
        padding: 16px;
    }

    .pipeline-step {
        min-width: 90px;
        padding: 12px;
    }

    .pipeline-arrow {
        font-size: 1rem;
    }

    .features-section {
        grid-template-columns: 1fr;
    }

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

    .main-container {
        padding: 24px 16px 40px;
    }
}

@media (max-width: 480px) {
    .nav-links {
        gap: 2px;
    }

    .nav-link {
        padding: 6px 8px;
        font-size: 0.75rem;
    }
    
    .nav-link-icon {
        font-size: 0.9rem;
    }

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