/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;800&display=swap');

:root {
    /* Color Palette */
    --primary: #00ff88;
    --primary-glow: rgba(0, 255, 136, 0.4);
    --secondary: #7000ff;
    --accent: #00d4ff;
    
    --bg-dark: #050510;
    --glass-bg: rgba(20, 20, 30, 0.6);
    --glass-border: rgba(255, 255, 255, 0.1);
    
    --text-main: #ffffff;
    --text-muted: #a0a0b0;

    --font-main: 'Outfit', sans-serif;
    
    --radius: 16px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
}

body {
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(112, 0, 255, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(0, 255, 136, 0.1) 0%, transparent 40%);
    color: var(--text-main);
    font-family: var(--font-main);
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #0a0a0a; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

.container {
    max-width: 1200px;
    margin: 40px auto;
    padding: 40px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: 0 20px 80px rgba(0,0,0,0.5);
    position: relative;
    overflow: hidden;
}

/* Decorative Glow */
.container::before {
    content: '';
    position: absolute;
    top: -50px; left: -50px;
    width: 200px; height: 200px;
    background: var(--primary);
    filter: blur(100px);
    opacity: 0.2;
    z-index: -1;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 40px;
}

h1 {
    font-size: 3.5rem;
    font-weight: 800;
    letter-spacing: -2px;
    margin: 0;
    background: linear-gradient(135deg, #fff 0%, #aaa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-transform: uppercase;
}

h1 span {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 1.1rem;
    color: var(--text-muted);
    font-weight: 300;
}

/* Grid Layout */
.grid-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

@media (max-width: 768px) {
    .grid-layout { grid-template-columns: 1fr; }
    .container { margin: 10px; padding: 20px; }
    h1 { font-size: 2.5rem; }
}

/* Controls */
.control-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Inputs & Selects */
input[type="file"], select, textarea {
    width: 100%;
    padding: 16px;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    color: #fff;
    font-family: var(--font-main);
    font-size: 1rem;
    transition: var(--transition);
    outline: none;
}

input[type="file"] {
    cursor: pointer;
    line-height: 1.2;
}

textarea {
    resize: vertical;
    min-height: 120px;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.1);
    background: rgba(0,0,0,0.5);
}

/* Buttons */
.btn {
    border: none;
    border-radius: var(--radius);
    padding: 18px 30px;
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #00b359);
    color: #000;
    box-shadow: 0 10px 30px rgba(0, 255, 136, 0.2);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(0, 255, 136, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, #ff0055, #cc0044);
    color: #fff;
    box-shadow: 0 10px 30px rgba(255, 0, 85, 0.2);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(255, 0, 85, 0.4);
}

.btn-glass {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
}
.btn-glass:hover {
    background: rgba(255,255,255,0.1);
    border-color: var(--text-main);
}

/* Status & Progress */
.progress-wrapper {
    margin-top: 20px;
    background: rgba(0,0,0,0.3);
    border-radius: 10px;
    overflow: hidden;
    height: 6px;
    opacity: 0;
    transition: opacity 0.3s;
}
.progress-wrapper.active { opacity: 1; }

.progress-bar {
    height: 100%;
    width: 0%;
    background: var(--primary);
    box-shadow: 0 0 10px var(--primary);
    transition: width 0.4s ease;
}

.status-text {
    margin-top: 10px;
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: center;
    min-height: 20px;
}

/* Image Display Area */
.display-area {
    margin-top: 40px;
    background: rgba(0,0,0,0.5);
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    min-height: 500px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 0 50px rgba(0,0,0,0.5);
}

.placeholder-text {
    color: var(--text-muted);
    font-size: 1.2rem;
    opacity: 0.5;
}

.generated-image {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

/* Loader */
.loader {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255,255,255,0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s infinite cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

@keyframes spin { 
    to { transform: rotate(360deg); } 
}

/* Controls Bar (Upscale) */
.tools-bar {
    display: flex;
    gap: 15px;
    margin-top: 20px;
    padding: 15px;
    background: rgba(255,255,255,0.03);
    border-radius: var(--radius);
    border: 1px solid var(--glass-border);
    align-items: center;
}

/* Slider Component */
.slider-container {
    position: relative;
    width: 100%;
    max-width: 1024px;
    margin: 0 auto;
    border-radius: 12px;
    overflow: hidden;
    cursor: ew-resize;
    user-select: none;
    touch-action: none;
}

.slider-img-wrapper {
    position: relative;
    width: 100%;
    line-height: 0;
}

.slider-img-wrapper img {
    width: 100%;
    height: auto;
    display: block;
}

.slider-overlay {
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 50%;
    overflow: hidden;
    border-right: 2px solid rgba(255,255,255,0.8);
    background: #000;
}

.slider-overlay img {
    height: 100%;
    width: auto; /* Important: maintain aspect ratio */
    max-width: none;
}

.slider-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 44px;
    height: 44px;
    background: rgba(255,255,255,0.9);
    backdrop-filter: blur(5px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    z-index: 10;
    color: #333;
    font-size: 1.2rem;
    pointer-events: none; /* Let clicks pass through to container */
}

.slider-label {
    position: absolute;
    top: 20px;
    padding: 6px 14px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    font-size: 0.85rem;
    border-radius: 8px;
    font-weight: 600;
    backdrop-filter: blur(4px);
    z-index: 5;
    pointer-events: none;
}

.lbl-before { left: 20px; border-left: 3px solid #ff4444; }
.lbl-after { right: 20px; border-right: 3px solid var(--primary); }

/* History Grid */
.history-section {
    margin-top: 60px;
    padding-top: 30px;
    border-top: 1px solid var(--glass-border);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-header h3 { margin: 0; color: var(--text-main); }

.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 15px;
}

.history-item {
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--glass-border);
    transition: var(--transition);
    cursor: pointer;
}

.history-item:hover {
    transform: scale(1.05);
    border-color: var(--primary);
    box-shadow: 0 5px 20px rgba(0,0,0,0.5);
}

.history-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.history-badge {
    position: absolute;
    bottom: 0;
    right: 0;
    background: rgba(0,0,0,0.7);
    color: #fff;
    font-size: 0.7rem;
    padding: 3px 6px;
    border-top-left-radius: 6px;
}
