/* ==========================================================================
   LSC i5.0 — Sistema de diseño (estilo Apple: minimalista, claro, con foco
   en tipografía, espacio en blanco, vidrio esmerilado y animaciones suaves).
   Complementa a TailwindCSS (CDN); componentes en CSS plano (sin @apply).
   ========================================================================== */

:root {
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: rgba(79, 70, 229, 0.12);

  --bg: #fbfbfd;
  --bg-tint: radial-gradient(1200px 600px at 80% -10%, rgba(79,70,229,.10), transparent 60%),
             radial-gradient(900px 500px at -10% 10%, rgba(34,211,238,.08), transparent 55%);
  --surface: #ffffff;
  --surface-2: #f5f5f7;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --border: rgba(0, 0, 0, 0.08);
  --glass: rgba(255, 255, 255, 0.72);

  --shadow-sm: 0 1px 2px rgba(0,0,0,.04), 0 1px 3px rgba(0,0,0,.05);
  --shadow: 0 8px 30px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
  --shadow-lg: 0 24px 60px rgba(0,0,0,.12), 0 8px 24px rgba(0,0,0,.08);

  --ease: cubic-bezier(.22, 1, .36, 1);
  --radius: 22px;
}

.dark {
  --accent: #7c7bf0;
  --accent-hover: #9a99f5;
  --accent-soft: rgba(124, 123, 240, 0.18);

  --bg: #0a0a0c;
  --bg-tint: radial-gradient(1200px 600px at 80% -10%, rgba(124,123,240,.14), transparent 60%),
             radial-gradient(900px 500px at -10% 10%, rgba(34,211,238,.06), transparent 55%);
  --surface: #1a1a1d;
  --surface-2: #232327;
  --text: #f5f5f7;
  --text-2: #a1a1a6;
  --border: rgba(255, 255, 255, 0.10);
  --glass: rgba(22, 22, 24, 0.72);

  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow: 0 10px 36px rgba(0,0,0,.5);
  --shadow-lg: 0 24px 70px rgba(0,0,0,.6);
}

* { -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
               "Inter", system-ui, "Segoe UI", sans-serif !important;
  background: var(--bg) !important;
  background-image: var(--bg-tint) !important;
  background-attachment: fixed;
  color: var(--text) !important;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  letter-spacing: -0.011em;
  transition: background-color .5s var(--ease), color .35s var(--ease);
}

h1, h2, h3 { letter-spacing: -0.025em; }

/* ----------------------------------------------------------- Tarjetas ---- */
.card {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform .4s var(--ease), box-shadow .4s var(--ease), border-color .3s var(--ease);
}
.card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

/* glass / superficie de vidrio esmerilado */
.glass {
  background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border: 1px solid var(--border);
}

/* ------------------------------------------------------------ Botones ---- */
/* Cada variante es autosuficiente: funciona aunque el HTML use solo
   .btn-primary / .btn-ghost / .btn-danger (sin la clase base .btn). */
.btn, .btn-primary, .btn-ghost, .btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
  border-radius: 980px;                /* pill, estilo Apple */
  padding: .72rem 1.5rem; font-size: .95rem; font-weight: 600; line-height: 1;
  cursor: pointer; border: 1px solid transparent; user-select: none;
  text-decoration: none; white-space: nowrap;
  transition: transform .2s var(--ease), background-color .25s var(--ease),
              box-shadow .3s var(--ease), opacity .2s var(--ease),
              color .2s var(--ease), border-color .2s var(--ease);
}
.btn:hover, .btn-primary:hover, .btn-ghost:hover, .btn-danger:hover { transform: translateY(-2px); }
.btn:active, .btn-primary:active, .btn-ghost:active, .btn-danger:active { transform: translateY(0) scale(.96); }
.btn:disabled, .btn-primary:disabled, .btn-ghost:disabled, .btn-danger:disabled {
  opacity: .45; cursor: not-allowed; transform: none; box-shadow: none;
}
.btn:focus-visible, .btn-primary:focus-visible, .btn-ghost:focus-visible, .btn-danger:focus-visible {
  outline: none; box-shadow: 0 0 0 4px var(--accent-soft);
}

.btn-primary {
  background-image: linear-gradient(180deg, var(--accent), var(--accent-hover));
  color: #fff; box-shadow: 0 8px 22px var(--accent-soft);
}
.btn-primary:hover { box-shadow: 0 14px 32px var(--accent-soft); }

.btn-ghost {
  background: var(--surface); color: var(--text);
  border-color: var(--border); box-shadow: var(--shadow-sm);
}
.btn-ghost:hover { background: var(--surface-2); box-shadow: var(--shadow); }

.btn-danger { background: #ff3b30; color: #fff; box-shadow: 0 8px 22px rgba(255, 59, 48, .28); }
.btn-danger:hover { background: #e0352b; box-shadow: 0 14px 32px rgba(255, 59, 48, .32); }

/* ------------------------------------------------------------- Inputs ---- */
.input {
  width: 100%; border-radius: 14px; border: 1px solid var(--border);
  background: var(--surface-2);
  padding: .72rem 1rem; font-size: .95rem; color: var(--text); outline: none;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease), background-color .2s var(--ease);
}
.input::placeholder { color: var(--text-2); }
.input:focus { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 4px var(--accent-soft); }

/* ----------------------------------------------- Interruptor tipo iOS ---- */
.switch { position: relative; display: inline-block; width: 50px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; cursor: pointer; border-radius: 980px;
  background: #c7c7cc; transition: background-color .3s var(--ease);
}
.dark .switch .track { background: #39393d; }
.switch .track::before {
  content: ""; position: absolute; height: 26px; width: 26px; left: 2px; top: 2px;
  background: #fff; border-radius: 50%; box-shadow: 0 2px 6px rgba(0,0,0,.25);
  transition: transform .3s var(--ease);
}
.switch input:checked + .track { background: #34c759; }
.switch input:checked + .track::before { transform: translateX(20px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 4px var(--accent-soft); }

/* ------------------------------------------------------- Animaciones ---- */
@keyframes reveal { from { opacity: 0; transform: translateY(16px) scale(.99); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes float-blob { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(20px,-24px) scale(1.06); } }
@keyframes pulse-soft { 0% { box-shadow: 0 0 0 0 var(--accent-soft); } 70% { box-shadow: 0 0 0 16px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@keyframes shimmer { 100% { background-position: 200% 0; } }

.reveal { animation: reveal .6s var(--ease) both; }
.animate-fade { animation: fade-in .5s var(--ease) both; }
.animate-fade-up { animation: reveal .6s var(--ease) both; }
.recording { animation: pulse-soft 1.8s infinite; }

/* gradiente animado de fondo (hero) */
.blob {
  position: absolute; border-radius: 50%; filter: blur(80px); opacity: .38;
  animation: float-blob 14s var(--ease) infinite; pointer-events: none; z-index: 0;
}
@media (max-width: 767px) { .blob { opacity: .22; filter: blur(70px); } }

/* texto con degradado */
.text-gradient {
  background: linear-gradient(120deg, var(--accent), #22d3ee 90%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* --------------------------------------------------- Navegación / chips --- */
.nav-link {
  display: flex; align-items: center; gap: .75rem; border-radius: 14px;
  padding: .6rem .8rem; font-size: .92rem; font-weight: 500; color: var(--text-2);
  transition: background-color .25s var(--ease), color .25s var(--ease), transform .2s var(--ease);
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--accent); color: #fff; box-shadow: 0 6px 16px var(--accent-soft); }
.nav-link:active { transform: scale(.97); }

/* ---------------------------------------------------------- Scrollbar ---- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 980px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-2); background-clip: padding-box; }

/* ----------------------------------------------------- Accesibilidad ---- */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* --------------------------------------------------------------- Toast ---- */
#toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999; display: flex; flex-direction: column; gap: .6rem; }
.toast {
  border-radius: 16px; padding: .8rem 1.1rem; font-size: .9rem; font-weight: 550; color: #fff;
  box-shadow: var(--shadow-lg); animation: reveal .4s var(--ease) both;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.bg-slate-800 { background: rgba(28,28,30,.92); } .bg-emerald-600 { background: #34c759; }
.bg-rose-600 { background: #ff3b30; } .bg-amber-500 { background: #ff9f0a; }

/* barra inferior móvil (tab bar tipo iOS) */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; justify-content: space-around; padding: .4rem .4rem calc(.4rem + env(safe-area-inset-bottom));
}
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .62rem; font-weight: 600; color: var(--text-2); padding: .35rem .5rem; border-radius: 12px; transition: color .2s var(--ease); }
.tabbar a .ic { font-size: 1.2rem; }
.tabbar a.active { color: var(--accent); }
@media (max-width: 767px) { body { padding-bottom: 4.6rem; } }
