@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400&family=Cormorant+Garamond:ital,wght@1,500&display=swap");

/* SweetGift Control: componentes en CSS puro (Django + HTMX, sin React).
   Prefijo sg-. Todos los valores vienen de tokens.css. */

body { margin: 0; font-family: var(--font-sans); font-size: 16px; line-height: 24px; background: var(--surface-page); color: var(--ink); -webkit-font-smoothing: antialiased; }
.sg-demo { padding: var(--space-5); display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.sg-demo-col { padding: var(--space-5); display: grid; gap: var(--space-4); }
.sg-num { font-variant-numeric: tabular-nums; }
.sg-label { font-size: 12px; line-height: 16px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-muted); }

/* Foco: un solo estilo en todo el sistema */
.sg-btn:focus-visible, .sg-input:focus-visible, .sg-select:focus-visible, .sg-textarea:focus-visible,
.sg-seg button:focus-visible, .sg-chip-col:focus-visible, .sg-check input:focus-visible + span, a:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 2px;
}

/* ---------- Botón ---------- */
.sg-btn { font: inherit; font-size: 15px; font-weight: 600; line-height: 1; height: var(--size-control); padding: 0 var(--space-5);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  border-radius: var(--radius-md); border: 1px solid transparent; cursor: pointer; text-decoration: none; white-space: nowrap; }
/* Un botón nunca sale de su recuadro; si no cabe, el texto baja a otra línea (revisión 2026-11-24) */
.sg-btn { max-width: 100%; box-sizing: border-box; }
.sg-card .sg-btn, .sg-field .sg-btn, .sg-stack > form > .sg-btn { white-space: normal; height: auto; min-height: var(--size-control);
  padding-block: 8px; line-height: 1.2; text-align: center; overflow-wrap: anywhere; }
.sg-btn-primary { background: var(--action); color: var(--on-action); }
.sg-btn-primary:hover { background: var(--action-hover); }
.sg-btn-primary:active { background: var(--action-pressed); }
.sg-btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.sg-btn-secondary:hover { background: var(--surface-sunken); }
.sg-btn-quiet { background: transparent; color: var(--action); padding: 0 var(--space-3); }
.sg-btn-ghost { background: transparent; color: var(--ink); border-color: transparent; }   /* faltaba: salía gris o azul de enlace (2026-11-24) */
.sg-btn-ghost:hover { background: var(--surface-page); border-color: var(--line); }
.sg-btn-quiet:hover { background: var(--action-soft); color: var(--action-pressed); }
.sg-btn-night { background: var(--surface-night); color: var(--ink-inverse); }
.sg-btn-danger { background: var(--surface); color: var(--danger); border-color: var(--danger); }
.sg-btn-danger:hover { background: var(--danger-soft); }
/* Cancelar o anular algo importante: rojo fuerte, siempre con data-confirm-tone="danger" */
.sg-btn-cancel { background: var(--danger); color: #fff; border-color: var(--danger); font-weight: 600; }
.sg-btn-cancel:hover { background: #8E1D17; border-color: #8E1D17; }
.sg-btn-cancel:active { background: #741711; }
/* Recuadro de cancelar: borde rojo y encabezado rojo suave para que se note */
.sg-card.sg-card-danger { border: 2px solid var(--danger); }
.sg-card.sg-card-danger > .sg-card-head { background: var(--danger-soft); border-bottom-color: var(--danger); border-radius: calc(var(--radius-md) - 2px) calc(var(--radius-md) - 2px) 0 0; }
.sg-card.sg-card-danger > .sg-card-head h2 { color: var(--danger); }
.sg-btn[disabled], .sg-btn[aria-disabled="true"] { background: var(--surface-sunken); color: var(--ink-muted); border-color: var(--line); cursor: not-allowed; }
.sg-btn-touch { height: var(--size-touch); font-size: 16px; }
.sg-btn-tablet { height: var(--size-touch-tablet); font-size: 18px; padding: 0 var(--space-6); }
.sg-btn-block { width: 100%; }
.sg-btn[aria-busy="true"]::before { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: sg-spin .8s linear infinite; }
@keyframes sg-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .sg-btn[aria-busy="true"]::before { animation: none; } }

/* ---------- Campo ---------- */
.sg-field { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-1); min-width: 0; }
.sg-field > * { min-width: 0; overflow-wrap: anywhere; }
.sg-field > .sg-input, .sg-field > .sg-select, .sg-field > .sg-textarea { min-width: 0; max-width: 100%; box-sizing: border-box; }
.sg-field > label { font-size: 14px; line-height: 20px; font-weight: 500; color: var(--ink); }
.sg-input, .sg-select, .sg-textarea { font: inherit; font-size: 16px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); height: var(--size-control); padding: 0 var(--space-3); box-sizing: border-box; width: 100%; }
.sg-textarea { height: auto; min-height: 96px; padding: var(--space-3); line-height: 24px; resize: vertical; }
.sg-input::placeholder, .sg-textarea::placeholder { color: var(--ink-muted); }
.sg-input[readonly] { background: var(--surface-sunken); }
.sg-help { font-size: 13px; line-height: 18px; color: var(--ink-muted); }
.sg-field[data-invalid] .sg-input, .sg-field[data-invalid] .sg-select { border-color: var(--danger); border-width: 2px; }
.sg-error { font-size: 13px; line-height: 18px; color: var(--danger); font-weight: 500; display: flex; gap: var(--space-1); }
.sg-error::before { content: "!"; display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: var(--danger); color: var(--on-action); font-size: 11px; font-weight: 700; flex: none; margin-top: 1px; }
.sg-check { display: inline-flex; gap: var(--space-2); align-items: center; font-size: 15px; cursor: pointer; }
.sg-check input { accent-color: var(--action); width: 18px; height: 18px; margin: 0; }

/* ---------- Chip de estado del pedido ---------- */
.sg-status { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 var(--space-2) 0 6px; border-radius: var(--radius-sm);
  font-size: 12px; line-height: 16px; font-weight: 600; letter-spacing: .02em; white-space: nowrap; }
.sg-status::before { content: ""; width: 8px; height: 8px; flex: none; background: currentColor; }
.sg-status-quote { background: var(--status-quote-soft); color: var(--status-quote); }
.sg-status-quote::before { background: transparent; border: 2px solid currentColor; width: 4px; height: 4px; border-radius: 50%; }
.sg-status-received { background: var(--status-received-soft); color: var(--status-received); }
.sg-status-received::before { border-radius: 50%; }
.sg-status-production { background: var(--status-production-soft); color: var(--status-production); }
.sg-status-production::before { border-radius: 50% 50% 0 0; height: 5px; }
.sg-status-delivery { background: var(--status-delivery-soft); color: var(--status-delivery); }
.sg-status-delivery::before { clip-path: polygon(0 0, 100% 50%, 0 100%); }
.sg-status-delivered { background: var(--status-delivered-soft); color: var(--status-delivered); }
.sg-status-delivered::before { width: 9px; height: 5px; background: transparent; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg) translateY(-1px); }
.sg-status-cancelled { background: var(--status-cancelled-soft); color: var(--status-cancelled); }
.sg-status-cancelled::before { height: 2px; }

/* ---------- Chip de colección ---------- */
.sg-chip-col { display: inline-flex; align-items: center; gap: var(--space-2); height: 28px; padding: 0 var(--space-3) 0 4px; border-radius: var(--radius-pill);
  background: var(--surface); border: 1px solid var(--line); font: inherit; font-size: 13px; font-weight: 500; color: var(--ink); white-space: nowrap; }
.sg-chip-col .sg-swatch { display: inline-flex; width: 20px; height: 20px; border-radius: 50%; overflow: hidden; transform: rotate(45deg); flex: none; }
.sg-chip-col .sg-swatch i { flex: 1; }
button.sg-chip-col { cursor: pointer; }
.sg-chip-col[aria-pressed="true"] { background: var(--action-soft); border-color: var(--action); color: var(--action-pressed); }

/* ---------- Avisos ---------- */
.sg-alert { display: grid; grid-template-columns: auto 1fr; gap: var(--space-1) var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); font-size: 14px; line-height: 20px; color: var(--ink); }
.sg-alert-icon { grid-row: span 2; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; color: var(--on-action); font-weight: 700; font-size: 13px; margin-top: 1px; }
.sg-alert strong { font-weight: 600; }
.sg-alert-info { background: var(--info-soft); } .sg-alert-info .sg-alert-icon { background: var(--info); } .sg-alert-info strong { color: var(--info); }
.sg-alert-success { background: var(--success-soft); } .sg-alert-success .sg-alert-icon { background: var(--success); } .sg-alert-success strong { color: var(--success); }
.sg-alert-warning { background: var(--warning-soft); } .sg-alert-warning .sg-alert-icon { background: var(--warning); } .sg-alert-warning strong { color: var(--warning); }
.sg-alert-danger { background: var(--danger-soft); } .sg-alert-danger .sg-alert-icon { background: var(--danger); } .sg-alert-danger strong { color: var(--danger); }
/* Aviso simple de una línea (sin ícono): class="sg-alert" data-tone="info|success|warning|danger" */
.sg-alert[data-tone] { display: block; }
.sg-alert[hidden] { display: none; }
.sg-alert[data-tone="info"] { background: var(--info-soft); } .sg-alert[data-tone="info"] strong { color: var(--info); }
.sg-alert[data-tone="success"] { background: var(--success-soft); } .sg-alert[data-tone="success"] strong { color: var(--success); }
.sg-alert[data-tone="warning"] { background: var(--warning-soft); } .sg-alert[data-tone="warning"] strong { color: var(--warning); }
.sg-alert[data-tone="danger"] { background: var(--danger-soft); } .sg-alert[data-tone="danger"] strong { color: var(--danger); }
.sg-banner { background: var(--brand-vanilla); color: var(--ink); text-align: center; font-size: 14px; line-height: 20px; font-weight: 500; padding: var(--space-2) var(--space-4); }

/* ---------- Selector segmentado ---------- */
.sg-seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-sunken); border-radius: var(--radius-md); border: 1px solid var(--line); }
.sg-seg button { font: inherit; font-size: 14px; font-weight: 500; height: 34px; padding: 0 var(--space-4); border: 0; border-radius: 8px; background: transparent; color: var(--ink-muted); cursor: pointer; display: inline-flex; align-items: center; gap: var(--space-2); }
.sg-seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-raised); }
.sg-seg .sg-count { font-size: 12px; font-weight: 600; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--radius-pill); background: var(--line); color: var(--ink); display: inline-grid; place-items: center; box-sizing: border-box; }
.sg-seg button[aria-pressed="true"] .sg-count { background: var(--action); color: var(--on-action); }

/* ---------- Tarjeta de pedido ---------- */
.sg-order { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); overflow: hidden; display: grid; grid-template-columns: 8px 1fr; max-width: 420px; }
.sg-order-band { display: flex; flex-direction: column; }
.sg-order-band i { flex: 1; }
.sg-order-body { padding: var(--space-4); display: grid; gap: var(--space-3); min-width: 0; }
.sg-order-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3); }
.sg-order-id { font-size: 18px; line-height: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.sg-order-meta { font-size: 14px; line-height: 20px; color: var(--ink-muted); }
.sg-order-items { margin: 0; padding: 0; list-style: none; font-size: 14px; line-height: 20px; display: grid; gap: 2px; }
.sg-order-foot { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); padding-top: var(--space-3); border-top: 1px solid var(--line); flex-wrap: wrap; }
.sg-order-total { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Tarjeta de producto (web) ---------- */
.sg-product { background: var(--surface); border-radius: var(--radius-md); overflow: hidden; display: grid; max-width: 300px; border: 1px solid var(--line); }
.sg-product-media { aspect-ratio: 1 / 1; position: relative; display: grid; place-items: center; overflow: hidden; max-width: 100%; }
.sg-product-media svg { width: 100%; height: 100%; display: block; }
.sg-product-flag { position: absolute; top: var(--space-3); left: var(--space-3); }
.sg-product-body { padding: var(--space-4); display: grid; gap: var(--space-1); }
.sg-product-name { font-size: 18px; line-height: 24px; font-weight: 600; margin: 0; }
.sg-product-desc { font-size: 14px; line-height: 20px; color: var(--ink-muted); margin: 0; }
.sg-product-row { display: flex; justify-content: space-between; align-items: center; margin-top: var(--space-3); gap: var(--space-3); }
.sg-product-price { font-size: 22px; line-height: 28px; font-weight: 600; font-variant-numeric: tabular-nums; }
.sg-product[data-soldout] .sg-product-media { filter: grayscale(1); opacity: .55; }

/* ---------- Tabla ---------- */
.sg-table-wrap { position: relative; overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); }
.sg-table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 20px; }
.sg-table th { text-align: left; background: var(--surface-sunken); font-size: 12px; line-height: 16px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-muted); padding: var(--space-3) var(--space-4); white-space: nowrap; }
.sg-table td { padding: var(--space-3) var(--space-4); border-top: 1px solid var(--line); vertical-align: middle; }
.sg-table td.sg-num, .sg-table th.sg-num { text-align: right; }
.sg-table tbody tr:hover { background: var(--surface-page); }
.sg-table tbody tr[aria-selected="true"] { background: var(--action-soft); }

/* ---------- Barra superior del panel ---------- */
.sg-appbar { display: flex; align-items: center; gap: var(--space-5); height: 60px; padding: 0 var(--space-5); background: var(--surface); border-bottom: 1px solid var(--line); }
.sg-appbar img { height: 26px; width: auto; display: block; }
.sg-appbar nav { display: flex; gap: var(--space-1); flex: 1; min-width: 0; overflow-x: auto; }
.sg-appbar nav a { font-size: 14px; font-weight: 500; color: var(--ink-muted); text-decoration: none; padding: var(--space-2) var(--space-3); border-radius: 8px; white-space: nowrap; }
.sg-appbar nav a:hover { color: var(--ink); background: var(--surface-sunken); }
.sg-appbar nav a[aria-current="page"] { color: var(--action-pressed); background: var(--action-soft); font-weight: 600; }
.sg-appbar-user { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-thistle); display: grid; place-items: center; font-size: 13px; font-weight: 600; flex: none; }

/* ---------- Mosaico (patrón de marca) ---------- */
.sg-mosaic { display: block; width: 100%; height: auto; max-width: 100%; background: var(--surface); }
.sg-dedicatoria { font-family: var(--font-dedicatoria); font-style: italic; font-weight: 500; font-size: 22px; line-height: 30px; }

/* Botón de «Elegir archivos» con el diseño del sistema (2026-11-17: se veía como el del navegador) */
input[type="file"] { font: inherit; font-size: 14px; color: var(--ink-muted); width: 100%; max-width: 100%; min-width: 0; }
input[type="file"]::file-selector-button { font: inherit; font-size: 14px; font-weight: 600; height: 36px; padding: 0 var(--space-4);
  margin-right: var(--space-3); border-radius: var(--radius-md); border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--ink); cursor: pointer; }
input[type="file"]::file-selector-button:hover { background: var(--surface-sunken); }

/* ---------- Campos con el diseño actual (Horacio, 2026-11-17: «se ven anticuados») ----------
   Esquinas como las tarjetas, flecha propia en las listas, foco rosa suave y casillas más claras. */
.sg-input, .sg-select, .sg-textarea { border-radius: var(--radius-md); padding: 0 14px;
  transition: border-color .15s, box-shadow .15s, background-color .15s; }
.sg-textarea { height: auto; padding: 12px 14px; }
.sg-input:hover, .sg-select:hover, .sg-textarea:hover { border-color: var(--ink); }
.sg-input:focus, .sg-select:focus, .sg-textarea:focus { outline: none; border-color: var(--action); box-shadow: 0 0 0 3px var(--action-soft); }
.sg-input:focus-visible, .sg-select:focus-visible, .sg-textarea:focus-visible { outline: none; }
.sg-select { appearance: none; -webkit-appearance: none; padding-right: 40px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235E554D' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; background-size: 16px; }
.sg-select[multiple] { background-image: none; height: auto; padding: 8px; }
.sg-input:disabled, .sg-select:disabled, .sg-textarea:disabled { background-color: var(--surface-sunken); color: var(--ink-muted); cursor: not-allowed; }
.sg-field > label { font-weight: 600; }
.sg-field > label .sg-help { font-weight: 400; }
.sg-check input[type="checkbox"], .sg-check input[type="radio"] { width: 20px; height: 20px; flex: none; cursor: pointer; }

/* Casilla grande tipo opción: toda la fila se puede tocar (formularios cortos) */
.sg-option { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-md); background: var(--surface); cursor: pointer; transition: border-color .15s, background-color .15s; }
.sg-option:hover { border-color: var(--ink); }
.sg-option:has(input:checked) { border-color: var(--action); background: var(--action-soft); }
.sg-option:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--action-soft); border-color: var(--action); }
.sg-option input { accent-color: var(--action); width: 20px; height: 20px; margin: 2px 0 0; flex: none; cursor: pointer; }
.sg-option > span { display: block; min-width: 0; }
.sg-option strong { display: block; font-size: 15px; line-height: 22px; font-weight: 600; }
.sg-option .sg-help { display: block; margin-top: 2px; }
