/* =============================================================================
   ScrapeGraph UI - Firecrawl-inspired Design (Blue Theme)
   ============================================================================= */

/* =============================================================================
   CSS Variables / Design Tokens
   ============================================================================= */
:root {
    /* Blue accent system */
    --blue-50: #eff6ff;
    --blue-100: #dbeafe;
    --blue-200: #bfdbfe;
    --blue-300: #93c5fd;
    --blue-400: #60a5fa;
    --blue-500: #3b82f6;
    --blue-600: #2563eb;
    --blue-700: #1d4ed8;
    --blue-800: #1e40af;
    --blue-900: #1e3a8a;
    
    /* Primary colors */
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    
    /* Backgrounds */
    --bg-body: #fafafa;
    --bg-card: #ffffff;
    --bg-muted: #f5f5f5;
    --bg-input: #ffffff;
    
    /* Text */
    --text-primary: #171717;
    --text-secondary: #404040;
    --text-muted: #737373;
    --text-placeholder: #a3a3a3;
    --text-inverse: #ffffff;
    
    /* Borders */
    --border: #e5e5e5;
    --border-light: #f5f5f5;
    --border-focus: #3b82f6;
    
    /* Status Colors */
    --success: #22c55e;
    --success-bg: #f0fdf4;
    --error: #ef4444;
    --error-bg: #fef2f2;
    --warning: #f59e0b;
    --warning-bg: #fffbeb;
    
    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    
    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-popover: 0 4px 20px rgba(0, 0, 0, 0.15);
    
    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    
    /* Font Sizes */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 2rem;
    --text-4xl: 2.5rem;
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.2s ease;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* =============================================================================
   ASCII Wave Accent - Minimalist Left & Right Sides (Water/Wave Theme with SMEV)
   ============================================================================= */
.ascii-wave {
    position: fixed;
    top: 0;
    width: 280px;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    line-height: 1.4;
    white-space: pre;
    color: rgba(180, 180, 180, 0.4);
}

.ascii-wave-left {
    left: 0;
    text-align: right;
    padding-right: 15px;
}

.ascii-wave-right {
    right: 0;
    text-align: left;
    padding-left: 15px;
}

/* Dark mode for ASCII wave is set in the main dark mode section */

/* =============================================================================
   Main Layout
   ============================================================================= */
.app-container {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-content {
    position: relative;
    z-index: 1;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    padding: var(--space-8) var(--space-6);
}

/* Removed dotted lines for cleaner look */

/* =============================================================================
   Header
   ============================================================================= */
.header {
    position: relative;
    text-align: center;
    margin-bottom: var(--space-8);
    padding-top: var(--space-10);
}

.header h1 {
    font-size: var(--text-4xl);
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    margin-bottom: var(--space-2);
}

.header-subtitle {
    color: var(--text-muted);
    font-size: var(--text-base);
}

/* Settings button in navigation - removed old header positioning */

/* =============================================================================
   Navigation Tabs - Firecrawl Style
   ============================================================================= */
.nav-tabs {
    display: flex;
    justify-content: center;
    margin-bottom: var(--space-8);
    position: relative;
}

.nav-tabs-inner {
    display: inline-flex;
    align-items: center;
    background: var(--bg-card);
    padding: var(--space-1);
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.nav-tab {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: var(--text-sm);
    font-weight: 500;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.nav-tab:hover {
    color: var(--text-primary);
}

.nav-tab.active {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.nav-tab-icon {
    font-size: 14px;
    opacity: 0.7;
}

.nav-tab.active .nav-tab-icon {
    color: var(--primary);
    opacity: 1;
}

.nav-separator {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 var(--space-1);
}

.nav-badge {
    font-size: 10px;
    padding: 2px 6px;
    background: var(--bg-muted);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.nav-settings-btn {
    position: absolute;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: var(--space-2);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.nav-settings-btn:hover {
    background: var(--bg-muted);
    border-color: var(--primary);
}

/* =============================================================================
   Action Card - Main Input Area (Compact)
   ============================================================================= */
.action-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    margin-bottom: var(--space-5);
    position: relative;
}

/* URL Input Row - Compact */
.url-input-row {
    display: flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    overflow: hidden;
    margin-bottom: var(--space-3);
}

.url-prefix {
    padding: 0 var(--space-3);
    color: var(--text-muted);
    font-size: 13px;
    background: transparent;
    border: none;
    white-space: nowrap;
}

.url-input {
    flex: 1;
    border: none;
    padding: 12px var(--space-3);
    font-size: 14px;
    outline: none;
    background: transparent;
}

.url-input::placeholder {
    color: var(--text-placeholder);
}

/* Controls Row - Compact */
.controls-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.controls-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.controls-right {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

/* Icon Buttons */
.icon-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    font-size: 15px;
}

.icon-btn:hover {
    border-color: var(--text-muted);
    color: var(--text-primary);
}

.icon-btn.active {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.icon-btn .dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 5px;
    height: 5px;
    background: var(--primary);
    border-radius: 50%;
}

/* Format Dropdown - Compact */
.format-dropdown {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.format-dropdown:hover {
    border-color: var(--text-muted);
}

.format-dropdown .icon {
    font-size: 14px;
    color: var(--text-muted);
}

.format-dropdown .label {
    color: var(--text-muted);
    font-size: 13px;
}

.format-dropdown .value {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 13px;
}

.format-dropdown .chevron {
    font-size: 10px;
    color: var(--text-muted);
    margin-left: 2px;
}

/* Get Code Button - Compact */
.btn-getcode {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-getcode:hover {
    border-color: var(--text-muted);
    color: var(--text-primary);
}

.btn-getcode .icon {
    font-size: 14px;
}

/* Primary Action Button - Compact */
.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    background: var(--primary);
    color: var(--text-inverse);
    border: none;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

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

/* Secondary Button - Compact */
.btn-secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-secondary:hover {
    border-color: var(--text-muted);
    color: var(--text-primary);
}

/* =============================================================================
   Options Popover - Compact Firecrawl Style
   ============================================================================= */
.popover {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: var(--space-2);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-popover);
    padding: var(--space-3);
    min-width: 260px;
    z-index: 100;
    display: none;
}

.popover.active {
    display: block;
    animation: popoverIn 0.15s ease;
}

@keyframes popoverIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.popover-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-3);
    padding-bottom: var(--space-2);
    border-bottom: none;
}

.popover-title {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-muted);
}

.popover-close {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-size: 16px;
}

.popover-close:hover {
    background: var(--bg-muted);
    color: var(--text-primary);
}

/* Option Row - Compact like Firecrawl */
.option-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: none;
}

.option-row:last-child {
    border-bottom: none;
}

.option-left {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.option-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 14px;
}

.option-label {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 400;
}

.option-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: var(--space-1);
}

.option-right {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

/* Toggle Switch - Compact */
.toggle {
    width: 40px;
    height: 22px;
    background: var(--border);
    border-radius: var(--radius-full);
    position: relative;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.toggle.active {
    background: var(--primary);
}

.toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    transition: transform var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.toggle.active::after {
    transform: translateX(18px);
}

/* Small Input - Compact */
.input-sm {
    width: 80px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    text-align: right;
    outline: none;
}

.input-sm:focus {
    border-color: var(--primary);
}

.input-suffix {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: 4px;
}

/* Add Button - Compact */
.btn-add {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
}

.btn-add:hover {
    background: var(--bg-muted);
}

/* Reset Settings Link */
.reset-link {
    display: block;
    text-align: center;
    margin-top: var(--space-3);
    padding-top: var(--space-2);
    border-top: 1px solid var(--border-light);
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    transition: color var(--transition-fast);
}

.reset-link:hover {
    color: var(--text-primary);
}

/* =============================================================================
   Tab Content
   ============================================================================= */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

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

/* =============================================================================
   Section Headers
   ============================================================================= */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-4);
}

.section-title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
}

.section-hint {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

/* =============================================================================
   Results Area
   ============================================================================= */
.result-container {
    display: none;
    margin-top: var(--space-6);
}

.result-container.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

.result-header {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-4);
}

pre {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: var(--space-5);
    border-radius: var(--radius-lg);
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    line-height: 1.6;
}

/* =============================================================================
   Recipe Cards
   ============================================================================= */
.recipes-section {
    margin-top: var(--space-8);
}

.recipes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-4);
}

.recipe-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    transition: all var(--transition-fast);
    display: flex;
    flex-direction: column;
}

.recipe-card:hover {
    border-color: var(--blue-300);
    box-shadow: var(--shadow-md);
}

.recipe-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
}

.recipe-card-name {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    word-break: break-word;
    line-height: 1.3;
}

.recipe-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    text-transform: uppercase;
    flex-shrink: 0;
}

.badge-discovery {
    background: #fef3c7;
    color: #92400e;
}

.badge-scrape {
    background: var(--blue-100);
    color: var(--blue-700);
}

.recipe-card-meta {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-bottom: var(--space-3);
    flex: 1;
}

.recipe-card-actions {
    display: flex;
    gap: var(--space-2);
    margin-top: auto;
}

.recipe-card-actions button {
    flex: 1;
    padding: var(--space-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-muted);
    font-size: var(--text-xs);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.recipe-card-actions button:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.recipe-card-actions .btn-delete:hover {
    border-color: var(--error);
    color: var(--error);
    background: var(--error-bg);
}

/* Section Label */
.section-label {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-3);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: var(--space-8);
    color: var(--text-muted);
    font-size: var(--text-sm);
}

/* =============================================================================
   Form Elements
   ============================================================================= */
.form-group {
    margin-bottom: var(--space-4);
}

.form-label {
    display: block;
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    margin-bottom: var(--space-2);
}

.form-input {
    width: 100%;
    padding: var(--space-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    outline: none;
    transition: border-color var(--transition-fast);
}

.form-input:focus {
    border-color: var(--primary);
}

.form-input::placeholder {
    color: var(--text-placeholder);
}

textarea.form-input {
    resize: vertical;
    min-height: 100px;
}

select.form-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23737373' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}

/* =============================================================================
   Modal
   ============================================================================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: var(--space-4);
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-5);
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: var(--text-lg);
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-size: 20px;
}

.modal-close:hover {
    background: var(--bg-muted);
    color: var(--text-primary);
}

.modal-body {
    padding: var(--space-5);
}

.modal-footer {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-5);
    border-top: 1px solid var(--border);
}

/* Code Block in Modal */
.code-block {
    background: #1e1e1e;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    background: #2d2d2d;
    border-bottom: 1px solid #404040;
}

.code-lang {
    font-size: var(--text-xs);
    color: #a3a3a3;
    font-weight: 500;
}

.code-copy {
    padding: var(--space-1) var(--space-2);
    background: transparent;
    border: 1px solid #404040;
    border-radius: var(--radius-sm);
    color: #a3a3a3;
    font-size: var(--text-xs);
    cursor: pointer;
}

.code-copy:hover {
    background: #404040;
    color: white;
}

.code-content {
    padding: var(--space-4);
    overflow-x: auto;
}

.code-content pre {
    margin: 0;
    padding: 0;
    background: transparent;
}

/* =============================================================================
   Utility Classes
   ============================================================================= */
.hidden {
    display: none !important;
}

.text-muted {
    color: var(--text-muted);
}

.text-sm {
    font-size: var(--text-sm);
}

.text-xs {
    font-size: var(--text-xs);
}

.mt-4 {
    margin-top: var(--space-4);
}

.mb-4 {
    margin-bottom: var(--space-4);
}

.flex {
    display: flex;
}

.items-center {
    align-items: center;
}

.gap-2 {
    gap: var(--space-2);
}

.gap-3 {
    gap: var(--space-3);
}

/* Warning Text */
.warning-text {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--warning);
    font-size: var(--text-sm);
}

/* =============================================================================
   Toast Notifications
   ============================================================================= */
.toast-container {
    position: fixed;
    top: var(--space-4);
    right: var(--space-4);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    min-width: 300px;
    max-width: 450px;
    pointer-events: auto;
    animation: toastIn 0.3s ease;
}

.toast.toast-exiting {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

.toast-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
    font-size: 14px;
}

.toast-success .toast-icon {
    background: var(--success-bg);
    color: var(--success);
}

.toast-error .toast-icon {
    background: var(--error-bg);
    color: var(--error);
}

.toast-warning .toast-icon {
    background: var(--warning-bg);
    color: var(--warning);
}

.toast-info .toast-icon {
    background: var(--blue-100);
    color: var(--blue-600);
}

.toast-content {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.toast-message {
    font-size: var(--text-xs);
    color: var(--text-muted);
    word-break: break-word;
}

.toast-close {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.toast-close:hover {
    background: var(--bg-muted);
    color: var(--text-primary);
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--primary);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    animation: toastProgress 4s linear forwards;
}

@keyframes toastProgress {
    from { width: 100%; }
    to { width: 0%; }
}

/* =============================================================================
   Loading Spinner
   ============================================================================= */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-sm {
    width: 16px;
    height: 16px;
}

.spinner-lg {
    width: 32px;
    height: 32px;
    border-width: 3px;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e5e7eb;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Button Loading State */
.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 18px;
    height: 18px;
    margin: -9px 0 0 -9px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.btn-secondary.btn-loading::after {
    border-color: var(--border);
    border-top-color: var(--primary);
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, var(--bg-muted) 25%, var(--border-light) 50%, var(--bg-muted) 75%);
    background-size: 200% 100%;
    animation: skeleton 1.5s ease-in-out infinite;
    border-radius: var(--radius-md);
}

@keyframes skeleton {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-text {
    height: 16px;
    margin-bottom: var(--space-2);
}

.skeleton-text:last-child {
    width: 60%;
}

.skeleton-card {
    height: 120px;
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: var(--space-3);
    z-index: 10;
    border-radius: var(--radius-lg);
}

.loading-text {
    font-size: var(--text-sm);
    color: var(--text-muted);
    font-weight: 500;
}

/* =============================================================================
   Recent Runs History
   ============================================================================= */
.history-section {
    margin-top: var(--space-6);
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-4);
}

.history-title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.history-badge {
    font-size: var(--text-xs);
    padding: 2px 8px;
    background: var(--bg-muted);
    color: var(--text-muted);
    border-radius: var(--radius-full);
    font-weight: 500;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.history-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.history-item:hover {
    border-color: var(--blue-300);
    box-shadow: var(--shadow-sm);
}

.history-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-muted);
    border-radius: var(--radius-md);
    font-size: 16px;
    flex-shrink: 0;
}

.history-item.success .history-icon {
    background: var(--success-bg);
}

.history-item.error .history-icon {
    background: var(--error-bg);
}

.history-content {
    flex: 1;
    min-width: 0;
}

.history-url {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-meta {
    font-size: var(--text-xs);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.history-time {
    color: var(--text-muted);
}

.history-type {
    padding: 1px 6px;
    background: var(--blue-100);
    color: var(--blue-700);
    border-radius: var(--radius-sm);
    font-weight: 500;
    text-transform: uppercase;
    font-size: 10px;
}

.history-actions {
    display: flex;
    gap: var(--space-2);
}

.history-action-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 12px;
}

.history-action-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.history-empty {
    text-align: center;
    padding: var(--space-8);
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.history-clear-btn {
    padding: var(--space-1) var(--space-3);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: var(--text-xs);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.history-clear-btn:hover {
    border-color: var(--error);
    color: var(--error);
}

/* =============================================================================
   Dark Mode Support
   ============================================================================= */
[data-theme="dark"] {
    --bg-body: #0a0a0a;
    --bg-card: #171717;
    --bg-muted: #262626;
    --bg-input: #1f1f1f;
    
    --text-primary: #fafafa;
    --text-secondary: #d4d4d4;
    --text-muted: #a3a3a3;
    --text-placeholder: #737373;
    
    --border: #404040;
    --border-light: #262626;
    --border-focus: #60a5fa;
    
    --success-bg: rgba(34, 197, 94, 0.15);
    --error-bg: rgba(239, 68, 68, 0.15);
    --warning-bg: rgba(245, 158, 11, 0.15);
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    --shadow-popover: 0 4px 20px rgba(0, 0, 0, 0.5);
}

/* Dark mode - Body & backgrounds */
[data-theme="dark"] body {
    background-color: #0a0a0a;
    color: #fafafa;
}

/* Dark mode - ASCII wave */
[data-theme="dark"] .ascii-wave {
    color: rgba(160, 160, 160, 0.4);
}

/* Dark mode - Cards & containers */
[data-theme="dark"] .action-card,
[data-theme="dark"] .recipe-card,
[data-theme="dark"] .result-container {
    background: #171717;
    border-color: #333;
}

/* Dark mode - URL input row */
[data-theme="dark"] .url-input-row {
    background: #1a1a1a;
    border-color: #333;
}

[data-theme="dark"] .url-prefix {
    background: #262626;
    color: #a3a3a3;
    border-color: #333;
}

[data-theme="dark"] .url-input {
    background: #1a1a1a;
    color: #fafafa;
}

[data-theme="dark"] .url-input::placeholder {
    color: #666;
}

/* Dark mode - All text inputs & textareas */
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="url"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] textarea,
[data-theme="dark"] .form-input {
    background: #1a1a1a;
    border-color: #333;
    color: #fafafa;
}

[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
    color: #666;
}

[data-theme="dark"] input:focus,
[data-theme="dark"] textarea:focus,
[data-theme="dark"] .form-input:focus {
    border-color: #60a5fa;
    background: #1f1f1f;
}

/* Dark mode - Select & dropdowns */
[data-theme="dark"] select,
[data-theme="dark"] .model-select,
[data-theme="dark"] .format-dropdown {
    background: #1a1a1a;
    border-color: #333;
    color: #fafafa;
}

[data-theme="dark"] .format-dropdown:hover {
    background: #262626;
    border-color: #404040;
}

/* Dark mode - Buttons */
[data-theme="dark"] .icon-btn {
    background: #1a1a1a;
    border-color: #333;
    color: #d4d4d4;
}

[data-theme="dark"] .icon-btn:hover {
    background: #262626;
    border-color: #404040;
}

[data-theme="dark"] .icon-btn.active {
    background: rgba(59, 130, 246, 0.2);
    border-color: #3b82f6;
}

[data-theme="dark"] .btn-secondary,
[data-theme="dark"] .btn-getcode {
    background: #1a1a1a;
    border-color: #333;
    color: #d4d4d4;
}

[data-theme="dark"] .btn-secondary:hover,
[data-theme="dark"] .btn-getcode:hover {
    background: #262626;
    border-color: #404040;
}

/* Dark mode - Navigation tabs */
[data-theme="dark"] .nav-tabs-inner {
    background: #171717;
    border-color: #333;
}

[data-theme="dark"] .nav-tab {
    color: #a3a3a3;
}

[data-theme="dark"] .nav-tab:hover {
    background: #262626;
    color: #fafafa;
}

[data-theme="dark"] .nav-tab.active {
    background: #262626;
    color: #fafafa;
}

[data-theme="dark"] .nav-separator {
    background: #333;
}

/* Dark mode - Popovers */
[data-theme="dark"] .popover {
    background: #1a1a1a;
    border-color: #333;
}

[data-theme="dark"] .popover-header {
    border-color: #333;
}

[data-theme="dark"] .option-row:hover {
    background: #262626;
}

[data-theme="dark"] .input-sm {
    background: #262626;
    border-color: #404040;
    color: #fafafa;
}

/* Dark mode - Toggle switch */
[data-theme="dark"] .toggle {
    background: #333;
}

[data-theme="dark"] .toggle.active {
    background: #3b82f6;
}

/* Dark mode - Result area */
[data-theme="dark"] .result-header {
    background: #1a1a1a;
    border-color: #333;
    color: #a3a3a3;
}

[data-theme="dark"] pre {
    background: #0f0f0f;
    color: #d4d4d4;
}

/* Dark mode - Code block & modal */
[data-theme="dark"] .code-block {
    background: #0f0f0f;
}

[data-theme="dark"] .code-header {
    background: #1a1a1a;
    border-color: #333;
}

[data-theme="dark"] .modal {
    background: #171717;
    border-color: #333;
}

[data-theme="dark"] .modal-header {
    border-color: #333;
}

[data-theme="dark"] .modal-close:hover {
    background: #333;
}

/* Dark mode - Recipe cards */
[data-theme="dark"] .recipe-card {
    background: #1a1a1a;
    border-color: #333;
}

[data-theme="dark"] .recipe-card:hover {
    border-color: #404040;
}

[data-theme="dark"] .recipe-card-actions button {
    background: #262626;
    border-color: #404040;
    color: #d4d4d4;
}

[data-theme="dark"] .recipe-card-actions button:hover {
    background: #333;
}

/* Dark mode - History */
[data-theme="dark"] .history-item {
    background: #1a1a1a;
    border-color: #333;
}

[data-theme="dark"] .history-item:hover {
    border-color: #404040;
}

[data-theme="dark"] .history-icon {
    background: #262626;
}

[data-theme="dark"] .history-action-btn {
    background: #262626;
    border-color: #404040;
    color: #a3a3a3;
}

[data-theme="dark"] .history-action-btn:hover {
    background: #333;
}

[data-theme="dark"] .history-clear-btn {
    border-color: #404040;
    color: #a3a3a3;
}

/* Dark mode - Toast notifications */
[data-theme="dark"] .toast {
    background: #1a1a1a;
    border-color: #333;
}

/* Dark mode - Loading overlay */
[data-theme="dark"] .loading-overlay {
    background: rgba(23, 23, 23, 0.9);
}

/* Dark mode - Scrollbar */
[data-theme="dark"] ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

[data-theme="dark"] ::-webkit-scrollbar-track {
    background: #1a1a1a;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: #404040;
    border-radius: 4px;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: #525252;
}

/* Theme Toggle Button */
.theme-toggle {
    position: fixed;
    bottom: var(--space-4);
    right: var(--space-4);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    z-index: 100;
    transition: all var(--transition-fast);
}

.theme-toggle:hover {
    transform: scale(1.1);
    border-color: var(--primary);
}

.theme-toggle .icon-light,
.theme-toggle .icon-dark {
    position: absolute;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.theme-toggle .icon-dark {
    opacity: 0;
    transform: rotate(-90deg);
}

[data-theme="dark"] .theme-toggle .icon-light {
    opacity: 0;
    transform: rotate(90deg);
}

[data-theme="dark"] .theme-toggle .icon-dark {
    opacity: 1;
    transform: rotate(0);
}

/* =============================================================================
   Responsive
   ============================================================================= */
@media (max-width: 1200px) {
    .ascii-bg {
        display: none;
    }
    
    .main-content::before,
    .main-content::after {
        display: none;
    }
}

@media (max-width: 768px) {
    .main-content {
        padding: var(--space-4);
    }
    
    .header h1 {
        font-size: var(--text-2xl);
    }
    
    .header-subtitle {
        font-size: var(--text-sm);
    }
    
    .nav-tabs-inner {
        flex-wrap: wrap;
        justify-content: center;
        border-radius: var(--radius-lg);
        gap: var(--space-1);
        padding: var(--space-2);
    }
    
    .nav-tab {
        padding: var(--space-2) var(--space-3);
        font-size: var(--text-xs);
    }
    
    .nav-tab-icon {
        font-size: 12px;
    }
    
    .nav-separator {
        display: none;
    }
    
    .action-card {
        padding: var(--space-4);
    }
    
    .url-input-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .url-prefix {
        padding: var(--space-2) var(--space-3);
        border-bottom: 1px solid var(--border);
    }
    
    .url-input {
        padding: var(--space-3);
    }
    
    .controls-row {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-3);
    }
    
    .controls-left {
        justify-content: flex-start;
        flex-wrap: wrap;
    }
    
    .controls-right {
        justify-content: stretch;
        margin-left: 0;
    }
    
    .controls-right .btn-primary {
        flex: 1;
    }
    
    .controls-right .btn-getcode {
        display: none;
    }
    
    .format-dropdown {
        font-size: var(--text-xs);
        padding: var(--space-2);
    }
    
    .icon-btn {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
    
    .popover {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        margin: 0;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        max-height: 80vh;
        overflow-y: auto;
        min-width: unset;
    }
    
    .recipes-grid {
        grid-template-columns: 1fr;
    }
    
    .recipe-card {
        padding: var(--space-3);
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-2);
    }
    
    .modal {
        margin: var(--space-2);
        max-height: calc(100vh - var(--space-4));
    }
    
    .modal-body {
        padding: var(--space-4);
    }
    
    .toast-container {
        left: var(--space-2);
        right: var(--space-2);
        top: var(--space-2);
    }
    
    .toast {
        min-width: unset;
        max-width: unset;
    }
    
    .history-item {
        flex-wrap: wrap;
    }
    
    .history-actions {
        width: 100%;
        justify-content: flex-end;
        margin-top: var(--space-2);
    }
    
    .theme-toggle {
        bottom: var(--space-2);
        right: var(--space-2);
        width: 40px;
        height: 40px;
    }
}

/* Small phones */
@media (max-width: 480px) {
    .main-content {
        padding: var(--space-3);
    }
    
    .header {
        padding-top: var(--space-6);
        margin-bottom: var(--space-4);
    }
    
    .header h1 {
        font-size: var(--text-xl);
    }
    
    .nav-tabs {
        margin-bottom: var(--space-4);
    }
    
    .nav-tab {
        padding: var(--space-1) var(--space-2);
    }
    
    .nav-tab span:not(.nav-tab-icon) {
        display: none;
    }
    
    .nav-tab-icon {
        margin: 0;
    }
    
    .action-card {
        padding: var(--space-3);
        border-radius: var(--radius-lg);
    }
    
    .btn-primary {
        width: 100%;
        justify-content: center;
    }
    
    .form-group {
        margin-bottom: var(--space-3);
    }
    
    pre {
        font-size: var(--text-xs);
        padding: var(--space-3);
    }
}

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

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

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

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* =============================================================================
   Recipe Choice Buttons
   ============================================================================= */
.recipe-choice-btn {
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    font-family: inherit;
    width: 100%;
    position: relative;
    z-index: 1;
}

.recipe-choice-btn:hover {
    border-color: var(--primary);
    background: #f0f9ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.recipe-choice-btn.selected {
    border-color: var(--primary);
    background: #eff6ff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.dark .recipe-choice-btn {
    background: #1f2937 !important;
    border: 2px solid #4b5563 !important;
    color: #f9fafb !important;
}

.dark .recipe-choice-btn:hover {
    border-color: #3b82f6 !important;
    background: #374151 !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3) !important;
}

.dark .recipe-choice-btn.selected {
    background: #374151 !important;
    border-color: #3b82f6 !important;
}

/* Fix all text colors in dark mode - be very specific */
body.dark .recipe-choice-btn * {
    color: #f9fafb !important;
}

body.dark .recipe-choice-btn div[style*="666"],
body.dark .recipe-choice-btn div[style*="999"] {
    color: #9ca3af !important;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #4b5563;
    transition: 0.3s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: #3b82f6;
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

.dark .toggle-slider {
    background-color: #374151;
}

.dark .toggle-switch input:checked + .toggle-slider {
    background-color: #3b82f6;
}
