/* Alma de Yeso · Admin — CSS (Fase C). Vanilla, mobile-first. */
:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface-2: #1d1a15;
  --cream: #efe6d8;
  --soft: #d9cdb8;
  --brown: #5a4636;
  --muted: #8a7e6e;
  --border: #2a2420;
  --error: #e07878;
  --ok: #9dc88d;
  --warn: #d9b06a;
  --info: #9db8d9;
  --radio: 12px;
  --fuente-titulos: "Cormorant Garamond", Georgia, serif;
  --fuente-texto: "Outfit", system-ui, -apple-system, sans-serif;
  --header-h: 56px;
  --bottombar-h: 64px;
}

* { box-sizing: border-box; }

/* Ninguna regla de este archivo puede anular el atributo hidden. */
[hidden] { display: none !important; }

/* Pantalla de carga de la app: overlay fijo, fuera del flujo. Se ELIMINA
   del DOM cuando la app está lista (ver mostrarApp en js/router.js). */
#carga {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: var(--bg, #0a0a0a);
}

/* Defensa extra: aunque otra regla quisiera mostrarla, hidden manda. */
#carga[hidden] { display: none !important; }

/* Guardián de arranque (BUG módulos): overlay de error + reintento.
   Sin estilos en línea (CSP): todo por clases. */
.boot-error {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: var(--bg, #0a0a0a);
  text-align: center;
}
.boot-caja {
  width: min(100%, 26rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radio);
  padding: 2rem 1.5rem;
}
.boot-titulo { color: var(--cream); margin-bottom: 0.4rem; }
.boot-codigo { font-size: 0.85rem; margin-bottom: 1.2rem; }
.boot-caja .btn { width: 100%; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--cream);
  font-family: var(--fuente-texto);
  font-weight: 300;
  line-height: 1.6;
  min-height: 100dvh;
}

h1, h2, h3 {
  font-family: var(--fuente-titulos);
  font-weight: 600;
  line-height: 1.2;
  margin: 0 0 0.6em;
  color: var(--cream);
}

p { margin: 0 0 1em; color: var(--muted); }

a { color: var(--soft); }

/* ---------- Login ---------- */
.login-pantalla {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-tarjeta {
  width: min(100%, 26rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radio);
  padding: 2rem 1.5rem;
  text-align: center;
}

.login-logo {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 1px solid var(--soft);
  object-fit: cover;
  margin: 0 auto 1rem;
}

.login-tarjeta h1 { font-size: 1.9rem; margin-bottom: 0.2rem; }
.login-sub { font-size: 0.9rem; margin-bottom: 1.5rem; }
.login-tarjeta form { text-align: left; }

/* ---------- Campos y botones ---------- */
.campo { margin-bottom: 1rem; }

.campo label {
  display: block;
  font-size: 0.85rem;
  color: var(--cream);
  margin-bottom: 0.35rem;
}

.campo input,
.campo textarea,
.campo select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--muted);
  border-radius: 6px;
  color: var(--cream);
  padding: 0.75rem 0.9rem;
  font-size: 1rem;
  font-family: inherit;
  min-height: 44px;
}

.campo textarea { resize: vertical; min-height: 88px; }

.campo input:focus,
.campo textarea:focus,
.campo select:focus {
  outline: 2px solid var(--soft);
  outline-offset: 1px;
}

.form-error {
  color: var(--error);
  font-size: 0.9rem;
  margin: 0 0 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 999px;
  padding: 0.8rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  min-height: 44px;
  text-decoration: none;
}

.btn-primario { background: var(--brown); border-color: var(--brown); color: var(--cream); width: 100%; }
.btn-primario:hover { filter: brightness(1.1); }
.btn-primario:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-linea { background: transparent; color: var(--cream); border-color: var(--border); }
.btn-linea:hover { border-color: var(--soft); }
.btn-linea:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-peligro { background: transparent; color: var(--error); border-color: var(--error); }
.btn-peligro:hover { background: rgba(224, 120, 120, 0.1); }

.btn-salir {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--cream);
  border-radius: 999px;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
}

/* ---------- App layout ---------- */
.admin-header {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 1rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.admin-marca {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--cream);
  font-family: var(--fuente-titulos);
  font-size: 1.1rem;
  min-height: 44px;
}

.admin-marca img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--soft);
  object-fit: cover;
}

.admin-layout { display: block; }

.admin-vista {
  padding: 1.25rem 1rem calc(var(--bottombar-h) + 2rem);
  width: min(100%, 60rem);
  margin-inline: auto;
}

.admin-sidebar { display: none; }

.admin-sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.admin-sidebar a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.8rem 1rem;
  border-radius: 8px;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.admin-sidebar a[aria-current="page"] {
  color: var(--cream);
  background: var(--surface);
  border: 1px solid var(--border);
}

.admin-bottombar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}

.admin-bottombar a {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.8rem;
  min-height: var(--bottombar-h);
  min-width: 44px;
  border-top: 2px solid transparent;
}

.admin-bottombar a[aria-current="page"] {
  color: var(--cream);
  border-top-color: var(--soft);
}

@media (min-width: 900px) {
  .admin-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    max-width: 72rem;
    margin-inline: auto;
  }
  .admin-sidebar {
    display: block;
    border-right: 1px solid var(--border);
    padding: 1.5rem 1rem;
    position: sticky;
    top: var(--header-h);
    align-self: start;
    min-height: calc(100dvh - var(--header-h));
  }
  .admin-bottombar { display: none; }
  .admin-vista { padding-bottom: 3rem; }
}

/* ---------- Tarjetas y listas ---------- */
.tarjeta {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radio);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.contador-grande {
  font-family: var(--fuente-titulos);
  font-size: 3.5rem;
  line-height: 1;
  color: var(--cream);
  margin: 0.25rem 0 0.75rem;
}

.enlace-tarjeta {
  display: block;
  text-decoration: none;
  color: inherit;
}

.lista { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }

.fila-pedido {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radio);
  padding: 1rem;
  text-decoration: none;
  color: inherit;
  min-height: 44px;
}

.fila-pedido:active { border-color: var(--soft); }

.fila-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.fila-numero { font-weight: 500; color: var(--cream); font-size: 1.05rem; }
.fila-fecha { font-size: 0.82rem; color: var(--muted); margin-bottom: 0.25rem; }
.fila-cliente { color: var(--cream); margin: 0; overflow-wrap: anywhere; }
.fila-total { color: var(--soft); font-weight: 500; margin: 0.25rem 0 0; }

.etiqueta-estado {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--border);
  white-space: nowrap;
}

.estado-pendiente { color: var(--warn); border-color: var(--warn); }
.estado-confirmado { color: var(--info); border-color: var(--info); }
.estado-en_preparacion { color: #d99a6c; border-color: #d99a6c; }
.estado-entregado { color: var(--ok); border-color: var(--ok); }
.estado-cancelado { color: var(--error); border-color: var(--error); }

/* ---------- Filtros ---------- */
.filtros {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.filtros select,
.filtros input[type="search"] {
  background: var(--bg);
  border: 1px solid var(--muted);
  border-radius: 6px;
  color: var(--cream);
  padding: 0.7rem 0.9rem;
  font-size: 0.95rem;
  font-family: inherit;
  min-height: 44px;
}

.filtros input[type="search"] { flex: 1; min-width: 10rem; }

.tabs { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.tabs a {
  flex: 1;
  text-align: center;
  padding: 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  text-decoration: none;
  min-height: 44px;
  font-size: 0.9rem;
}
.tabs a[aria-current="page"] { color: var(--cream); background: var(--brown); border-color: var(--brown); }

/* ---------- Pedido detalle ---------- */
.dato { margin-bottom: 0.9rem; }
.dato-titulo { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin: 0 0 0.2rem; }
.dato-valor { color: var(--cream); margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }

.botones-contacto { display: flex; gap: 0.6rem; flex-wrap: wrap; margin: 0.5rem 0 0; }
.botones-contacto a { flex: 1; min-width: 9rem; }

.item-pedido {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 0.9rem;
  align-items: start;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}

.item-pedido img {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--bg);
}

.item-nombre { color: var(--cream); font-weight: 500; margin: 0 0 0.2rem; overflow-wrap: anywhere; }
.item-linea { font-size: 0.88rem; color: var(--muted); margin: 0; }

.total-grande {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  margin-top: 1rem;
  font-size: 1.3rem;
  color: var(--cream);
  font-weight: 500;
}

.botones-estado { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
.botones-estado button {
  flex: 1 1 8rem;
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--cream);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.7rem 0.5rem;
}
.botones-estado button[aria-pressed="true"] { background: var(--brown); border-color: var(--brown); }
.botones-estado button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Catálogo ---------- */
.fila-producto {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 0.85rem;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radio);
  padding: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.fila-producto img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--bg);
}

.fila-producto-nombre { color: var(--cream); font-weight: 500; margin: 0; overflow-wrap: anywhere; }
.fila-producto-meta { font-size: 0.85rem; color: var(--muted); margin: 0.15rem 0 0; }

.vista-previa {
  width: min(100%, 22rem);
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  display: block;
  margin: 0.6rem 0;
}

.ayuda { font-size: 0.82rem; color: var(--muted); margin: 0.3rem 0 0; }
.aviso-ok { color: var(--ok); font-size: 0.9rem; }
.aviso-error { color: var(--error); font-size: 0.9rem; }

.acciones-fila { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 1rem; }
.acciones-fila .btn { flex: 1; min-width: 8rem; }

/* ---------- Toast / vacío / offline ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bottombar-h) + 1rem);
  transform: translate(-50%, 20px);
  background: var(--soft);
  color: #111;
  padding: 0.7rem 1.2rem;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 500;
  opacity: 0;
  visibility: hidden;
  z-index: 80;
  max-width: calc(100vw - 2rem);
  text-align: center;
}

.toast.visible { opacity: 1; visibility: visible; transform: translate(-50%, 0); }

@media (min-width: 900px) {
  .toast { bottom: 2rem; }
}

.vacio { text-align: center; padding: 3rem 1rem; }
.cargando { text-align: center; padding: 3rem 1rem; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
