/* ============================================================
   Aether — AI Design Studio
   Sistema de diseño: dark premium, glassmorphism, violeta
   ============================================================ */

:root {
  --bg: #0a0a0a;
  --surface: #131313;
  --surface-low: #1c1b1b;
  --surface-container: #201f1f;
  --surface-high: #2a2a2a;
  --glass: rgba(18, 18, 18, 0.7);
  --border: rgba(255, 255, 255, 0.08);
  --text: #e5e2e1;
  --text-muted: #a1a1aa;
  --text-soft: #ccc3d8;
  --primary: #7c3aed;
  --primary-dark: #6d28d9;
  --primary-light: #a78bfa;
  --primary-tint: #d2bbff;
  --error: #ef4444;
  --success: #22c55e;
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --sidebar-w: 256px;
  --font-ui: 'Inter', system-ui, sans-serif;
  --font-label: 'Geist', 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
}

.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  font-size: 20px;
  vertical-align: middle;
  user-select: none;
}

a { color: var(--primary-light); text-decoration: none; }

/* ---------- Glass ---------- */
.glass {
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: rgba(19, 19, 19, 0.75);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  z-index: 50;
}

.sidebar-brand h1 {
  margin: 0;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(120deg, var(--primary-tint), var(--primary-light));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.sidebar-brand p {
  margin: 2px 0 0;
  font-family: var(--font-label);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--text-muted);
}

.sidebar-cta { margin: 24px 0 16px; }

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

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font-label);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s, color 0.2s;
}

.sidebar-nav a:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); }

.sidebar-nav a.is-active {
  background: rgba(255, 255, 255, 0.06);
  color: var(--primary-tint);
  box-shadow: inset 2px 0 0 var(--primary);
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 14px;
  min-width: 0;
}

.sidebar-user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  font-size: 13px;
  font-family: var(--font-label);
}

.sidebar-logout:hover { color: var(--error); }

/* ---------- Main ---------- */
.main {
  margin-left: var(--sidebar-w);
  padding: 48px;
  min-height: 100vh;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}

.page-header h2 {
  margin: 0;
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.page-sub { margin: 4px 0 0; color: var(--text-muted); font-size: 15px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: var(--font-label);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s, background 0.2s, border-color 0.2s, box-shadow 0.2s;
  text-decoration: none;
  color: var(--text);
  background: transparent;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(to right, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.25);
}

.btn-primary:hover { opacity: 0.9; box-shadow: 0 4px 28px rgba(124, 58, 237, 0.4); }

.btn-ghost {
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-soft);
}

.btn-ghost:hover { background: rgba(255, 255, 255, 0.08); color: var(--text); }

.btn-danger:hover { color: var(--error); border-color: rgba(239, 68, 68, 0.4); }

.btn-block { width: 100%; }
.btn-lg { padding: 14px 28px; font-size: 15px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-sm .material-symbols-outlined { font-size: 18px; }

/* ---------- Forms ---------- */
.field { display: block; margin-bottom: 20px; }

.field-label {
  display: block;
  font-family: var(--font-label);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

input[type="text"], input[type="email"], input[type="password"], input[type="number"], select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.25);
}

textarea { resize: vertical; }

/* Prompt container con borde degradado (estilo Aether) */
.prompt-container {
  background: linear-gradient(#1e1e21, #1e1e21) padding-box,
              linear-gradient(to right, rgba(255,255,255,0.1), rgba(124,58,237,0.4), rgba(45,212,191,0.3)) border-box;
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 24px;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
}

.prompt-container textarea {
  background: transparent;
  border: none;
  box-shadow: none;
  font-size: 17px;
  min-height: 120px;
  padding: 6px;
}

.prompt-container textarea:focus { box-shadow: none; }

/* ---------- Option cards (formatos) ---------- */
.option-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.option-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 12px;
  background: var(--surface-low);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  text-align: center;
}

.option-card input { display: none; }

.option-card:hover { border-color: rgba(124, 58, 237, 0.5); }

.option-card.is-selected {
  border-color: var(--primary);
  background: rgba(124, 58, 237, 0.1);
  box-shadow: 0 0 20px rgba(124, 58, 237, 0.15);
}

.format-shape {
  width: 48px;
  max-height: 64px;
  background: rgba(124, 58, 237, 0.25);
  border: 1px solid var(--primary-light);
  border-radius: 4px;
}

.option-label { font-size: 13px; font-weight: 500; font-family: var(--font-label); }
.option-detail { font-size: 11px; color: var(--text-muted); font-family: var(--font-label); }

/* ---------- Chips (estilos) ---------- */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  padding: 8px 18px;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  font-family: var(--font-label);
  font-size: 13px;
  color: var(--text-soft);
  cursor: pointer;
  transition: all 0.2s;
}

.chip input { display: none; }

.chip:hover { background: rgba(255, 255, 255, 0.08); }

.chip.is-selected {
  background: rgba(124, 58, 237, 0.2);
  border-color: var(--primary);
  color: var(--primary-tint);
}

.field-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 14px;
}

.field-toggle small { color: var(--text-muted); }

.new-design-form { max-width: 760px; }
.new-design-form .btn-lg { margin-top: 8px; }

/* ---------- Dashboard grid ---------- */
.design-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 24px;
}

.design-card {
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

.design-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.design-thumb {
  display: block;
  width: 100%;
  max-height: 280px;
  overflow: hidden;
  background: var(--surface-low);
}

.design-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.design-thumb-placeholder {
  width: 100%;
  height: 100%;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  background: linear-gradient(135deg, #1a1325, #131313 60%);
}

.design-thumb-placeholder .material-symbols-outlined { font-size: 42px; opacity: 0.5; }

.design-card-body { padding: 14px 16px 16px; }

.design-card-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.design-card-title h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.design-card-actions { display: flex; gap: 6px; }
.design-card-actions form { display: inline; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 9999px;
  font-family: var(--font-label);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge .material-symbols-outlined { font-size: 14px; }

.badge-muted { background: rgba(255,255,255,0.06); color: var(--text-muted); }
.badge-working { background: rgba(124, 58, 237, 0.18); color: var(--primary-tint); }
.badge-working .material-symbols-outlined { animation: spin 1.4s linear infinite; }
.badge-ready { background: rgba(34, 197, 94, 0.15); color: #6ee7a0; }
.badge-error { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }
.badge-exported { background: rgba(210, 187, 255, 0.15); color: var(--primary-tint); }

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

/* ---------- Empty state ---------- */
.empty-state {
  max-width: 480px;
  margin: 80px auto;
  padding: 48px 40px;
  text-align: center;
}

.empty-icon { font-size: 48px; color: var(--primary-light); }
.empty-state h3 { margin: 16px 0 8px; font-size: 20px; }
.empty-state p { color: var(--text-muted); margin: 0 0 24px; }

/* ---------- Status / stepper ---------- */
.status-panel {
  max-width: 560px;
  margin: 0 auto;
  padding: 40px;
}

.stepper { list-style: none; margin: 0 0 32px; padding: 0; }

.stepper li {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  color: var(--text-muted);
  font-size: 15px;
  transition: color 0.3s;
}

.step-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
  position: relative;
  transition: all 0.3s;
}

.stepper li.is-active { color: var(--text); }

.stepper li.is-active .step-dot {
  border-color: var(--primary);
  box-shadow: 0 0 12px rgba(124, 58, 237, 0.6);
  animation: pulse 1.6s ease-in-out infinite;
}

.stepper li.is-done { color: var(--text-soft); }

.stepper li.is-done .step-dot {
  border-color: var(--success);
  background: rgba(34, 197, 94, 0.2);
}

.stepper li.is-done .step-dot::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--success);
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 8px rgba(124, 58, 237, 0.4); }
  50% { box-shadow: 0 0 18px rgba(124, 58, 237, 0.8); }
}

.status-working {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 14px;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  flex-shrink: 0;
}

.status-ready, .status-failed { text-align: center; }
.ready-icon { font-size: 48px; color: var(--success); }
.error-icon { font-size: 48px; color: var(--error); }
.status-ready p, .status-failed p { margin: 12px 0 20px; font-size: 16px; }
.status-failed form { display: inline-block; margin-right: 8px; }

/* ---------- Alerts ---------- */
.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 20px;
}

.alert-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}

/* ---------- Shimmer (procesando IA) ---------- */
.shimmer { position: relative; overflow: hidden; }

.shimmer::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(167, 139, 250, 0.12), transparent);
  animation: shimmer 1.8s infinite;
}

@keyframes shimmer { 100% { transform: translateX(100%); } }

/* ---------- Login ---------- */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  position: relative;
  overflow: hidden;
}

.login-glow {
  position: absolute;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(124, 58, 237, 0.18), transparent 65%);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 40px;
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.login-brand { text-align: center; margin-bottom: 24px; }

.login-brand h1 {
  margin: 0;
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(120deg, var(--primary-tint), var(--primary-light));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.login-brand p {
  margin: 2px 0 0;
  font-family: var(--font-label);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--text-muted);
}

.login-card h2 {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 600;
  text-align: center;
}

.login-sub {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  margin: 0 0 24px;
}

/* ---------- Error page ---------- */
.error-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.error-box { text-align: center; }
.error-box h1 { font-size: 64px; margin: 0 0 8px; color: var(--primary-light); }
.error-box p { color: var(--text-muted); margin: 0 0 24px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .sidebar {
    position: static;
    width: 100%;
    flex-direction: row;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar-brand p, .sidebar-footer .sidebar-user { display: none; }
  .sidebar-brand h1 { font-size: 22px; }
  .sidebar-cta { margin: 0; width: auto; }
  .sidebar-nav { flex-direction: row; }
  .sidebar-footer { border: none; padding: 0; margin-left: auto; }
  .main { margin-left: 0; padding: 20px 16px; }
}
