/* =====================================================================
   Habla Más — hoja de estilos
   Port de los tokens de src/index.css (Tailwind/shadcn) a CSS plano.
   Sin build step: nada de PostCSS ni Node en producción.
   ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
  --background: hsl(36 33% 97%);
  --foreground: hsl(24 10% 10%);
  --card: hsl(0 0% 100%);
  --primary: hsl(25 95% 53%);
  --primary-soft: hsl(25 95% 53% / 0.10);
  --primary-fg: hsl(0 0% 100%);
  --secondary: hsl(36 33% 92%);
  --muted: hsl(36 20% 94%);
  --muted-fg: hsl(24 10% 45%);
  --accent: hsl(160 60% 45%);
  --accent-soft: hsl(160 60% 45% / 0.10);
  --destructive: hsl(0 84% 60%);
  --border: hsl(30 20% 88%);
  --sidebar-bg: hsl(30 25% 95%);
  --radius: 0.75rem;
  --font-heading: 'Space Grotesk', ui-sans-serif, system-ui, sans-serif;
  --font-body: 'Inter', ui-sans-serif, system-ui, sans-serif;
  --shadow-sm: 0 1px 2px hsl(24 10% 10% / 0.06);
  --shadow-md: 0 4px 14px hsl(24 10% 10% / 0.08);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--font-heading); margin: 0; line-height: 1.2; }
a { color: inherit; }
button { font-family: inherit; }

.container { max-width: 780px; margin: 0 auto; padding: 0 24px; }
.container-wide { max-width: 1180px; margin: 0 auto; padding: 0 24px; }
.muted { color: var(--muted-fg); }
.text-xs { font-size: 12px; }
.text-sm { font-size: 13.5px; }
.center { text-align: center; }
.hidden { display: none !important; }

/* --- Cabecera -------------------------------------------------------- */
.appbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 24px;
  background: hsl(0 0% 100% / 0.8);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 12px;
  background: var(--primary); color: var(--primary-fg);
  display: grid; place-items: center; font-size: 18px; flex-shrink: 0;
}
.brand h1 { font-size: 17px; font-weight: 700; }
.appbar-actions { display: flex; align-items: center; gap: 8px; }

/* --- Botones --------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--radius);
  border: 1px solid transparent; background: var(--primary); color: var(--primary-fg);
  font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none;
  transition: filter .15s ease, background .15s ease, transform .05s ease;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--muted-fg); }
.btn-ghost:hover { background: var(--muted); color: var(--foreground); }
.btn-outline { background: var(--card); color: var(--foreground); border-color: var(--border); }
.btn-outline:hover { background: var(--muted); }
.btn-block { width: 100%; }
.btn-icon { padding: 9px; width: 38px; height: 38px; }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* --- Tarjetas y formularios ------------------------------------------ */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 20px; box-shadow: var(--shadow-sm);
}
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.input, .textarea {
  width: 100%; padding: 11px 14px; font: inherit; font-size: 14px;
  color: var(--foreground); background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.input:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.textarea { resize: none; min-height: 48px; max-height: 140px; }

.alert { padding: 12px 14px; border-radius: var(--radius); font-size: 13.5px; margin-bottom: 16px; }
.alert-error { background: hsl(0 84% 60% / .08); color: hsl(0 60% 40%); border: 1px solid hsl(0 84% 60% / .25); }
.alert-ok { background: var(--accent-soft); color: hsl(160 60% 27%); border: 1px solid hsl(160 60% 45% / .3); }
.alert-info { background: hsl(230 60% 60% / .08); color: hsl(230 45% 42%); border: 1px solid hsl(230 60% 60% / .25); }

/* --- Pantallas de autenticación -------------------------------------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 32px 20px; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card .brand { justify-content: center; margin-bottom: 20px; }
.auth-head { text-align: center; margin-bottom: 24px; }
.auth-head h2 { font-size: 24px; font-weight: 700; margin-bottom: 6px; }
.auth-foot { text-align: center; font-size: 13px; margin-top: 18px; color: var(--muted-fg); }
.auth-foot a { color: var(--primary); font-weight: 600; text-decoration: none; }

/* --- Selector de escenarios ------------------------------------------ */
.picker-head { text-align: center; margin: 40px 0 28px; }
.picker-head h2 { font-size: 30px; font-weight: 700; margin-bottom: 8px; }

.filters { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 28px; }
.chip {
  padding: 7px 16px; border-radius: 999px; font-size: 13.5px; font-weight: 500;
  background: var(--card); border: 1px solid var(--border); color: var(--muted-fg);
  text-decoration: none; transition: all .15s ease;
}
.chip:hover { background: var(--muted); }
.chip.is-active { background: var(--primary); border-color: var(--primary); color: var(--primary-fg); box-shadow: var(--shadow-sm); }

.banner-note {
  display: flex; gap: 12px; align-items: flex-start;
  background: hsl(230 60% 60% / .07); border: 1px solid hsl(230 60% 60% / .25);
  border-radius: 16px; padding: 16px 20px; margin-bottom: 24px;
  font-size: 13.5px; color: hsl(230 40% 40%);
}

.scenario-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; padding-bottom: 56px; }
@media (max-width: 640px) { .scenario-grid { grid-template-columns: 1fr; } }

.scenario-card {
  display: block; text-align: left; text-decoration: none; color: inherit;
  padding: 20px; border-radius: 16px; border: 2px solid var(--border);
  background: var(--card); cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
  animation: rise .35s ease both;
}
.scenario-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.scenario-card .row { display: flex; gap: 12px; align-items: flex-start; }
.scenario-card .emoji { font-size: 28px; line-height: 1; }
.scenario-card h3 { font-size: 15.5px; font-weight: 600; }
.scenario-card p { margin: 4px 0 0; font-size: 12.5px; color: var(--muted-fg); }
.card-tags { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 10px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 500; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--card); color: var(--muted-fg);
}

/* Temas de tarjeta (equivalen a las clases bg-*-50 de Tailwind) */
.theme-indigo { background: hsl(226 100% 97%); border-color: hsl(226 60% 88%); }
.theme-indigo h3, .theme-indigo .badge-theme { color: hsl(226 55% 45%); }
.theme-blue   { background: hsl(214 100% 97%); border-color: hsl(214 60% 87%); }
.theme-blue h3   { color: hsl(214 65% 40%); }
.theme-purple { background: hsl(270 100% 98%); border-color: hsl(270 50% 89%); }
.theme-purple h3 { color: hsl(270 50% 45%); }
.theme-rose   { background: hsl(350 100% 98%); border-color: hsl(350 60% 90%); }
.theme-rose h3   { color: hsl(350 60% 45%); }
.theme-slate  { background: hsl(215 25% 97%); border-color: hsl(215 20% 88%); }
.theme-slate h3  { color: hsl(215 20% 35%); }
.theme-orange { background: hsl(28 100% 97%); border-color: hsl(28 70% 87%); }
.theme-orange h3 { color: hsl(25 80% 42%); }
.theme-sky    { background: hsl(200 100% 97%); border-color: hsl(200 60% 86%); }
.theme-sky h3    { color: hsl(200 70% 36%); }
.theme-amber  { background: hsl(45 100% 96%); border-color: hsl(45 80% 85%); }
.theme-amber h3  { color: hsl(35 80% 38%); }
.theme-red    { background: hsl(0 100% 97%); border-color: hsl(0 70% 90%); }
.theme-red h3    { color: hsl(0 65% 45%); }
.theme-pink   { background: hsl(330 100% 97%); border-color: hsl(330 60% 90%); }
.theme-pink h3   { color: hsl(330 60% 45%); }
.theme-violet { background: hsl(258 100% 98%); border-color: hsl(258 50% 90%); }
.theme-violet h3 { color: hsl(258 50% 48%); }
.theme-green  { background: hsl(140 60% 96%); border-color: hsl(140 40% 85%); }
.theme-green h3  { color: hsl(150 60% 30%); }

/* --- Pantalla de entrenamiento --------------------------------------- */
.training { display: flex; height: 100vh; overflow: hidden; }
.training-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.context-bar {
  padding: 10px 24px; background: var(--secondary);
  border-bottom: 1px solid var(--border);
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  font-size: 12.5px; color: var(--muted-fg);
}
.context-bar strong { color: var(--foreground); font-weight: 600; }

.tip-bar {
  padding: 8px 24px; text-align: center; font-size: 12.5px;
  background: var(--primary-soft); border-bottom: 1px solid hsl(25 95% 53% / .18);
  color: hsl(25 70% 38%);
}

.messages { flex: 1; overflow-y: auto; }
.messages-inner { max-width: 680px; margin: 0 auto; padding: 24px; display: flex; flex-direction: column; gap: 16px; }

.msg-persona { display: flex; gap: 12px; max-width: 85%; animation: slide-in-left .35s ease both; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: var(--primary-soft); border: 2px solid hsl(25 95% 53% / .2);
  display: grid; place-items: center; font-size: 19px;
}
.msg-meta { display: flex; gap: 8px; align-items: baseline; margin-bottom: 4px; font-size: 12px; }
.msg-meta .name { font-weight: 600; }
.msg-meta .desc { color: var(--muted-fg); font-style: italic; }
.bubble {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px 16px 16px 4px; padding: 12px 16px;
  font-size: 14px; box-shadow: var(--shadow-sm);
}
.msg-user { display: flex; justify-content: flex-end; animation: slide-in-right .35s ease both; }
.bubble-user {
  max-width: 85%; background: var(--primary); color: var(--primary-fg);
  border-radius: 16px 16px 4px 16px; padding: 12px 16px; font-size: 14px;
  box-shadow: var(--shadow-sm); white-space: pre-wrap;
}

.feedback {
  border: 2px solid hsl(25 95% 53% / .2); background: var(--primary-soft);
  border-radius: 16px; padding: 20px; animation: rise .4s ease both;
}
.feedback.is-good { border-color: hsl(160 60% 45% / .4); background: var(--accent-soft); }
.feedback-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.feedback-head span { font-family: var(--font-heading); font-weight: 600; font-size: 13.5px; }
.stars { letter-spacing: 2px; font-size: 15px; color: hsl(45 93% 47%); }
.stars .off { color: hsl(30 15% 80%); }
.feedback p { margin: 0 0 14px; font-size: 14px; }
.criteria { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 520px) { .criteria { grid-template-columns: 1fr; } }
.criterion {
  display: flex; gap: 8px; align-items: center; font-size: 12px;
  padding: 8px 12px; border-radius: 10px;
  background: var(--muted); color: var(--muted-fg);
}
.criterion.met { background: var(--accent-soft); color: hsl(160 60% 27%); }

.typing { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted-fg); }
.spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--primary);
  animation: spin .7s linear infinite;
}

.composer {
  border-top: 1px solid var(--border); background: hsl(0 0% 100% / .85);
  backdrop-filter: blur(8px); padding: 16px 24px; flex-shrink: 0;
}
.composer-inner { max-width: 680px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end; }

/* --- Panel lateral --------------------------------------------------- */
.sidebar {
  width: 320px; flex-shrink: 0; background: var(--sidebar-bg);
  border-left: 1px solid var(--border); overflow-y: auto; padding: 24px;
}
.sidebar-label {
  font-size: 11px; font-weight: 500; text-transform: uppercase;
  letter-spacing: .07em; color: var(--muted-fg); display: block; margin-bottom: 12px;
}
.sidebar hr { border: none; border-top: 1px solid var(--border); margin: 24px 0; }

.streak { display: flex; align-items: center; gap: 16px; }
.streak-count { display: flex; align-items: center; gap: 6px; font-family: var(--font-heading); font-weight: 700; font-size: 19px; }
.streak-flame { font-size: 18px; filter: grayscale(1); opacity: .5; }
.streak-flame.on { filter: none; opacity: 1; }

.technique {
  border: 1px solid var(--border); background: hsl(0 0% 100% / .5);
  border-radius: 14px; padding: 14px; margin-bottom: 10px; opacity: .6;
  transition: all .25s ease;
}
.technique.is-active {
  border: 2px solid var(--primary); background: var(--primary-soft);
  opacity: 1; box-shadow: var(--shadow-md);
}
.technique .row { display: flex; gap: 12px; align-items: flex-start; }
.technique h4 { font-size: 13.5px; font-weight: 600; }
.technique .desc { font-size: 12px; color: var(--muted-fg); margin: 4px 0 0; }
.technique .example {
  margin-top: 8px; padding: 8px 12px; border-radius: 10px;
  background: var(--primary-soft); font-size: 12px; font-style: italic; color: hsl(25 70% 38%);
}

.level-btn {
  display: flex; gap: 10px; align-items: center; width: 100%;
  padding: 10px 12px; margin-bottom: 6px; border-radius: 14px;
  border: 2px solid transparent; background: transparent; cursor: pointer; text-align: left;
}
.level-btn:hover { background: var(--muted); }
.level-btn.is-active { border-color: var(--primary); background: var(--primary-soft); }
.level-btn .name { font-size: 13.5px; font-weight: 500; display: block; }
.level-btn .desc { font-size: 11.5px; color: var(--muted-fg); }

.stat-row { display: flex; justify-content: space-between; align-items: center; font-size: 13.5px; margin-bottom: 10px; }
.stat-row .val { font-family: var(--font-heading); font-weight: 600; }
.progressbar { height: 8px; border-radius: 999px; background: var(--muted); overflow: hidden; }
.progressbar > div { height: 100%; background: var(--primary); border-radius: 999px; transition: width .4s ease; }

/* Panel lateral en móvil */
.sidebar-backdrop { display: none; }
@media (max-width: 1024px) {
  .sidebar {
    position: fixed; inset: 0 0 0 auto; z-index: 50; width: 320px;
    transform: translateX(100%); transition: transform .28s ease;
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-backdrop.is-open {
    display: block; position: fixed; inset: 0; z-index: 40; background: hsl(0 0% 0% / .4);
  }
}
@media (min-width: 1025px) { .sidebar-toggle { display: none; } }

/* --- Aviso de hito --------------------------------------------------- */
.milestone {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  z-index: 60; background: var(--card); border: 2px solid var(--primary);
  border-radius: 16px; padding: 14px 22px; box-shadow: var(--shadow-md);
  display: flex; gap: 10px; align-items: center; font-size: 14px; font-weight: 600;
  animation: pop .35s ease both;
}

/* --- Historial ------------------------------------------------------- */
.history-item { border-bottom: 1px solid var(--border); padding: 16px 0; }
.history-item:last-child { border-bottom: none; }
.history-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; margin-bottom: 6px; }
.history-quote {
  margin: 6px 0; padding-left: 12px; border-left: 3px solid var(--border);
  font-size: 13.5px; color: var(--foreground);
}
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 28px; }
@media (max-width: 640px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 16px; text-align: center; }
.stat-card .big { font-family: var(--font-heading); font-size: 24px; font-weight: 700; }

/* --- Animaciones ----------------------------------------------------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: translate(-50%, 12px) scale(.95); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }
@keyframes slide-in-left  { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: none; } }
@keyframes slide-in-right { from { opacity: 0; transform: translateX(16px); }  to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
