/*
  Panel de contenidos Mayans Motos.
  - Tema claro: herramienta de carga usada desde el celular a plena luz.
  - Acento rojo Honda solo en la acción principal y la pestaña activa.
  - Outfit en títulos (misma fuente display del sitio público); sistema en el cuerpo.
*/
:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-sunken: #efede8;
  --ink: #16181d;
  --ink-soft: #4b4f58;
  --ink-faint: #6b6f78;
  --line: #e2dfd8;
  --line-strong: #cbc7be;
  --accent: #d10027;
  --accent-ink: #ffffff;
  --accent-hover: #b30021;
  --danger: #b42318;
  --ok: #067647;
  --warn: #b54708;
  --radius-sm: 6px;
  --radius-md: 10px;
  --font-display: 'Outfit', system-ui, sans-serif;
  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --shadow-drawer: -12px 0 40px rgba(22, 24, 29, 0.18);
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; margin: 0; }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: 40px; padding: 0 0.95rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-weight: 600; font-size: 0.9rem;
  cursor: pointer; white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { background: var(--surface-sunken); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-sunken); }
.btn-danger { color: var(--danger); }
.btn-sm { min-height: 34px; padding: 0 0.7rem; font-size: 0.85rem; }

/* ---------- Login ---------- */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-md); padding: 2rem 1.75rem;
}
.login-brand { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1.75rem; }
.login-brand img { width: 44px; height: 44px; }
.login-brand h1 { font-size: 1.35rem; }
.login-brand p { margin: 0.15rem 0 0; color: var(--ink-faint); font-size: 0.85rem; }
.login-card form { display: grid; gap: 1rem; }
.login-error { color: var(--danger); font-size: 0.88rem; margin: 0; min-height: 1.2em; }

/* ---------- Campos ---------- */
.field { display: grid; gap: 0.35rem; }
.field label, .field .label {
  font-weight: 600; font-size: 0.86rem; color: var(--ink);
}
.field .optional { color: var(--ink-faint); font-weight: 400; }
.input, .select, .textarea {
  width: 100%; min-height: 42px;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface);
}
.textarea { min-height: 88px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.field-hint { margin: 0; font-size: 0.8rem; color: var(--ink-faint); }
.field-error { margin: 0; font-size: 0.8rem; color: var(--danger); }
.field-error:empty { display: none; }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea { border-color: var(--danger); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }

.check {
  display: flex; align-items: center; gap: 0.55rem;
  font-weight: 600; font-size: 0.88rem; cursor: pointer;
}
.check input { width: 18px; height: 18px; accent-color: var(--ink); }

/* Switch de visibilidad: marca un estado real (publicado / oculto) */
.switch { position: relative; display: inline-flex; align-items: center; gap: 0.5rem; cursor: pointer; font-size: 0.82rem; color: var(--ink-soft); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track {
  width: 38px; height: 22px; border-radius: 11px;
  background: var(--line-strong); position: relative; transition: background 0.15s ease;
  flex-shrink: 0;
}
.switch-track::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  transition: transform 0.15s ease;
}
.switch input:checked + .switch-track { background: var(--ok); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ---------- Shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 0.7rem 1.25rem;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.topbar-brand { display: flex; align-items: center; gap: 0.6rem; margin-right: auto; }
.topbar-brand img { width: 32px; height: 32px; }
.topbar-brand strong { font-family: var(--font-display); font-size: 1.05rem; }
.topbar-user { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; color: var(--ink-soft); }

.tabs { max-width: 1080px; margin: 0 auto; padding: 0 1.25rem; display: flex; gap: 0.25rem; overflow-x: auto; }
.tab {
  border: 0; background: none; cursor: pointer;
  padding: 0.7rem 0.9rem; font-weight: 600; color: var(--ink-faint);
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab[aria-selected='true'] { color: var(--ink); border-bottom-color: var(--accent); }

.publish-bar {
  max-width: 1080px; margin: 1rem auto 0; padding: 0 1.25rem;
}
.publish-status {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap;
  padding: 0.65rem 0.9rem; border-radius: var(--radius-sm);
  background: var(--surface-sunken); font-size: 0.86rem; color: var(--ink-soft);
}
.publish-status[data-state='failed'] { background: #fef3f2; color: var(--danger); }
.publish-status[data-state='scheduled'], .publish-status[data-state='running'] { background: #fffaeb; color: var(--warn); }

.page { max-width: 1080px; margin: 0 auto; padding: 1.25rem 1.25rem 4rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h2 { font-size: 1.5rem; }
.page-head p { margin: 0.25rem 0 0; color: var(--ink-faint); font-size: 0.9rem; max-width: 52ch; }
.toolbar { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 0.9rem; }
.toolbar .input { max-width: 320px; }

/* ---------- Listas ---------- */
.list { display: grid; gap: 0.5rem; }
.row {
  display: grid; grid-template-columns: 72px 1fr auto; gap: 0.9rem; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: 0.6rem 0.75rem;
}
.row.is-hidden { background: transparent; }
.row.is-hidden .row-thumb { opacity: 0.5; }
.row-thumb {
  width: 72px; height: 54px; border-radius: var(--radius-sm);
  object-fit: cover; background: var(--surface-sunken);
  display: grid; place-items: center; font-size: 0.7rem; color: var(--ink-faint); font-weight: 600;
}
.row-main { min-width: 0; }
.row-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 0.83rem; color: var(--ink-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-tag {
  display: inline-block; margin-top: 0.2rem; padding: 0.05rem 0.45rem;
  border-radius: 4px; background: #fdecee; color: var(--accent);
  font-size: 0.72rem; font-weight: 700;
}
.row-actions { display: flex; align-items: center; gap: 0.35rem; }
@media (max-width: 640px) {
  .row { grid-template-columns: 60px 1fr; }
  .row-thumb { width: 60px; height: 48px; }
  .row-actions { grid-column: 1 / -1; justify-content: space-between; flex-wrap: wrap; }
}

.empty {
  border: 1px dashed var(--line-strong); border-radius: var(--radius-md);
  padding: 2rem 1.25rem; text-align: center; color: var(--ink-soft);
}
.empty strong { display: block; color: var(--ink); font-size: 1rem; margin-bottom: 0.35rem; }
.empty p { margin: 0 auto 1rem; max-width: 46ch; font-size: 0.9rem; }

.loading { padding: 2rem 0; color: var(--ink-faint); text-align: center; }

/* ---------- Drawer (dialog nativo: foco atrapado y Escape gratis) ---------- */
dialog.drawer {
  margin: 0 0 0 auto; height: 100%; max-height: 100%;
  width: min(620px, 100%); max-width: 100%;
  border: 0; padding: 0; background: var(--bg);
  box-shadow: var(--shadow-drawer);
}
dialog.drawer::backdrop { background: rgba(22, 24, 29, 0.42); }
.drawer-shell { display: grid; grid-template-rows: auto 1fr auto; height: 100%; }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--line);
}
.drawer-head h2 { font-size: 1.15rem; }
.drawer-body { overflow-y: auto; padding: 1.25rem; display: grid; gap: 1.25rem; align-content: start; }
.drawer-foot {
  display: flex; justify-content: flex-end; gap: 0.6rem;
  padding: 0.85rem 1.25rem; background: var(--surface); border-top: 1px solid var(--line);
}
.form-error { margin: 0; color: var(--danger); font-size: 0.88rem; margin-right: auto; align-self: center; }
.form-error:empty { display: none; }

.section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 1rem; display: grid; gap: 0.9rem; }
.section > h3 { font-size: 1rem; }
.section > .section-lead { margin: -0.5rem 0 0; font-size: 0.83rem; color: var(--ink-faint); }
details.section > summary { cursor: pointer; font-family: var(--font-display); font-weight: 700; list-style-position: inside; }
details.section[open] > summary { margin-bottom: 0.2rem; }

.template-note {
  margin: 0; padding: 0.6rem 0.75rem; border-radius: var(--radius-sm);
  background: var(--surface-sunken); font-size: 0.83rem; color: var(--ink-soft);
}

/* ---------- Media ---------- */
.media-field { display: grid; gap: 0.5rem; }
.media-preview {
  position: relative; width: 100%; max-width: 280px; aspect-ratio: 4 / 3;
  border-radius: var(--radius-sm); background: var(--surface-sunken);
  overflow: hidden; display: grid; place-items: center;
  color: var(--ink-faint); font-size: 0.82rem; text-align: center; padding: 0.5rem;
}
.media-preview.is-vertical { aspect-ratio: 9 / 16; max-width: 170px; }
.media-preview img, .media-preview video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.media-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.progress { width: 100%; max-width: 280px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--ink); width: 0; transition: width 0.1s linear; }

.gallery { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.gallery-item { position: relative; width: 84px; height: 64px; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-sunken); }
.gallery-item img { width: 100%; height: 100%; object-fit: cover; }
.gallery-item button {
  position: absolute; top: 3px; right: 3px; width: 24px; height: 24px; border-radius: 50%;
  border: 0; background: rgba(22, 24, 29, 0.78); color: #fff; cursor: pointer; font-size: 0.8rem; line-height: 1;
}

/* ---------- Slides de historia ---------- */
.slide-card { border: 1px solid var(--line); border-radius: var(--radius-md); padding: 0.9rem; display: grid; gap: 0.85rem; background: var(--bg); }
.slide-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.slide-head strong { font-family: var(--font-display); }
.swatches { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.swatch { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.3rem 0.6rem 0.3rem 0.35rem; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); cursor: pointer; font-size: 0.82rem; }
.swatch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.swatch i { width: 18px; height: 18px; border-radius: 4px; display: block; }
.swatch:has(input:checked) { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.swatch:has(input:focus-visible) { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ---------- Usuarios ---------- */
.user-row { grid-template-columns: 1fr auto; }
.user-row .row-actions select { min-height: 34px; padding: 0.2rem 0.5rem; }
@media (max-width: 640px) { .user-row { grid-template-columns: 1fr; } }

/* ---------- Toasts ---------- */
.toasts { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); z-index: 100; display: grid; gap: 0.5rem; width: min(420px, calc(100% - 2rem)); }
.toast { padding: 0.7rem 0.95rem; border-radius: var(--radius-sm); background: var(--ink); color: #fff; font-size: 0.88rem; }
.toast.is-error { background: var(--danger); }

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

