:root {
    /* --- COLOR PALETTE (Ultimate Neon) --- */
    --bg-dark: #0a0a0f;
    --bg-panel: #13131f;
    --bg-card: #1c1c2e;

    --primary: #ff3366;
    /* Hot Pink */
    --primary-glow: rgba(255, 51, 102, 0.4);
    --secondary: #7000ff;
    /* Electric Purple */
    --accent: #00f0ff;
    /* Cyan */

    --text-main: #ffffff;
    --text-muted: #8b8b9e;

    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-bg: rgba(20, 20, 30, 0.6);

    /* --- SPACING & RADIUS --- */
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 8px;
    --header-height: 80px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
    /* App-like feel */
    height: 100vh;
    width: 100vw;
}

/* --- APP LAYOUT GRID --- */
.app-layout {
    display: grid;
    grid-template-columns: 280px 1fr 340px;
    /* Sidebar | Canvas | Controls */
    height: 100vh;
    width: 100vw;
}

/* Animations */
@keyframes pulse-glow {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 51, 102, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(255, 51, 102, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(255, 51, 102, 0);
    }
}

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

    100% {
        background-position: 200% 0;
    }
}

.generating .canvas-container {
    animation: pulse-glow 2s infinite;
    border-color: var(--primary);
}

.generating .progress-line .fill {
    background: linear-gradient(90deg, var(--primary) 25%, var(--secondary) 50%, var(--primary) 75%);
    background-size: 200% 100%;
    animation: shimmer 2s infinite linear;
}

/* ==========================================================================
   COLUMN 1: SIDEBAR
   ========================================================================== */
.sidebar {
    background: var(--bg-panel);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 20px;
    z-index: 10;
}

.logo-area h1 {
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 40px;
    letter-spacing: -1px;
    background: linear-gradient(135deg, #fff, var(--text-muted));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-area .highlight {
    color: var(--primary);
    -webkit-text-fill-color: var(--primary);
}

.workflow-nav {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nav-category {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    margin-top: 20px;
    margin-bottom: 5px;
    letter-spacing: 1px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.nav-item:hover {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(255, 51, 102, 0.1), transparent);
    border-left: 3px solid var(--primary);
    color: white;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.nav-item .icon {
    font-size: 18px;
}

.system-status {
    margin-top: auto;
    padding: 15px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-border);
}

.status-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    margin-bottom: 5px;
    color: var(--text-muted);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #444;
}

.status-indicator.online {
    background: #00ff88;
    box-shadow: 0 0 10px #00ff88;
}

.low-vram {
    color: #ffaa00;
    font-weight: 700;
}

/* ==========================================================================
   COLUMN 2: CENTER STAGE
   ========================================================================== */
.center-stage {
    display: flex;
    flex-direction: column;
    padding: 30px;
    background: radial-gradient(circle at 50% 30%, #1a1a2e 0%, var(--bg-dark) 70%);
    position: relative;
    overflow: hidden;
}

/* Top Bar (Prompt Presets) */
.top-bar {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.glass-select,
.glass-btn {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 10px 20px;
    border-radius: 50px;
    cursor: pointer;
    backdrop-filter: blur(10px);
    transition: all 0.2s;
}

.glass-select:hover,
.glass-btn:hover {
    border-color: var(--primary);
    box-shadow: 0 0 15px var(--primary-glow);
}

/* Canvas Area */
.canvas-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    border-radius: var(--radius-lg);
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--glass-border);
    margin-bottom: 25px;
    overflow: hidden;
    justify-content: center;
    align-items: center;
    box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.5);
}

.preview-area {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.preview-area img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    cursor: zoom-in;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.placeholder-content {
    text-align: center;
    color: var(--text-muted);
    opacity: 0.5;
}

.big-icon {
    font-size: 60px;
    display: block;
    margin-bottom: 10px;
}

/* Upload Overlay */
.upload-zone {
    position: absolute;
    inset: 10px;
    border: 2px dashed var(--glass-border);
    border-radius: var(--radius-md);
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.8);
    cursor: pointer;
    z-index: 50;
    backdrop-filter: blur(5px);
}

.upload-zone:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* Progress Line (Top of canvas) */
.progress-line {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: #000;
}

.progress-line .fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    width: 0%;
    transition: width 0.3s;
    box-shadow: 0 0 10px var(--primary);
}

/* Prompt Area */
.prompt-bar {
    background: var(--bg-panel);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

#prompt-input {
    background: transparent;
    border: none;
    color: white;
    font-size: 16px;
    resize: none;
    outline: none;
    width: 100%;
    height: 60px;
    font-family: 'Outfit', sans-serif;
}

#prompt-input::placeholder {
    color: rgba(255, 255, 255, 0.2);
}

.prompt-tools {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tool-btn {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    transition: 0.2s;
}

.tool-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.generate-btn {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
    color: white;
    padding: 12px 30px;
    border-radius: 50px;
    font-weight: 800;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 10px 20px rgba(255, 51, 102, 0.3);
}

.generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 30px rgba(255, 51, 102, 0.5);
}

/* ==========================================================================
   COLUMN 3: CONTROL PANEL
   ========================================================================== */
.control-panel {
    background: var(--bg-panel);
    border-left: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
}

.panel-header {
    padding: 20px;
    border-bottom: 1px solid var(--glass-border);
}

.scrollable-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.control-group {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 15px;
    margin-bottom: 15px;
}

.group-title {
    display: block;
    font-size: 11px;
    font-weight: 800;
    color: var(--text-muted);
    margin-bottom: 15px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

label {
    font-size: 13px;
    color: var(--text-main);
    font-weight: 600;
}

.val-display {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--primary);
    background: rgba(255, 51, 102, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

input[type="range"] {
    width: 100%;
    accent-color: var(--primary);
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px var(--primary);
    margin-top: -6px;
}

input[type="range"]::-webkit-slider-runnable-track {
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

/* Resolution Inputs */
.res-inputs {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.res-inputs input {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 8px;
    border-radius: var(--radius-sm);
    width: 100%;
    font-family: 'JetBrains Mono';
    text-align: center;
}

.res-presets {
    display: flex;
    gap: 5px;
}

.res-presets button {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: var(--text-muted);
    padding: 6px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
}

.res-presets button:hover {
    background: var(--primary);
    color: white;
}

/* Tooltip FIX - Position Absolute/Fixed strategy */
.info-tooltip {
    background: rgba(255, 255, 255, 0.1);
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    font-size: 10px;
    color: var(--text-muted);
    cursor: help;
    position: relative;
    margin-left: 5px;
}

/* Using a simplified tooltip that won't clip */
.info-tooltip:hover::after {
    content: attr(data-tooltip);
    position: fixed;
    /* Fixed solves overflow clipping! */
    right: 360px;
    /* Positioned to the left of the control panel */
    top: 50%;
    /* Centered vertically relative to viewport (rough approx, handled better via JS ideally but CSS fixed works for now) */
    transform: translateY(-50%);
    width: 250px;
    background: rgba(10, 10, 15, 0.95);
    border: 1px solid var(--primary);
    padding: 15px;
    border-radius: var(--radius-md);
    color: white;
    font-size: 13px;
    line-height: 1.4;
    z-index: 9999;
    pointer-events: none;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
}

.sub-control {
    margin-bottom: 15px;
}

/* Mini Gallery */
.mini-gallery {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    margin-top: 10px;
}

.mini-gallery img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
    transition: 0.2s;
}

.mini-gallery img:hover {
    transform: scale(1.1);
    z-index: 2;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

/* Utilities */
.hidden {
    display: none !important;
}

/* Overlays */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

#viewer-image {
    max-height: 95vh;
    max-width: 95vw;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
}

.close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
}