/* ============================================================================
   Componentes "Comanda de Autor" — Botones, Tarjetas, Ticket Vivo y 5 Estados
   ============================================================================ */

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-card);
  container-type: inline-size;
}

.card-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.card-subtitle {
  font-size: var(--text-sm);
  color: var(--ink-secondary);
}

/* Badges y Etiquetas Semánticas */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 600;
  border: 1px solid transparent;
}

.badge-ok {
  background: var(--status-ok-soft);
  color: var(--status-ok);
}

.badge-warn {
  background: var(--status-warn-soft);
  color: var(--status-warn);
}

.badge-danger {
  background: var(--status-danger-soft);
  color: var(--status-danger);
}

.badge-accent {
  background: var(--accent-soft);
  color: var(--accent-primary);
}

.badge-wa {
  background: oklch(93% 0.04 150);
  color: var(--channel-wa);
}

.badge-tg {
  background: oklch(93% 0.04 245);
  color: var(--channel-tg);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

/* Botones con área táctil mínima >= 48px */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--touch-min);
  padding: 0 var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--ink-primary);
  font-weight: 600;
  font-size: var(--text-sm);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out-expo),
              transform var(--dur-fast) var(--ease-out-expo);
}

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

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: var(--ink-on-accent);
}

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

.btn-ghost {
  border-color: transparent;
  background: transparent;
}

.btn-sm {
  min-height: 44px;
  padding: 0 var(--space-3);
  font-size: var(--text-xs);
}

/* Formularios accesibles en una sola columna */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink-primary);
}

.input, .select {
  width: 100%;
  min-height: var(--touch-min);
  padding: 0 var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-canvas);
  color: var(--ink-primary);
}

.field-hint {
  font-size: var(--text-xs);
  color: var(--ink-muted);
}

/* Selector visual de giro gastronómico */
.business-pills {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
}

.business-pill {
  min-height: var(--touch-min);
  padding: var(--space-2) var(--space-3);
  border: 1.5px solid var(--border-hairline);
  border-radius: var(--radius-md);
  background: var(--bg-canvas);
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.business-pill[aria-pressed="true"] {
  border-color: var(--accent-primary);
  background: var(--accent-soft);
}

.business-pill strong {
  font-size: var(--text-sm);
}

.business-pill span {
  font-size: var(--text-xs);
  color: var(--ink-secondary);
}

/* Tarjetas KPI */
.kpi-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.kpi-label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  font-weight: 700;
}

.kpi-value {
  font-size: var(--text-xl);
  font-weight: 700;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* Ticket Vivo (Comanda impresa táctil con micro-perforaciones) */
.live-ticket-paper {
  position: relative;
  background: var(--bg-ticket);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  box-shadow: var(--shadow-ticket);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.ticket-divider {
  border: 0;
  border-top: 1.5px dashed var(--border-strong);
  margin: 0;
}

.ticket-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-2);
  font-size: var(--text-sm);
}

.ticket-item-mod {
  font-size: var(--text-xs);
  color: var(--ink-secondary);
  padding-left: var(--space-3);
}

.ticket-total {
  font-size: var(--text-lg);
  font-weight: 700;
}

/* 5 Estados Explícitos por Pantalla (Vacío, Cargando, Error, Éxito, Sin Permisos) */
.state-panel {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-3);
  background: var(--bg-canvas);
}

.state-panel--error {
  border-style: solid;
  border-color: var(--status-danger);
  background: var(--status-danger-soft);
}

.state-panel--forbidden {
  border-style: solid;
  border-color: var(--status-warn);
  background: var(--status-warn-soft);
}

.skeleton-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: 100%;
}

.skeleton-line {
  height: 16px;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--bg-subtle) 25%, var(--border-hairline) 50%, var(--bg-subtle) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
}

.skeleton-line--short {
  width: 45%;
}

.skeleton-line--tall {
  height: 44px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Selector de tabs (Login / Registro / Estados) */
.tab-bar {
  display: inline-flex;
  padding: 4px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  gap: 4px;
}

.tab-btn {
  min-height: 40px;
  padding: 0 var(--space-3);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-secondary);
  font-size: var(--text-xs);
  font-weight: 700;
  cursor: pointer;
}

.tab-btn[aria-selected="true"] {
  background: var(--bg-surface);
  color: var(--ink-primary);
  box-shadow: var(--shadow-card);
}

/* Toast no intrusivo de éxito/alerta */
.toast-region {
  position: fixed;
  right: var(--space-4);
  bottom: calc(var(--bottom-nav-height) + var(--space-4));
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: min(380px, calc(100vw - 2rem));
}

@media (min-width: 768px) {
  .toast-region {
    bottom: var(--space-4);
  }
}

.toast {
  background: var(--ink-primary);
  color: var(--bg-surface);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-ticket);
  font-size: var(--text-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
}

.toast .btn-ghost {
  color: var(--bg-surface);
  border-color: color-mix(in oklch, var(--bg-surface) 28%, transparent);
}

.toast .btn-ghost:hover {
  background: color-mix(in oklch, var(--bg-surface) 14%, transparent);
}

/* Banner de Cookies Legal */
.cookie-banner {
  position: fixed;
  left: var(--space-4);
  right: var(--space-4);
  bottom: calc(var(--bottom-nav-height) + var(--space-3));
  z-index: 70;
  max-width: 640px;
  margin-inline: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-ticket);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.cookie-banner[hidden] {
  display: none;
}

@media (min-width: 768px) {
  .cookie-banner {
    bottom: var(--space-4);
  }
}

.inline-alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  border: 1px solid var(--status-danger);
  background: var(--status-danger-soft);
  color: var(--status-danger);
}

.inline-alert--ok {
  border-color: var(--status-ok);
  background: var(--status-ok-soft);
  color: var(--status-ok);
}

.field-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink-primary);
}

.inline-alert[hidden] {
  display: none;
}

.legal-container {
  max-width: 760px;
  margin: var(--space-8) auto;
  padding: 0 var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

/* ============================================================================
   Sprint 1: <inventory-stock-bar>, Listas en Tarjeta y Recetario
   ============================================================================ */

.view-section[hidden] {
  display: none;
}

.stack-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.entity-card {
  background: var(--bg-canvas);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.entity-card--alert {
  border-color: var(--status-warn);
  background: var(--status-warn-soft);
}

.entity-card--critical {
  border-color: var(--status-danger);
  background: var(--status-danger-soft);
}

.entity-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-pill);
  background: var(--bg-subtle);
  border: 1px solid var(--border-hairline);
  font-size: var(--text-xs);
  color: var(--ink-secondary);
}

.stock-track {
  position: relative;
  width: 100%;
  height: 10px;
  border-radius: var(--radius-pill);
  background: var(--bg-subtle);
  overflow: hidden;
}

.stock-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  transition: width var(--dur-med) var(--ease-out-expo);
}

.stock-fill--ok {
  background: var(--status-ok);
}

.stock-fill--low {
  background: var(--status-warn);
}

.stock-fill--critical {
  background: var(--status-danger);
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
}

@container (min-width: 500px) {
  .form-grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* ============================================================================
   Sprint 2: CRM Omnicanal (<crm-chat-thread>, Bandeja SSE, Pipeline y Tickets)
   ============================================================================ */

.crm-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

@container workspace (min-width: 780px) {
  .crm-layout {
    grid-template-columns: 320px minmax(0, 1fr);
    align-items: start;
  }
}

.conv-item {
  width: 100%;
  text-align: left;
  background: var(--bg-canvas);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.conv-item[aria-selected="true"] {
  border-color: var(--accent-primary);
  background: var(--accent-soft);
}

.chat-feed {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-height: 260px;
  max-height: 440px;
  overflow-y: auto;
  padding: var(--space-4);
  background: var(--bg-canvas);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-md);
}

.chat-bubble {
  max-width: 82%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: var(--text-sm);
  word-break: break-word;
}

.chat-bubble--customer {
  align-self: flex-start;
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
}

.chat-bubble--agent {
  align-self: flex-end;
  background: var(--accent-primary);
  color: var(--ink-on-accent);
}

.chat-bubble--agent .chat-meta {
  color: oklch(95% 0.01 85 / 0.85);
}

.chat-meta {
  font-size: 0.72rem;
  color: var(--ink-muted);
}

.pipeline-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
}

@container workspace (min-width: 680px) {
  .pipeline-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@container workspace (min-width: 1020px) {
  .pipeline-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* ============================================================================
   Sprint 3: POS Mostrador Táctil (60/40), KDS Cocina, Calendario y ESC/POS
   ============================================================================ */

.pos-split {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

@container workspace (min-width: 720px) {
  .pos-split {
    grid-template-columns: 1.45fr 1fr;
    align-items: start;
  }
}

.pos-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--space-3);
}

.pos-tile {
  min-height: 84px;
  padding: var(--space-3);
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-hairline);
  background: var(--bg-canvas);
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  transition: border-color var(--dur-fast) var(--ease-out-expo),
              transform var(--dur-fast) var(--ease-out-expo);
}

.pos-tile:hover {
  border-color: var(--accent-primary);
}

.pos-tile:active {
  transform: scale(0.98);
}

.kds-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

@container workspace (min-width: 760px) {
  .kds-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: start;
  }
}

.escpos-preview {
  margin: 0;
  padding: var(--space-4);
  background: var(--bg-ticket);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.4;
  white-space: pre-wrap;
  overflow-x: auto;
}

.ad-canvas-frame {
  width: 100%;
  max-width: 420px;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-ticket);
  display: block;
}

/* Rastreador automático por estación / lugar físico en Ticket Vivo */
.station-tracker {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--bg-canvas);
  border: 1px solid var(--border-hairline);
}

.station-step {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--ink-muted);
}

.station-step-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: transparent;
  flex-shrink: 0;
}

.station-step--done {
  color: var(--status-ok);
  font-weight: 600;
}

.station-step--done .station-step-dot {
  border-color: var(--status-ok);
  background: var(--status-ok);
}

.station-step--active {
  color: var(--accent-primary);
  font-weight: 700;
}

.station-step--active .station-step-dot {
  border-color: var(--accent-primary);
  background: var(--accent-primary);
}

.chip[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  font-weight: 700;
}

/* Asistente de Inicio de Negocio (Wizard 5 pasos) */
.wizard-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-2);
}

.wizard-step {
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-hairline);
  background: var(--bg-canvas);
  color: var(--ink-secondary);
  font-size: var(--text-xs);
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.wizard-step--done {
  border-color: var(--status-ok);
  background: var(--status-ok-soft);
  color: var(--status-ok);
}

.wizard-step--active {
  border-color: var(--accent-primary);
  background: var(--accent-soft);
  color: var(--accent-primary);
}

.wizard-nav-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-hairline);
}

.qr-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-strong);
  background: var(--bg-canvas);
}

.qr-box {
  width: 220px;
  height: 220px;
  border-radius: var(--radius-md);
  background: #fff;
  padding: 8px;
  border: 1px solid var(--border-hairline);
}





