/* ===== RESET & ROOT ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-base:      #0d0d12;
  --bg-panel:     #13131a;
  --bg-card:      #1a1a24;
  --bg-hover:     #22222f;
  --bg-input:     #16161f;
  --border:       #2a2a3a;
  --border-focus: #7C6FFF;

  --accent:       #7C6FFF;
  --accent-2:     #3ECFCF;
  --accent-3:     #FF6B9D;
  --accent-grad:  linear-gradient(135deg, #7C6FFF 0%, #3ECFCF 100%);

  --text-primary:   #f0f0f8;
  --text-secondary: #888899;
  --text-muted:     #555566;

  --claude-color:    #D4A843;
  --openai-color:    #10A37F;
  --gemini-color:    #4285F4;
  --qwen-color:      #8B5CF6;
  --pollinations-color: #FF6B9D;
  --kokoro-color:    #3ECFCF;

  --sidebar-w: 220px;
  --topbar-h:  58px;
  --radius:    12px;
  --radius-sm: 8px;
  --radius-lg: 18px;

  --font-display: 'Syne', sans-serif;
  --font-body:    'DM Sans', sans-serif;

  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-accent: 0 0 20px rgba(124,111,255,0.25);
}

html { scroll-behavior: smooth; }
body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  position: fixed;
  left: 0; top: 0;
  z-index: 100;
  transition: transform .3s ease;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 20px;
}
.logo-text {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.logo-dot { color: var(--accent); }

.btn-crear {
  background: var(--accent-grad);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 24px;
  transition: opacity .2s, transform .2s;
  box-shadow: var(--shadow-accent);
}
.btn-crear:hover { opacity: .9; transform: translateY(-1px); }
.btn-crear span { font-size: 18px; line-height: 1; }

.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 14px 8px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active {
  background: rgba(124,111,255,0.15);
  color: #a99fff;
}
.nav-item.active svg { color: var(--accent); }

.sidebar-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); }
.ai-status-bar { display: flex; align-items: center; gap: 8px; padding: 6px 8px; }
.status-label { font-size: 11px; color: var(--text-muted); }
.status-dots { display: flex; gap: 4px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); transition: background .3s; }
.status-dot.active { background: #22cc66; box-shadow: 0 0 6px #22cc66; }

/* ===== TOPBAR ===== */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--topbar-h);
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-toggle {
  background: none; border: none; color: var(--text-secondary); cursor: pointer;
  display: none;
  padding: 6px;
  border-radius: 6px;
}
.topbar-toggle:hover { background: var(--bg-hover); color: var(--text-primary); }

.topbar-breadcrumb {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  flex: 1;
}

.ai-selector-mini {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: border-color .2s;
}
.ai-selector-mini:hover { border-color: var(--accent); }
.ai-dot { width: 8px; height: 8px; border-radius: 50%; }

/* ===== PAGE CONTAINER ===== */
.page-container { flex: 1; padding: 28px 32px; }
.page { display: none; animation: fadeUp .3s ease; }
.page.active { display: block; }

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

/* ===== INICIO PAGE ===== */
.page-hero {
  margin-bottom: 36px;
  padding: 40px;
  background: radial-gradient(ellipse at 20% 50%, rgba(124,111,255,0.08) 0%, transparent 60%),
              radial-gradient(ellipse at 80% 20%, rgba(62,207,207,0.06) 0%, transparent 50%),
              var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  position: relative;
  overflow: hidden;
}
.page-hero::after {
  content: '';
  position: absolute;
  right: -60px; top: -60px;
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(62,207,207,0.06), transparent 70%);
  pointer-events: none;
}

.hero-badge {
  display: inline-block;
  background: rgba(124,111,255,0.15);
  color: var(--accent);
  border: 1px solid rgba(124,111,255,0.3);
  border-radius: 99px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .05em;
  margin-bottom: 16px;
}

.hero-title {
  font-family: var(--font-display);
  font-size: 42px;
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 12px;
  letter-spacing: -1px;
}
.gradient-text {
  background: var(--accent-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero-sub { color: var(--text-secondary); font-size: 15px; max-width: 500px; line-height: 1.6; }

.quick-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-bottom: 36px;
}
.quick-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: border-color .2s, transform .2s, box-shadow .2s;
}
.quick-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-accent);
}
.quick-card-icon {
  width: 52px; height: 52px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.img-icon { background: rgba(255,107,157,0.12); color: var(--accent-3); }
.vid-icon { background: rgba(62,207,207,0.12); color: var(--accent-2); }
.txt-icon { background: rgba(124,111,255,0.12); color: var(--accent); }
.voz-icon { background: rgba(212,168,67,0.12); color: var(--claude-color); }

.quick-card-content { flex: 1; }
.quick-card-content h3 { font-family: var(--font-display); font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.quick-card-content p { font-size: 12px; color: var(--text-secondary); line-height: 1.5; }
.quick-card-arrow { color: var(--text-muted); font-size: 18px; }
.quick-card:hover .quick-card-arrow { color: var(--accent); }

.section-title {
  font-family: var(--font-display);
  font-size: 18px; font-weight: 700;
  margin-bottom: 16px;
}

.models-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.model-chip {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  transition: border-color .2s;
}
.model-chip:hover { border-color: var(--border-focus); }
.model-chip-dot { width: 7px; height: 7px; border-radius: 50%; }
.model-chip.claude .model-chip-dot { background: var(--claude-color); box-shadow: 0 0 6px var(--claude-color); }
.model-chip.openai .model-chip-dot { background: var(--openai-color); box-shadow: 0 0 6px var(--openai-color); }
.model-chip.gemini .model-chip-dot { background: var(--gemini-color); box-shadow: 0 0 6px var(--gemini-color); }
.model-chip.qwen .model-chip-dot { background: var(--qwen-color); box-shadow: 0 0 6px var(--qwen-color); }
.model-chip.pollinations .model-chip-dot { background: var(--pollinations-color); box-shadow: 0 0 6px var(--pollinations-color); }
.model-chip.kokoro .model-chip-dot { background: var(--kokoro-color); box-shadow: 0 0 6px var(--kokoro-color); }
.model-chip-type {
  font-size: 10px;
  background: rgba(255,255,255,0.06);
  padding: 2px 7px;
  border-radius: 99px;
  color: var(--text-secondary);
}

/* ===== PAGE HEADER (shared) ===== */
.page-header { margin-bottom: 28px; }
.page-header h2 { font-family: var(--font-display); font-size: 26px; font-weight: 800; margin-bottom: 6px; }
.page-header p { color: var(--text-secondary); font-size: 14px; }

/* ===== FORM ELEMENTS ===== */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

textarea, input[type="text"], input[type="password"], select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  transition: border-color .2s;
  resize: vertical;
}
textarea:focus, input:focus, select:focus { border-color: var(--border-focus); }
select option { background: var(--bg-card); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  border: none;
  transition: opacity .2s, transform .2s;
}
.btn:hover { opacity: .88; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--accent-grad); color: #fff; box-shadow: var(--shadow-accent); }
.btn-secondary { background: var(--bg-card); border: 1px solid var(--border); color: var(--text-primary); }
.btn-full { width: 100%; justify-content: center; }

/* ===== AI SELECTOR TABS ===== */
.ai-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
}
.ai-tab {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: none; border: none;
  color: var(--text-secondary);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.ai-tab:hover { background: var(--bg-hover); color: var(--text-primary); }
.ai-tab.active { background: var(--bg-card); color: var(--text-primary); border: 1px solid var(--border); }
.ai-tab .tab-dot { width: 7px; height: 7px; border-radius: 50%; }

/* ===== ASPECT RATIO SELECTOR ===== */
.ratio-selector { display: flex; gap: 10px; margin-bottom: 16px; }
.ratio-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  transition: all .15s;
}
.ratio-btn.active { border-color: var(--accent); color: var(--accent); background: rgba(124,111,255,0.08); }
.ratio-preview-h { width: 22px; height: 38px; border-radius: 3px; border: 2px solid currentColor; }
.ratio-preview-w { width: 44px; height: 26px; border-radius: 3px; border: 2px solid currentColor; }

/* ===== UPLOAD AREA ===== */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  position: relative;
}
.upload-area:hover, .upload-area.dragover {
  border-color: var(--accent);
  background: rgba(124,111,255,0.04);
}
.upload-area input[type="file"] { position: absolute; inset:0; opacity:0; cursor:pointer; }
.upload-area svg { color: var(--text-muted); margin-bottom: 10px; }
.upload-area p { color: var(--text-secondary); font-size: 13px; }
.upload-area span { color: var(--accent); text-decoration: underline; }
.upload-preview { max-width: 100%; max-height: 200px; border-radius: var(--radius-sm); margin-top: 12px; }

/* ===== RESULTS AREA ===== */
.result-area {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 20px;
  min-height: 100px;
}
.result-area.loading { display: flex; align-items: center; justify-content: center; }
.result-img {
  max-width: 100%;
  border-radius: var(--radius-sm);
  display: block;
  margin: 0 auto;
}
.result-text {
  line-height: 1.7;
  color: var(--text-primary);
  white-space: pre-wrap;
}
.result-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

/* ===== SPINNER ===== */
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== CHAT ===== */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--topbar-h) - 56px - 80px);
  min-height: 400px;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.chat-msg { display: flex; gap: 10px; }
.chat-msg.user { flex-direction: row-reverse; }
.chat-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.chat-msg.ai .chat-avatar { background: rgba(124,111,255,0.2); color: var(--accent); }
.chat-msg.user .chat-avatar { background: rgba(62,207,207,0.2); color: var(--accent-2); }
.chat-bubble {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: 16px;
  line-height: 1.65;
  font-size: 14px;
}
.chat-msg.ai .chat-bubble { background: var(--bg-card); border-radius: 4px 16px 16px 16px; }
.chat-msg.user .chat-bubble { background: rgba(124,111,255,0.2); border-radius: 16px 4px 16px 16px; }

.chat-input-row {
  display: flex;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 12px;
}
.chat-input-row textarea {
  flex: 1; min-height: 44px; max-height: 140px; resize: none;
  border-radius: var(--radius-sm); padding: 10px 14px;
}

/* ===== VOZ PAGE ===== */
.voice-player {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 16px;
}
.voice-player audio { width: 100%; margin-top: 10px; filter: invert(0); }
.voice-players-list { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }

/* ===== CONFIG PAGE ===== */
.config-section {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}
.config-section h3 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}
.config-section .config-desc { color: var(--text-secondary); font-size: 13px; margin-bottom: 20px; }

.api-key-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.api-key-row .api-label {
  width: 100px;
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600;
  flex-shrink: 0;
}
.api-key-row input { flex: 1; }
.api-badge { width: 10px; height: 10px; border-radius: 50%; }

.save-notice {
  background: rgba(62,207,207,0.1);
  border: 1px solid rgba(62,207,207,0.3);
  color: var(--accent-2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-top: 14px;
  display: none;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: var(--bg-card);
  border: 1px solid var(--accent);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-size: 13px;
  z-index: 9999;
  transform: translateY(80px);
  opacity: 0;
  transition: transform .3s, opacity .3s;
  max-width: 300px;
}
.toast.show { transform: translateY(0); opacity: 1; }

/* ===== MODAL ===== */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 420px;
  width: 90%;
  position: relative;
  animation: fadeUp .25s ease;
}
.modal-box h3 { font-family: var(--font-display); font-size: 20px; font-weight: 800; margin-bottom: 20px; }
.modal-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-opt {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 14px;
  color: var(--text-primary);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.modal-opt:hover { border-color: var(--accent); background: rgba(124,111,255,0.08); }
.modal-close {
  position: absolute; top: 14px; right: 16px;
  background: none; border: none;
  color: var(--text-muted); font-size: 18px;
  cursor: pointer;
}
.modal-close:hover { color: var(--text-primary); }

/* ===== NOTICE ADULTO ===== */
.notice-adulto {
  background: rgba(255,60,60,0.08);
  border: 1px solid rgba(255,80,80,0.25);
  color: #ff8888;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12px;
  margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .topbar-toggle { display: flex; }
  .quick-grid { grid-template-columns: 1fr; }
  .page-container { padding: 20px 16px; }
  .hero-title { font-size: 28px; }
  .page-hero { padding: 24px; }
}
