/* =========================================================
   Tienda conectada: carrito, checkout, acceso, cuenta y administración
   (usa los colores y tipografías de styles.css)
   ========================================================= */

/* ---------- Carrito lateral ---------- */
html.cart-open { overflow: hidden; }
.cart-drawer { position: fixed; inset: 0; z-index: 120; }
.cart-drawer__scrim { position: absolute; inset: 0; background: rgba(14, 42, 31, .5); opacity: 0; transition: opacity .25s; }
.cart-drawer__panel {
  position: absolute; right: 0; top: 0; bottom: 0;
  width: min(440px, 100%);
  display: flex; flex-direction: column;
  background: var(--paper);
  box-shadow: -20px 0 50px -20px rgba(0, 0, 0, .45);
  transform: translateX(100%);
  transition: transform .3s var(--ease);
}
.cart-drawer.is-open .cart-drawer__scrim { opacity: 1; }
.cart-drawer.is-open .cart-drawer__panel { transform: none; }
.cart-drawer__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px 14px; background: var(--teal); color: var(--cream-50);
  border-bottom: 4px solid var(--ochre);
}
.cart-drawer__head h2 { color: var(--cream-50); font-size: 1.6rem; }
.cart-drawer__close { width: 44px; height: 44px; border: 0; border-radius: 50%; background: rgba(251, 243, 230, .12); color: var(--cream-50); font-size: 1.8rem; line-height: 1; }
.cart-drawer__close:hover { background: rgba(251, 243, 230, .25); }
.cart-drawer__body { flex: 1; overflow-y: auto; padding: 16px 22px; }
.cart-drawer__foot { padding: 14px 22px 22px; border-top: 1px solid rgba(92, 64, 51, .14); background: var(--cream-50); }
.cart-empty { display: grid; justify-items: center; gap: 16px; padding: 48px 0; text-align: center; }
.cart-loading, .cart-note { font-size: .88rem; color: var(--brown); }
.cart-warn { padding: 10px 12px; border-radius: 10px; background: rgba(200, 32, 26, .1); color: var(--red-900); font-size: .9rem; margin-bottom: 10px; }
.cart-lines { display: grid; gap: 12px; }
.cart-line { display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: start; padding: 12px; background: var(--cream-50); border-radius: 14px; }
.cart-line img { width: 64px; height: 64px; object-fit: contain; }
.cart-line__info { display: grid; gap: 2px; }
.cart-line__info b { font-family: var(--font-display); font-weight: 400; font-size: 1.05rem; color: var(--forest); line-height: 1.2; }
.cart-line__info small { font-size: .78rem; color: var(--brown); }
.cart-line__disc { color: #1F6B32 !important; font-weight: 700; }
.cart-line__qty { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-weight: 700; color: var(--forest); }
.cart-line__qty button[data-step] { width: 40px; height: 40px; border: 0; border-radius: 50%; background: rgba(26, 120, 102, .12); color: var(--forest); font-size: 1.1rem; }
.cart-line__qty button:disabled { opacity: .35; }
.cart-line__remove { margin-left: auto; padding: 10px 4px; border: 0; background: none; color: var(--red-900); font-size: .78rem; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.cart-line__price { font-weight: 700; color: var(--forest); white-space: nowrap; }
.cart-ship { font-size: .88rem; margin-bottom: 6px; }
.cart-ship__bar { height: 6px; border-radius: 99px; background: rgba(92, 64, 51, .12); overflow: hidden; margin-bottom: 12px; }
.cart-ship__bar span { display: block; height: 100%; width: calc(var(--p) * 100%); background: var(--teal); border-radius: inherit; }
.cart-totals { display: grid; gap: 4px; margin-bottom: 12px; }
.cart-totals div { display: flex; justify-content: space-between; font-size: .95rem; }
.cart-totals .is-disc { color: #1F6B32; font-weight: 700; }
.cart-totals .is-total { padding-top: 8px; margin-top: 4px; border-top: 1px dashed rgba(92, 64, 51, .25); font-weight: 700; font-size: 1.15rem; color: var(--forest); }
.cart-go { width: 100%; margin-top: 6px; }

/* ---------- Páginas de la tienda conectada ---------- */
.shell { width: min(1160px, calc(100% - var(--gutter) * 2)); margin-inline: auto; padding-block: clamp(28px, 5vw, 56px) clamp(48px, 7vw, 88px); }
.shell--narrow { width: min(520px, calc(100% - var(--gutter) * 2)); }
.page-title { font-size: clamp(2rem, 4vw, 2.8rem); margin-bottom: .4rem; }
.page-lead { margin-bottom: 1.6rem; }
.card {
  background: var(--cream-50);
  border-radius: 20px;
  padding: clamp(18px, 2.6vw, 30px);
  box-shadow: 0 1px 0 rgba(92, 64, 51, .08), 0 24px 44px -34px rgba(43, 31, 24, .6);
}
.card + .card { margin-top: 18px; }
.card h2 { font-size: clamp(1.35rem, 2vw, 1.7rem); margin-bottom: .8rem; }
.card h3 { font-size: 1.15rem; margin-bottom: .5rem; }

/* Formularios */
.form { display: grid; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.field { display: grid; gap: 6px; }
.field > span, .field-label { font-size: .72rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--brown); }
.field input, .field select, .field textarea {
  width: 100%; min-height: 48px; padding: 10px 14px;
  border: 1.5px solid rgba(92, 64, 51, .25); border-radius: 12px;
  background: #fff; color: var(--forest); font: inherit; font-size: 1rem;
}
.field textarea { min-height: 84px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 3px solid var(--ochre-300); outline-offset: 1px; border-color: var(--teal); }
.field input[aria-invalid="true"] { border-color: var(--red); }
.field small { font-size: .8rem; color: var(--brown); }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: .92rem; line-height: 1.45; cursor: pointer; }
.check input { flex: none; width: 20px; height: 20px; margin-top: 1px; accent-color: var(--teal); }
.check a { color: var(--teal-800); font-weight: 700; text-underline-offset: 3px; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; }
.link { color: var(--teal-800); font-weight: 700; text-underline-offset: 3px; background: none; border: 0; padding: 0; font: inherit; cursor: pointer; text-decoration: underline; }

/* Avisos */
.alert { padding: 12px 16px; border-radius: 12px; font-size: .95rem; line-height: 1.45; }
.alert--error { background: rgba(200, 32, 26, .1); color: var(--red-900); }
.alert--ok { background: rgba(46, 138, 71, .12); color: #1F6B32; }
.alert--info { background: rgba(26, 120, 102, .1); color: var(--teal-800); }
.alert--warn { background: rgba(174, 99, 8, .12); color: #7A4506; }
.alert[hidden] { display: none; }

/* Estados */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: .38em .8em .28em; border-radius: 999px;
  font-size: .7rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; white-space: nowrap;
  background: rgba(92, 64, 51, .1); color: var(--brown);
}
.badge--pending_payment, .badge--awaiting_payment { background: rgba(174, 99, 8, .14); color: #7A4506; }
.badge--paid { background: rgba(26, 120, 102, .14); color: var(--teal-800); }
.badge--preparing { background: rgba(242, 182, 50, .2); color: #6B4A06; }
.badge--shipped { background: rgba(14, 42, 31, .12); color: var(--forest); }
.badge--delivered, .badge--active { background: rgba(46, 138, 71, .16); color: #1F6B32; }
.badge--cancelled, .badge--skipped, .badge--expired { background: rgba(92, 64, 51, .1); color: rgba(72, 50, 40, .75); }
.badge--payment_failed { background: rgba(200, 32, 26, .12); color: var(--red-900); }
.badge--paused { background: rgba(174, 99, 8, .14); color: #7A4506; }

/* ---------- Checkout ---------- */
.checkout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, .85fr); gap: clamp(18px, 3vw, 36px); align-items: start; }
.checkout__summary { position: sticky; top: 96px; }
.sum-lines { display: grid; gap: 10px; margin-bottom: 14px; }
.sum-line { display: grid; grid-template-columns: 52px 1fr auto; gap: 10px; align-items: center; }
.sum-line img { width: 52px; height: 52px; object-fit: contain; }
.sum-line b { display: block; color: var(--forest); font-weight: 700; font-size: .95rem; }
.sum-line small { font-size: .78rem; }
.pay-box { margin-top: 16px; display: grid; gap: 12px; justify-items: stretch; }
.pay-box__bold { min-height: 56px; display: grid; place-items: center; }
.pay-secure { display: flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--brown); }
.pay-secure svg { width: 18px; height: 18px; fill: none; stroke: var(--teal); stroke-width: 1.8; }
.auth-choice { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 6px; }
.auth-choice button { min-height: 48px; border-radius: 12px; border: 1.5px solid rgba(92, 64, 51, .25); background: #fff; color: var(--forest); font-weight: 700; font-size: .85rem; letter-spacing: .08em; text-transform: uppercase; }
.auth-choice button[aria-pressed="true"] { background: var(--forest); color: var(--cream-50); border-color: var(--forest); }

/* Resultado del pago */
.result { text-align: center; display: grid; justify-items: center; gap: 14px; }
.result__icon { width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center; box-shadow: 0 0 0 8px var(--cream-50), 0 0 0 12px var(--ring, var(--teal)); background: var(--ring, var(--teal)); color: #fff; }
.result__icon svg { width: 48px; height: 48px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.result--ok { --ring: #2E8A47; }
.result--fail { --ring: var(--red); }
.result--wait { --ring: var(--ochre); }
.result--wait .result__icon svg { animation: spin 1.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Acceso ---------- */
.auth-card { margin-top: 8px; }
.auth-card .form-actions .btn { flex: 1 1 auto; }
.auth-alt { margin-top: 14px; font-size: .92rem; text-align: center; }

/* ---------- Pestañas (cuenta y administración) ---------- */
.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a, .tabs button {
  flex: none; padding: .7em 1.1em .55em; border-radius: 999px; border: 0; background: transparent;
  color: var(--brown); font-weight: 700; font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; text-decoration: none; cursor: pointer;
}
.tabs a:hover, .tabs button:hover { background: rgba(26, 120, 102, .1); }
.tabs [aria-current="page"], .tabs [aria-selected="true"] { background: var(--forest); color: var(--cream-50); }

/* Tablas */
.table-wrap { overflow-x: auto; border-radius: 14px; box-shadow: inset 0 0 0 1px rgba(92, 64, 51, .12); background: #fff; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid rgba(92, 64, 51, .1); vertical-align: middle; }
.table th { font-size: .68rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--brown); background: var(--cream-50); position: sticky; top: 0; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: rgba(26, 120, 102, .04); }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table .mono { font-family: ui-monospace, Consolas, monospace; font-size: .82rem; }
.table button.link { font-size: .85rem; }
.empty { padding: 28px; text-align: center; color: var(--brown); }

/* Línea de tiempo del pedido */
.timeline { display: grid; gap: 0; margin-top: 6px; }
.timeline li { position: relative; padding: 0 0 14px 26px; font-size: .9rem; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 3px rgba(26, 120, 102, .18); }
.timeline li::after { content: ""; position: absolute; left: 9.5px; top: 18px; bottom: 0; width: 1px; background: rgba(92, 64, 51, .2); }
.timeline li:last-child::after { display: none; }
.timeline small { display: block; color: var(--brown); font-size: .76rem; }

/* ---------- Administración ---------- */
.admin-page { background: #F3EBDD; }
.admin { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.admin__side { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--forest); color: var(--cream); padding: 22px 16px; display: flex; flex-direction: column; gap: 18px; }
.admin__brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.admin__brand img:first-child { height: 40px; width: auto; }
.admin__brand img:last-child { height: 15px; width: auto; }
.admin__nav { display: grid; gap: 4px; }
.admin__nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: rgba(245, 230, 211, .86); text-decoration: none; font-weight: 600; font-size: .92rem; }
.admin__nav a:hover { background: rgba(245, 230, 211, .08); color: #fff; }
.admin__nav a[aria-current="page"] { background: var(--teal); color: #fff; }
.admin__nav svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.admin__side-foot { margin-top: auto; font-size: .8rem; color: rgba(245, 230, 211, .7); display: grid; gap: 8px; }
.admin__side-foot a, .admin__side-foot button { color: var(--cream); }
.admin__main { padding: clamp(18px, 3vw, 34px); min-width: 0; }
.admin__top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.admin__top h1 { font-size: clamp(1.7rem, 3vw, 2.3rem); }
.admin__menu { display: none; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { padding: 16px 18px; border-radius: 16px; background: #fff; box-shadow: inset 0 0 0 1px rgba(92, 64, 51, .1); }
.kpi span { display: block; font-size: .68rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--brown); }
.kpi b { display: block; margin-top: 6px; font-family: var(--font-display); font-weight: 400; font-size: clamp(1.4rem, 2.2vw, 1.9rem); color: var(--forest); }
.kpi small { color: var(--brown); font-size: .8rem; }
.admin-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 14px; }
.filters .field { min-width: 150px; }
.filters .field input, .filters .field select { min-height: 42px; padding: 6px 12px; font-size: .92rem; }
.btn--sm2 { min-height: 42px; padding: .7em 1.1em .55em; font-size: .72rem; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding-top: 8px; }
.bars span { flex: 1; min-width: 4px; background: var(--teal); border-radius: 4px 4px 0 0; opacity: .85; }
.bars span:hover { opacity: 1; background: var(--ochre); }
.status-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.dialog { border: 0; border-radius: 20px; padding: 0; width: min(760px, calc(100% - 24px)); max-height: calc(100vh - 40px); box-shadow: 0 40px 80px -30px rgba(0, 0, 0, .6); background: var(--paper); color: var(--brown); }
.dialog::backdrop { background: rgba(14, 42, 31, .55); }
.dialog__head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 22px; background: var(--teal); color: var(--cream-50); }
.dialog__head h2 { color: var(--cream-50); font-size: 1.4rem; }
.dialog__body { padding: 20px 22px; overflow-y: auto; display: grid; gap: 16px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: .92rem; }
.kv dt { font-weight: 700; color: var(--forest); }
.kv dd { margin: 0; }

@media (max-width: 960px) {
  .checkout { grid-template-columns: 1fr; }
  .checkout__summary { position: static; order: -1; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-grid { grid-template-columns: 1fr; }
  .admin { grid-template-columns: 1fr; }
  .admin__side { position: fixed; z-index: 50; inset: 0 auto 0 0; width: 260px; transform: translateX(-100%); transition: transform .25s var(--ease); }
  .admin.is-menu .admin__side { transform: none; box-shadow: 20px 0 50px -20px rgba(0, 0, 0, .5); }
  .admin__menu { display: inline-flex; }
}
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .auth-choice { grid-template-columns: 1fr; }
  .table { font-size: .84rem; }
  .table th, .table td { padding: 9px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .cart-drawer__panel, .cart-drawer__scrim, .admin__side { transition: none; }
  .result--wait .result__icon svg { animation: none; }
}
.field-inline { width: 130px; min-height: 40px; padding: 6px 10px; border: 1.5px solid rgba(92, 64, 51, .25); border-radius: 10px; font: inherit; color: var(--forest); background: #fff; }
.field-inline:focus { outline: 3px solid var(--ochre-300); outline-offset: 1px; }
.status-chips a { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 12px; background: #fff; text-decoration: none; color: var(--forest); box-shadow: inset 0 0 0 1px rgba(92, 64, 51, .1); }
.cart-link { white-space: nowrap; }
.bars__axis { display: flex; justify-content: space-between; font-size: .72rem; color: var(--brown); margin-top: 4px; }

/* checkout: datos ya enviados, plegados en un resumen */
.checkout-done h2 { font-size: 1.4rem; margin-bottom: .4rem; }
.checkout-done p { margin-top: .4rem; }
.link-btn { margin-top: .6rem; padding: 8px 0; border: 0; background: none; color: var(--teal-800); font: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

.form[hidden] { display: none; }

/* ---------- contraseñas por correo (recuperar / restablecer) ---------- */
.field > label { font-size: .72rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--brown); }
.auth-hint { margin-top: 12px; font-size: .88rem; line-height: 1.5; color: var(--brown); }
.reset-for { margin-bottom: 4px; font-size: .95rem; overflow-wrap: anywhere; }
.pw-field { position: relative; }
.pw-field input { width: 100%; padding-right: 96px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  min-height: 36px; padding: 0 12px; border: 0; border-radius: 999px;
  background: rgba(26, 120, 102, .1); color: var(--teal-800);
  font: inherit; font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; cursor: pointer;
}
.pw-toggle:hover { background: rgba(26, 120, 102, .18); }
.pw-toggle:focus-visible { outline: 3px solid var(--ochre-300); outline-offset: 1px; }

/* ---------- administradores ---------- */
.row-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.btn--danger { --fg: var(--red-900); border-color: rgba(200, 32, 26, .45); }
.btn--danger:hover { --bg: var(--red); --fg: #fff; border-color: var(--red); }

/* pantallas de 320–380 px: el encabezado (logo + enlaces) cabe sin desplazamiento horizontal */
@media (max-width: 380px) {
  .legal-header .header-inner { gap: 10px; }
  .legal-header .brand { gap: 8px; }
  .legal-header .brand__b { height: 32px; }
  .legal-header .brand__word { height: 12px; }
  .legal-header__links { gap: 12px; }
  .legal-header__links a { font-size: .7rem; letter-spacing: .08em; }
  .auth-card .btn { letter-spacing: .08em; line-height: 1.25; }
}
