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

:root {
    --primary-bg: #0f172a;
    --accent-color: #38bdf8;
    --secondary-accent: #818cf8;
    --text-main: #f8fafc;
    --text-dim: #94a3b8;
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--primary-bg);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Background Animation */
#bg-canvas {
    position: fixed;
    top: 0;
    left: 0;
    z-index: -1;
    width: 100%;
    height: 100%;
}

.gradient-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 50% 50%, #1e293b 0%, #0f172a 100%);
    z-index: -2;
}

.glow {
    position: fixed;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(56, 189, 248, 0.15) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
    z-index: -1;
    transition: transform 0.1s ease-out;
}

/* Layout */
.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

header {
    text-align: center;
    margin-bottom: 50px;
}

h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 4rem;
    font-weight: 800;
    background: linear-gradient(135deg, #fff 0%, var(--accent-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -2px;
    margin-bottom: 10px;
}

header p {
    color: var(--text-dim);
    font-size: 1.1rem;
    letter-spacing: 1px;
}

/* Main UI Card */
.forge-card {
    width: 100%;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 40px;
    box-shadow: var(--glass-shadow);
}

/* Input Area */
.input-section {
    margin-bottom: 30px;
}

.input-box {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 20px;
    color: #fff;
    font-size: 1.1rem;
    font-family: inherit;
    resize: none;
    min-height: 150px;
    transition: var(--transition);
    outline: none;
}

.input-box:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.1);
}

/* Selector Groups (Size, Goal, Framing) */
.selector-group {
    display: flex;
    gap: 10px;
    margin: 15px 0 25px 0;
    flex-wrap: wrap;
}

.selector-group button {
    flex: 1;
    min-width: 120px;
    padding: 10px 15px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    color: var(--text-dim);
    cursor: pointer;
    font-weight: 500;
    font-size: 0.85rem;
    transition: var(--transition);
}

.selector-group button:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.selector-group button.active {
    background: var(--accent-color);
    color: var(--primary-bg);
    border-color: var(--accent-color);
    font-weight: 700;
}

.sub-category-section {
    width: 100%;
    margin: 10px 0 20px 0;
    padding: 15px;
    background: rgba(56, 189, 248, 0.03);
    border-radius: 16px;
    border: 1px solid rgba(56, 189, 248, 0.1);
    animation: slideDown 0.3s ease-out;
}

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

/* Controls & Upload Section */
.controls {
    width: 100%;
    margin-bottom: 30px;
}

.upload-section {
    display: flex;
    align-items: center;
    gap: 20px;
}

.upload-label {
    flex: 1;
    padding: 15px 25px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
}

.upload-label:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-color);
}

.upload-label i {
    color: var(--accent-color);
    font-size: 1.1rem;
}

#file-upload { display: none; }

.auto-mode, .identity-mode {
    display: flex;
    align-items: center;
    gap: 12px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input { display: none; }

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border-radius: 34px;
}

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

input:checked + .slider { background-color: var(--accent-color); }
input:checked + .slider:before { transform: translateX(26px); }

/* Image Preview System */
.preview-container {
    margin: 20px 0;
    padding: 20px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px dashed rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    animation: fadeInDown 0.5s ease-out;
}

.preview-box {
    position: relative;
    width: fit-content;
    margin: 0 auto;
    border-radius: 12px;
    overflow: visible;
}

.preview-box img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    display: block;
}

.remove-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #1a1a1a;
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
}

.remove-btn:hover {
    background: #ff4757;
    transform: scale(1.1);
}

/* Scanning Animation */
.preview-box {
    position: relative;
    overflow: hidden !important;
}

.scan-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(to bottom, transparent, var(--accent-color), transparent);
    box-shadow: 0 0 15px var(--accent-color);
    display: none;
    z-index: 5;
}

.scanning .scan-line {
    display: block;
    animation: scan 2s linear infinite;
}

@keyframes scan {
    0% { top: 0; }
    50% { top: 100%; }
    100% { top: 0; }
}

/* Output Box Loading State */
.output-box.loading {
    border-color: var(--accent-color);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 5px rgba(56, 189, 248, 0.1); }
    50% { box-shadow: 0 0 20px rgba(56, 189, 248, 0.3); }
    100% { box-shadow: 0 0 5px rgba(56, 189, 248, 0.1); }
}

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

.pills-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 30px;
    justify-content: center;
    animation: fadeInDown 0.4s ease-out;
}

.pill {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    color: #fff;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.pill:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--accent-color);
}

.pill.active {
    background: var(--accent-color);
    color: var(--primary-bg);
    border-color: var(--accent-color);
    font-weight: 700;
}

/* Skin Color Picker */
.skin-color-section {
    width: 100%;
    margin: 10px 0 20px 0;
    padding: 15px;
    background: rgba(56, 189, 248, 0.03);
    border-radius: 16px;
    border: 1px solid rgba(56, 189, 248, 0.1);
    animation: slideDown 0.3s ease-out;
}

.skin-color-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.skin-swatch {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    min-width: 44px;
    min-height: 44px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.skin-swatch:hover {
    border-color: var(--accent-color);
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.08);
}

.skin-swatch.active {
    border-color: var(--accent-color);
    background: rgba(56, 189, 248, 0.15);
    color: #fff;
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.3);
}

.swatch-color {
    display: block;
    width: 26px;
    height: 26px;
    min-width: 26px;
    min-height: 26px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.25);
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.2);
}

.skin-swatch.active .swatch-color {
    border-color: #fff;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.4), inset 0 1px 3px rgba(0,0,0,0.2);
}

.hidden {
    display: none !important;
}

/* Action Button */
.generate-btn {
    width: 100%;
    padding: 20px;
    background: linear-gradient(135deg, var(--accent-color) 0%, var(--secondary-accent) 100%);
    border: none;
    border-radius: 16px;
    color: white;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 2px;
    transition: var(--transition);
    box-shadow: 0 10px 20px rgba(56, 189, 248, 0.2);
}

.generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 30px rgba(56, 189, 248, 0.3);
}

.generate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Output Panel */
.output-panel {
    margin-top: 40px;
    display: none;
    animation: slideUp 0.5s ease-out;
}

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

.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.type-tag {
    background: rgba(56, 189, 248, 0.1);
    color: var(--accent-color);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.word-count {
    font-size: 0.8rem;
    color: var(--text-dim);
}

.output-box {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 30px;
    color: #fff;
    font-family: 'Inter', sans-serif;
    line-height: 1.8;
    max-height: 600px;
    overflow-y: auto;
    position: relative;
    white-space: pre-wrap;
}

.copy-btn {
    margin-top: 15px;
    background: transparent;
    border: 1px solid var(--glass-border);
    color: #fff;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition);
}

.copy-btn:hover {
    background: rgba(255,255,255,0.1);
}

/* Loading Animation */
.loader {
    display: none;
    margin: 20px auto;
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,0.1); }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }
