/* ============================================
   Gemini 3 Pro Image Generator - Styles
   ============================================ */

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: rgba(20, 20, 30, 0.8);
  --bg-tertiary: rgba(30, 30, 45, 0.6);
  --bg-card: rgba(25, 25, 40, 0.9);
  --text-primary: #f0f0f5;
  --text-secondary: rgba(200, 200, 220, 0.7);
  --text-muted: rgba(150, 150, 180, 0.5);
  --accent: #a855f7;
  --accent-light: #c084fc;
  --accent-dark: #7c3aed;
  --accent-glow: rgba(168, 85, 247, 0.4);
  --border: rgba(255, 255, 255, 0.08);
  --border-light: rgba(255, 255, 255, 0.12);
  --success: #34d399;
  --error: #f87171;
  --warning: #fbbf24;
  --favorite: #f472b6;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
  --glow: 0 0 20px var(--accent-glow);
}

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

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

/* Animated Background */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(120, 50, 200, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(80, 100, 220, 0.1) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(100, 60, 180, 0.05) 0%, transparent 70%);
  pointer-events: none;
  z-index: -1;
}

.container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px;
}

/* ============================================
   Header
   ============================================ */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

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

.logo-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: var(--glow);
}

h1 {
  font-size: 1.3rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

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

.api-config {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ============================================
   Form Elements
   ============================================ */
input, textarea, select, button {
  font-family: inherit;
  font-size: 14px;
}

input[type="text"], input[type="password"], textarea, select {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  color: var(--text-primary);
  outline: none;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23a0a0b0' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* ============================================
   Buttons
   ============================================ */
button {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 10px 18px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

button::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.5s ease;
}

button:hover::before { left: 100%; }
button:hover {
  transform: translateY(-2px);
  box-shadow: var(--glow);
}
button:active { transform: translateY(0); }
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--bg-secondary);
  border-color: var(--border-light);
}

.btn-small {
  padding: 8px 14px;
  font-size: 13px;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 16px;
}

.btn-danger {
  background: linear-gradient(135deg, var(--error), #dc2626);
}

.btn-success {
  background: linear-gradient(135deg, var(--success), #059669);
}

/* ============================================
   Main Layout
   ============================================ */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 24px;
}

@media (max-width: 1200px) {
  .main-grid { grid-template-columns: 1fr; }
}

/* ============================================
   Panels
   ============================================ */
.panel {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: all 0.3s ease;
}

.panel:hover { border-color: var(--border-light); }

.panel-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.panel-title-text {
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-icon { font-size: 16px; }

.panel-actions {
  display: flex;
  gap: 6px;
}

/* ============================================
   Form Groups
   ============================================ */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

@media (max-width: 600px) {
  .form-row { grid-template-columns: repeat(2, 1fr); }
}

textarea#prompt, textarea#negativePrompt {
  width: 100%;
  min-height: 100px;
  resize: vertical;
  line-height: 1.5;
}

textarea#negativePrompt {
  min-height: 60px;
  font-size: 13px;
}

/* Prompt Container */
.prompt-container {
  position: relative;
}

.prompt-tools {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.prompt-history-select {
  width: 160px;
  padding: 6px 10px;
  font-size: 12px;
  background: var(--bg-secondary);
}

/* Style Presets */
.style-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.style-preset {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 20px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s ease;
}

.style-preset:hover {
  border-color: var(--accent);
  background: rgba(168, 85, 247, 0.1);
}

.style-preset.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* Negative Prompt Presets */
.negative-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.negative-preset {
  padding: 3px 8px;
  font-size: 11px;
  border-radius: 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s ease;
}

.negative-preset:hover {
  border-color: var(--error);
  color: var(--error);
}

/* ============================================
   Upload Zone
   ============================================ */
.upload-zone {
  border: 2px dashed var(--border-light);
  border-radius: var(--radius-lg);
  padding: 30px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  background: var(--bg-tertiary);
}

.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--accent);
  background: rgba(168, 85, 247, 0.05);
  transform: scale(1.01);
}

.upload-zone input[type="file"] { display: none; }

.upload-icon {
  font-size: 40px;
  margin-bottom: 12px;
  filter: grayscale(0.3);
}

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

.upload-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}

.upload-hint kbd {
  background: var(--bg-secondary);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  border: 1px solid var(--border);
}

/* Image Preview Grid */
.image-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.preview-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-tertiary);
  border: 2px solid transparent;
  transition: all 0.3s ease;
}

.preview-item:hover {
  border-color: var(--accent);
  transform: scale(1.05);
}

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

.preview-item .remove-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  background: rgba(248, 113, 113, 0.9);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  opacity: 0;
  transition: all 0.2s ease;
  border: none;
  color: white;
  padding: 0;
}

.preview-item:hover .remove-btn { opacity: 1; }

/* ============================================
   Generate Button
   ============================================ */
.generate-btn {
  width: 100%;
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
  margin-top: 8px;
  background: linear-gradient(135deg, var(--accent), #6366f1);
  letter-spacing: 0.5px;
}

.generate-btn:hover {
  box-shadow: 0 0 30px var(--accent-glow);
}

.generate-btn.loading { color: transparent; }

.generate-btn.loading::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  border: 3px solid transparent;
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ============================================
   Results Grid
   ============================================ */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.result-item {
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  transition: all 0.3s ease;
  position: relative;
}

.result-item:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent);
}

.result-item img {
  width: 100%;
  display: block;
  cursor: pointer;
  transition: transform 0.3s ease;
}

.result-item:hover img { transform: scale(1.02); }

.result-meta {
  padding: 8px 10px;
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.result-meta span {
  background: var(--bg-secondary);
  padding: 2px 6px;
  border-radius: 4px;
}

.result-actions {
  display: flex;
  gap: 4px;
  padding: 8px 10px;
  background: var(--bg-secondary);
}

.result-actions button {
  flex: 1;
  font-size: 11px;
  padding: 6px 8px;
}

/* Favorite Button */
.result-favorite {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  opacity: 0;
  transition: all 0.2s ease;
  border: none;
  cursor: pointer;
}

.result-item:hover .result-favorite { opacity: 1; }

.result-favorite.active {
  opacity: 1;
  background: var(--favorite);
}

/* ============================================
   History Grid
   ============================================ */
.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
  padding-right: 6px;
}

.history-grid::-webkit-scrollbar { width: 5px; }
.history-grid::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
  border-radius: 3px;
}
.history-grid::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 3px;
}

.history-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.3s ease;
}

.history-item:hover {
  border-color: var(--accent);
  transform: scale(1.05);
}

.history-item.selected {
  border-color: var(--success);
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.4);
}

.history-item.favorited::after {
  content: '❤';
  position: absolute;
  top: 4px;
  left: 4px;
  font-size: 12px;
}

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

.history-item .delete-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  background: rgba(248, 113, 113, 0.9);
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  border: none;
  color: white;
  padding: 0;
}

.history-item:hover .delete-btn { display: flex; }

/* ============================================
   Progress
   ============================================ */
.progress-bar {
  height: 5px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 16px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  transition: width 0.3s ease;
  box-shadow: 0 0 10px var(--accent-glow);
}

.progress-count {
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

/* ============================================
   Toast
   ============================================ */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  padding: 14px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast::before {
  content: '';
  width: 4px;
  height: 100%;
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 4px 0 0 4px;
  background: var(--accent);
}

.toast.success::before { background: var(--success); }
.toast.error::before { background: var(--error); }

@keyframes slideIn {
  from { transform: translateX(120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ============================================
   Modal / Gallery
   ============================================ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(10px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 40px;
}

.modal.active { display: flex; }

.modal-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
}

.modal-content img {
  max-width: 100%;
  max-height: 85vh;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  font-size: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.modal-close:hover {
  background: var(--error);
  border-color: var(--error);
}

/* Gallery Navigation */
.gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 50%;
  font-size: 24px;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.gallery-nav:hover {
  background: var(--accent);
  border-color: var(--accent);
}

.gallery-prev { left: 20px; }
.gallery-next { right: 20px; }

.gallery-counter {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  color: var(--text-secondary);
}

/* Gallery Info Panel */
.gallery-info {
  position: absolute;
  bottom: 20px;
  right: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  max-width: 300px;
  font-size: 12px;
}

.gallery-info h4 {
  font-size: 13px;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.gallery-info p {
  color: var(--text-secondary);
  margin-bottom: 8px;
  word-break: break-word;
}

.gallery-info .meta-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.gallery-info .meta-tag {
  background: var(--bg-tertiary);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
}

/* ============================================
   Settings Modal
   ============================================ */
.settings-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.settings-modal.active { display: flex; }

.settings-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 500px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
}

.settings-content h2 {
  font-size: 1.2rem;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.settings-section {
  margin-bottom: 20px;
}

.settings-section h3 {
  font-size: 13px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.settings-row:last-child { border-bottom: none; }

.settings-row label {
  color: var(--text-primary);
  font-size: 14px;
}

/* ============================================
   Status Dot
   ============================================ */
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--error);
  display: inline-block;
  margin-right: 8px;
  box-shadow: 0 0 8px currentColor;
}

.status-dot.connected { background: var(--success); }

/* Server Status Indicator */
.server-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: linear-gradient(135deg, var(--success), #059669);
  color: white;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.8; }
}

/* ============================================
   Empty State
   ============================================ */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: 0.5;
}

/* ============================================
   API Key Input
   ============================================ */
#apiKey { width: 260px; }

/* ============================================
   Shortcuts Hint
   ============================================ */
.shortcuts-hint {
  position: fixed;
  bottom: 24px;
  left: 24px;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
}

.shortcuts-hint kbd {
  background: var(--bg-tertiary);
  padding: 2px 5px;
  border-radius: 3px;
  margin: 0 2px;
  font-size: 10px;
}

/* ============================================
   Tabs
   ============================================ */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  padding: 4px;
  background: var(--bg-tertiary);
  border-radius: var(--radius);
}

.tab {
  flex: 1;
  padding: 8px 16px;
  font-size: 13px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

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

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
  .container { padding: 16px; }
  header { flex-direction: column; gap: 12px; padding: 16px; }
  .header-actions { width: 100%; justify-content: center; flex-wrap: wrap; }
  .api-config { width: 100%; }
  #apiKey { width: 100%; }
  .panel { padding: 16px; }
  .upload-zone { padding: 20px; }
  .shortcuts-hint { display: none; }
  .form-row { grid-template-columns: repeat(2, 1fr); }
  .gallery-info { display: none; }
}
