/* ============================================
   OLLAMA IMAGE GENERATOR — Design System
   Premium dark mode with glassmorphism
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ---------- CSS Custom Properties ---------- */
:root {
    /* Palette */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a2e;
    --bg-glass: rgba(255, 255, 255, 0.03);
    --bg-glass-hover: rgba(255, 255, 255, 0.06);
    --border-glass: rgba(255, 255, 255, 0.08);
    --border-glass-hover: rgba(255, 255, 255, 0.14);

    /* Accent */
    --accent-primary: #7c5cfc;
    --accent-primary-hover: #9478ff;
    --accent-secondary: #4ecdc4;
    --accent-gradient: linear-gradient(135deg, #7c5cfc 0%, #4ecdc4 100%);
    --accent-glow: rgba(124, 92, 252, 0.25);

    /* Text */
    --text-primary: #f0f0f5;
    --text-secondary: #9494a8;
    --text-tertiary: #5c5c72;
    --text-accent: #b8a4ff;

    /* Status */
    --success: #4ecdc4;
    --warning: #ffd166;
    --error: #ef476f;
    --info: #7c5cfc;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Shadows */
    --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 var(--accent-glow);

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

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

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

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

/* Ambient background glow */
body::before {
    content: '';
    position: fixed;
    top: -40%;
    left: -20%;
    width: 80%;
    height: 80%;
    background: radial-gradient(circle, rgba(124, 92, 252, 0.06) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

body::after {
    content: '';
    position: fixed;
    bottom: -40%;
    right: -20%;
    width: 70%;
    height: 70%;
    background: radial-gradient(circle, rgba(78, 205, 196, 0.04) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* ---------- Layout ---------- */
.ig-app {
    position: relative;
    z-index: 1;
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--space-xl);
    min-height: 100vh;
}

.ig-header {
    text-align: center;
    margin-bottom: var(--space-2xl);
    padding: var(--space-xl) 0;
}

.ig-header__logo {
    display: inline-flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-sm);
}

.ig-header__icon {
    width: 48px;
    height: 48px;
    background: var(--accent-gradient);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: var(--shadow-glow);
}

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

.ig-header__subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 400;
    margin-top: var(--space-xs);
}

.ig-main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-xl);
    align-items: start;
}

/* ---------- Glass Panel ---------- */
.ig-panel {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    transition: border-color var(--transition-base);
}

.ig-panel:hover {
    border-color: var(--border-glass-hover);
}

.ig-panel__title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-lg);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.ig-panel__title-icon {
    font-size: 1.2rem;
    opacity: 0.8;
}

/* ---------- Form Controls ---------- */
.ig-field {
    margin-bottom: var(--space-lg);
}

.ig-field:last-child {
    margin-bottom: 0;
}

.ig-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: var(--space-sm);
}

.ig-select,
.ig-input,
.ig-textarea {
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    padding: var(--space-md);
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.ig-select:focus,
.ig-input:focus,
.ig-textarea:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.ig-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239494a8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
}

.ig-textarea {
    resize: vertical;
    min-height: 140px;
    line-height: 1.5;
}

.ig-textarea::placeholder {
    color: var(--text-tertiary);
}

/* ---------- Range Slider ---------- */
.ig-range-group {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.ig-range {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    outline: none;
    transition: background var(--transition-fast);
}

.ig-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-primary);
    cursor: pointer;
    border: 3px solid var(--bg-primary);
    box-shadow: 0 0 10px var(--accent-glow);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.ig-range::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 0 18px var(--accent-glow);
}

.ig-range::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-primary);
    cursor: pointer;
    border: 3px solid var(--bg-primary);
    box-shadow: 0 0 10px var(--accent-glow);
}

.ig-range-value {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-accent);
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: var(--space-xs) var(--space-sm);
    min-width: 64px;
    text-align: center;
    outline: none;
    transition: border-color var(--transition-fast);
}

.ig-range-value:focus {
    border-color: var(--accent-primary);
}

/* ---------- Presets ---------- */
.ig-presets {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-top: var(--space-sm);
}

.ig-preset {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    padding: var(--space-xs) var(--space-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.ig-preset:hover {
    border-color: var(--accent-primary);
    color: var(--text-accent);
    background: rgba(124, 92, 252, 0.08);
}

.ig-preset.is-active {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: rgba(124, 92, 252, 0.12);
}

/* ---------- Divider ---------- */
.ig-divider {
    border: none;
    height: 1px;
    background: var(--border-glass);
    margin: var(--space-lg) 0;
}

/* ---------- Generate Button ---------- */
.ig-btn-generate {
    width: 100%;
    padding: var(--space-md) var(--space-xl);
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    box-shadow: var(--shadow-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
}

.ig-btn-generate:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 0 40px var(--accent-glow);
}

.ig-btn-generate:active:not(:disabled) {
    transform: translateY(0);
}

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

.ig-btn-generate::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
    transform: translateX(-100%);
    transition: transform 0.6s ease;
}

.ig-btn-generate:hover:not(:disabled)::before {
    transform: translateX(100%);
}

/* ---------- Result Panel ---------- */
.ig-result {
    position: sticky;
    top: var(--space-xl);
}

.ig-result__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    color: var(--text-tertiary);
    text-align: center;
    gap: var(--space-md);
}

.ig-result__empty-icon {
    font-size: 3rem;
    opacity: 0.3;
}

.ig-result__empty-text {
    font-size: 0.95rem;
    max-width: 240px;
    line-height: 1.5;
}

/* Image container */
.ig-image-wrap {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-secondary);
    min-height: 300px;
}

.ig-image-wrap img {
    width: 100%;
    height: auto;
    display: block;
    opacity: 0;
    animation: ig-fadeIn 0.5s ease forwards;
}

@keyframes ig-fadeIn {
    to { opacity: 1; }
}

/* ---------- Stats bar ---------- */
.ig-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-sm);
    margin-top: var(--space-md);
}

.ig-stat {
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    text-align: center;
    transition: border-color var(--transition-fast);
}

.ig-stat:hover {
    border-color: var(--border-glass-hover);
}

.ig-stat__value {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-accent);
    margin-bottom: 2px;
}

.ig-stat__label {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* ---------- Actions ---------- */
.ig-actions {
    display: flex;
    gap: var(--space-sm);
    margin-top: var(--space-md);
}

.ig-btn-action {
    flex: 1;
    padding: var(--space-md);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
}

.ig-btn-download {
    background: rgba(78, 205, 196, 0.1);
    color: var(--accent-secondary);
    border-color: rgba(78, 205, 196, 0.2);
}

.ig-btn-download:hover {
    background: rgba(78, 205, 196, 0.18);
    border-color: var(--accent-secondary);
}

.ig-btn-copy-prompt {
    background: var(--bg-glass);
    color: var(--text-secondary);
}

.ig-btn-copy-prompt:hover {
    background: var(--bg-glass-hover);
    border-color: var(--border-glass-hover);
    color: var(--text-primary);
}

/* ---------- Loading / Progress ---------- */
.ig-loading {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    gap: var(--space-lg);
    text-align: center;
}

.ig-loading.is-visible {
    display: flex;
}

.ig-spinner {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 3px solid var(--bg-tertiary);
    border-top-color: var(--accent-primary);
    animation: ig-spin 0.8s linear infinite;
}

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

.ig-loading__text {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.ig-progress-bar {
    width: 200px;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.ig-progress-bar__fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: var(--radius-full);
    width: 0%;
    transition: width var(--transition-base);
}

.ig-loading__step {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-tertiary);
}

/* ---------- Error ---------- */
.ig-error {
    display: none;
    background: rgba(239, 71, 111, 0.08);
    border: 1px solid rgba(239, 71, 111, 0.2);
    border-radius: var(--radius-md);
    padding: var(--space-md) var(--space-lg);
    color: var(--error);
    font-size: 0.9rem;
    margin-top: var(--space-md);
    align-items: center;
    gap: var(--space-sm);
}

.ig-error.is-visible {
    display: flex;
}

/* ---------- Model Info Badge ---------- */
.ig-model-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    padding: 3px var(--space-sm);
    background: rgba(124, 92, 252, 0.1);
    border: 1px solid rgba(124, 92, 252, 0.2);
    border-radius: var(--radius-full);
    color: var(--text-accent);
    margin-top: var(--space-xs);
}

.ig-model-badge__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
    animation: ig-pulse 2s ease infinite;
}

@keyframes ig-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ---------- Prompt char count ---------- */
.ig-char-count {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-tertiary);
    text-align: right;
    margin-top: var(--space-xs);
}

/* ---------- Seed field inline ---------- */
.ig-seed-group {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.ig-seed-group .ig-input {
    flex: 1;
}

.ig-btn-random-seed {
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--space-md);
    font-size: 1.1rem;
    line-height: 1;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ig-btn-random-seed:hover {
    border-color: var(--accent-primary);
    color: var(--text-accent);
}

/* ---------- Keep Alive Select ---------- */
.ig-keep-alive-group {
    display: flex;
    gap: var(--space-sm);
}

.ig-keep-alive-group .ig-input {
    flex: 1;
}

.ig-keep-alive-group .ig-select {
    width: auto;
    min-width: 90px;
}

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
    .ig-main {
        grid-template-columns: 1fr;
    }

    .ig-result {
        position: static;
    }
}

@media (max-width: 640px) {
    .ig-app {
        padding: var(--space-md);
    }

    .ig-header__title {
        font-size: 1.5rem;
    }

    .ig-panel {
        padding: var(--space-md);
    }

    .ig-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

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

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

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
}

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

/* ---------- Selection ---------- */
::selection {
    background: rgba(124, 92, 252, 0.3);
    color: var(--text-primary);
}

/* ---------- Hidden utility ---------- */
.is-hidden {
    display: none !important;
}

/* ---------- Toast notification ---------- */
.ig-toast {
    position: fixed;
    bottom: var(--space-xl);
    right: var(--space-xl);
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: var(--space-md) var(--space-lg);
    color: var(--text-primary);
    font-size: 0.9rem;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    transform: translateY(20px);
    opacity: 0;
    transition: all var(--transition-base);
    pointer-events: none;
}

.ig-toast.is-visible {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.ig-toast--success {
    border-color: rgba(78, 205, 196, 0.3);
}

.ig-toast--error {
    border-color: rgba(239, 71, 111, 0.3);
}
