/* ═══════════════════════════════════════════════════════════════
   MEGA PROMPT MASTER SENIOR — Minimalist V2 (Chatbot)
   Aesthetic: "OLED Void" + Amber + Nucleo
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Clash+Display:wght@400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500;600&display=swap');

:root {
  --bg-void: hsl(240, 10%, 4%);
  --surface: hsl(240, 8%, 8%);
  --surface-hover: hsl(240, 8%, 12%);
  --border: hsl(240, 8%, 16%);
  
  --accent: hsl(45, 100%, 60%);
  --accent-dim: hsl(45, 60%, 30%);
  --accent-glow: hsla(45, 100%, 60%, 0.15);

  --text-primary: hsl(0, 0%, 92%);
  --text-secondary: hsl(0, 0%, 60%);
  
  --font-display: 'Clash Display', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
  font-family: var(--font-mono);
  background: var(--bg-void);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.hidden { display: none !important; }

/* ── Void effect ── */
.void-bg {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 0%, hsla(45, 100%, 60%, 0.03), transparent 60%);
}

/* ── Header ── */
.app-header {
  position: relative; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 24px 40px;
}

.logo {
  display: flex; align-items: center; gap: 12px;
  font-family: var(--font-display); font-weight: 600; font-size: 1.1rem;
  letter-spacing: -0.02em; color: var(--text-primary);
}

.icon-gear {
  width: 24px; height: 24px; color: var(--accent);
}

.engine-badge {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.75rem; color: var(--text-secondary);
  border: 1px solid var(--border); border-radius: 99px; padding: 4px 12px;
}

.form-actions {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 32px;
  align-items: center;
}

.legal-consent {
  font-size: 0.75rem;
  color: var(--text-muted, #80808a);
  text-align: center;
  max-width: 320px;
  line-height: 1.4;
  margin-top: 4px;
  opacity: 0.8;
  transition: opacity 0.3s ease;
}

.legal-consent:hover {
  opacity: 1;
}

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

.btn-icon-circular {
  background: transparent; color: var(--text-secondary); border: 1px solid var(--border);
  width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.2s;
}
.btn-icon-circular:hover {
  color: var(--accent); border-color: var(--accent-dim); background: hsla(45, 100%, 60%, 0.1);
}

.pulse {
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: pulsing 2s infinite var(--ease);
}
@keyframes pulsing {
  0%, 100% { opacity: 1; } 50% { opacity: 0.4; }
}

/* ── Main Container ── */
.chatbot-container {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  width: 100%; max-width: 800px; margin: 0 auto;
  padding: 40px; position: relative; z-index: 10;
}

/* ── Typography ── */
.hero-title {
  font-family: var(--font-display); font-size: 3rem; font-weight: 600;
  letter-spacing: -0.03em; text-align: center; margin-bottom: 16px;
}

.hero-subtitle {
  font-size: 0.9rem; color: var(--text-secondary); text-align: center;
  margin-bottom: 48px; max-width: 500px; margin-inline: auto;
}

/* ── Input Box ── */
.section-input { width: 100%; animation: fadeUp 0.6s var(--ease) both; }

.input-glass-box {
  background: hsla(240, 8%, 8%, 0.6); backdrop-filter: blur(20px);
  border: 1px solid var(--border); border-radius: 16px;
  padding: 24px; transition: border-color 0.3s var(--ease);
}
.input-glass-box:focus-within { border-color: var(--accent-dim); box-shadow: 0 0 0 1px var(--accent-glow); }

textarea {
  width: 100%; background: transparent; border: none; outline: none;
  color: var(--text-primary); font-family: var(--font-mono); font-size: 1rem;
  line-height: 1.6; resize: none; overflow-y: hidden;
}
textarea::placeholder { color: hsla(0,0%,55%,0.5); }

.input-footer {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--border);
}
.hint { font-size: 0.75rem; color: var(--text-secondary); }

/* ── Buttons ── */
button {
  cursor: pointer; border: none; font-family: var(--font-mono); outline: none;
  border-radius: 8px; transition: all 0.2s;
}

.btn-primary {
  background: var(--text-primary); color: var(--bg-void); padding: 8px 12px;
  display: flex; align-items: center; justify-content: center;
}
.btn-primary:hover { background: var(--accent); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(1px); }

.btn-ghost {
  background: transparent; color: var(--text-secondary); border: 1px solid var(--border);
  padding: 6px 12px; font-size: 0.8rem;
}
.btn-ghost:hover { color: var(--text-primary); border-color: var(--text-secondary); }

/* ── Premium CTA (Waitlist) ── */
.btn-cta-waitlist {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 15px 24px;
  font-family: var(--font-mono); font-size: 0.95rem; font-weight: 600;
  letter-spacing: 0.01em;
  color: hsl(240, 10%, 4%);
  background: linear-gradient(135deg, hsl(48, 100%, 68%) 0%, hsl(42, 100%, 55%) 50%, hsl(38, 95%, 48%) 100%);
  border: 1px solid hsla(48, 100%, 75%, 0.6);
  border-radius: 99px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  box-shadow:
    0 0 0 1px hsla(45, 100%, 60%, 0.2),
    0 8px 24px hsla(45, 100%, 50%, 0.25),
    0 2px 6px hsla(45, 100%, 40%, 0.35),
    inset 0 1px 0 hsla(0, 0%, 100%, 0.4);
  transition: transform 0.25s cubic-bezier(.2, .8, .2, 1), box-shadow 0.25s ease, filter 0.2s ease;
}
.btn-cta-waitlist::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 30%, hsla(0, 0%, 100%, 0.35) 50%, transparent 70%);
  transform: translateX(-120%); transition: transform 0.7s ease;
  pointer-events: none;
}
.btn-cta-waitlist:hover {
  transform: translateY(-2px);
  filter: brightness(1.06);
  box-shadow:
    0 0 0 1px hsla(45, 100%, 60%, 0.35),
    0 14px 32px hsla(45, 100%, 50%, 0.4),
    0 4px 10px hsla(45, 100%, 40%, 0.45),
    inset 0 1px 0 hsla(0, 0%, 100%, 0.55);
}
.btn-cta-waitlist:hover::before { transform: translateX(120%); }
.btn-cta-waitlist:active { transform: translateY(0); filter: brightness(0.97); }
.btn-cta-waitlist svg { flex-shrink: 0; }

/* ── Loading Spinner ── */
.section-loading {
  text-align: center; color: var(--accent); font-size: 0.85rem; letter-spacing: 0.05em;
}
.spinner {
  width: 40px; height: 40px; animation: rotate 2s linear infinite; margin-bottom: 16px;
}
.spinner .path {
  stroke: var(--accent); stroke-linecap: round;
  animation: dash 1.5s ease-in-out infinite;
}
@keyframes rotate { 100% { transform: rotate(360deg); } }
@keyframes dash {
  0% { stroke-dasharray: 1, 150; stroke-dashoffset: 0; }
  50% { stroke-dasharray: 90, 150; stroke-dashoffset: -35; }
  100% { stroke-dasharray: 90, 150; stroke-dashoffset: -124; }
}

/* ── Output Box ── */
.section-output { width: 100%; animation: fadeUp 0.6s var(--ease) both; }

.output-header {
  display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 16px;
}
.output-header h2 { font-family: var(--font-display); font-size: 1.5rem; font-weight: 500; }
.output-actions { display: flex; gap: 8px; }

.output-glass-box {
  background: hsla(240, 8%, 6%, 0.8); border: 1px solid var(--border);
  border-radius: 12px; padding: 24px; overflow-x: auto;
}
pre { white-space: pre-wrap; font-size: 0.85rem; line-height: 1.6; color: var(--text-primary); }

/* ── Streaming cursor: barra iluminada con pulso + halo respiratorio ── */
#prompt-output.is-streaming::after {
  content: '▊';
  display: inline-block;
  margin-left: 2px;
  color: var(--accent);
  text-shadow:
    0 0 6px var(--accent),
    0 0 14px hsla(45, 100%, 60%, 0.6),
    0 0 28px hsla(45, 100%, 60%, 0.35);
  animation: cursor-pulse 0.9s ease-in-out infinite, cursor-halo 2.4s ease-in-out infinite;
  transform-origin: center;
  vertical-align: baseline;
  will-change: opacity, text-shadow, transform;
}
@keyframes cursor-pulse {
  0%, 100% { opacity: 1; transform: scaleY(1); }
  50%      { opacity: 0.15; transform: scaleY(0.92); }
}
@keyframes cursor-halo {
  0%, 100% {
    text-shadow:
      0 0 4px var(--accent),
      0 0 10px hsla(45, 100%, 60%, 0.4),
      0 0 22px hsla(45, 100%, 60%, 0.2);
  }
  50% {
    text-shadow:
      0 0 8px var(--accent),
      0 0 18px hsla(45, 100%, 60%, 0.7),
      0 0 36px hsla(45, 100%, 60%, 0.45);
  }
}
@media (prefers-reduced-motion: reduce) {
  #prompt-output.is-streaming::after { animation: none; opacity: 1; }
}

/* ── Idea original: chip plegable (debajo del prompt) ── */
.intent-chip {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,0.02);
  overflow: hidden;
  transition: border-color 0.2s var(--ease);
}
.intent-chip:hover { border-color: var(--accent-dim); }

.intent-chip-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  transition: color 0.2s var(--ease);
}
.intent-chip-toggle:hover { color: var(--text-primary); }
.intent-chip-icon { opacity: 0.7; flex-shrink: 0; }
.intent-chip-label { flex: 1; text-align: left; font-weight: 600; }
.intent-chip-caret {
  transition: transform 0.3s var(--ease);
  opacity: 0.6;
  flex-shrink: 0;
}
.intent-chip.expanded .intent-chip-caret { transform: rotate(180deg); }

.intent-chip-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.3s var(--ease);
}
.intent-chip-body > span {
  overflow: hidden;
  padding: 0 16px;
  font-size: 0.95rem;
  font-style: italic;
  line-height: 1.5;
  color: var(--text-muted, var(--text-secondary));
  opacity: 0.9;
}
.intent-chip.expanded .intent-chip-body { grid-template-rows: 1fr; }
.intent-chip.expanded .intent-chip-body > span { padding: 0 16px 16px 16px; }

/* ── Fuentes consultadas (Google Search grounding) ── */
.sources-block {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,0.02);
}
.sources-header {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  margin-bottom: 12px;
}
.sources-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.source-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--bg-void);
  color: var(--text-primary);
  font-size: 0.75rem;
  text-decoration: none;
  transition: border-color 0.2s var(--ease), transform 0.2s var(--ease);
}
.source-chip:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.source-chip img {
  border-radius: 3px;
  flex-shrink: 0;
}

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

/* ── History Panel ── */
.history-overlay {
  position: fixed; inset: 0; background: hsla(0,0%,0%,0.6); backdrop-filter: blur(4px);
  z-index: 40; opacity: 0; pointer-events: none; transition: opacity 0.3s var(--ease);
}
.history-overlay.active { opacity: 1; pointer-events: auto; }

.history-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: 360px; max-width: 100vw;
  background: var(--surface); border-left: 1px solid var(--border);
  z-index: 50; transform: translateX(100%); transition: transform 0.4s var(--ease);
  display: flex; flex-direction: column;
}
.history-panel.open { transform: translateX(0); }

.history-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 24px; border-bottom: 1px solid var(--border);
}
.history-header h2 { font-family: var(--font-display); font-size: 1.25rem; font-weight: 500; }

.history-list {
  flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px;
}

.history-item {
  background: var(--bg-void); border: 1px solid var(--border); border-radius: 8px;
  padding: 16px; cursor: pointer; transition: border-color 0.2s; position: relative;
}
.history-item:hover { border-color: var(--accent-dim); }

.history-item-date { font-size: 0.7rem; color: var(--text-secondary); margin-bottom: 8px; display: block; }
.history-item-intent { 
  font-size: 0.85rem; line-height: 1.4; color: var(--text-primary);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.btn-delete-history {
  position: absolute; top: 12px; right: 12px; background: none; border: none; 
  color: var(--text-secondary); cursor: pointer; opacity: 0; transition: opacity 0.2s;
}
.btn-delete-history:hover { color: #ff4a4a; }
.history-item:hover .btn-delete-history { opacity: 1; }

/* ── Landing Page ── */
.section-landing { width: 100%; animation: fadeUp 0.6s var(--ease) both; text-align: center; }
.landing-content { max-width: 600px; margin: 0 auto; padding: 40px 0; display: flex; flex-direction: column; align-items: center; }
.btn-large { font-size: 1.1rem; padding: 12px 24px; border-radius: 99px; font-weight: 500; margin-top: 24px; width: max-content; }

/* ── Login Form ── */
.section-login { width: 100%; animation: fadeUp 0.6s var(--ease) both; }
.login-glass-box {
  background: hsla(240, 8%, 8%, 0.6); backdrop-filter: blur(20px);
  border: 1px solid var(--border); border-radius: 16px;
  padding: 40px; max-width: 400px; margin: 0 auto;
}
.login-title { font-family: var(--font-display); font-size: 1.75rem; font-weight: 500; margin-bottom: 8px; text-align: center; }
.login-subtitle { font-size: 0.85rem; color: var(--text-secondary); text-align: center; margin-bottom: 32px; }

.login-form { display: flex; flex-direction: column; gap: 20px; }
.form-group { display: flex; flex-direction: column; gap: 8px; }
.form-group label { font-size: 0.8rem; color: var(--text-secondary); letter-spacing: 0.02em; }
.form-group input {
  background: hsla(240, 8%, 6%, 0.8); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px 16px; color: var(--text-primary);
  font-family: var(--font-mono); font-size: 0.9rem; transition: all 0.2s;
}
.form-group input:focus { border-color: var(--accent-dim); box-shadow: 0 0 0 1px var(--accent-glow); outline: none; }

.login-error-msg { color: #ff4a4a; font-size: 0.8rem; text-align: center; margin-top: -8px; }
