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

:root {
    --bg-dark: #050505;
    --bg-page: #0a0a0a;
    --glass-surface: rgba(20, 20, 20, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-highlight: rgba(255, 255, 255, 0.03);
    --text-primary: #ededed;
    --text-secondary: #a1a1a1;
    --text-muted: #525252;
    --accent-blue: #60a5fa;
    --accent-purple: #a78bfa;
    --accent-green: #22c55e;
    --accent-red: #ef4444;
    --font-sans: 'Inter', sans-serif;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-page);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    overflow: hidden;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

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

.main-container {
    flex: 1;
    display: flex;
    height: 100vh;
    overflow: hidden;
    margin-left: 40px;
}

nav a:hover {
    color: var(--text-primary);
    background: var(--glass-highlight);
}

nav a.active {
    color: var(--text-primary);
    background: var(--glass-highlight);
    border: 1px solid var(--glass-border);
}

/* Main Layout - Two Column */
.main-container {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Left Panel - Controls */
.controls-panel {
    width: 380px;
    background: var(--glass-surface);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex-shrink: 0;
}

.panel-section {
    padding: 1.25rem;
    border-bottom: 1px solid var(--glass-border);
}

.panel-section:last-child {
    border-bottom: none;
}

.section-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    font-weight: 600;
}

/* Custom Dropdown */
.custom-dropdown {
    position: relative;
    width: 100%;
}

.dropdown-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border: 1px solid var(--glass-border);
    background: var(--glass-highlight);
    color: var(--text-primary);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 0.875rem;
}

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

.custom-dropdown.open .dropdown-trigger {
    border-color: var(--accent-blue);
    border-radius: 10px 10px 0 0;
}

.dropdown-trigger i {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.custom-dropdown.open .dropdown-trigger i {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #141414;
    border: 1px solid var(--accent-blue);
    border-top: none;
    border-radius: 0 0 10px 10px;
    max-height: 320px;
    overflow-y: auto;
    z-index: 100;
    display: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.dropdown-menu::-webkit-scrollbar {
    width: 8px;
}

.dropdown-menu::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
}

.dropdown-menu::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.dropdown-menu::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.15);
}

.custom-dropdown.open .dropdown-menu {
    display: block;
}

.dropdown-group-label {
    padding: 0.6rem 1rem 0.4rem;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.02);
    border-top: 1px solid var(--glass-border);
}

.dropdown-group-label:first-child {
    border-top: none;
}

.dropdown-item {
    padding: 0.65rem 1rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.1s;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.dropdown-item.selected {
    background: rgba(96, 165, 250, 0.1);
    color: var(--accent-blue);
}

.dropdown-item.selected::after {
    content: '✓';
    font-size: 0.75rem;
}

/* Hidden native select for form compatibility */
.model-select-wrapper select {
    display: none;
}

/* Aspect Ratio Presets */
.aspect-presets {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.aspect-btn {
    padding: 0.5rem;
    border: 1px solid var(--glass-border);
    background: transparent;
    color: var(--text-secondary);
    border-radius: 8px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

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

.aspect-btn.active {
    border-color: var(--accent-blue);
    background: rgba(96, 165, 250, 0.1);
    color: var(--accent-blue);
}

.aspect-btn .ratio-icon {
    width: 24px;
    height: 24px;
    border: 1.5px solid currentColor;
    border-radius: 3px;
}

.aspect-btn[data-ratio="1:1"] .ratio-icon {
    width: 20px;
    height: 20px;
}

.aspect-btn[data-ratio="16:9"] .ratio-icon {
    width: 26px;
    height: 15px;
}

.aspect-btn[data-ratio="9:16"] .ratio-icon {
    width: 15px;
    height: 26px;
}

.aspect-btn[data-ratio="4:3"] .ratio-icon {
    width: 24px;
    height: 18px;
}

.aspect-btn[data-ratio="3:4"] .ratio-icon {
    width: 18px;
    height: 24px;
}

.aspect-btn[data-ratio="3:2"] .ratio-icon {
    width: 24px;
    height: 16px;
}

.aspect-btn[data-ratio="2:3"] .ratio-icon {
    width: 16px;
    height: 24px;
}

/* Size Inputs with Stepper */
.size-inputs {
    display: flex;
    gap: 12px;
    align-items: center;
}

.size-input-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.size-input-group label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.number-stepper {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--glass-highlight);
    transition: border-color 0.15s;
}

.number-stepper:focus-within {
    border-color: var(--accent-blue);
}

.number-stepper input {
    flex: 1;
    width: 100%;
    font-family: inherit;
    font-size: 0.875rem;
    padding: 0.5rem;
    border: none;
    background: transparent;
    color: var(--text-primary);
    text-align: center;
    outline: none;
    appearance: textfield;
    -moz-appearance: textfield;
}

.number-stepper input::-webkit-outer-spin-button,
.number-stepper input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.stepper-btn {
    width: 32px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.stepper-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.stepper-btn:active {
    background: rgba(255, 255, 255, 0.1);
}

.stepper-btn i {
    width: 14px;
    height: 14px;
}

.size-link {
    margin-top: 20px;
    color: var(--text-muted);
}

/* Quality Select */
.quality-options {
    display: flex;
    gap: 8px;
}

.quality-btn {
    flex: 1;
    padding: 0.6rem;
    border: 1px solid var(--glass-border);
    background: transparent;
    color: var(--text-secondary);
    border-radius: 8px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s;
}

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

.quality-btn.active {
    border-color: var(--accent-blue);
    background: rgba(96, 165, 250, 0.1);
    color: var(--accent-blue);
}

/* Advanced Options */
.advanced-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 0.5rem 0;
}

.advanced-toggle:hover {
    color: var(--text-primary);
}

.advanced-toggle i {
    transition: transform 0.2s;
}

.advanced-toggle.open i {
    transform: rotate(180deg);
}

.advanced-options {
    display: none;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}

.advanced-options.show {
    display: flex;
}

.option-row {
    display: flex;
    gap: 12px;
}

.option-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.option-group label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.option-group input,
.option-group textarea {
    width: 100%;
    font-family: inherit;
    font-size: 0.85rem;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--glass-border);
    background: var(--glass-highlight);
    color: var(--text-primary);
    border-radius: 8px;
    outline: none;
}

.option-group input:focus,
.option-group textarea:focus {
    border-color: var(--accent-blue);
}

.option-group textarea {
    resize: none;
    min-height: 60px;
}

/* Prompt Section */
.prompt-section {
    padding: 1.25rem;
    background: rgba(0, 0, 0, 0.2);
}

.prompt-wrapper {
    position: relative;
}

.prompt-wrapper textarea {
    width: 100%;
    font-family: inherit;
    font-size: 0.95rem;
    padding: 1rem;
    padding-bottom: 2rem;
    border: 1px solid var(--glass-border);
    background: var(--glass-highlight);
    color: var(--text-primary);
    border-radius: 12px;
    outline: none;
    resize: none;
    min-height: 120px;
    line-height: 1.5;
}

.prompt-wrapper textarea::placeholder {
    color: var(--text-muted);
}

.prompt-wrapper textarea:focus {
    border-color: var(--accent-blue);
}

.prompt-footer {
    position: absolute;
    bottom: 8px;
    left: 12px;
    right: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.char-count {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.prompt-actions {
    display: flex;
    gap: 4px;
}

.prompt-action-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

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

/* Generate Button */
.generate-section {
    padding: 1.25rem;
}

.generate-btn {
    width: 100%;
    font-family: inherit;
    background: var(--text-primary);
    color: var(--bg-dark);
    border: none;
    padding: 0.9rem 1.25rem;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    letter-spacing: 0.02em;
}

.generate-btn:hover {
    background: #ffffff;
    box-shadow: 0 2px 12px rgba(255, 255, 255, 0.15);
}

.generate-btn:active {
    transform: scale(0.98);
}

.generate-btn:disabled {
    background: var(--glass-border);
    color: var(--text-muted);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.generate-btn i {
    width: 16px;
    height: 16px;
}

/* Right Panel - Result */
.result-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: radial-gradient(circle at 50% 0%, #1a1a1a 0%, var(--bg-page) 50%);
    overflow: hidden;
}

.result-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    position: relative;
}

.result-image-container {
    position: relative;
    max-width: 100%;
    max-height: 100%;
}

.result-image-container img {
    max-width: 100%;
    max-height: calc(100vh - 200px);
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.image-actions {
    position: absolute;
    bottom: -50px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: all 0.2s;
}

.result-image-container:hover .image-actions {
    opacity: 1;
    bottom: 12px;
}

.image-action-btn {
    padding: 0.6rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    color: white;
    border-radius: 8px;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s;
}

.image-action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

.image-action-btn i {
    width: 16px;
    height: 16px;
}

/* Empty State */
.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
}

.empty-state-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    border: 2px dashed var(--glass-border);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.empty-state h2 {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.empty-state p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    max-width: 300px;
    margin: 0 auto;
}

/* Loading State */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid var(--glass-border);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

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

/* History Panel */
.history-section {
    border-top: 1px solid var(--glass-border);
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.history-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
}

.clear-history-btn {
    font-size: 0.7rem;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
}

.clear-history-btn:hover {
    color: var(--accent-red);
}

.history-grid {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.history-item {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    flex-shrink: 0;
    transition: all 0.15s;
}

.history-item:hover {
    border-color: var(--text-muted);
}

.history-item.active {
    border-color: var(--accent-blue);
}

.history-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hidden {
    display: none !important;
}

/* Mobile Responsive */
@media (max-width: 900px) {
    .main-container {
        flex-direction: column;
    }

    .controls-panel {
        width: 100%;
        max-height: 50vh;
        border-right: none;
        border-bottom: 1px solid var(--glass-border);
    }

    .result-area {
        padding: 1rem;
    }

    .aspect-presets {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 768px) {
    header {
        padding: 1rem;
        flex-wrap: wrap;
        gap: 1rem;
    }

    nav {
        width: 100%;
        overflow-x: auto;
    }

    .panel-section {
        padding: 1rem;
    }
}


/* Light Theme */
[data-theme="light"] {
    --bg-dark: #ffffff;
    --bg-page: #f5f5f5;
    --glass-surface: rgba(255, 255, 255, 0.9);
    --glass-border: rgba(0, 0, 0, 0.1);
    --glass-highlight: rgba(0, 0, 0, 0.03);
    --text-primary: #1a1a1a;
    --text-secondary: #525252;
    --text-muted: #a1a1a1;
    --accent-blue: #3b82f6;
    --accent-purple: #8b5cf6;
    --accent-green: #10b981;
    --accent-red: #ef4444;
}

[data-theme="light"] .controls-panel,
[data-theme="light"] .result-panel {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .panel-section {
    border-bottom-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .custom-dropdown .dropdown-trigger,
[data-theme="light"] .custom-dropdown .dropdown-menu {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .dropdown-item:hover {
    background: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .dropdown-item.selected {
    background: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .aspect-btn,
[data-theme="light"] .quality-btn {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .aspect-btn.active,
[data-theme="light"] .quality-btn.active {
    background: #1a1a1a;
    color: #ffffff;
    border-color: #1a1a1a;
}

[data-theme="light"] input[type="number"],
[data-theme="light"] textarea {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.1);
    color: #1a1a1a;
}

[data-theme="light"] .generate-btn {
    background: #1a1a1a;
    color: #ffffff;
}

[data-theme="light"] .result-area {
    background: rgba(255, 255, 255, 0.95);
}

[data-theme="light"] .history-grid img {
    border-color: rgba(0, 0, 0, 0.1);
}
