/* ============================================================
   ASTERIA · Panel de administración
   ============================================================ */
body.admin {
  background: #F6F2EC;
  /* el sidebar usa los tokens del pie: aquí vuelven a ser oscuros */
  --footer-bg: #221D1D;
  --footer-ink: #F4EBDD;
}

/* Velo para cerrar el menú lateral en móvil */
.scrim { position: fixed; inset: 0; background: rgba(30,18,53,.5); z-index: 90; }

/* ---- Login ---- */
.login { min-height: 100vh; display: grid; place-items: center; padding: var(--gutter); }
.login__card { background: var(--ivory); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: clamp(2rem,5vw,3.5rem); width: min(420px, 100%); text-align: center; }
.login__card img { height: 54px; margin: 0 auto var(--s-5); }
.login__card h1 { font-size: 1.8rem; margin-bottom: var(--s-2); }
.login__card p { margin: 0 auto var(--s-6); font-size: .9rem; }
.login__err { color: var(--danger); font-size: .82rem; min-height: 1.2em; margin-top: .5rem; }

/* ---- Shell ---- */
.admin-shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar { background: var(--footer-bg); color: var(--footer-ink); padding: var(--s-6) var(--s-5); position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain; }
.sidebar__logo img { height: 40px; margin-bottom: var(--s-7); }
.sidebar__nav { display: flex; flex-direction: column; gap: .25rem; flex: 1; }
.sidebar__nav button {
  display: flex; align-items: center; gap: .75rem; width: 100%; text-align: left;
  padding: .8em 1em; border-radius: var(--r-sm); font-size: .9rem; font-weight: 500;
  color: color-mix(in srgb, var(--footer-ink) 80%, transparent); transition: all var(--dur-fast);
}
.sidebar__nav button:hover { background: rgba(255,255,255,.06); color: var(--ivory); }
.sidebar__nav button.is-active { background: var(--cocoa); color: var(--ivory); }
.sidebar__nav svg { width: 19px; height: 19px; flex: none; }
.sidebar__foot { border-top: 1px solid color-mix(in srgb, var(--footer-ink) 18%, transparent); padding-top: var(--s-4); display: grid; gap: .5rem; }
.sidebar__foot a, .sidebar__foot button { font-size: .82rem; color: color-mix(in srgb, var(--footer-ink) 75%, transparent); text-align: left; padding: .4em 0; }
.sidebar__foot a:hover, .sidebar__foot button:hover { color: var(--ivory); }

.admin-main { padding: clamp(1.5rem,3vw,3rem); max-width: 1000px; }
.admin-head { margin-bottom: var(--s-6); }
.admin-head .eyebrow { color: var(--lilac-deep); }
.admin-head h1 { font-size: clamp(2rem,4vw,2.8rem); margin-top: var(--s-2); }
.admin-head p { margin-top: var(--s-3); font-size: .95rem; }
.panel { display: none; }
.panel.is-active { display: block; animation: fadeIn .3s var(--ease); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } }

/* ---- Tarjetas ---- */
.acard { background: var(--ivory); border: 1px solid var(--line); border-radius: var(--r); padding: clamp(1.2rem,3vw,2rem); margin-bottom: var(--s-5); }
.acard__head { display: flex; justify-content: space-between; align-items: center; gap: var(--s-4); margin-bottom: var(--s-5); flex-wrap: wrap; }
.acard__head h3 { font-size: 1.4rem; }
.acard__head .sub { font-size: .85rem; color: var(--ink-faint-text); margin-top: .2rem; }

/* ---- Guía de carga (instrucciones) ---- */
.guide { background: var(--lilac-soft); border: 1px solid color-mix(in srgb, var(--lilac) 40%, transparent); border-radius: var(--r-sm); padding: var(--s-4) var(--s-5); margin-bottom: var(--s-5); }
.guide h4 { display: flex; align-items: center; gap: .5rem; font-family: var(--font-body); font-size: .82rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--plum); margin-bottom: .6rem; }
.guide h4 svg { width: 16px; height: 16px; }
.guide__purpose { font-size: .88rem; color: var(--ink-soft); margin-bottom: .7rem; }
.guide__specs { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .7rem; }
.guide__specs li { font-size: .74rem; background: var(--white); border: 1px solid color-mix(in srgb, var(--lilac) 35%, transparent); border-radius: var(--r-pill); padding: .3em .9em; color: var(--plum); font-weight: 600; }
.guide__tip { font-size: .84rem; color: var(--ink-soft); }
.guide__tip strong { color: var(--cocoa); }

/* ---- Dropzone ---- */
.dropzone {
  border: 1.5px dashed var(--line-strong); border-radius: var(--r-sm); padding: var(--s-6);
  text-align: center; color: var(--ink-faint-text); cursor: pointer; transition: all var(--dur-fast);
  background: var(--cream);
}
.dropzone:hover, .dropzone.is-drag { border-color: var(--lilac-deep); background: var(--lilac-soft); color: var(--plum); }
.dropzone svg { width: 34px; height: 34px; margin: 0 auto .5rem; color: var(--lilac-deep); }
.dropzone strong { display: block; font-family: var(--font-body); font-weight: 600; color: var(--ink); }
.dropzone span { font-size: .8rem; }

/* ---- Miniaturas / previews ---- */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: var(--s-3); margin-top: var(--s-4); }
.thumb { position: relative; aspect-ratio: 4/5; border-radius: var(--r-xs); overflow: hidden; border: 1px solid var(--line); background: var(--cream); }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; }
.thumb__rm { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: var(--r-pill); background: rgba(34,29,29,.72); color: #fff; font-size: 13px; display: flex; align-items: center; justify-content: center; }
.thumb__rm:hover { background: var(--danger); }
.thumb__main { position: absolute; bottom: 4px; left: 4px; font-size: .68rem; background: var(--cocoa); color: #fff; padding: .2em .5em; border-radius: var(--r-pill); letter-spacing: .06em; }
.preview-single { max-width: 280px; aspect-ratio: 4/5; background: var(--cream); border-radius: var(--r-sm); overflow: hidden; border: 1px solid var(--line); margin-top: var(--s-4); position: relative; }
.preview-single img, .preview-single video { width: 100%; height: 100%; object-fit: contain; display: block; }

/* ---- Form grid ---- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-4); }
@media (max-width: 720px){ .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ---- Lista de productos ---- */
.plist { display: grid; gap: var(--s-3); }
.prow { display: grid; grid-template-columns: 64px 1fr auto auto; gap: var(--s-4); align-items: center; background: var(--ivory); border: 1px solid var(--line); border-radius: var(--r-sm); padding: var(--s-3) var(--s-4); }
.prow img { width: 64px; height: 80px; object-fit: cover; border-radius: var(--r-xs); }
.prow__name { font-family: var(--font-display); font-size: 1.2rem; color: var(--ink); }
.prow__meta { font-size: .8rem; color: var(--ink-faint-text); }
.prow__tags { display: flex; gap: .3rem; margin-top: .2rem; }
.prow__actions { display: flex; gap: .4rem; }
.icon-mini { width: 36px; height: 36px; border-radius: var(--r-sm); border: 1px solid var(--line-strong); display: inline-flex; align-items: center; justify-content: center; color: var(--ink-soft); transition: all var(--dur-fast); }
.icon-mini:hover { border-color: var(--cocoa); color: var(--cocoa); }
.icon-mini[disabled] { opacity: .25; cursor: default; pointer-events: none; }
.icon-mini.danger:hover { border-color: var(--danger); color: var(--danger); }
.icon-mini svg { width: 17px; height: 17px; }

/* ---- Toggle switch ---- */
.switch { display: inline-flex; align-items: center; gap: .8rem; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch__track { width: 50px; height: 28px; border-radius: var(--r-pill); background: var(--line-strong); position: relative; transition: background var(--dur-fast); flex: none; }
.switch__track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: var(--r-pill); background: #fff; transition: transform var(--dur-fast); box-shadow: var(--shadow-sm); }
.switch input:checked + .switch__track { background: var(--ok); }
.switch input:checked + .switch__track::after { transform: translateX(22px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--lilac-deep); outline-offset: 2px; }
.switch__label { font-weight: 600; color: var(--ink); }

.pay-state { display: inline-flex; align-items: center; gap: .5rem; font-size: .8rem; font-weight: 600; padding: .4em 1em; border-radius: var(--r-pill); }
.pay-state.on { background: #DCFCE7; color: var(--ok); }
.pay-state.off { background: var(--lilac-soft); color: var(--lilac-deep); }

/* ---- Editor modal de producto ---- */
.modal-scrim { position: fixed; inset: 0; background: rgba(30,18,53,.55); z-index: 200; display: none; align-items: flex-start; justify-content: center; overflow-y: auto; padding: var(--s-6) var(--gutter); }
.modal-scrim.is-open { display: flex; }
.modal { background: var(--ivory); border-radius: var(--r-lg); width: min(720px, 100%); box-shadow: var(--shadow-lg); }
.modal__head { display: flex; justify-content: space-between; align-items: center; padding: var(--s-5) var(--s-6); border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--ivory); border-radius: var(--r-lg) var(--r-lg) 0 0; z-index: 2; }
.modal__body { padding: var(--s-6); }
.modal__foot { padding: var(--s-5) var(--s-6); border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: var(--s-3); position: sticky; bottom: 0; background: var(--ivory); }

/* ---- Indicador de guardado ---- */
.saved-pill { position: fixed; right: 1.5rem; bottom: 1.5rem; background: var(--ok); color: #fff; padding: .8em 1.4em; border-radius: var(--r-pill); font-size: .85rem; box-shadow: var(--shadow); opacity: 0; transform: translateY(10px); transition: all var(--dur-fast); z-index: 300; }
.saved-pill.show { opacity: 1; transform: none; }
.saved-pill.error { background: var(--danger); }

.field-row { display: flex; align-items: center; justify-content: space-between; padding: var(--s-4) 0; border-bottom: 1px solid var(--line-soft); gap: var(--s-4); flex-wrap: wrap; }
.field-row:last-child { border-bottom: 0; }
.field-row__info h4 { font-family: var(--font-body); font-size: .95rem; font-weight: 600; color: var(--ink); }
.field-row__info p { font-size: .82rem; color: var(--ink-faint-text); margin-top: .2rem; max-width: 52ch; }

.danger-zone { border-color: color-mix(in srgb, var(--danger) 30%, var(--line)); }
.btn--danger { --btn-bg: transparent; --btn-fg: var(--danger); --btn-bd: color-mix(in srgb, var(--danger) 45%, transparent); }
.btn--danger:hover { --btn-bg: var(--danger); --btn-fg: #fff; --btn-bd: var(--danger); }

.mobile-topbar { display: none; }
@media (max-width: 820px) {
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 100; transform: translateX(-100%); transition: transform var(--dur) var(--ease); width: 260px; }
  .sidebar.is-open { transform: none; }
  .mobile-topbar { display: flex; align-items: center; justify-content: space-between; padding: var(--s-4) var(--gutter); background: var(--ivory); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50; }
  .mobile-topbar img { height: 32px; }
}

/* Botones de icono (cerrar modal, menú móvil) */
.icon-btn { width: 42px; height: 42px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--r-pill); color: var(--ink); transition: background var(--dur-fast) var(--ease); }
.icon-btn:hover { background: var(--cream); }
.icon-btn svg { width: 21px; height: 21px; }
.modal-scrim.is-open { animation: fadeIn .22s var(--ease); }
.modal-scrim.is-open .modal { animation: fadeIn .3s var(--ease); }

/* ---- Editor de producto: controles intuitivos ---- */
.size-chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.schip {
  padding: .6em 1.1em; border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  font-size: .78rem; font-weight: 600; letter-spacing: .06em; color: var(--ink-soft);
  transition: all var(--dur-fast) var(--ease);
}
.schip:hover { border-color: var(--ink); color: var(--ink); }
.schip.is-on { background: var(--ink); border-color: var(--ink); color: var(--white); }

.palette { display: flex; flex-wrap: wrap; gap: .5rem; }
.palette__dot {
  width: 30px; height: 30px; border-radius: 50%; border: 0; cursor: pointer;
  box-shadow: 0 0 0 1px var(--line-strong);
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.palette__dot:hover { transform: scale(1.15); box-shadow: 0 0 0 1.5px var(--ink); }
.palette__dot.is-used { opacity: .25; cursor: default; transform: none; box-shadow: 0 0 0 1px var(--line-strong); }

.color-row {
  display: flex; align-items: center; gap: .7rem; flex-wrap: wrap;
  padding: .6rem .7rem; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--white);
}
.color-dot { width: 26px; height: 26px; border-radius: 50%; flex: 0 0 auto; box-shadow: 0 0 0 1px var(--line-strong); }
.photo-pick { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; flex: 1; }
.photo-pick__t {
  width: 40px; height: 50px; border-radius: var(--r-xs); overflow: hidden; padding: 0;
  border: 2px solid transparent; opacity: .55; transition: all var(--dur-fast) var(--ease);
}
.photo-pick__t img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-pick__t:hover { opacity: 1; }
.photo-pick__t.is-on { border-color: var(--ink); opacity: 1; box-shadow: var(--shadow-sm); }

.thumb__nav {
  position: absolute; bottom: 4px; right: 4px;
  width: 26px; height: 26px; border-radius: var(--r-xs);
  background: rgba(34,29,29,.72); color: #fff; font-size: .7rem;
  display: flex; align-items: center; justify-content: center;
}
.thumb__nav.left { right: 34px; }
.thumb__nav[disabled] { opacity: .3; }
.thumb__main--alt { background: var(--lilac-deep); }
