/* =========================================================================
 * LatLinks · style.css
 * Estilos propios de la plataforma. Tailwind (CDN) aporta las utilidades
 * y se configura en index.html (tailwind.config).
 *   1. Base: variables de color (claro/oscuro), tipografía y estilos generales
 *   2. Componentes: botones, campos, tarjetas de vidrio, navegación
 * ========================================================================= */

/* -------------------------------------------------------------------------
 * 1. BASE
 * ---------------------------------------------------------------------- */
:root {
  --c-canvas:250 250 250; --c-surface:255 255 255; --c-elev:228 228 231; --c-fg:24 24 27;
  --c-muted:82 82 91; --c-subtle:113 113 122; --c-line:24 24 27; --c-inset:255 255 255;
  color-scheme: light;
}
:root.dark {
  --c-canvas:9 9 11; --c-surface:24 24 27; --c-elev:39 39 42; --c-fg:244 244 245;
  --c-muted:161 161 170; --c-subtle:113 113 122; --c-line:255 255 255; --c-inset:9 9 11;
  color-scheme: dark;
}
body { font-family:"Plus Jakarta Sans", Inter, system-ui, sans-serif; -webkit-font-smoothing:antialiased; }
.ambient {
  background:
    radial-gradient(600px circle at 15% -10%, rgb(59 130 246 / .12), transparent 60%),
    radial-gradient(500px circle at 100% 0%, rgb(99 102 241 / .10), transparent 55%);
}
.grid-bg {
  background-image: linear-gradient(rgb(var(--c-line) / .03) 1px, transparent 1px), linear-gradient(90deg, rgb(var(--c-line) / .03) 1px, transparent 1px);
  background-size: 32px 32px;
  -webkit-mask-image: radial-gradient(ellipse at top, #000 30%, transparent 75%);
  mask-image: radial-gradient(ellipse at top, #000 30%, transparent 75%);
}
::-webkit-scrollbar { width:8px; height:8px; }
::-webkit-scrollbar-thumb { background:rgb(var(--c-line) / .1); border-radius:8px; }
::-webkit-scrollbar-thumb:hover { background:rgb(var(--c-line) / .2); }
::-webkit-scrollbar-track { background:transparent; }
.no-scrollbar::-webkit-scrollbar { display:none; }
.no-scrollbar { scrollbar-width:none; }
details > summary::-webkit-details-marker { display:none; }
input[type=range] { accent-color:#6366f1; }
.field-error:empty { display:none; }

/* Switch */
.switch > span { transition:transform .2s; }
.switch[aria-checked="true"] { background:#4f46e5; }
.switch[aria-checked="true"] > span { transform:translateX(20px); }

/* Selector de color personalizado */
.swatch-custom { background:conic-gradient(#f43f5e,#f59e0b,#10b981,#3b82f6,#8b5cf6,#f43f5e); }

/* ---------- Editor ----------
   PC:         panel lateral de 400px + vista previa en un celular simulado.
   Smartphone: editor a pantalla completa con pestañas "Editar / Vista previa". */
#workspace { transition: margin-right .3s cubic-bezier(.32,.72,0,1); }
#previewPane { display:none; }
.ui-desktop body.editing #workspace { margin-right:400px; }
.ui-desktop body.editing #previewPane { display:flex; }
#editor { transform:translateX(100%); transition:transform .3s cubic-bezier(.32,.72,0,1); }
body.editing #editor { transform:translateX(0); }
@media (max-width:1439px) { .ui-desktop body.editing #main { display:none; } .ui-desktop body.editing #previewPane { flex:1; width:auto; } }
.ui-mobile #editor { width:100% !important; left:0; }

/* ---------- Interfaz smartphone ---------- */
.bn-item { display:flex; flex-direction:column; align-items:center; justify-content:flex-end; gap:2px; padding:8px 0 6px; font-size:10px; white-space:nowrap; letter-spacing:-.01em; font-weight:600; color:rgb(var(--c-subtle)); transition:color .2s; }
.bn-item.active { color:rgb(var(--c-fg)); }
.bn-item.active .bn-ico { color:#6366f1; }
.safe-b { padding-bottom:env(safe-area-inset-bottom); }
/* Smartphone elegido en una pantalla grande: la app se muestra con ancho de celular.
   El transform hace que los elementos "fixed" (editor, modales, avisos) queden dentro del marco. */
html.ui-framed body { background:rgb(var(--c-canvas)); }
html.ui-framed #shell { position:relative; max-width:430px; height:100vh; margin:0 auto; overflow:hidden; transform:translateZ(0);
  border-left:1px solid rgb(var(--c-line) / .1); border-right:1px solid rgb(var(--c-line) / .1); box-shadow:0 0 80px -20px rgb(0 0 0 / .35); }
html.ui-framed #route-app, html.ui-framed #route-app > div { height:100vh; }

/* ---------- Animations ---------- */
@keyframes fadeIn  { from { opacity:0 } to { opacity:1 } }
@keyframes popIn   { from { opacity:0; transform:translateY(8px) scale(.98) } to { opacity:1; transform:none } }
@keyframes toastIn { from { opacity:0; transform:translateY(12px) scale(.96) } to { opacity:1; transform:none } }
@keyframes toastOut{ to { opacity:0; transform:translateY(8px) scale(.97) } }
@keyframes shake   { 10%,90%{transform:translateX(-1px)} 20%,80%{transform:translateX(2px)} 30%,50%,70%{transform:translateX(-4px)} 40%,60%{transform:translateX(4px)} }
@keyframes shimmer { from { transform:translateX(-100%) } to { transform:translateX(100%) } }
@keyframes blink   { 50% { opacity:0 } }
@keyframes flash   { from { background:rgb(99 102 241 / .18) } to { background:transparent } }
@keyframes floaty  { 0%,100% { transform:translateY(0) } 50% { transform:translateY(-8px) } }
.anim-fade { animation:fadeIn .2s ease-out; }
.anim-pop  { animation:popIn .25s cubic-bezier(.32,.72,0,1); }
.toast     { animation:toastIn .25s cubic-bezier(.32,.72,0,1); }
.toast-out { animation:toastOut .2s ease-in forwards; }
.shake     { animation:shake .4s; }
.floaty    { animation:floaty 6s ease-in-out infinite; }
.shimmer::after { content:""; position:absolute; inset:0; background:linear-gradient(90deg, transparent, rgb(255 255 255 / .35), transparent); animation:shimmer 1.4s infinite; }
.caret::after { content:"▋"; margin-left:3px; animation:blink 1s steps(1) infinite; color:#818cf8; }
.row-flash { animation:flash 1.8s ease-out; }

/* ---------- Phone mockup ---------- */
.phone {
  width:320px; height:660px; border-radius:48px; padding:12px; flex-shrink:0;
  background:linear-gradient(145deg,#27272a,#09090b);
  box-shadow:0 0 0 1px rgb(255 255 255 / .08), 0 30px 80px -20px rgb(0 0 0 / .55), inset 0 0 0 2px rgb(255 255 255 / .04);
}
.phone-screen { position:relative; height:100%; border-radius:38px; overflow:hidden; background:#fafafa; }
.phone-notch { position:absolute; top:10px; left:50%; transform:translateX(-50%); width:96px; height:26px; border-radius:999px; background:#000; z-index:30; }
@media (max-height:780px) { #previewPane .phone { transform:scale(.85); } }
@media (max-width:380px) { .phone { transform:scale(.9); } }
@media (prefers-reduced-motion:reduce) { *, *::after { animation-duration:.01ms !important; transition-duration:.01ms !important; } }

/* ---------- Página pública del negocio (?id=): banners de modo demo ---------- */
:root { --ll-banner-h: 40px; }
.ll-demo-banner {
  position: fixed; left: 0; right: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--ll-banner-h); padding: 8px 14px; box-sizing: border-box;
  background: #dc2626; color: #fff; text-align: center;
  font: 600 13px/1.3 "Plus Jakarta Sans", Inter, system-ui, sans-serif;
  box-shadow: 0 4px 20px -6px rgba(0,0,0,.45);
}
.ll-demo-banner svg { width: 16px; height: 16px; flex-shrink: 0; }
#demoBannerTop { top: 0; }
#demoBannerBottom { bottom: 0; box-shadow: 0 -4px 20px -6px rgba(0,0,0,.45); }
body.ll-is-demo #route-demo { padding-top: var(--ll-banner-h); padding-bottom: var(--ll-banner-h); }
body.ll-is-demo #route-demo [data-site] > .sticky.top-0 { top: var(--ll-banner-h) !important; }
body.ll-is-demo #route-demo [data-site] > .sticky.bottom-0 { bottom: var(--ll-banner-h) !important; }
body.ll-is-demo #route-demo a[data-wa-href] { cursor: not-allowed; }
.ll-state { min-height: 100vh; display: grid; place-items: center; padding: 24px; box-sizing: border-box; text-align: center; }
.ll-spin { width: 28px; height: 28px; margin: 0 auto; border-radius: 999px; border: 3px solid #6366f1; border-top-color: transparent; animation: llspin 1s linear infinite; }
@keyframes llspin { to { transform: rotate(360deg); } }

/* Estado de guardado en Supabase (editor) */
.ll-cloud:empty { display: none; }
.ll-cloud::before { content: "·"; margin: 0 .35rem; }
.ll-cloud[data-state="error"] { color: #ef4444; }
.ll-cloud[data-state="ok"] { color: #10b981; }

/* Ocultar la barra flotante de Netlify */
netlifydrawer-app, [data-netlify-drawers], #netlify-notification-drawer {
  display: none !important;
}

/* -------------------------------------------------------------------------
 * 2. COMPONENTES
 * Antes estaban en <style type="text/tailwindcss"> con @apply. Ese tipo de
 * bloque solo lo procesa Tailwind cuando está dentro del HTML, así que aquí
 * están traducidos a CSS normal con los mismos valores de Tailwind.
 * Van después de la base para respetar el orden original; las utilidades de
 * Tailwind (px-6, w-full, hidden…) siguen pudiendo sobrescribirlos.
 * ---------------------------------------------------------------------- */
.glass {
  border-width: 1px;
  border-color: rgb(var(--c-line) / .1);
  background-color: rgb(var(--c-surface) / .6);
  --tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .03);
  box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
.dark .glass { --tw-shadow: 0 0 #0000; box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow); }

/* Botones */
.btn-primary,
.btn-ghost,
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  border-radius: .5rem;
  padding: .5rem 1rem;
  font-size: .875rem;
  line-height: 1.25rem;
  font-weight: 500;
  transition-property: all;
  transition-timing-function: cubic-bezier(.4, 0, .2, 1);
  transition-duration: 200ms;
}
.btn-primary {
  background-image: linear-gradient(to right, #2563eb, #4f46e5);
  color: #fff;
  --tw-shadow: 0 10px 15px -3px rgb(79 70 229 / .2), 0 4px 6px -4px rgb(79 70 229 / .2);
  box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
}
.btn-primary:hover { transform: scale(1.02); background-image: linear-gradient(to right, #3b82f6, #6366f1); }
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { pointer-events: none; opacity: .5; }

.btn-ghost {
  border-width: 1px;
  border-color: rgb(var(--c-line) / .1);
  background-color: rgb(var(--c-surface) / .6);
  color: rgb(var(--c-muted));
}
.btn-ghost:hover { background-color: rgb(var(--c-elev) / .6); color: rgb(var(--c-fg)); }

.btn-danger {
  background-image: linear-gradient(to right, #dc2626, #e11d48);
  color: #fff;
  --tw-shadow: 0 10px 15px -3px rgb(220 38 38 / .2), 0 4px 6px -4px rgb(220 38 38 / .2);
  box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
}
.btn-danger:hover { transform: scale(1.02); }
.btn-danger:active { transform: scale(.98); }

.icon-btn {
  display: grid;
  height: 2rem;
  width: 2rem;
  flex-shrink: 0;
  place-items: center;
  border-radius: .5rem;
  color: rgb(var(--c-muted));
  transition-property: all;
  transition-timing-function: cubic-bezier(.4, 0, .2, 1);
  transition-duration: 200ms;
}
.icon-btn:hover { background-color: rgb(var(--c-elev) / .6); color: rgb(var(--c-fg)); }

/* Navegación lateral */
.nav-item {
  display: flex;
  width: 100%;
  align-items: center;
  gap: .75rem;
  border-radius: .5rem;
  padding: .5rem .75rem;
  font-size: .875rem;
  line-height: 1.25rem;
  font-weight: 500;
  color: rgb(var(--c-muted));
  transition-property: all;
  transition-timing-function: cubic-bezier(.4, 0, .2, 1);
  transition-duration: 200ms;
}
.nav-item:hover { background-color: rgb(var(--c-elev) / .4); color: rgb(var(--c-fg)); }
.nav-item.active { background-color: rgb(var(--c-elev) / .6); color: rgb(var(--c-fg)); }

/* Textos */
.section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: rgb(var(--c-subtle));
}
.link {
  font-weight: 500;
  color: #4f46e5;
  transition-property: all;
  transition-timing-function: cubic-bezier(.4, 0, .2, 1);
  transition-duration: 200ms;
}
.link:hover { color: #6366f1; }
.dark .link { color: #818cf8; }
.dark .link:hover { color: #a5b4fc; }
.hint { margin-top: .25rem; font-size: 11px; color: rgb(var(--c-subtle)); }
.field-error { margin-top: .375rem; font-size: .75rem; line-height: 1rem; font-weight: 500; color: #dc2626; }
.dark .field-error { color: #f87171; }

/* Formularios */
.label { display: block; font-size: .75rem; font-weight: 500; color: rgb(var(--c-muted)); margin-bottom: .375rem; }
.field {
  width: 100%;
  border-radius: .625rem;
  background: rgb(var(--c-inset) / .6);
  border: 1px solid rgb(var(--c-line) / .12);
  padding: .625rem .75rem;
  font-size: .875rem;
  color: rgb(var(--c-fg));
  outline: none;
  transition: all .2s;
}
.field::placeholder { color: rgb(var(--c-subtle) / .8); }
.field:focus { border-color: rgb(99 102 241 / .6); box-shadow: 0 0 0 3px rgb(99 102 241 / .15); }
.field.invalid { border-color: rgb(239 68 68 / .7); box-shadow: 0 0 0 3px rgb(239 68 68 / .15); }
select.field { appearance: none; background-image: none; }
/* Carrito público: sube sobre el banner inferior de DEMO */
.ll-cart-bar.ll-fixed { bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
body.ll-is-demo .ll-cart-bar.ll-fixed { bottom: calc(var(--ll-banner-h, 48px) + 14px); }
