/* ==========================================================================
   Panel de administración. Hereda los tokens de elixir.css.
   Prioridad: densidad, legibilidad y pulgar. Se usa desde el celular.
   ========================================================================== */

body.admin {
  background: var(--bg-deep);
  padding-bottom: 7rem;
}

/* ------------------------------------------------------------------- nav -- */

.anav {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: color-mix(in oklab, var(--bg) 92%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.anav__inner {
  width: min(100% - 2rem, 1100px);
  margin-inline: auto;
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 58px;
  flex-wrap: wrap;
}

.anav__marca {
  font-weight: 800;
  font-stretch: 116%;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  font-size: 1.05rem;
}

.anav__marca span {
  font-weight: 500;
  font-stretch: 100%;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.anav__links {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  overflow-x: auto;
  scrollbar-width: none;
  margin-left: auto;
}

.anav__links::-webkit-scrollbar { display: none; }

.anav__links a {
  flex: none;
  padding: 0.5rem 0.75rem;
  border-radius: var(--r-sm);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
}

.anav__links a:hover { color: var(--primary); background: color-mix(in oklab, var(--primary) 10%, transparent); }
.anav__salir { color: var(--muted); }
.anav__salir:hover { color: var(--peligro) !important; background: color-mix(in oklab, var(--peligro) 14%, transparent) !important; }

/* ---------------------------------------------------------------- layout -- */

.awrap {
  width: min(100% - 2rem, 1100px);
  margin-inline: auto;
  padding-top: 1.5rem;
}

.acab {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.acab h1 {
  font-size: clamp(1.6rem, 6vw, 2.2rem);
  font-weight: 750;
  font-stretch: 108%;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.acab__meta { color: var(--muted); font-size: 0.9rem; margin-top: 0.35rem; max-width: 60ch; }
.acab__meta a { color: var(--primary); }

.aviso {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem 1.1rem;
  border-radius: var(--r-md);
  margin-bottom: 1rem;
  font-weight: 600;
  font-size: 0.92rem;
  border: 1px solid;
  overflow: hidden;
  max-height: 14rem;
  /* Se anima también el alto y los márgenes: si sólo se desvaneciera, el
     contenido de abajo pegaría un salto al desaparecer. */
  transition:
    opacity 0.3s var(--ease),
    translate 0.3s var(--ease),
    max-height 0.4s var(--ease),
    margin-bottom 0.4s var(--ease),
    padding-block 0.4s var(--ease),
    border-width 0.4s var(--ease);
}

.aviso > span { flex: 1; }

.aviso.is-yendo {
  opacity: 0;
  translate: 0 -6px;
  max-height: 0;
  margin-bottom: 0;
  padding-block: 0;
  border-width: 0;
}

.aviso__cerrar {
  flex: none;
  width: 22px;
  height: 22px;
  margin: -0.1rem -0.35rem 0 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: inherit;
  opacity: 0.55;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.aviso__cerrar:hover { opacity: 1; background: color-mix(in oklab, currentColor 16%, transparent); }

.aviso--ok { background: color-mix(in oklab, var(--primary) 14%, var(--bg)); border-color: var(--primary); color: var(--primary); }
.aviso--error { background: color-mix(in oklab, var(--peligro) 16%, var(--bg)); border-color: var(--peligro); color: oklch(0.82 0.13 25); }
.aviso--info { background: var(--bg-deep); border-color: var(--line); color: var(--muted); font-weight: 500; }

.aayuda { color: var(--muted); font-size: 0.85rem; line-height: 1.5; margin-block: 0.35rem 0; }

/* --------------------------------------------------------------- filtros -- */

.afiltros {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: 1.5rem;
}

.afiltros__buscar { position: relative; flex: 1 1 220px; }

.afiltros__buscar svg {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  translate: 0 -50%;
  width: 18px;
  height: 18px;
  color: var(--muted);
  pointer-events: none;
}

.afiltros input[type="search"],
.afiltros select {
  width: 100%;
  min-height: 48px;
  padding: 0.6rem 0.9rem;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.afiltros__buscar input { padding-left: 2.6rem !important; }
.afiltros select { width: auto; min-width: 190px; }
.afiltros .btn { min-height: 48px; }
.alimpiar { color: var(--muted); font-size: 0.88rem; text-decoration: underline; text-underline-offset: 3px; }

/* --------------------------------------------------------------- listado -- */

.afilas { display: grid; gap: 0.6rem; }

.afilas__cat {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--muted);
  margin-top: 1.25rem;
}

.afilas__cat:first-child { margin-top: 0; }

.afila {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas:
    "foto   id     id"
    "precio precio stock"
    "sw     acciones acciones";
  gap: 0.6rem 0.75rem;
  align-items: center;
  padding: 0.75rem;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line);
}

@media (min-width: 880px) {
  .afila {
    grid-template-columns: 52px minmax(0, 1fr) 130px 92px 108px auto;
    grid-template-areas: "foto id precio stock sw acciones";
  }
}

.afila__foto {
  grid-area: foto;
  width: 52px;
  aspect-ratio: 3 / 4;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
  overflow: hidden;
  display: grid;
  place-items: center;
}

.afila__foto img { width: 100%; height: 100%; object-fit: cover; }
.afila__foto .frasco { width: 80%; }

.afila__id { grid-area: id; min-width: 0; }
.afila__nombre { font-weight: 650; font-size: 0.98rem; line-height: 1.25; display: block; }
.afila__nombre:hover { color: var(--primary); }
.afila__marca { color: var(--muted); font-size: 0.8rem; }

.apromo-chip {
  display: inline-block;
  background: var(--primary);
  color: var(--on-fill);
  font-weight: 700;
  font-size: 0.7rem;
  padding: 0.05rem 0.4rem;
  border-radius: 5px;
  margin-left: 0.3rem;
  vertical-align: 1px;
}

.afila__campo { display: grid; gap: 0.25rem; }
.afila__campo:nth-of-type(1) { grid-area: precio; }
.afila__campo--corto { grid-area: stock; }
.afila__campo span { font-size: 0.72rem; color: var(--muted); font-weight: 600; }

.afila__campo input {
  width: 100%;
  min-height: 44px;
  padding: 0.4rem 0.6rem;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--bg-deep);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

.afila__campo input:focus { border-color: var(--primary); outline: none; }

.afila__acciones { grid-area: acciones; display: flex; gap: 0.4rem; justify-content: flex-end; }

/* --------------------------------------------------------------- switch -- */

.aswitch {
  grid-area: sw;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}

.aswitch input { position: absolute; opacity: 0; width: 0; height: 0; }

.aswitch span {
  width: 40px;
  height: 24px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  border: 1px solid var(--line);
  position: relative;
  flex: none;
  transition: background-color 0.25s var(--ease), border-color 0.25s;
}

.aswitch span::after {
  content: "";
  position: absolute;
  inset: 2px auto 2px 2px;
  width: 18px;
  border-radius: var(--r-full);
  background: var(--muted);
  transition: translate 0.3s var(--ease), background-color 0.25s;
}

.aswitch input:checked + span { background: color-mix(in oklab, var(--primary) 30%, var(--bg)); border-color: var(--primary); }
.aswitch input:checked + span::after { translate: 16px 0; background: var(--primary); }
.aswitch input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.aswitch small { font-size: 0.82rem; color: var(--muted); }

/* -------------------------------------------------------------- botones -- */

.abtn-mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 0.85rem;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background-color 0.2s;
}

.abtn-mini:hover { border-color: var(--primary); color: var(--primary); }
.abtn-mini--peligro { color: var(--muted); }
.abtn-mini--peligro:hover { border-color: var(--peligro); color: oklch(0.82 0.13 25); background: color-mix(in oklab, var(--peligro) 12%, transparent); }

.abarra-guardar {
  position: sticky;
  bottom: 0;
  z-index: var(--z-sticky);
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
  padding: 0.85rem 0 calc(0.85rem + env(safe-area-inset-bottom, 0px));
  margin-top: 1.5rem;
  background: linear-gradient(to top, var(--bg-deep) 65%, transparent);
}

/* ------------------------------------------------------------ formularios */

.aform { display: grid; gap: 1rem; }
.aform--ancho { max-width: 900px; }

.apanel {
  padding: clamp(1rem, 4vw, 1.5rem);
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--line);
  display: grid;
  gap: 0.9rem;
  align-content: start;
}

.apanel h2 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--muted);
}

.apanel h3 { font-size: 0.95rem; font-weight: 650; }

.apanel--nuevo {
  background: color-mix(in oklab, var(--primary) 7%, var(--surface));
  border-color: color-mix(in oklab, var(--primary) 35%, var(--line));
}

.agrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0.85rem; }
.agrid__ancho { grid-column: 1 / -1; }

.achecks { display: flex; flex-wrap: wrap; gap: 1rem 1.5rem; }
.achecks .aswitch { grid-area: auto; }

.apromo {
  display: grid;
  gap: 0.85rem;
  padding: 1rem;
  border-radius: var(--r-md);
  background: var(--bg-deep);
  border: 1px solid var(--line);
}

.apromo__pie {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.apromo .aswitch { grid-area: auto; }

/* ----------------------------------------------------------------- fotos -- */

.afotos { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 0.75rem; }

.afoto {
  position: relative;
  margin: 0;
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--bg-deep);
  aspect-ratio: 3 / 4;
}

.afoto img { width: 100%; height: 100%; object-fit: cover; }

.afoto__pill {
  position: absolute;
  top: 0.4rem;
  left: 0.4rem;
  background: var(--primary);
  color: var(--on-fill);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.12rem 0.4rem;
  border-radius: var(--r-sm);
}

.afoto__acciones {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  gap: 0.3rem;
  padding: 0.4rem;
  background: linear-gradient(to top, oklch(0.08 0.02 288 / 0.92), transparent);
}

.afoto__acciones .abtn-mini {
  min-height: 32px;
  padding: 0 0.5rem;
  font-size: 0.75rem;
  background: color-mix(in oklab, var(--bg-deep) 70%, transparent);
  backdrop-filter: blur(4px);
}

.ahero-foto { display: grid; grid-template-columns: 110px 1fr; gap: 1rem; align-items: start; }

.ahero-foto__vista {
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--bg-deep);
  aspect-ratio: 3 / 4;
  overflow: hidden;
  display: grid;
  place-items: center;
  padding: 0.5rem;
}

.ahero-foto__vista img,
.ahero-foto__vista video { width: 100%; height: 100%; object-fit: contain; }

.ahero-foto__falta { color: var(--muted); font-size: 0.75rem; text-align: center; }

.ahero-foto + .ahero-foto { border-top: 1px solid var(--line); padding-top: 1rem; }

.apanel code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.88em;
  padding: 0.1em 0.35em;
  border-radius: 5px;
  background: var(--bg-deep);
  border: 1px solid var(--line);
}

/* ---------------------------------------------------------------- vacío -- */

.avacio {
  display: grid;
  justify-items: center;
  gap: 0.6rem;
  text-align: center;
  padding: clamp(2.5rem, 12vw, 5rem) 1.5rem;
  border-radius: var(--r-lg);
  border: 1px dashed var(--line);
  background: var(--surface);
}

.avacio svg { width: 38px; height: 38px; color: var(--primary); }
.avacio h2 { font-size: 1.25rem; font-weight: 700; }
.avacio p { color: var(--muted); max-width: 44ch; }
.avacio .btn { margin-top: 0.75rem; }

/* ------------------------------------------------------------ ver clave -- */

.aclave { position: relative; display: block; }

/* Deja lugar para el ojo, si no el texto le pasa por abajo. */
.aclave input { padding-right: 3.1rem !important; }

.aclave__ojo {
  position: absolute;
  right: 0.4rem;
  top: 50%;
  translate: 0 -50%;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s, background-color 0.2s;
}

.aclave__ojo:hover {
  color: var(--primary);
  background: color-mix(in oklab, var(--primary) 12%, transparent);
}

.aclave__ojo[aria-pressed="true"] { color: var(--primary); }
.aclave__ojo svg { width: 20px; height: 20px; }

/* ---------------------------------------------------------------- login -- */

.login { min-height: 100svh; display: grid; place-items: center; padding: 1.5rem; }

.login__caja {
  width: min(100%, 400px);
  padding: clamp(1.5rem, 6vw, 2.5rem);
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--line);
  display: grid;
  gap: 0.9rem;
}

.login__marca {
  font-weight: 800;
  font-stretch: 118%;
  text-transform: uppercase;
  letter-spacing: -0.025em;
  font-size: 1.5rem;
  color: var(--primary);
  line-height: 1;
}

.login__caja h1 { font-size: 1.45rem; font-weight: 700; letter-spacing: -0.015em; line-height: 1.15; }
.login__ayuda { color: var(--muted); font-size: 0.9rem; }
.login__caja .aform { gap: 0.85rem; margin-top: 0.35rem; }
.login__volver { text-align: center; font-size: 0.85rem; }
.login__volver a { color: var(--muted); }
.login__volver a:hover { color: var(--primary); }
