/* Panel del Basinger Order Orchestrator. Sin dependencias externas.
 *
 * Marca según el Manual de Identidad Visual de Basinger: Rojo Basinger
 * #CF202B, blanco y gris #414141; tipografía DM Sans. El logo va en blanco
 * sobre el rojo de la barra superior y en rojo sobre fondo blanco.
 * Verde (terminado) y naranja (atención) son colores de estado, no de marca:
 * así un estado nunca depende solo de tonos de rojo. */

@font-face { font-family: 'DM Sans'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/dm-sans-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'DM Sans'; font-style: normal; font-weight: 500; font-display: swap; src: url('/fonts/dm-sans-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'DM Sans'; font-style: normal; font-weight: 600; font-display: swap; src: url('/fonts/dm-sans-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'DM Sans'; font-style: normal; font-weight: 700; font-display: swap; src: url('/fonts/dm-sans-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'DM Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/dm-mono-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'DM Mono'; font-style: normal; font-weight: 500; font-display: swap; src: url('/fonts/dm-mono-latin-500-normal.woff2') format('woff2'); }

:root {
  --brand-red: #cf202b;
  --ground: #f4f4f4;
  --card: #ffffff;
  --ink: #414141;
  --muted: #6b6b6b;
  --line: #e0e0e0;
  --line-soft: #ededed;
  --accent: var(--brand-red);
  --accent-dark: #a3141d;
  --wait-bg: #eeeeee;
  --wait-fg: #414141;
  --work-bg: #fce8e9;
  --work-fg: #a3141d;
  --done-bg: #0e5a4b;
  --alert-bg: #fbe3c8;
  --alert-fg: #6b3205;
  --alert-line: #b4530a;
  /* Rechazar o cancelar: gris con borde, para no confundirse con el botón principal rojo. */
  --danger: #414141;
  --on-red-line: #ee8f95;
  --on-red-soft: #ffe3e5;
  --sans: 'DM Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono: 'DM Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ground); color: var(--ink); font: 15px/1.45 var(--sans); }
h1 { margin: 0; font-size: 26px; font-weight: 600; }
h2 { margin: 0; font-size: 18px; font-weight: 600; }
h3 { margin: 0; font-size: 15px; font-weight: 600; }
p { margin: 0; }
a { color: var(--accent); }
a:hover { color: var(--accent-dark); }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.loading { padding: 48px 28px; color: var(--muted); }

/* Botones */
button { font: inherit; cursor: pointer; }
.btn { min-height: 44px; padding: 0 16px; white-space: nowrap; border: 1px solid var(--ink); border-radius: 6px; background: var(--card); color: var(--ink); font-weight: 500; }
.btn:hover { background: var(--ground); }
.btn.primary { border-color: var(--accent); background: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.big { min-height: 48px; font-size: 16px; }
a.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
a.btn.primary:hover { color: #fff; }
.btn:disabled { cursor: not-allowed; border: 1px dashed #6b6b6b; background: var(--ground); color: var(--muted); }
:focus-visible { outline: 3px solid #1a1a1a; outline-offset: 2px; }

/* Encabezado: barra Rojo Basinger con el logo en blanco (mínimo 130 px de ancho, según el manual). */
.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 28px; padding: 12px 28px; background: var(--brand-red); color: #fff; }
.top :focus-visible { outline-color: #fff; }
.brand { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; }
.brand img { display: block; width: 132px; height: auto; }
.brand .brand-text { display: flex; flex-direction: column; gap: 2px; padding-left: 16px; border-left: 1px solid var(--on-red-line); }
.brand strong { font-size: 15px; font-weight: 600; }
.brand span { font: 12px var(--mono); color: var(--on-red-soft); }
.nav { display: flex; flex-wrap: wrap; gap: 6px; }
.nav button { min-height: 44px; padding: 0 18px; border: 1px solid var(--on-red-line); border-radius: 6px; background: transparent; color: #fff; font-weight: 500; }
.nav button:hover { background: var(--accent-dark); }
.nav button[aria-current='page'] { border-color: #fff; background: #fff; color: var(--brand-red); }
.who { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.who button { min-height: 36px; padding: 0 12px; border: 1px solid var(--on-red-line); border-radius: 6px; background: transparent; color: #fff; }
.who button:hover { background: var(--accent-dark); }

main { max-width: 1280px; margin: 0 auto; padding: 28px; display: flex; flex-direction: column; gap: 28px; }
section { display: flex; flex-direction: column; gap: 12px; }
.head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; }
.stack { display: flex; flex-direction: column; gap: 6px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }

/* Tarjetas y tablas */
.card { display: flex; flex-direction: column; gap: 12px; padding: 16px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.card.attention { border: 2px solid var(--alert-line); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr)); gap: 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr)); gap: 12px; }
.kpi { display: flex; flex-direction: column; gap: 4px; padding: 16px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.kpi span { font-size: 13px; color: var(--muted); }
.kpi strong { font: 500 34px var(--mono); }
.empty { padding: 20px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; color: var(--muted); }

.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; min-width: 860px; }
th { padding: 12px 16px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
td { padding: 12px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.mono, td .mono { white-space: nowrap; }

/* Etiquetas de estado: el color nunca va solo, siempre con texto. */
.pill { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.pill.wait { background: var(--wait-bg); color: var(--wait-fg); }
.pill.work { background: var(--work-bg); color: var(--work-fg); }
.pill.ready { background: var(--ink); color: #fff; }
.pill.done { background: var(--done-bg); color: #fff; }
.pill.alert { background: var(--alert-bg); color: var(--alert-fg); }

.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 14px; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.items { display: flex; flex-direction: column; gap: 6px; font: 14px var(--mono); }
.note { font-size: 13px; color: var(--alert-fg); }
.ok { color: var(--done-bg); font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { min-height: 44px; padding: 0 16px; border: 1px solid var(--ink); border-radius: 999px; background: var(--card); color: var(--ink); font-weight: 500; }
.chips button[aria-pressed='true'] { background: var(--ink); color: #fff; }

.timeline { display: flex; flex-direction: column; padding: 4px 16px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.timeline li { display: flex; flex-direction: column; gap: 2px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); list-style: none; }
.timeline li:last-child { border-bottom: 0; }
ol.timeline { margin: 0; }
.split { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.split > .wide { flex: 999 1 520px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.split > .narrow { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }

/* Inicio de sesión */
.login { max-width: 400px; margin: 72px auto; padding: 28px; }
.login form { display: flex; flex-direction: column; gap: 14px; }
.login { border-top: 4px solid var(--brand-red); }
.login h1 { display: flex; flex-direction: column; gap: 10px; font-size: 22px; }
.login h1 img { display: block; width: 168px; height: auto; }

/* Formularios y ventanas */
label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; }
label .hint { font-weight: 400; font-size: 13px; color: var(--muted); }
input, select, textarea { min-height: 44px; padding: 8px 12px; border: 1px solid #8c8c8c; border-radius: 6px; background: #fff; color: var(--ink); font: inherit; }
textarea { min-height: 88px; resize: vertical; }
dialog { width: min(520px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); }
dialog::backdrop { background: rgba(65, 65, 65, 0.6); }
dialog form { display: flex; flex-direction: column; gap: 16px; padding: 24px; }
dialog .buttons { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.error { padding: 12px 14px; border: 2px solid var(--brand-red); border-radius: 6px; background: #fdf3f3; color: #7a1017; }
.error strong { display: block; }

/* Pedidos de tienda a fábrica */
.pill.store { padding: 2px 9px; border: 1.5px solid var(--brand-red); background: #fff; color: var(--brand-red); align-self: flex-start; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 14px; }
.fields .full { grid-column: 1 / -1; }
.line-row { display: grid; grid-template-columns: minmax(150px, 1fr) minmax(200px, 2fr) 110px auto; gap: 12px; align-items: end; padding: 12px; background: var(--ground); border-radius: 8px; }
fieldset { display: flex; flex-direction: column; gap: 8px; min-width: 0; margin: 0; padding: 0; border: 0; }
legend { margin-bottom: 8px; padding: 0; font-weight: 500; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); gap: 10px; }
.choice { flex-direction: row; align-items: center; gap: 10px; min-height: 52px; padding: 10px 14px; border: 1px solid #8c8c8c; border-radius: 8px; background: #fff; cursor: pointer; }
.choice input { min-height: 0; width: 18px; height: 18px; margin: 0; accent-color: var(--brand-red); }
.choice:has(input:checked) { border: 2px solid var(--brand-red); background: var(--work-bg); }
.after-save { display: flex; flex-direction: column; gap: 4px; padding: 14px; border-radius: 8px; background: var(--work-bg); color: var(--work-fg); }
.card.success { border: 2px solid var(--done-bg); }
.receipt { display: flex; flex-direction: column; gap: 16px; max-width: 760px; padding: 28px; background: var(--card); border: 1px solid var(--line); border-radius: 4px; }
.receipt-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px 24px; padding-bottom: 14px; border-bottom: 2px solid var(--brand-red); }
.receipt-head img { display: block; width: 150px; height: auto; }
.receipt-number { align-items: flex-end; }
.receipt-number strong { font-size: 24px; }
.receipt table { min-width: 0; }
.receipt .table-wrap { border-radius: 4px; }
.receipt-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 16px; }
.receipt-total { font-size: 22px; }
.receipt-foot { padding-top: 12px; border-top: 1px dashed #8c8c8c; font-size: 13px; color: var(--muted); }

/* Al imprimir solo sale el comprobante. */
@media print {
  .top, .no-print { display: none !important; }
  body { background: #fff; }
  main { max-width: none; padding: 0; }
  .receipt { max-width: none; padding: 0; border: 0; }
}

@media (max-width: 640px) {
  .top, main { padding-left: 16px; padding-right: 16px; }
  .line-row { grid-template-columns: 1fr; }
  .brand .brand-text { padding-left: 0; border-left: 0; }
  h1 { font-size: 22px; }
}

[hidden] { display: none !important; }
