/* Sistema visual de Living POS: un solo tamaño de control, tablas sobrias y jerarquía clara.
   Va después de overrides.css y usa tokens de Bootstrap para que el modo oscuro herede. */

:root {
  --lp-radius: 0.625rem;
  --lp-radius-sm: 0.5rem;
}

/* `:root` también es el <html> oscuro: los tonos claros solo cuando no lo es. */
:root:not([data-bs-theme="dark"]),
[data-bs-theme="light"] {
  --lp-line: #e3e8ef;
  --lp-control-border: #cbd5e1;
  --lp-muted: #64748b;
  --lp-head-bg: #f8fafc;
  --lp-row-hover: #f5f8ff;
  --lp-ring: rgba(29, 78, 216, 0.18);
  --lp-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.04);
  --bs-body-color: #1e293b;
  --bs-border-color: var(--lp-line);
  --bs-secondary-color: var(--lp-muted);
}

[data-bs-theme="dark"] {
  --lp-line: #2f3b4d;
  --lp-control-border: #3d4b60;
  --lp-muted: #94a3b8;
  --lp-head-bg: rgba(255, 255, 255, 0.03);
  --lp-row-hover: rgba(59, 130, 246, 0.08);
  --lp-ring: rgba(96, 165, 250, 0.3);
  --lp-shadow: none;
  --bs-border-color: var(--lp-line);
}

body {
  background-color: var(--bs-tertiary-bg);
}

/* Tarjetas */

.card {
  border: 1px solid var(--lp-line);
  border-radius: var(--lp-radius);
  box-shadow: var(--lp-shadow);
}

.card > .card-header {
  padding: 0.875rem 1.25rem;
  font-weight: 600;
  border-bottom-color: var(--lp-line) !important;
  border-radius: var(--lp-radius) var(--lp-radius) 0 0;
}

.card > .card-footer {
  border-top-color: var(--lp-line) !important;
  border-radius: 0 0 var(--lp-radius) var(--lp-radius);
}

/* Formularios: un alto para todo, con `-sm` solo dentro de tablas densas. */

.form-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--bs-emphasis-color);
  margin-bottom: 0.375rem;
}

.form-control,
.form-select {
  min-height: 2.5rem;
  font-size: 0.9375rem;
  border-color: var(--lp-control-border);
  border-radius: var(--lp-radius-sm);
}

.form-control-sm,
.form-select-sm {
  min-height: 2.25rem;
  font-size: 0.875rem;
}

textarea.form-control {
  min-height: 4.5rem;
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus,
.btn:focus-visible {
  border-color: var(--bs-primary);
  box-shadow: 0 0 0 3px var(--lp-ring);
}

/* Reemplaza el anillo naranja que traía la plantilla. */
.input-group:focus-within,
[data-bs-theme="dark"] .input-group:focus-within {
  box-shadow: 0 0 0 3px var(--lp-ring);
}

.input-group-text {
  border-color: var(--lp-control-border);
  background: var(--lp-head-bg);
  color: var(--lp-muted);
}

.form-text {
  font-size: 0.8125rem;
  color: var(--lp-muted);
}

.form-check-input {
  border-color: var(--lp-control-border);
}

/* Bloques de un formulario largo: título, ayuda y campos. */
.form-section + .form-section {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--lp-line);
}

.form-section-title {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.form-section-hint {
  font-size: 0.8125rem;
  color: var(--lp-muted);
  margin-bottom: 1rem;
}

/* Barra de acciones al pie del formulario: la principal primero y del mismo alto. */
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 1.25rem;
}

.form-actions .btn {
  min-height: 2.5rem;
  padding-inline: 1.125rem;
  font-size: 0.875rem;
}

/* Botones */

.btn {
  border-radius: var(--lp-radius-sm);
  font-weight: 500;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.btn-sm {
  min-height: 2.125rem;
  padding: 0.3125rem 0.75rem;
  font-size: 0.8125rem;
}

.btn-lg {
  min-height: 3rem;
  border-radius: var(--lp-radius);
}

/* El secundario se lee como secundario: gris suave, no un borde negro. */
.btn-outline-secondary {
  --bs-btn-color: var(--bs-emphasis-color);
  --bs-btn-bg: var(--bs-body-bg);
  --bs-btn-border-color: var(--lp-control-border);
  --bs-btn-hover-color: var(--bs-emphasis-color);
  --bs-btn-hover-bg: var(--lp-head-bg);
  --bs-btn-hover-border-color: #94a3b8;
  --bs-btn-active-color: var(--bs-emphasis-color);
  --bs-btn-active-bg: var(--lp-line);
  --bs-btn-active-border-color: #94a3b8;
  --bs-btn-disabled-color: var(--lp-muted);
  --bs-btn-disabled-bg: var(--bs-body-bg);
  --bs-btn-disabled-border-color: var(--lp-line);
}

.btn-outline-primary {
  --bs-btn-bg: var(--bs-body-bg);
}

.btn:disabled,
.btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Filtros por estado: control segmentado en vez de una fila de botones. */
.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.25rem;
  background: var(--lp-head-bg);
  border: 1px solid var(--lp-line);
  border-radius: var(--lp-radius);
}

.segmented a {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  min-height: 2rem;
  padding: 0.25rem 0.75rem;
  border-radius: var(--lp-radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--lp-muted);
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.segmented a:hover {
  color: var(--bs-emphasis-color);
}

.segmented a[aria-current="page"] {
  background: var(--bs-body-bg);
  color: var(--bs-primary);
  box-shadow: var(--lp-shadow), 0 0 0 1px var(--lp-line);
}

.segmented .count {
  min-width: 1.25rem;
  padding: 0 0.375rem;
  border-radius: 999px;
  background: var(--lp-line);
  font-size: 0.6875rem;
  text-align: center;
}

/* Tablas: encabezado discreto, filas separadas por línea y realce al pasar. */

.table {
  --bs-table-striped-bg: transparent;
  --bs-table-hover-bg: var(--lp-row-hover);
  --bs-table-border-color: var(--lp-line);
  margin-bottom: 0;
}

.table > thead > tr > th,
.table > thead th {
  padding: 0.625rem 0.75rem;
  background: var(--lp-head-bg);
  border-bottom: 1px solid var(--lp-line);
  color: var(--lp-muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}

.table > thead th:first-child { border-top-left-radius: var(--lp-radius-sm); }
.table > thead th:last-child { border-top-right-radius: var(--lp-radius-sm); }

.table > tbody > tr > td,
.table > tbody > tr > th {
  padding: 0.75rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--lp-line);
}

.table-sm > tbody > tr > td,
.table-sm > tbody > tr > th {
  padding: 0.5rem 0.75rem;
}

.table > tbody > tr:last-child > * {
  border-bottom: 0;
}

.table-striped > tbody > tr:hover > * {
  --bs-table-bg-state: var(--lp-row-hover);
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
  --bs-table-bg-type: transparent;
}

.table td,
.table th {
  font-variant-numeric: tabular-nums;
}

/* Insignias de estado */

.badge {
  border-radius: 999px;
  padding: 0.3em 0.65em;
  font-size: 0.75rem;
  font-weight: 600;
}

/* Encabezado de página */

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* Editor de líneas de producto: rejilla, no tabla, para que el buscador no quede recortado. */

.line-editor {
  border: 1px solid var(--lp-line);
  border-radius: var(--lp-radius);
}

.line-editor-head,
.line-editor-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 2.5rem;
  gap: 0.75rem;
  align-items: center;
  padding: 0.625rem 0.75rem;
}

.line-editor-head {
  background: var(--lp-head-bg);
  border-bottom: 1px solid var(--lp-line);
  border-radius: var(--lp-radius) var(--lp-radius) 0 0;
  color: var(--lp-muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.line-editor-row + .line-editor-row {
  border-top: 1px solid var(--lp-line);
}

.line-editor-numbers {
  display: grid;
  grid-template-columns: var(--line-cols, 7rem);
  gap: 0.75rem;
}

.line-editor-head .line-editor-numbers > span {
  text-align: right;
}

.line-editor-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.625rem 0.75rem;
  border-top: 1px solid var(--lp-line);
  background: var(--lp-head-bg);
  border-radius: 0 0 var(--lp-radius) var(--lp-radius);
}

.line-editor-total {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.line-editor-label {
  display: none;
}

.btn-remove-line {
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--lp-radius-sm);
  color: var(--lp-muted);
  background: transparent;
  border: 0;
}

.btn-remove-line:hover {
  color: var(--bs-danger);
  background: rgba(var(--bs-danger-rgb), 0.08);
}

/* En el móvil cada línea es una ficha: producto arriba y cifras con su rótulo debajo. */
@media (max-width: 767.98px) {
  .line-editor-head {
    display: none;
  }

  .line-editor-row {
    grid-template-columns: minmax(0, 1fr) 2.75rem;
  }

  .line-editor-numbers {
    grid-column: 1 / 2;
    grid-row: 2;
  }

  .line-editor-label {
    display: block;
    font-size: 0.75rem;
    color: var(--lp-muted);
    margin-bottom: 0.25rem;
  }
}

/* Carrito del punto de venta */

.cart-lines {
  border-top: 1px solid var(--lp-line);
}

.cart-line {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--lp-line);
}

.cart-line-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.cart-line-name {
  font-weight: 600;
  line-height: 1.3;
}

.cart-line-controls {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.cart-line-controls .form-label {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--lp-muted);
  margin-bottom: 0.125rem;
}

.cart-line-total {
  margin-left: auto;
  font-weight: 700;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  padding-bottom: 0.4rem;
}

.cart-summary {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 1rem 0 0.25rem;
}

.cart-summary-total {
  font-size: 1.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* Indicadores del panel: el icono toma el tono de la marca salvo cuando alerta. */
.dashboard-chip:not(.dashboard-chip--alert) {
  background: rgba(var(--bs-primary-rgb), 0.1);
  color: var(--bs-primary);
}

a:hover > .card {
  border-color: rgba(var(--bs-primary-rgb), 0.35);
}

/* Montos y códigos en una sola línea: partidos no se leen. */
.table td.text-end,
.table th.text-end,
.table .font-monospace {
  white-space: nowrap;
}

/* En los filtros angostos el panel no se ajusta al botón: necesita ancho para leer. */
.ss-panel {
  min-width: 16rem;
}

/* Bloqueo por inactividad: tapa todo y deja solo el PIN. */
.session-lock-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(6px);
}

.session-lock-overlay[hidden] {
  display: none;
}

.session-lock-card {
  width: 100%;
  max-width: 340px;
  padding: 1.75rem 1.5rem 1.25rem;
  background: var(--bs-body-bg);
  border-radius: 1rem;
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.3);
}

/* Teclado del PIN */

.pin-pad-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.pin-pad-dots {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin: 0.5rem 0 0.75rem;
}

.pin-pad-dots span {
  width: 0.875rem;
  height: 0.875rem;
  border-radius: 50%;
  border: 2px solid var(--lp-control-border);
  transition: background-color 0.12s ease, border-color 0.12s ease, transform 0.12s ease;
}

.pin-pad-dots span.filled {
  background: var(--bs-primary);
  border-color: var(--bs-primary);
  transform: scale(1.1);
}

.pin-pad-error {
  min-height: 1.25rem;
  margin-bottom: 0.5rem;
  font-size: 0.8125rem;
  color: var(--bs-danger);
  text-align: center;
}

.pin-pad-keys {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.625rem;
}

/* 56 px: se acierta con el pulgar sin mirar. */
.pin-pad-key {
  height: 3.5rem;
  border: 1px solid var(--lp-line);
  border-radius: 0.875rem;
  background: var(--lp-head-bg);
  color: var(--bs-emphasis-color);
  font-size: 1.375rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition: background-color 0.1s ease, transform 0.1s ease;
  touch-action: manipulation;
}

.pin-pad-key:hover {
  background: var(--lp-row-hover);
}

.pin-pad-key:active {
  transform: scale(0.95);
  background: rgba(var(--bs-primary-rgb), 0.15);
}

.pin-pad-key-erase {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border-color: transparent;
  color: var(--lp-muted);
}

.shake {
  animation: pin-shake 0.32s ease;
}

@keyframes pin-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

@media (prefers-reduced-motion: reduce) {
  .shake { animation: none; }
  .pin-pad-key, .pin-pad-dots span { transition: none; }
}

/* Fotos del producto en su ficha */

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.625rem;
}

.photo-tile {
  position: relative;
  margin: 0;
  aspect-ratio: 1;
  border-radius: var(--lp-radius-sm);
  overflow: hidden;
  border: 1px solid var(--lp-line);
  background: var(--lp-head-bg);
}

.photo-tile.is-cover {
  border-color: var(--bs-primary);
  box-shadow: 0 0 0 2px var(--lp-ring);
}

.photo-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-tile-badge {
  position: absolute;
  top: 0.375rem;
  left: 0.375rem;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.4375rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  background: var(--bs-primary);
  color: #fff;
}

.photo-tile-actions {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.375rem;
  background: linear-gradient(transparent, rgba(15, 23, 42, 0.65));
}

.photo-tile-actions form { margin: 0; }

.photo-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: #0f172a;
  cursor: pointer;
}

.photo-action:hover { background: #fff; color: var(--bs-primary); }
.photo-action-danger:hover { color: var(--bs-danger); }

.photo-drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 1.25rem 1rem;
  border: 1.5px dashed var(--lp-control-border);
  border-radius: var(--lp-radius);
  text-align: center;
  color: var(--bs-body-color);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.photo-drop:hover,
.photo-drop:focus-within {
  border-color: var(--bs-primary);
  background: var(--lp-row-hover);
}

/* El input cubre la zona: recibe el arrastre y el toque. */
.photo-drop-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* Miniatura de la foto principal en el carrito y en la búsqueda del POS */

.product-thumb {
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--lp-radius-sm);
  object-fit: cover;
  background: var(--lp-head-bg);
  border: 1px solid var(--lp-line);
}

.product-thumb.is-empty {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--lp-muted);
}

/* Apariencia del catálogo en Parámetros: plantillas y vista previa */

.theme-templates {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 0.75rem;
}

.theme-template {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  padding: 0.75rem;
  border: 1px solid var(--lp-line);
  border-radius: var(--lp-radius);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.theme-template:hover { border-color: var(--lp-control-border); }

.theme-template:has(input:checked) {
  border-color: var(--bs-primary);
  box-shadow: 0 0 0 3px var(--lp-ring);
}

.theme-template:has(input:focus-visible) { outline: 2px solid var(--bs-primary); outline-offset: 2px; }

.theme-template-swatches {
  display: flex;
  height: 1.75rem;
  border-radius: var(--lp-radius-sm);
  overflow: hidden;
  border: 1px solid var(--lp-line);
}

.theme-template-swatches span { flex: 1; }
.theme-template-swatches span:first-child { flex: 2; }

.theme-template-name { font-weight: 600; font-size: 0.9375rem; }
.theme-template-desc { font-size: 0.75rem; color: var(--lp-muted); }

.theme-colors {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.75rem;
}

.theme-color {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.theme-color .form-control-color { width: 100%; height: 2.5rem; padding: 0.25rem; }

.theme-preview {
  overflow: hidden;
  border: 1px solid var(--lp-line);
  border-radius: var(--lp-radius);
  background: var(--cat-bg);
  color: var(--cat-text);
  font-family: var(--cat-font-body), "Inter", sans-serif;
}

.theme-preview-hero {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1.25rem;
  background: linear-gradient(135deg, var(--cat-hero-from), var(--cat-primary));
  color: var(--cat-primary-ink);
}

.theme-preview-eyebrow { font-size: 0.625rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; opacity: 0.75; }
.theme-preview-title { font-family: var(--cat-font-heading), "Inter", sans-serif; font-size: 1.5rem; font-weight: 700; line-height: 1.1; }

.theme-preview-search {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.5rem;
  padding: 0.25rem 0.25rem 0.25rem 0.75rem;
  border-radius: var(--cat-btn-radius);
  background: var(--cat-surface);
  color: color-mix(in srgb, var(--cat-text) 55%, var(--cat-surface));
  font-size: 0.75rem;
}

.theme-preview-cta {
  padding: 0.25rem 0.625rem;
  border-radius: var(--cat-btn-radius);
  background: var(--cat-cta);
  color: var(--cat-cta-ink);
  font-size: 0.6875rem;
  font-weight: 600;
}

.theme-preview-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  padding: 1rem;
}

.theme-preview-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--cat-text) 12%, var(--cat-bg));
  border-radius: var(--cat-radius);
  background: var(--cat-surface);
}

.theme-preview-media { aspect-ratio: 4 / 3; background: color-mix(in srgb, var(--cat-text) 8%, var(--cat-surface)); }

.theme-preview-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  padding: 0.625rem;
}

.theme-preview-eyebrow-sm { font-size: 0.5625rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--cat-primary); }
.theme-preview-name { font-family: var(--cat-font-heading), "Inter", sans-serif; font-size: 0.8125rem; font-weight: 650; line-height: 1.2; }
.theme-preview-muted { font-size: 0.6875rem; color: color-mix(in srgb, var(--cat-text) 62%, var(--cat-surface)); }

.theme-preview-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.25rem;
  margin-top: auto;
  padding: 0.5rem 0.625rem;
  border-top: 1px solid color-mix(in srgb, var(--cat-text) 12%, var(--cat-bg));
}

.theme-preview-price { font-size: 0.8125rem; font-weight: 700; color: var(--cat-primary); white-space: nowrap; }

/* Botones de filtro tipo píldora (categorías del punto de venta) */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 2.25rem;
  padding: 0.25rem 0.875rem;
  border: 1px solid var(--lp-control-border);
  border-radius: 999px;
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.chip:hover {
  border-color: var(--bs-primary);
  color: var(--bs-primary);
}

.chip[aria-current="true"] {
  background: var(--bs-primary);
  border-color: var(--bs-primary);
  color: #fff;
}
