/* ═══════════════════════════════════════════
 NanoBanana Studio — Instagram-style White UI
 ═══════════════════════════════════════════ */

:root {
 --white: #ffffff;
 --bg: #fafafa;
 --card: #ffffff;
 --border: #dbdbdb;
 --border-light: #efefef;
 --text: #262626;
 --text-secondary: #8e8e8e;
 --primary: #f5a623;
 --primary-hover: #e6951a;
 --primary-light: #fff8ed;
 --danger: #ed4956;
 --success: #58c322;
 --video-accent: #6366f1;
 --video-light: #eef2ff;
 --radius: 12px;
 --radius-sm: 8px;
 --shadow: 0 1px 3px rgba(0,0,0,0.08);
 --shadow-lg: 0 4px 20px rgba(0,0,0,0.1);
 --transition: all 0.2s ease;
}

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

body {
 font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
 background: var(--bg);
 color: var(--text);
 line-height: 1.5;
 -webkit-font-smoothing: antialiased;
}

/* ─── Buttons ─── */
.btn {
 display: inline-flex;
 align-items: center;
 justify-content: center;
 gap: 6px;
 padding: 10px 20px;
 border: none;
 border-radius: var(--radius-sm);
 font-family: inherit;
 font-size: 14px;
 font-weight: 600;
 cursor: pointer;
 transition: var(--transition);
 text-decoration: none;
}
.btn-primary {
 background: var(--primary);
 color: white;
}
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn-outline {
 background: transparent;
 border: 1.5px solid var(--border);
 color: var(--text);
}
.btn-outline:hover { border-color: var(--text); }
.btn-full { width: 100%; }
.btn-lg { padding: 14px 32px; font-size: 16px; border-radius: var(--radius); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.hidden { display: none !important; }

/* ─── Forms ─── */
.form-group { margin-bottom: 16px; }
.form-group label {
 display: block;
 font-size: 13px;
 font-weight: 600;
 color: var(--text);
 margin-bottom: 6px;
}
.form-group input,
.form-group textarea,
.form-group select {
 width: 100%;
 padding: 12px 14px;
 border: 1.5px solid var(--border);
 border-radius: var(--radius-sm);
 font-family: inherit;
 font-size: 14px;
 background: var(--bg);
 transition: var(--transition);
 outline: none;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
 border-color: var(--primary);
 background: var(--white);
 box-shadow: 0 0 0 3px rgba(245, 166, 35, 0.1);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }

.error-msg {
 background: #fef2f2;
 color: var(--danger);
 padding: 10px 14px;
 border-radius: var(--radius-sm);
 font-size: 13px;
 margin-bottom: 16px;
 border: 1px solid #fecaca;
}
.success-msg {
 background: #f0fdf4;
 color: var(--success);
 padding: 10px 14px;
 border-radius: var(--radius-sm);
 font-size: 13px;
 margin-bottom: 16px;
 border: 1px solid #bbf7d0;
}

/* ═══ Landing Page ═══ */
.page-landing { background: var(--white); }
.landing {
 min-height: 100vh;
 display: flex;
 flex-direction: column;
 align-items: center;
 justify-content: center;
 padding: 40px 20px;
}
.landing-hero {
 text-align: center;
 margin-bottom: 60px;
}
.landing-logo {
 font-size: 72px;
 margin-bottom: 16px;
 animation: bounce 2s infinite;
}
@keyframes bounce {
 0%, 100% { transform: translateY(0); }
 50% { transform: translateY(-10px); }
}
.landing h1 {
 font-size: 48px;
 font-weight: 900;
 letter-spacing: -1px;
 background: linear-gradient(135deg, var(--primary), #ff6b6b);
 -webkit-background-clip: text;
 -webkit-text-fill-color: transparent;
 background-clip: text;
}
.landing-sub {
 font-size: 18px;
 color: var(--text-secondary);
 margin-top: 8px;
 margin-bottom: 32px;
}
.landing-actions { display: flex; gap: 12px; justify-content: center; }
.landing-features {
 display: grid;
 grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
 gap: 24px;
 max-width: 800px;
 width: 100%;
}
.feature-card {
 background: var(--bg);
 border: 1px solid var(--border-light);
 border-radius: var(--radius);
 padding: 28px 24px;
 text-align: center;
 transition: var(--transition);
}
.feature-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.feature-icon { font-size: 36px; margin-bottom: 12px; }
.feature-card h3 { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.feature-card p { font-size: 13px; color: var(--text-secondary); }

/* ═══ Auth Pages ═══ */
.page-auth { background: var(--bg); }
.auth-container {
 min-height: 100vh;
 display: flex;
 align-items: center;
 justify-content: center;
 padding: 20px;
}
.auth-card {
 background: var(--white);
 border: 1px solid var(--border-light);
 border-radius: var(--radius);
 padding: 40px;
 width: 100%;
 max-width: 400px;
 box-shadow: var(--shadow);
 text-align: center;
}
.auth-logo { font-size: 48px; margin-bottom: 8px; }
.auth-card h1 {
 font-size: 28px;
 font-weight: 800;
 margin-bottom: 4px;
}
.auth-subtitle {
 color: var(--text-secondary);
 font-size: 14px;
 margin-bottom: 24px;
}
.auth-card form { text-align: left; }
.auth-footer {
 margin-top: 20px;
 font-size: 13px;
 color: var(--text-secondary);
}
.auth-footer a {
 color: var(--primary);
 font-weight: 600;
 text-decoration: none;
}
.auth-footer a:hover { text-decoration: underline; }

/* ═══ Dashboard ═══ */
.page-dashboard { background: var(--bg); }

/* Top Nav */
.topnav {
 background: var(--white);
 border-bottom: 1px solid var(--border-light);
 position: sticky;
 top: 0;
 z-index: 100;
}
.topnav-inner {
 max-width: 960px;
 margin: 0 auto;
 padding: 12px 20px;
 display: flex;
 align-items: center;
 justify-content: space-between;
}
.topnav-brand {
 font-size: 18px;
 font-weight: 800;
 text-decoration: none;
 color: var(--text);
}
.topnav-right {
 display: flex;
 align-items: center;
 gap: 12px;
}
.topnav-user {
 font-size: 14px;
 font-weight: 600;
 color: var(--text-secondary);
}

/* Dashboard Layout */
.dashboard {
 max-width: 960px;
 margin: 0 auto;
 padding: 24px 20px;
}

/* ═══ Top-level Tabs (Image / Video) ═══ */
.top-tabs {
 display: flex;
 gap: 0;
 margin-bottom: 24px;
 background: var(--white);
 border: 1px solid var(--border-light);
 border-radius: var(--radius);
 overflow: hidden;
 box-shadow: var(--shadow);
}
.top-tab {
 flex: 1;
 padding: 14px 24px;
 border: none;
 background: transparent;
 font-family: inherit;
 font-size: 15px;
 font-weight: 700;
 cursor: pointer;
 transition: var(--transition);
 color: var(--text-secondary);
 position: relative;
}
.top-tab:first-child { border-right: 1px solid var(--border-light); }
.top-tab.active {
 color: var(--primary);
 background: var(--primary-light);
}
.top-tab.active::after {
 content: '';
 position: absolute;
 bottom: 0;
 left: 0;
 right: 0;
 height: 3px;
 background: var(--primary);
}
.top-tab:hover:not(.active) {
 background: var(--bg);
 color: var(--text);
}

/* Tab Content */
.tab-content {
 display: none;
}
.tab-content.active {
 display: block;
}

/* Generate Card */
.generate-section { margin-bottom: 32px; }
.generate-card {
 background: var(--white);
 border: 1px solid var(--border-light);
 border-radius: var(--radius);
 padding: 28px;
 box-shadow: var(--shadow);
}
.generate-card h2 {
 font-size: 20px;
 font-weight: 700;
 margin-bottom: 20px;
}

/* Mode Tabs */
.mode-tabs {
 display: flex;
 gap: 8px;
 margin-bottom: 20px;
}
.mode-tab {
 padding: 8px 16px;
 border: 1.5px solid var(--border);
 border-radius: 20px;
 background: transparent;
 font-family: inherit;
 font-size: 13px;
 font-weight: 600;
 cursor: pointer;
 transition: var(--transition);
 color: var(--text-secondary);
}
.mode-tab.active {
 background: var(--primary-light);
 border-color: var(--primary);
 color: var(--primary);
}
.mode-tab:hover { border-color: var(--primary); }

/* Ratio Group */
.ratio-group { display: flex; gap: 8px; }
.ratio-option {
 cursor: pointer;
 display: flex;
 align-items: center;
}
.ratio-option input { display: none; }
.ratio-option span {
 padding: 8px 18px;
 border: 1.5px solid var(--border);
 border-radius: 20px;
 font-size: 13px;
 font-weight: 600;
 transition: var(--transition);
 color: var(--text-secondary);
}
.ratio-option.active span,
.ratio-option input:checked + span {
 background: var(--primary-light);
 border-color: var(--primary);
 color: var(--primary);
}

/* Upload Area */
.upload-area {
 border: 2px dashed var(--border);
 border-radius: var(--radius);
 padding: 24px;
 text-align: center;
 cursor: pointer;
 transition: var(--transition);
}
.upload-area:hover,.upload-area.dragover {
 border-color: var(--primary);
 background: var(--primary-light);
}
.upload-icon { font-size: 32px; }
.upload-placeholder p { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.upload-previews { display: flex; gap: 12px; margin-top: 12px; }
.upload-preview {
 width: 80px;
 text-align: center;
}
.upload-preview img {
 width: 80px;
 height: 80px;
 object-fit: cover;
 border-radius: var(--radius-sm);
 border: 1px solid var(--border);
}
.upload-name {
 font-size: 11px;
 color: var(--text-secondary);
 display: block;
 margin-top: 4px;
 overflow: hidden;
 text-overflow: ellipsis;
 white-space: nowrap;
}

/* Generate Button */
.btn-generate {
 margin-top: 8px;
 padding: 14px;
 font-size: 16px;
 border-radius: var(--radius);
}

/* Result Section */
.result-section { margin-bottom: 32px; }
.result-card {
 background: var(--white);
 border: 1px solid var(--border-light);
 border-radius: var(--radius);
 padding: 28px;
 box-shadow: var(--shadow);
 text-align: center;
}
.result-status { padding: 40px 0; }
.spinner {
 width: 40px;
 height: 40px;
 border: 3px solid var(--border);
 border-top-color: var(--primary);
 border-radius: 50%;
 animation: spin 0.8s linear infinite;
 margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.result-status p { color: var(--text-secondary); font-size: 14px; }
.result-image img {
 max-width: 100%;
 border-radius: var(--radius);
 margin-bottom: 16px;
 box-shadow: var(--shadow-lg);
}
.result-actions { display: flex; gap: 8px; justify-content: center; }

/* Video Result */
.result-video-player {
 width: 100%;
 max-width: 720px;
 border-radius: var(--radius);
 margin-bottom: 16px;
 box-shadow: var(--shadow-lg);
 background: #000;
}

/* History */
.history-section { margin-bottom: 40px; }
.history-section h2 {
 font-size: 20px;
 font-weight: 700;
 margin-bottom: 16px;
}
.history-grid {
 display: grid;
 grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
 gap: 16px;
}
.history-item {
 background: var(--white);
 border: 1px solid var(--border-light);
 border-radius: var(--radius);
 overflow: hidden;
 transition: var(--transition);
}
.history-item:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.history-item img {
 width: 100%;
 aspect-ratio: 1;
 object-fit: cover;
 display: block;
}
.history-placeholder {
 width: 100%;
 aspect-ratio: 1;
 display: flex;
 align-items: center;
 justify-content: center;
 background: var(--bg);
 font-size: 32px;
 position: relative;
}
.history-media-wrap {
 position: relative;
 width: 100%;
}
.history-media-wrap img {
 width: 100%;
 aspect-ratio: 1;
 object-fit: cover;
 display: block;
}
.history-video-thumb {
 position: relative;
 width: 100%;
}
.history-video-thumb video {
 width: 100%;
 aspect-ratio: 1;
 object-fit: cover;
 display: block;
 background: #000;
}
.history-type-badge {
 position: absolute;
 top: 8px;
 left: 8px;
 background: rgba(255,255,255,0.9);
 backdrop-filter: blur(4px);
 border-radius: 6px;
 padding: 2px 6px;
 font-size: 14px;
 line-height: 1;
 box-shadow: 0 1px 3px rgba(0,0,0,0.15);
 z-index: 2;
}
.history-type-badge.video {
 background: rgba(99, 102, 241, 0.15);
}
.history-type-badge.image {
 background: rgba(245, 166, 35, 0.15);
}
.history-meta { padding: 10px 12px; }
.history-prompt {
 font-size: 12px;
 color: var(--text-secondary);
 margin-bottom: 4px;
 line-height: 1.4;
}
.history-badge {
 font-size: 11px;
 font-weight: 600;
 padding: 2px 8px;
 border-radius: 10px;
 display: inline-block;
}
.history-badge.done { background: #f0fdf4; color: var(--success); }
.history-badge.processing { background: #fff8ed; color: var(--primary); }
.history-badge.pending { background: var(--bg); color: var(--text-secondary); }
.history-badge.timeout { background: #fef2f2; color: var(--danger); }
.history-badge.failed { background: #fef2f2; color: var(--danger); }
.history-empty {
 grid-column: 1 / -1;
 text-align: center;
 padding: 40px;
 color: var(--text-secondary);
 font-size: 14px;
}

/* ═══ API Keys ═══ */
.apikey-section { margin-bottom: 32px; }
.apikey-header {
 display: flex;
 align-items: center;
 justify-content: space-between;
 margin-bottom: 8px;
}
.apikey-header h2 { margin-bottom: 0; }
.apikey-desc {
 font-size: 13px;
 color: var(--text-secondary);
 margin-bottom: 16px;
}
.new-key-box {
 background: #fffbeb;
 border: 1.5px solid #f59e0b;
 border-radius: var(--radius-sm);
 padding: 14px;
 margin-bottom: 16px;
}
.new-key-label {
 font-size: 13px;
 font-weight: 600;
 color: #92400e;
 margin-bottom: 8px;
}
.new-key-value {
 display: flex;
 align-items: center;
 gap: 8px;
}
.new-key-value code {
 flex: 1;
 background: var(--white);
 border: 1px solid var(--border);
 border-radius: var(--radius-sm);
 padding: 8px 12px;
 font-size: 13px;
 word-break: break-all;
 font-family: 'SF Mono', 'Fira Code', monospace;
}
.keys-list { display: flex; flex-direction: column; gap: 8px; }
.key-item {
 display: flex;
 align-items: center;
 justify-content: space-between;
 padding: 12px 14px;
 background: var(--bg);
 border: 1px solid var(--border-light);
 border-radius: var(--radius-sm);
}
.key-info { display: flex; align-items: center; gap: 12px; }
.key-prefix {
 font-family: 'SF Mono', 'Fira Code', monospace;
 font-size: 13px;
 color: var(--text);
}
.key-date { font-size: 12px; color: var(--text-secondary); }
.keys-empty {
 text-align: center;
 padding: 20px;
 color: var(--text-secondary);
 font-size: 13px;
}
.btn-danger {
 background: var(--danger);
 color: white;
 border: none;
}
.btn-danger:hover { background: #dc2626; }

/* ═══ Type Tabs (Image / Video) ═══ */
.type-tabs {
 display: flex;
 gap: 0;
 margin-bottom: 24px;
 background: var(--white);
 border: 1px solid var(--border-light);
 border-radius: var(--radius);
 overflow: hidden;
 box-shadow: var(--shadow);
}
.type-tab {
 flex: 1;
 padding: 14px 20px;
 border: none;
 background: transparent;
 font-family: inherit;
 font-size: 15px;
 font-weight: 700;
 cursor: pointer;
 transition: var(--transition);
 color: var(--text-secondary);
 position: relative;
}
.type-tab.active {
 background: var(--primary-light);
 color: var(--primary);
}
.type-tab:not(.active):hover {
 background: var(--bg);
}
.type-tab + .type-tab {
 border-left: 1px solid var(--border-light);
}
.type-panel.hidden { display: none !important; }

/* ═══ Video Styles ═══ */
.form-select {
 width: 100%;
 padding: 12px 14px;
 border: 1.5px solid var(--border);
 border-radius: var(--radius-sm);
 font-family: inherit;
 font-size: 14px;
 background: var(--bg);
 transition: var(--transition);
 outline: none;
 cursor: pointer;
 appearance: none;
 background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238e8e8e' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
 background-repeat: no-repeat;
 background-position: right 14px center;
}
.form-select:focus {
 border-color: var(--primary);
 background-color: var(--white);
 box-shadow: 0 0 0 3px rgba(245, 166, 35, 0.1);
}
.label-optional {
 font-weight: 400;
 color: var(--text-secondary);
 font-size: 12px;
}

/* Video result */
.result-video video {
 max-width: 100%;
 border-radius: var(--radius);
 margin-bottom: 16px;
 box-shadow: var(--shadow-lg);
 background: #000;
}

/* History video items */
.history-item.video-item .history-video {
 width: 100%;
 aspect-ratio: 16/9;
 object-fit: cover;
 display: block;
 background: #000;
}
.history-badge.timeout { background: #fef2f2; color: var(--danger); }

/* ═══ Responsive ═══ */
@media (max-width: 640px) {
 .landing h1 { font-size: 36px; }
 .landing-sub { font-size: 15px; }
 .landing-actions { flex-direction: column; }
 .auth-card { padding: 28px 24px; }
 .generate-card { padding: 20px; }
 .form-row { flex-direction: column; gap: 0; }
 .history-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
 .top-tabs { border-radius: var(--radius-sm); }
 .top-tab { padding: 12px 16px; font-size: 14px; }
}
