/* ============================================
   Nano Banana - AI Image Tool
   Premium Dark Theme
   ============================================ */

:root {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #242424;
    --bg-hover: #2a2a2a;
    --bg-active: #333333;
    --border: #2e2e2e;
    --border-active: #555;
    --text-primary: #f0f0f0;
    --text-secondary: #999;
    --text-muted: #666;
    --accent: #f5a623;
    --accent-hover: #f7b84e;
    --accent-glow: rgba(245, 166, 35, 0.2);
    --accent-border: rgba(245, 166, 35, 0.4);
    --danger: #e74c3c;
    --success: #2ecc71;
    --glass: rgba(255, 255, 255, 0.04);
    --glass-border: rgba(255, 255, 255, 0.08);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.6);
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 16px;
    --transition: all 0.2s ease;
    --panel-width: 340px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
}

/* ============================================
   HEADER
   ============================================ */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 56px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    font-size: 22px;
    background: linear-gradient(135deg, var(--accent), #ff6b35);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 8px var(--accent-glow));
}

.logo-text {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
    background: linear-gradient(to right, var(--text-primary), var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

.header-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.header-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* ============================================
   MODAL
   ============================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 460px;
    box-shadow: var(--shadow-lg);
    transform: scale(0.95) translateY(10px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 0;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--danger);
    color: white;
}

.modal-body {
    padding: 20px 24px 24px;
}

.modal-body p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.5;
}

.input-group {
    position: relative;
    margin-bottom: 12px;
}

.input-group input {
    width: 100%;
    padding: 12px 44px 12px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: var(--transition);
}

.input-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.toggle-visibility {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    transition: var(--transition);
}

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

.get-key-link {
    display: inline-block;
    font-size: 13px;
    color: var(--accent);
    text-decoration: none;
    margin-bottom: 20px;
    transition: var(--transition);
}

.get-key-link:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.btn-save-key {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: var(--transition);
}

.btn-save-key:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px var(--accent-glow);
}

/* ============================================
   MAIN LAYOUT
   ============================================ */
.main-container {
    display: flex;
    height: calc(100vh - 56px);
}

/* ============================================
   LEFT PANEL - CONTROLS
   ============================================ */
.control-panel {
    width: var(--panel-width);
    min-width: var(--panel-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--bg-active) transparent;
}

.control-panel::-webkit-scrollbar {
    width: 4px;
}

.control-panel::-webkit-scrollbar-track {
    background: transparent;
}

.control-panel::-webkit-scrollbar-thumb {
    background: var(--bg-active);
    border-radius: 4px;
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    padding: 0;
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 10;
}

.tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.tab::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 16px;
    right: 16px;
    height: 2px;
    background: transparent;
    border-radius: 2px 2px 0 0;
    transition: var(--transition);
}

.tab:hover {
    color: var(--text-primary);
    background: var(--glass);
}

.tab.active {
    color: var(--text-primary);
}

.tab.active::after {
    background: var(--accent);
}

/* Sections */
.section {
    padding: 16px 16px 0;
}

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

/* PRO Badge */
.pro-badge {
    padding: 3px 10px;
    background: linear-gradient(135deg, var(--accent), #e8941d);
    color: #000;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.section-title {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.section-header .section-title {
    margin-bottom: 0;
}

/* Model Selection */
.model-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.model-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-family: 'Inter', sans-serif;
}

.model-btn:hover {
    border-color: var(--border-active);
    background: var(--bg-hover);
}

.model-btn.active {
    border-color: var(--accent-border);
    background: rgba(245, 166, 35, 0.06);
    color: var(--text-primary);
}

.model-name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
}

.model-desc {
    font-size: 11px;
    opacity: 0.7;
}

/* Aspect Ratio Grid */
.ratio-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.ratio-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 10px 4px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-family: 'Inter', sans-serif;
    min-height: 58px;
}

.ratio-btn span {
    font-size: 11px;
    font-weight: 500;
}

.ratio-btn:hover {
    border-color: var(--border-active);
    background: var(--bg-hover);
}

.ratio-btn.active {
    border-color: var(--accent-border);
    background: rgba(245, 166, 35, 0.06);
    color: var(--accent);
}

.ratio-btn.active svg {
    stroke: var(--accent);
}

/* Resolution */
.resolution-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.resolution-btn {
    padding: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 24px;
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.resolution-btn:hover {
    border-color: var(--border-active);
    background: var(--bg-hover);
}

.resolution-btn.active {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
}

/* Action Button */
.btn-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: calc(100% - 32px);
    margin: 20px 16px;
    padding: 14px;
    background: linear-gradient(135deg, var(--accent), #e8941d);
    color: #000;
    border: none;
    border-radius: var(--radius);
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.btn-action::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.6s;
}

.btn-action:hover::before {
    left: 100%;
}

.btn-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px var(--accent-glow);
}

.btn-action:active {
    transform: translateY(0);
}

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

.btn-action:disabled::before {
    display: none;
}

/* Prompt Textarea */
.prompt-textarea {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    line-height: 1.5;
    resize: vertical;
    outline: none;
    transition: var(--transition);
    min-height: 80px;
}

.prompt-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

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

/* Style Grid */
.style-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
}

.style-btn {
    padding: 10px 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
}

.style-btn:hover {
    border-color: var(--border-active);
    background: var(--bg-hover);
    color: var(--text-primary);
}

.style-btn.active {
    border-color: var(--accent-border);
    background: rgba(245, 166, 35, 0.06);
    color: var(--accent);
}

/* Tab Content */
.tab-content {
    display: none;
    flex-direction: column;
    flex: 1;
}

.tab-content.active {
    display: flex;
}

/* ============================================
   RIGHT PANEL - PREVIEW
   ============================================ */
.preview-panel {
    flex: 1;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

/* Upload Zone */
.upload-zone {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.upload-zone.drag-over {
    background: rgba(245, 166, 35, 0.05);
}

.upload-zone.drag-over .upload-content {
    border-color: var(--accent);
    background: rgba(245, 166, 35, 0.04);
    transform: scale(1.02);
}

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 60px 40px;
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    transition: var(--transition);
    max-width: 440px;
}

.upload-content:hover {
    border-color: var(--text-muted);
}

.upload-icon {
    color: var(--text-muted);
    opacity: 0.6;
}

.upload-content h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.upload-content p {
    font-size: 13px;
    color: var(--text-secondary);
}

.upload-formats {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Image Preview Area */
.image-preview-area {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    min-height: 46px;
}

.preview-tabs {
    display: flex;
    gap: 4px;
}

.preview-tab {
    padding: 6px 16px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 20px;
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.preview-tab:hover {
    color: var(--text-primary);
    background: var(--glass);
}

.preview-tab.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border);
}

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

.preview-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.preview-action-btn:hover {
    background: var(--bg-active);
    color: var(--text-primary);
}

.preview-action-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.preview-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    position: relative;
    overflow: auto;
}

.image-container {
    position: relative;
    max-width: 100%;
    max-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-container img {
    max-width: 100%;
    max-height: calc(100vh - 140px);
    object-fit: contain;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.image-label {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 4px 12px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    z-index: 5;
}

/* Loading */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 15, 15, 0.85);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

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

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

.loading-spinner p {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.loading-progress {
    width: 200px;
    height: 3px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #ff6b35);
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* ============================================
   HIDDEN UTILITY
   ============================================ */
.hidden {
    display: none !important;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast-container {
    position: fixed;
    top: 72px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    font-size: 13px;
    color: var(--text-primary);
    animation: slideIn 0.3s ease;
    max-width: 360px;
}

.toast.success {
    border-left: 3px solid var(--success);
}

.toast.error {
    border-left: 3px solid var(--danger);
}

.toast.info {
    border-left: 3px solid var(--accent);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    :root {
        --panel-width: 100%;
    }

    .main-container {
        flex-direction: column;
        height: auto;
        overflow: auto;
    }

    body {
        overflow: auto;
    }

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

    .preview-panel {
        min-height: 50vh;
    }

    .preview-content {
        padding: 16px;
    }

    .image-container img {
        max-height: 40vh;
    }
}

@media (max-width: 480px) {
    .ratio-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .style-grid {
        grid-template-columns: 1fr;
    }

    .header {
        padding: 0 12px;
    }

    .logo-text {
        font-size: 16px;
    }
}