/* Design System Tokens */
:root {
    --bg-dark: #0B0F19;
    --card-bg: rgba(17, 24, 39, 0.7);
    --card-border: rgba(255, 255, 255, 0.08);
    --text-primary: #F3F4F6;
    --text-secondary: #9CA3AF;
    --text-muted: #6B7280;

    /* Accent & Status Colors */
    --color-primary-start: #6366F1; /* Indigo */
    --color-primary-end: #A855F7;   /* Purple */
    --color-success: #10B981;       /* Emerald */
    --color-success-glow: rgba(16, 185, 129, 0.15);
    --color-warning: #F59E0B;       /* Amber */
    --color-warning-glow: rgba(245, 158, 11, 0.15);
    --color-error: #EF4444;         /* Crimson Red */
    --color-error-glow: rgba(239, 68, 68, 0.15);

    /* Gradients */
    --brand-gradient: linear-gradient(135deg, var(--color-primary-start) 0%, var(--color-primary-end) 100%);
    --glow-gradient: linear-gradient(135deg, #4F46E5 0%, #7C3AED 50%, #C084FC 100%);
    
    /* System Values */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px; /* Consistent card rounding */
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --card-shadow: 0 8px 24px rgba(0, 0, 0, 0.35); /* Cohesive card shadow */
}

/* Reset and Core Layout */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    overflow-x: hidden;
}

/* Background Glow Effects - Muted for Mature Aesthetic */
.background-glows {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 0;
    pointer-events: none;
}

.glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(150px);
    opacity: 0.08; /* Reduced glow by ~45% */
    animation: drift 20s infinite alternate ease-in-out;
}

.glow-1 {
    top: -10%;
    left: 10%;
    width: 500px;
    height: 500px;
    background: var(--color-primary-start);
}

.glow-2 {
    bottom: 10%;
    right: 5%;
    width: 600px;
    height: 600px;
    background: var(--color-primary-end);
    animation-delay: -5s;
}

@keyframes drift {
    0% {
        transform: translate(0, 0) scale(1);
    }
    100% {
        transform: translate(50px, 30px) scale(1.1);
    }
}

/* Sticky Navigation Bar */
.navbar {
    width: 100%;
    height: 56px;
    background: rgba(11, 15, 25, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    justify-content: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    width: 100%;
    max-width: 1200px;
    padding: 0 16px;
    display: flex;
    align-items: center;
}

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

.nav-brand-icon {
    font-size: 1.15rem;
    color: var(--color-primary-start);
}

.nav-title {
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

.nav-divider {
    color: rgba(255, 255, 255, 0.15);
    font-size: 0.85rem;
    margin: 0 2px;
}

.nav-tagline {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.nav-brand-svg {
    width: 20px;
    height: 20px;
    display: inline-block;
}

/* App Container */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: relative;
    z-index: 1;
}

/* Page Header - Professional Title and Byline */
header {
    text-align: left;
    margin-bottom: 4px;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

.subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    max-width: 800px;
    margin-top: 4px;
}

/* Glass Card Component - Cohesive Shadow and Corners */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
    overflow: hidden;
    transition: var(--transition-smooth);
}

.card:hover {
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
}

/* Editor Styling */
.input-card {
    display: flex;
    flex-direction: column;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 14px 20px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--card-border);
}

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

.dot.red { background-color: #EF4444; }
.dot.yellow { background-color: #F59E0B; }
.dot.green { background-color: #10B981; }

.card-title {
    margin-left: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.editor-container {
    display: flex;
    position: relative;
    width: 100%;
    height: 200px;
    background: rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

#editor-gutter {
    width: 48px;
    height: 100%;
    padding: 16px 10px 16px 0;
    font-family: var(--font-mono);
    font-size: 0.95rem;
    line-height: 1.6;
    text-align: right;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.2);
    border-right: 1px solid var(--card-border);
    overflow: hidden;
    user-select: none;
    box-sizing: border-box;
}

.line-num {
    display: block;
    height: 1.6em; /* Must match code line-height */
    color: rgba(255, 255, 255, 0.2);
    font-size: 0.85rem;
    transition: var(--transition-smooth);
}

.line-num.active-error {
    color: var(--color-error);
    font-weight: 700;
    text-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
}

.editor-area {
    position: relative;
    flex: 1;
    height: 100%;
    overflow: hidden;
}

#code-input, #editor-highlight {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 16px 20px;
    border: none;
    outline: none;
    font-family: var(--font-mono);
    font-size: 0.95rem;
    line-height: 1.6;
    tab-size: 4;
    -moz-tab-size: 4;
    white-space: pre;
    overflow: auto; /* Support x & y scroll */
    box-sizing: border-box;
}

#code-input {
    background: transparent;
    color: transparent;
    caret-color: #ffffff;
    resize: none;
    z-index: 2;
}

#editor-highlight {
    background: transparent;
    color: var(--text-primary);
    pointer-events: none;
    z-index: 1;
}

#code-input::placeholder {
    color: var(--text-muted);
}

/* Syntax Highlighting Tokens */
.hl-keyword { color: #A855F7; font-weight: 600; } /* Purple */
.hl-string { color: #34D399; } /* Emerald */
.hl-comment { color: #6B7280; font-style: italic; } /* Slate Muted */
.hl-number { color: #F59E0B; } /* Amber */
.hl-operator { color: #EC4899; } /* Pink */

/* Editor Line Wrap & Highlighting */
.editor-line {
    display: block;
    height: 1.6em;
    white-space: pre;
    box-sizing: border-box;
}

.editor-line.error-highlight {
    background-color: rgba(239, 68, 68, 0.15);
    border-left: 3px solid var(--color-error);
    margin-left: -20px; /* Offset the 20px padding left */
    padding-left: 17px;
    width: calc(100% + 20px);
    animation: shakeError 0.4s ease-in-out;
}

@keyframes shakeError {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-4px); }
    40%, 80% { transform: translateX(4px); }
}

/* Scrollbar Customization */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.card-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px; /* Space out the Clear and Fix It buttons */
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.15);
    border-top: 1px solid var(--card-border);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 22px;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 600;
    color: white;
    background: var(--brand-gradient);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to right, rgba(255,255,255,0.1), rgba(255,255,255,0));
    opacity: 0;
    transition: var(--transition-smooth);
}

.btn:hover {
    transform: translateY(-2px) scale(1.01);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.3);
    filter: brightness(1.05);
}

.btn:hover::before {
    opacity: 1;
}

.btn:active {
    transform: translateY(-1px) scale(0.99);
}

.btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-icon {
    font-size: 0.9rem;
    transition: var(--transition-smooth);
}

.btn:hover .btn-icon {
    transform: rotate(15deg) scale(1.1);
}

.spinner {
    display: inline-block;
}

.hidden {
    display: none !important;
}

/* Outputs Area Layout */
.outputs-wrapper {
    display: flex;
    flex-direction: column;
    gap: 16px; /* Consistent spacing between rows */
    width: 100%;
    animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.outputs-top-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px; /* Consistent spacing between columns */
    align-items: start; /* Hug height of content */
}

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

/* Output Cards Specifics */
.output-card {
    position: relative;
    transition: var(--transition-smooth);
}

.output-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--card-border);
}

.output-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
}

.status-icon {
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
}

.status-icon.warning {
    color: var(--color-warning);
}

.status-icon.error {
    color: var(--color-error);
}

.status-icon.success {
    color: var(--color-success);
}

.output-content {
    padding: 12px 16px; /* Consistent compact padding for all output cards */
    font-size: 0.9rem;
    color: var(--text-primary);
    overflow-x: auto;
}

/* Styling differences for statuses */
/* What's Wrong Card (Yellow/Orange) */
.whats-wrong-card {
    border-left: 4px solid var(--color-warning);
}
.whats-wrong-card:hover {
    box-shadow: inset 0 0 20px var(--color-warning-glow), 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}
.whats-wrong-card .output-content {
    line-height: 1.7;
    color: #FDE047; /* Soft yellow/amber text for readability */
}

@keyframes pulseWarning {
    0% {
        box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5), 
                    0 0 5px rgba(245, 158, 11, 0.1);
    }
    50% {
        box-shadow: 0 15px 35px -10px rgba(0, 0, 0, 0.6), 
                    0 0 25px rgba(245, 158, 11, 0.4);
    }
    100% {
        box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5), 
                    0 0 5px rgba(245, 158, 11, 0.1);
    }
}
.whats-wrong-card.pulse-glow {
    animation: pulseWarning 2.2s infinite ease-in-out;
}

.whats-wrong-card.error-flash {
    animation: redFlashPulse 1s ease-out;
}

@keyframes redFlashPulse {
    0% {
        box-shadow: 0 0 0 0px rgba(239, 68, 68, 0.6);
        background-color: rgba(239, 68, 68, 0.25);
    }
    50% {
        box-shadow: 0 0 25px 8px rgba(239, 68, 68, 0.4);
        background-color: rgba(239, 68, 68, 0.12);
    }
    100% {
        box-shadow: 0 0 0 0px rgba(239, 68, 68, 0);
        background-color: transparent;
    }
}

/* Broken Line Card (Red) */
.broken-line-card {
    border-left: 4px solid var(--color-error);
}
.broken-line-card:hover {
    box-shadow: inset 0 0 20px var(--color-error-glow), 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

/* The Fix Card (Green) */
.the-fix-card {
    border-left: 4px solid var(--color-success);
}
.the-fix-card:hover {
    box-shadow: inset 0 0 20px var(--color-success-glow), 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

/* Code Display Formats (Broken Line & Fix) */
.code-display-wrapper {
    background-color: rgba(0, 0, 0, 0.25);
    margin: 0;
    border-top: none;
    padding: 12px 0; /* Native top/bottom padding, zero horizontal margin */
}

.code-display-wrapper pre {
    margin: 0;
}

.code-display-wrapper code {
    font-family: var(--font-mono);
    font-size: 0.95rem;
    line-height: 1.6;
    display: block;
    white-space: pre;
    overflow-x: auto;
}

.display-line {
    display: flex;
    align-items: flex-start;
    min-height: 1.6em;
    width: 100%;
    box-sizing: border-box;
}

.display-line.error-highlight {
    background-color: rgba(239, 68, 68, 0.15);
    border-left: 4px solid var(--color-error);
}

.display-line.success-highlight {
    background-color: rgba(16, 185, 129, 0.15);
    border-left: 4px solid var(--color-success);
}

/* Line numbers gutter and text styles for The Fix box */
.line-gutter {
    width: 48px;
    padding: 0 10px 0 0;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.6;
    text-align: right;
    color: rgba(255, 255, 255, 0.25);
    background: rgba(0, 0, 0, 0.15);
    border-right: 1px solid var(--card-border);
    user-select: none;
    flex-shrink: 0;
    box-sizing: border-box;
}

.line-text {
    flex: 1;
    font-family: var(--font-mono);
    font-size: 0.95rem;
    line-height: 1.6;
    padding-left: 16px;
    white-space: pre-wrap;
    word-break: break-all;
    box-sizing: border-box;
}

#broken-line-output {
    color: #F87171; /* Soft red text color to match the red accent box */
    padding: 10px 0;
}

#broken-line-output .display-line {
    padding: 0 16px;
}

#broken-line-output .display-line.error-highlight {
    padding-left: 12px; /* Offset the 4px border-left spacing */
}

#fix-output {
    color: #34D399; /* Greenish text color */
    padding: 10px 0;
    white-space: pre-wrap; /* Wrap long lines inside fix output */
    word-break: break-all;
}

#fix-output .display-line {
    white-space: pre-wrap; /* Wrap text in line wrapper divisions */
    word-break: break-all;
    padding: 0;
}

/* Copy Button for Fixed Code */
.copy-btn {
    margin-left: auto;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.copy-btn:active {
    transform: scale(0.9);
}

.copy-btn.success {
    color: var(--color-success);
}

.copy-btn .copy-text {
    font-size: 0.78rem;
    font-weight: 500;
    margin-left: 6px;
    font-family: var(--font-sans);
}

/* Footer styling */
footer {
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding: 24px 0 16px 0;
    margin-top: 32px;
}

.footer-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.counter-container {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    padding: 6px 12px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    transition: var(--transition-smooth);
}

.counter-icon {
    color: var(--color-success);
    font-size: 0.85rem;
}

/* Try Examples Styling */
.examples-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: -4px;
    flex-wrap: wrap;
    z-index: 2;
}

.examples-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.btn-outline {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-secondary);
    padding: 6px 14px;
    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-smooth);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
    transform: translateY(-1px);
}

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

/* Card Footer Clear Button Specifics (High contrast & matches fix-btn dimensions) */
.card-footer .btn-outline {
    padding: 10px 22px;
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: var(--text-primary);
}

.card-footer .btn-outline:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px) scale(1.01);
}

/* How It Works Steps Styling */
.steps-container {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 16px;
    margin-bottom: 4px;
    flex-wrap: wrap;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    padding: 10px 16px;
    border-radius: var(--radius-md);
}

.step-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.step-badge {
    width: 22px;
    height: 22px;
    background: rgba(99, 102, 241, 0.15);
    color: #A5B4FC;
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
}

.step-title {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.step-separator {
    color: var(--text-muted);
    font-size: 0.75rem;
    display: flex;
    align-items: center;
}

/* Category Badges Styling */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-left: 10px;
}

.badge.syntax-error {
    background-color: rgba(239, 68, 68, 0.12);
    color: #EF4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge.logic-error {
    background-color: rgba(245, 158, 11, 0.12);
    color: #F59E0B;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge.missing-punctuation {
    background-color: rgba(236, 72, 153, 0.12);
    color: #EC4899;
    border: 1px solid rgba(236, 72, 153, 0.2);
}

.badge.other-error {
    background-color: rgba(168, 85, 247, 0.12);
    color: #A855F7;
    border: 1px solid rgba(168, 85, 247, 0.2);
}

.badge.clean {
    background-color: rgba(16, 185, 129, 0.12);
    color: #10B981;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

/* Responsive adjustments */
@media (max-width: 900px) {
    /* Grid layout naturally stacks dashboard columns */
}

@media (max-width: 640px) {
    header h1 {
        font-size: 1.75rem;
    }
    .container {
        padding: 16px 12px;
        gap: 16px;
    }
    .editor-container {
        height: 160px;
    }
    .outputs-top-row {
        grid-template-columns: 1fr; /* Stack What's Wrong and Broken Line vertically */
    }
    .steps-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .step-separator {
        display: none; /* Hide arrows on vertical stack */
    }
}

/* High-density laptops or projector displays */
@media (max-height: 800px) {
    .container {
        padding: 12px 24px;
        gap: 14px;
    }
    header h1 {
        font-size: 1.75rem;
        margin-bottom: 2px;
    }
    .logo {
        margin-bottom: 2px;
    }
    .subtitle {
        font-size: 0.9rem;
    }
    .editor-container {
        height: 160px;
    }
}
