/* Estilos compartidos entre la tienda y el panel */
:root {
  --bg: #ffffff;
  --bg-soft: #f4f7f8;
  --surface: #ffffff;
  --text: #1b2433;
  --muted: #64708a;
  --border: #e2e7ef;
  /* Paleta tomada del logo de Todo Herramientas */
  --brand: #0b4aa6;          /* azul royal claro (detalles, íconos, contadores) */
  --primary: #023c86;        /* azul royal del logo (botones) */
  --primary-dark: #0d2749;   /* azul marino del logo */
  --navy: #0d2749;
  --primary-soft: #e8eff9;
  --accent: #e03131;         /* rojo sólo para ofertas */
  --danger: #d23b3b;
  --whatsapp: #25d366;
  --whatsapp-btn: #1e9e50;
  --whatsapp-dark: #188543;
  --warn: #b7791f;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, .12);
  --font: "Krub", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.45; }
img { max-width: 100%; display: block; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
a { color: inherit; }
[hidden] { display: none !important; }
svg.i { width: 22px; height: 22px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.container { max-width: 1240px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); font-size: .9rem; }
.empty { color: var(--muted); text-align: center; padding: 48px 16px; }

/* ---------- botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 9px 16px; border-radius: 10px; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: #f0f2f5; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.whatsapp { background: var(--whatsapp-btn); border-color: var(--whatsapp-btn); color: #fff; }
.btn.whatsapp:hover { background: var(--whatsapp-dark); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 5px 10px; font-size: .85rem; }
.btn.block { width: 100%; padding: 13px 16px; font-size: 1rem; }
.link { background: none; border: 0; color: var(--primary); font: inherit; cursor: pointer; padding: 4px 0; }
.link.danger { color: var(--danger); font-size: .85rem; }
.icon-btn { background: none; border: 0; cursor: pointer; padding: 6px; color: var(--muted); display: inline-flex; border-radius: 8px; }
.icon-btn:hover { background: var(--bg-soft); color: var(--text); }

.badge {
  display: inline-block; min-width: 22px; padding: 1px 7px; border-radius: 999px;
  background: var(--primary); color: #fff; font-size: .8rem; text-align: center;
}

/* ---------- encabezado del panel ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 64px; }
.topbar h1 { font-size: 1.25rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border); background: var(--surface); padding: 6px 14px;
  border-radius: 999px; cursor: pointer; font: inherit; font-size: .9rem;
}
.chip:hover { border-color: var(--brand); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.qty { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: #fff; }
.qty button { border: 0; background: var(--bg-soft); width: 36px; height: 36px; font-size: 1.15rem; cursor: pointer; color: var(--text); }
.qty button:hover:not(:disabled) { background: var(--primary-soft); }
.qty button:disabled { opacity: .4; cursor: not-allowed; }
.qty span { min-width: 34px; text-align: center; font-weight: 600; }

/* ---------- panel lateral (carrito / menú) ---------- */
.overlay { position: fixed; inset: 0; background: rgba(16, 24, 40, .45); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100%);
  background: var(--surface); z-index: 50; display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .22s ease; visibility: hidden;
}
.drawer.left { right: auto; left: 0; transform: translateX(-100%); width: min(320px, 88%); }
.drawer.open { transform: none; visibility: visible; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 16px; border-bottom: 1px solid var(--border); }
.drawer-head h2 { font-size: 1.15rem; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px; }
.drawer-foot { padding: 16px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.drawer-foot:empty { display: none; }
.total { display: flex; justify-content: space-between; font-size: 1.1rem; }

.line { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.line:last-child { border-bottom: 0; }
.line img, .line-noimg { width: 68px; height: 68px; object-fit: contain; border-radius: 8px; background: var(--bg-soft); flex-shrink: 0; border: 1px solid var(--border); }
.line-info { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.line-name { font-weight: 600; font-size: .95rem; }
.line-info .qty { align-self: flex-start; }
.line-right { display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; }

/* ---------- formularios ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form label, .label { display: flex; flex-direction: column; gap: 5px; font-size: .9rem; font-weight: 600; }
.form input:not([type=radio]):not([type=checkbox]), .form select, .form textarea {
  font: inherit; font-weight: 400; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 10px; background: #fff; width: 100%; color: var(--text);
}
.form input:focus, .form select:focus, .form textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
.form .check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
.hint { font-weight: 400; color: var(--muted); font-size: .8rem; }

.seg { display: flex; gap: 8px; border: 0; padding: 0; margin: 0; flex-wrap: wrap; }
.seg label {
  flex: 1; flex-direction: row; align-items: center; gap: 8px; border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; cursor: pointer; font-weight: 500; min-width: 140px;
}
.seg label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }

.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; margin-top: 6px; }
.slot input { position: absolute; opacity: 0; pointer-events: none; }
.slot span { display: block; text-align: center; padding: 8px 0; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-weight: 500; }
.slot input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }
.slot input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.slot.full span { text-decoration: line-through; color: var(--muted); background: #f3f4f6; cursor: not-allowed; }

.success { text-align: center; padding: 24px 8px; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.success .check-icon { width: 64px; height: 64px; border-radius: 50%; background: #e7f6ed; color: var(--whatsapp-btn); display: grid; place-items: center; font-size: 2rem; }

/* ---------- aviso ---------- */
.toast {
  position: fixed; left: 50%; top: 18px; transform: translateX(-50%); z-index: 100;
  background: var(--text); color: #fff; padding: 10px 18px; border-radius: 10px;
  box-shadow: var(--shadow-lg); max-width: calc(100% - 32px); text-align: center;
}
.toast.error { background: var(--danger); }
