:root {
  --bg: #faf8f6;
  --surface: #ffffff;
  --ink: #26211d;
  --ink-soft: #6b625a;
  --line: #e7e1da;
  --accent: #8a6d3b;
  --accent-dark: #6b5329;
  --danger: #b3453b;
  --danger-bg: #fbeceb;
  --ok: #3f7d5c;
  --ok-bg: #eaf4ee;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(38, 33, 29, 0.08), 0 1px 2px rgba(38, 33, 29, 0.06);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
}

a { color: inherit; }

/* ── Navbar ─────────────────────────────────────────────────────────────── */

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.navbar .brand {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-decoration: none;
  color: var(--ink);
}

.navbar .brand span { color: var(--accent); }

.navbar nav { display: flex; gap: 10px; align-items: center; }

/* ── Buttons ────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover { background: #f2ede7; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); }

.btn-sm { padding: 5px 10px; font-size: 0.8rem; }

.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ── Layout containers ──────────────────────────────────────────────────── */

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.page-title {
  font-size: 1.4rem;
  font-weight: 600;
  margin: 4px 0 20px;
}

/* ── Filtros del catálogo ───────────────────────────────────────────────── */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 22px;
}

.filters input, .filters select {
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 0.9rem;
  color: var(--ink);
}

.filters input { flex: 1; min-width: 200px; }

/* ── Grid de catálogo ───────────────────────────────────────────────────── */

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
}

/* El grid de "Crea tu Set" comparte espacio con el panel lateral (300px), así
   que con minmax(240px) solo entraban 2 columnas en pantallas de escritorio.
   Se fuerzan 3 columnas fijas ahí para que no dependa del ancho sobrante. */
@media (min-width: 801px) {
  .set-main .catalog-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.card-photo {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: #f2ede7;
  display: block;
}

.card-photo.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  font-size: 0.8rem;
}

.card-body { padding: 14px 16px 16px; flex: 1; display: flex; flex-direction: column; gap: 6px; }

.card-marca { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--accent); font-weight: 600; }

.card-nombre { font-size: 1.05rem; font-weight: 600; }

.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 4px; }

.tag {
  font-size: 0.72rem;
  padding: 3px 9px;
  border-radius: 999px;
  background: #f2ede7;
  color: var(--ink-soft);
}

.card-notas { font-size: 0.82rem; color: var(--ink-soft); }

.decant-list { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }

.decant-row { display: flex; justify-content: space-between; align-items: center; font-size: 0.88rem; gap: 8px; }

.decant-row .precio { font-weight: 600; }

.decant-actions { display: flex; align-items: center; gap: 8px; }

.badge-agotado { font-size: 0.72rem; color: var(--danger); background: var(--danger-bg); padding: 2px 8px; border-radius: 999px; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--ink-soft); }

/* ── Formularios ────────────────────────────────────────────────────────── */

.form-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  max-width: 380px;
  margin: 60px auto;
}

.form-card h1 { font-size: 1.2rem; margin: 0 0 18px; }

.field { margin-bottom: 14px; }

.field label { display: block; font-size: 0.85rem; margin-bottom: 5px; color: var(--ink-soft); }

.field input, .field select, .field textarea {
  width: 100%;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--line);
  font-size: 0.92rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--ink);
}

.field textarea { resize: vertical; min-height: 70px; }

.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

.form-error {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 14px;
}

.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* ── Tablas admin ───────────────────────────────────────────────────────── */

.table-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 24px;
}

table { width: 100%; border-collapse: collapse; }

th, td { text-align: left; padding: 11px 14px; font-size: 0.88rem; border-bottom: 1px solid var(--line); }

th { color: var(--ink-soft); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; background: #faf8f6; }

tr:last-child td { border-bottom: none; }

.row-actions { display: flex; gap: 6px; }

.pill {
  font-size: 0.72rem;
  padding: 2px 9px;
  border-radius: 999px;
  font-weight: 600;
}

.pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-off { background: var(--danger-bg); color: var(--danger); }

/* ── Tabs admin ─────────────────────────────────────────────────────────── */

.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }

.tab {
  padding: 10px 18px;
  border: none;
  background: none;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.tab.active { color: var(--accent); border-color: var(--accent); }

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

/* ── Modal ──────────────────────────────────────────────────────────────── */

dialog {
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0;
  max-width: 420px;
  width: 90%;
}

dialog::backdrop { background: rgba(38, 33, 29, 0.35); }

.modal-body { padding: 24px; }

.modal-body h2 { font-size: 1.1rem; margin: 0 0 16px; }

/* ── Decants dentro de un perfume expandido ────────────────────────────── */

.decant-panel {
  background: #faf8f6;
  padding: 14px;
  border-top: 1px solid var(--line);
}

.decant-panel table { background: var(--surface); border-radius: 8px; overflow: hidden; }

.stock-input {
  width: 70px;
  padding: 5px 7px;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.muted { color: var(--ink-soft); font-size: 0.85rem; }

.spinner-text { text-align: center; padding: 40px; color: var(--ink-soft); }

/* ── Chips de filtro (Ocasión / Temperatura) ───────────────────────────── */

.chip-group { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }

.callout-ocasion {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  text-align: center;
  padding: 10px 16px;
  border-radius: var(--radius);
  margin: 4px 0 14px;
}

.chip-group-label { font-size: 0.82rem; color: var(--ink-soft); min-width: 90px; }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  font-size: 0.78rem;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
}

.chip:hover { background: #f2ede7; }

.chip-active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── Checkboxes de Ocasión/Temperatura en el admin ─────────────────────── */

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 6px 10px;
  margin-top: 4px;
}

/* ── Vista previa de precio de decants (cálculo automático) ────────────── */

.price-preview {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 6px;
}

.price-preview-item {
  flex: 1;
  min-width: 80px;
  text-align: center;
}

.price-preview-item .ml { display: block; font-size: 0.72rem; color: var(--ink-soft); }
.price-preview-item .val { display: block; font-size: 1rem; font-weight: 700; color: var(--accent-dark); }

@media (min-width: 641px) {
  .container-admin { max-width: 1400px; }
}

/* ── Inventario: lista apilada (misma lectura en escritorio y en móvil) ─── */

.inventory-list { display: flex; flex-direction: column; }

.inventory-item {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.inventory-item:last-child { border-bottom: none; }

.inventory-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}

.inventory-title { display: flex; flex-direction: column; gap: 2px; }
.inventory-title .nombre { font-weight: 700; font-size: 1rem; }
.inventory-title .marca { color: var(--ink-soft); font-size: 0.85rem; }

.inventory-badges { display: flex; gap: 6px; flex-wrap: wrap; }

.inventory-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  font-size: 0.86rem;
  color: var(--ink-soft);
}

.inventory-meta strong { color: var(--ink); font-weight: 600; }

.inventory-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.checkbox-item { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; font-weight: 400; }
.checkbox-item input { width: auto; }

/* ── Crea tu Set ────────────────────────────────────────────────────────── */

.set-layout { display: grid; grid-template-columns: 1fr 300px; gap: 28px; align-items: start; }

.set-panel {
  position: sticky;
  top: 84px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.set-lista { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }

.set-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
}

.chip-remove {
  border: none;
  background: none;
  color: var(--danger);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.set-mensaje { font-size: 0.85rem; color: var(--ink-soft); margin: 6px 0 14px; }

.set-subtotal-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--ink-soft);
  padding: 2px 0;
}

.set-descuento-row { color: var(--ok); }

.set-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  margin-bottom: 14px;
}

/* ── Banner promocional ─────────────────────────────────────────────────── */

.promo-banner {
  background: var(--accent);
  color: #fff;
  text-align: center;
  padding: 12px 20px;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
}

.promo-banner a { color: #fff; text-decoration: underline; }

/* ── Toast de confirmación (ej. "Agregado al Set") ─────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(12px);
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 300;
  max-width: 90%;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Barra fija de "Agregar al carrito" en móvil (Crea tu Set) ─────────── */

.set-barra-movil { display: none; }

@media (max-width: 800px) {
  .set-layout { grid-template-columns: 1fr; padding-bottom: 76px; }
  .set-panel { position: static; }

  .set-barra-movil {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding: 10px 16px;
    box-shadow: 0 -2px 10px rgba(38, 33, 29, 0.1);
    z-index: 250;
  }

  .set-barra-info { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
  .set-barra-info strong { font-size: 0.88rem; }
  .set-barra-info span { font-size: 0.78rem; color: var(--ink-soft); }

  .set-barra-movil button { flex-shrink: 0; }

  .toast { bottom: 84px; }
}

/* ── Carrito ────────────────────────────────────────────────────────────── */

.carrito-lista { display: flex; flex-direction: column; gap: 12px; margin-bottom: 10px; }

.carrito-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.carrito-foto {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
  background: #f2ede7;
  flex-shrink: 0;
}

.carrito-info { display: flex; flex-direction: column; gap: 2px; flex: 1 1 160px; min-width: 160px; }

.carrito-qty { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

.carrito-subtotal { min-width: 70px; text-align: right; flex: 0 0 auto; }

/* ── Mobile ─────────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  .navbar {
    flex-wrap: wrap;
    row-gap: 8px;
    padding: 12px 16px;
  }

  .navbar nav {
    width: 100%;
    flex-wrap: wrap;
    gap: 8px;
  }

  .navbar .btn { padding: 7px 12px; font-size: 0.84rem; }

  .promo-banner { font-size: 0.8rem; padding: 10px 14px; line-height: 1.4; }

  .container { padding: 16px; }

  .page-title { font-size: 1.2rem; margin: 2px 0 16px; }

  .filters { flex-direction: column; }
  .filters input, .filters select { width: 100%; min-width: 0; }

  .chip-group { flex-direction: column; align-items: flex-start; gap: 4px; }
  .chip-group-label { min-width: 0; }

  .catalog-grid { grid-template-columns: 1fr; gap: 14px; }

  .set-panel { padding: 14px; }

  .carrito-item { flex-wrap: wrap; row-gap: 10px; }
  .carrito-subtotal { margin-left: auto; }

  .form-card { margin: 30px auto; padding: 22px; max-width: 92%; }

  .form-actions { flex-wrap: wrap; }

  .checkbox-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }

  .table-card { overflow-x: auto; }
  .table-card table { min-width: 480px; }

  dialog { max-width: 94%; }
}
