/*
 * Restofy Pro - Global CSS
 * 100% reusable, prefix classes with .ui-
 */

:root {
  /* Con el naranja de respaldo: solo el menú digital define --color-primary* (color de marca). */
  --primary: rgb(var(--color-primary, 255 69 0));
  --primary-light: rgb(var(--color-primary-light, 255 116 63));
  --primary-dark: rgb(var(--color-primary-dark, 204 55 0));
  --bg-dark: #1A1A1E;
  --surface-dark: #242428;
  --border-dark: #374151;
}

/* Red de seguridad: un panel/dropdown mal posicionado nunca debe abrir scroll horizontal de la pagina.
   `clip` (no `hidden`): recorta el overflow horizontal SIN volver al body contenedor de scroll,
   evitando el bug de iOS/PWA donde `overflow-x:hidden` rompe `position:fixed` (barras y popovers
   fijos scrollean con la pagina en vez de quedar pegados al viewport). */
html, body {
  overflow-x: clip;
}

body {
  font-family: 'Roboto', sans-serif;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* iOS Safari hace zoom automático al enfocar un input con font-size < 16px.
   Forzamos 16px solo en mobile para no alterar el tamaño en desktop/tablet.
   !important porque debe ganar sin depender de la especificidad de cada
   clase de input existente o futura (ui-input, utilities de Tailwind, etc). */
@media (max-width: 767px) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]),
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* Base Panel */
.ui-panel {
  background-color: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 1rem;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.dark .ui-panel {
  background-color: var(--surface-dark);
  border-color: var(--border-dark);
}

/* Panel hover effect */
.ui-panel-hover:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.01);
}

.dark .ui-panel-hover:hover {
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
}

/* Buttons */
.ui-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border-radius: 0.75rem;
  font-weight: 500;
  font-size: 0.875rem;
  transition: all 0.2s;
  cursor: pointer;
  gap: 0.5rem;
  user-select: none;
}

.ui-btn-primary {
  background-color: var(--primary);
  color: white;
  border: transparent;
}

.ui-btn-primary:hover {
  background-color: var(--primary-light);
  box-shadow: 0 4px 14px 0 rgb(var(--color-primary, 255 69 0) / 0.39);
}

.ui-btn-secondary {
  background-color: #ffffff;
  color: #374151;
  border: 1px solid #e5e7eb;
}

.ui-btn-secondary:hover {
  background-color: #f9fafb;
  border-color: #d1d5db;
  color: #111827;
}

.dark .ui-btn-secondary {
  background-color: transparent;
  color: #d1d5db;
  border-color: var(--border-dark);
}

.dark .ui-btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: #ffffff;
}

.ui-btn-ghost {
  background-color: transparent;
  color: #4b5563;
}

.dark .ui-btn-ghost {
  color: #9ca3af;
}

.ui-btn-ghost:hover {
  background-color: #f3f4f6;
  color: #111827;
}

.dark .ui-btn-ghost:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: #f9fafb;
}

.ui-btn-icon {
  padding: 0.5rem;
  border-radius: 0.75rem;
  color: #6b7280;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s, color 0.2s;
}

.ui-btn-icon:hover {
  background-color: #f3f4f6;
  color: #111827;
}

.dark .ui-btn-icon {
  color: #9ca3af;
}

.dark .ui-btn-icon:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: #e5e7eb;
}

/* Botones icono + texto en mobile: la app entera arma estos botones a mano con
   "flex items-center justify-center", lo que en pantallas chicas hace saltar de
   linea el texto largo (ej. "Editar comensales") porque el grupo no puede achicarse.
   Corregimos con un solo selector estructural (icono <i> seguido de <span> de texto)
   habilitando el truncado con "..." sin tocar cada .php. No forzamos alineación:
   con min-width:0 el texto trunca igual y los botones anchos (ej. CTA "Agregar")
   se mantienen centrados como los diseñó cada página. */
@media (max-width: 639px) {
  button:has(> i:first-child + span):not(.flex-col),
  a:has(> i:first-child + span):not(.flex-col) {
    min-width: 0;
  }

  button:has(> i:first-child + span):not(.flex-col) > i:first-child,
  a:has(> i:first-child + span):not(.flex-col) > i:first-child {
    flex-shrink: 0;
  }

  button:has(> i:first-child + span):not(.flex-col) > span:last-child,
  a:has(> i:first-child + span):not(.flex-col) > span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
  }
}

/* Sidebar Links */
.ui-nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  color: #4b5563;
  font-weight: 500;
  font-size: 0.875rem;
  transition: all 0.2s;
}

.dark .ui-nav-link {
  color: #9ca3af;
}

.ui-nav-link:hover {
  background-color: rgb(var(--color-primary, 255 69 0) / 0.08);
  color: var(--primary);
}

.ui-nav-link.active {
  background-color: rgb(var(--color-primary, 255 69 0) / 0.1);
  color: var(--primary);
  box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.02);
}

.ui-nav-link i {
  font-size: 1.25rem;
  width: 1.5rem;
  text-align: center;
  transition: transform 0.2s;
}

.ui-nav-link:hover i, .ui-nav-link.active i {
  transform: scale(1.1);
}

/* Sin flechitas de incremento en inputs numéricos: el scroll accidental de la
   rueda cambiaba el valor. El formateo de miles los pasa a type=text de todos modos. */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* En iOS (WebKit) los inputs date/time nativos ignoran nuestro box model y centran
   el valor. Reseteamos su apariencia para que respeten padding, alto y alineación. */
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="month"] {
  -webkit-appearance: none;
  appearance: none;
}
input[type="date"]::-webkit-date-and-time-value,
input[type="time"]::-webkit-date-and-time-value,
input[type="datetime-local"]::-webkit-date-and-time-value,
input[type="month"]::-webkit-date-and-time-value {
  text-align: left;
}
/* Vacíos, iOS ya no muestra el placeholder nativo y el campo se colapsa:
   fijamos alto mínimo para igualar el resto de inputs. */
.ui-input[type="date"],
.ui-input[type="time"],
.ui-input[type="datetime-local"],
.ui-input[type="month"] {
  min-height: 2.625rem;
}

/* Inputs */
.ui-input {
  width: 100%;
  background-color: #f9fafb;
  border: 1px solid #e5e7eb;
  color: #111827;
  font-size: 0.875rem;
  border-radius: 0.75rem;
  padding: 0.625rem 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.ui-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgb(var(--color-primary, 255 69 0) / 0.2);
}

.dark .ui-input {
  background-color: var(--bg-dark);
  border-color: var(--border-dark);
  color: #ffffff;
}

.ui-input-wrapper {
  position: relative;
}

.ui-input-wrapper > i {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
}

.ui-input-wrapper .ui-input {
  padding-left: 2.5rem;
}

/* El ícono después del input (ej. la X de limpiar) va a la derecha, no encima de la lupa */
.ui-input-wrapper > .ui-input ~ i {
  left: auto;
  right: 1rem;
}

.ui-input-wrapper > .ui-input:has(~ i) {
  padding-right: 2.5rem;
}

/* Badges */
.ui-badge {
  display: inline-flex;
  align-items: center;
  /* Separa el ícono del texto: en un flex el espacio entre los dos se pierde. */
  gap: 0.375rem;
  padding: 0.125rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.ui-badge-success { background-color: rgba(16, 185, 129, 0.1); color: #059669; }
.dark .ui-badge-success { background-color: rgba(16, 185, 129, 0.15); color: #34d399; }

.ui-badge-warning { background-color: rgba(245, 158, 11, 0.1); color: #d97706; }
.dark .ui-badge-warning { background-color: rgba(245, 158, 11, 0.15); color: #fbbf24; }

.ui-badge-danger { background-color: rgba(239, 68, 68, 0.1); color: #dc2626; }
.dark .ui-badge-danger { background-color: rgba(239, 68, 68, 0.15); color: #f87171; }

.ui-badge-primary { background-color: rgb(var(--color-primary, 255 69 0) / 0.1); color: var(--primary); }

/* Info: estado en proceso/neutral (azul). No alarmante: el rojo queda para error/anulación. */
.ui-badge-info { background-color: rgba(59, 130, 246, 0.1); color: #2563eb; }
.dark .ui-badge-info { background-color: rgba(59, 130, 246, 0.15); color: #60a5fa; }

/* Neutral: estado inactivo/descartado (gris). Sin alarma: no es error, quedó fuera de juego. */
.ui-badge-neutral { background-color: rgba(107, 114, 128, 0.12); color: #4b5563; }
.dark .ui-badge-neutral { background-color: rgba(156, 163, 175, 0.15); color: #9ca3af; }

/* Glassmorphism */
.ui-glass {
  background-color: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.dark .ui-glass {
  background-color: rgba(36, 36, 40, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background-color: #d1d5db;
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background-color: #9ca3af;
}
.dark ::-webkit-scrollbar-thumb {
  background-color: #4b5563;
}
.dark ::-webkit-scrollbar-thumb:hover {
  background-color: #6b7280;
}

/* Typography fix */
.text-balance {
  text-wrap: balance;
}

/* Oculta el scrollbar pero mantiene el scroll funcional (chips horizontales, etc.) */
.no-scrollbar {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.no-scrollbar::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

/* Indica al usuario que se puede arrastrar; el handler vive en shared/utils/drag-scroll.js */
.drag-scroll {
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.drag-scroll.is-dragging {
  cursor: grabbing;
}

/* Modal overlay (oscuro + blur) — disponible en todas las páginas */
.ui-modal-overlay {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* Switch de encendido/apagado — disponible en todas las páginas */
.ui-switch {
  appearance: none;
  -webkit-appearance: none;
  width: 2.6rem;
  height: 1.5rem;
  border-radius: 999px;
  background: #d1d5db;
  position: relative;
  cursor: pointer;
  transition: background 0.2s ease;
  flex-shrink: 0;
}
.dark .ui-switch { background: #4b5563; }
.ui-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 999px;
  background: #fff;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
.ui-switch:checked { background: var(--primary); }
.ui-switch:checked::after { transform: translateX(1.1rem); }

/* Animations */
@keyframes pulseSoft {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.animate-pulse-soft {
  animation: pulseSoft 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Respaldo de imagen rota: reemplaza el alt feo del navegador por un ícono centrado y neutro.
   Lo inyecta shared/web/utils/image-fallback.js sobre cualquier <img class="js-img-fallback">. */
.ui-img-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: #9ca3af;
  opacity: 0.65;
}
.dark .ui-img-fallback { color: #6b7280; }

/* Asistentes de asignación masiva (productos, insumos): checkbox, selector de modo, chips y tarjetas de categoría. */

/* Checkbox */
.ui-checkbox {
    appearance: none;
    width: 1.15rem;
    height: 1.15rem;
    border: 2px solid #d1d5db;
    border-radius: 0.375rem;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: border-color 0.15s, background-color 0.15s;
}
.dark .ui-checkbox {
    border-color: #4b5563;
    background-color: transparent;
}
.ui-checkbox:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}
.ui-checkbox:checked::after {
    content: "\f00c";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 0.6875rem;
    color: #fff;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Segmented control (Reemplazar / Sumar) */
.ui-segmented {
    display: inline-flex;
    padding: 0.2rem;
    border-radius: 0.6rem;
    background-color: #f3f4f6;
    gap: 0.15rem;
}
.dark .ui-segmented {
    background-color: #1a1a1e;
}
.ui-segmented button {
    padding: 0.3rem 0.7rem;
    border-radius: 0.45rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: #6b7280;
    transition: background-color 0.15s, color 0.15s;
}
.ui-segmented button:hover {
    color: #374151;
}
.dark .ui-segmented button:hover {
    color: #d1d5db;
}
.ui-segmented button.is-active {
    background-color: #fff;
    color: var(--primary);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}
.dark .ui-segmented button.is-active {
    background-color: #242428;
    color: var(--primary);
}

/* Input de chips (anexos comunes) */
.ui-chips-input {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    width: 100%;
    min-height: 2.75rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    background-color: #fff;
    cursor: text;
}
.dark .ui-chips-input {
    border-color: #374151;
    background-color: #1a1a1e;
}
.ui-chips-input:focus-within {
    border-color: var(--primary);
}
.ui-chips-input input {
    flex: 1;
    min-width: 8rem;
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.875rem;
    color: #111827;
}
.dark .ui-chips-input input {
    color: #f3f4f6;
}
.ui-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.5rem 0.2rem 0.6rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    background-color: rgb(var(--color-primary, 255 69 0) / 0.1);
    color: var(--primary);
}
.ui-chip button {
    display: inline-flex;
    opacity: 0.7;
}
.ui-chip button:hover {
    opacity: 1;
}

/* Chip seleccionable de los bloques del paso 2 (menús, impuestos, alérgenos, modificadores) */
.ui-pick-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    max-width: 100%;
    padding: 0.4rem 0.7rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    background-color: #fff;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}
.dark .ui-pick-chip {
    border-color: #374151;
    background-color: #1a1a1e;
    color: #d1d5db;
}
.ui-pick-chip:hover {
    border-color: #d1d5db;
}
.dark .ui-pick-chip:hover {
    border-color: #4b5563;
}
.ui-pick-chip.is-active {
    border-color: rgb(var(--color-primary, 255 69 0) / 0.4);
    background-color: rgb(var(--color-primary, 255 69 0) / 0.1);
    color: var(--primary);
}
.ui-pick-chip-note {
    font-size: 0.75rem;
    font-weight: 400;
    color: #9ca3af;
}
.ui-pick-chip.is-active .ui-pick-chip-note {
    color: var(--primary);
    opacity: 0.8;
}

/* Card de categoría seleccionable (paso 1) */
.ui-cat-card {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.7rem;
    border-radius: 0.75rem;
    border: 1.5px solid #e5e7eb;
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s;
    text-align: left;
}
.dark .ui-cat-card {
    border-color: #374151;
}
.ui-cat-card:hover {
    border-color: #d1d5db;
}
.dark .ui-cat-card:hover {
    border-color: #4b5563;
}
.ui-cat-card.is-active {
    border-color: var(--primary);
    background-color: rgb(var(--color-primary, 255 69 0) / 0.05);
}
