/* ============================================
   TACOS DOÑA ELDA — Estilos compartidos
   Paleta tomada del logo: salsa roja, tortilla de
   maíz dorada, cilantro verde y carne asada.
   ============================================ */

:root {
  --rojo: #c1341f;        /* salsa roja del logo */
  --rojo-dark: #8f2415;
  --rojo-light: #ffddd4;
  --rojo-soft: #fff4f1;
  --crema: #fdf3e0;       /* tortilla */
  --maiz-light: #f6dfae;  /* maíz claro */
  --terracota: #a8542a;
  --carne: #6b4a35;       /* carne asada del logo */
  --verde: #4a8b3a;       /* cilantro */
  --verde-dark: #35682a;
  --amarillo: #e0a32e;    /* dorado del maíz */
  --azul: #1971c2;
  --texto: #2b1a10;
  --texto-suave: #7a5c48;
  --linea: #f0dcc8;
  --bg: #fffaf3;
  --blanco: #ffffff;
  --sombra: 0 4px 14px rgba(107, 74, 53, 0.10);
  --sombra-fuerte: 0 10px 30px rgba(107, 74, 53, 0.20);
  --radio: 14px;
  --radio-sm: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  overflow: hidden;
  position: fixed;
  width: 100%;
  -webkit-overflow-scrolling: touch;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--texto);
  font-size: 15px;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  touch-action: manipulation;
}

button, input, select, .menu-item, .mesa-card, .cat-chip, .mod-toggle, .tab, .rol-card {
  touch-action: manipulation;
}
input, select, textarea { font-size: 16px !important; }

/* ============== FONDO DECORATIVO ============== */
.papel-picado {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.04;
  background-image:
    radial-gradient(circle at 20% 30%, var(--rojo) 0, transparent 30%),
    radial-gradient(circle at 80% 70%, var(--terracota) 0, transparent 30%),
    radial-gradient(circle at 50% 50%, var(--amarillo) 0, transparent 25%);
  z-index: 0;
}

/* ============== HEADER GENERAL ============== */
.app-header {
  position: relative;
  z-index: 10;
  background: linear-gradient(135deg, var(--rojo) 0%, var(--rojo-dark) 100%);
  color: white;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--sombra);
}
.app-header::before {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 0;
  right: 0;
  height: 8px;
  background-image: radial-gradient(circle at 8px 0, transparent 6px, var(--rojo-dark) 6px, var(--rojo-dark) 8px, transparent 8px);
  background-size: 16px 8px;
  background-repeat: repeat-x;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--crema) url('../icons/logo-taco.png') center/82% no-repeat;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.brand-mark > svg { display: none; }
.brand-text h1 {
  font-family: 'Fraunces', serif;
  font-size: 17px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.01em;
}
.brand-text h1 span { font-style: italic; font-weight: 500; }
.brand-text p {
  font-size: 11px;
  opacity: 0.85;
  margin-top: 3px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.header-pill {
  background: rgba(255,255,255,0.15);
  padding: 6px 12px;
  border-radius: var(--radio-sm);
  text-align: right;
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.2);
}
.header-pill .label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.85;
}
.header-pill .amount {
  display: block;
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.1;
}
.header-pill.cerrar-sesion {
  background: rgba(0,0,0,0.18);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 12px;
}

/* ============== BOTONES ============== */
.btn-primary, .btn-add-table {
  background: var(--rojo);
  color: white;
  border: none;
  padding: 12px 18px;
  border-radius: var(--radio-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 2px 8px rgba(193, 52, 31, 0.3);
  transition: transform 0.15s;
}
.btn-primary:active, .btn-add-table:active { transform: scale(0.97); }

.btn-secondary {
  background: var(--rojo-soft);
  color: var(--rojo-dark);
  border: 1px solid var(--linea);
  padding: 12px 18px;
  border-radius: var(--radio-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-secondary:active { transform: scale(0.97); }

.btn-danger {
  background: #e03131;
  color: white;
  border: none;
  padding: 12px 18px;
  border-radius: var(--radio-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-danger:active { transform: scale(0.97); }

.btn-success {
  background: linear-gradient(135deg, var(--verde) 0%, var(--verde-dark) 100%);
  color: white;
  border: none;
  padding: 12px 18px;
  border-radius: var(--radio-sm);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(74, 139, 58, 0.3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-success:active { transform: scale(0.97); }
.btn-success:disabled { opacity: 0.5; background: #b5b5b5; box-shadow: none; cursor: not-allowed; }

.btn-back, .btn-icon-danger {
  background: var(--rojo-soft);
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--rojo-dark);
  cursor: pointer;
  flex-shrink: 0;
}
.btn-icon-danger { color: #e03131; background: #ffe3e3; }

/* ============== TABS ============== */
.tabs {
  position: relative;
  z-index: 9;
  display: flex;
  background: white;
  border-bottom: 1px solid var(--linea);
  padding: 0 4px;
  flex-shrink: 0;
}
.tab {
  flex: 1;
  background: none;
  border: none;
  padding: 12px 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--texto-suave);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  position: relative;
}
.tab.active { color: var(--rojo); }
.tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 20%;
  right: 20%;
  height: 3px;
  background: var(--rojo);
  border-radius: 3px 3px 0 0;
}

/* ============== MAIN / VISTAS ============== */
.app-main {
  position: relative;
  z-index: 5;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.view {
  display: none;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
}
.view.active { display: block; }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 10px;
  flex-wrap: wrap;
}
.section-head h2 {
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: 24px;
  color: var(--rojo-dark);
  letter-spacing: -0.02em;
}
.subhead {
  font-family: 'Fraunces', serif;
  font-size: 17px;
  color: var(--rojo-dark);
  margin: 20px 0 10px;
  font-weight: 600;
}

/* ============== EMPTY STATE ============== */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 20px;
  color: var(--texto-suave);
}
.empty-state svg { margin-bottom: 12px; opacity: 0.5; }
.empty-state p { font-weight: 700; margin-bottom: 4px; }

/* ============== MODAL ============== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(42, 22, 32, 0.55);
  backdrop-filter: blur(4px);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  padding: 0;
  animation: fade-in 0.2s ease;
}
.modal.open { display: flex; }
.modal-content {
  background: white;
  width: 100%;
  max-width: 480px;
  border-radius: 20px 20px 0 0;
  padding: 24px 20px 20px;
  animation: slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  max-height: 90vh;
  overflow-y: auto;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal h3 {
  font-family: 'Fraunces', serif;
  font-size: 22px;
  color: var(--rojo-dark);
  margin-bottom: 16px;
  font-weight: 700;
}
.modal p { color: var(--texto-suave); margin-bottom: 16px; font-size: 14px; }
.modal label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--texto-suave);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
  margin-top: 12px;
}
.modal label:first-of-type { margin-top: 0; }
.modal input, .modal select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--linea);
  border-radius: var(--radio-sm);
  font-family: inherit;
  font-size: 16px !important;
  color: var(--texto);
  background: var(--rojo-soft);
  outline: none;
}
.modal input:focus, .modal select:focus { border-color: var(--rojo); background: white; }
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
}
.modal-actions button { flex: 1; min-width: 100px; }

/* Fila con checkbox dentro de un modal */
.modal label.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--texto);
  margin-top: 16px;
  cursor: pointer;
}
.modal label.check-row input[type="checkbox"] {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  accent-color: var(--rojo);
  margin: 0;
}
#nuevo-cocina-hint { color: var(--texto-suave); margin-top: 6px !important; }

/* ============== TOAST ============== */
.toast {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--texto);
  color: white;
  padding: 12px 20px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--sombra-fuerte);
  z-index: 200;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--verde); }
.toast.error { background: #e03131; }

/* ============== PANTALLA DE CARGA / LOGIN ============== */
.pantalla-completa {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, var(--rojo) 0%, var(--rojo-dark) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
  color: white;
}

.logo-grande {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: var(--crema) url('../icons/logo-taco.png') center/82% no-repeat;
  display: grid;
  place-items: center;
  margin-bottom: 20px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.logo-grande > svg { display: none; }
.titulo-pantalla {
  font-family: 'Fraunces', serif;
  font-size: 30px;
  font-weight: 900;
  text-align: center;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.titulo-pantalla span { font-style: italic; font-weight: 500; }
.subtitulo-pantalla {
  text-align: center;
  opacity: 0.85;
  font-size: 13px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 28px;
}

/* Selector de roles */
.roles-grid {
  display: grid;
  gap: 12px;
  width: 100%;
  max-width: 360px;
}
.rol-card {
  background: white;
  color: var(--texto);
  border: none;
  border-radius: var(--radio);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  box-shadow: 0 6px 18px rgba(0,0,0,0.12);
  transition: transform 0.15s;
}
.rol-card:active { transform: scale(0.97); }
.rol-card .icon-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--rojo-soft);
  color: var(--rojo);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.rol-card .icon-circle svg { width: 24px; height: 24px; }
.rol-card .info { flex: 1; }
.rol-card .nombre-rol {
  font-family: 'Fraunces', serif;
  font-size: 19px;
  font-weight: 700;
  color: var(--rojo-dark);
  line-height: 1;
}
.rol-card .desc-rol {
  font-size: 12px;
  color: var(--texto-suave);
  margin-top: 4px;
}
.rol-card .arrow {
  color: var(--rojo);
}

/* Login con nombre */
.login-card {
  background: white;
  color: var(--texto);
  border-radius: var(--radio);
  padding: 24px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.18);
}
.login-card h2 {
  font-family: 'Fraunces', serif;
  font-size: 22px;
  color: var(--rojo-dark);
  margin-bottom: 6px;
  font-weight: 700;
}
.login-card p {
  font-size: 13px;
  color: var(--texto-suave);
  margin-bottom: 18px;
}
.login-card input {
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--linea);
  border-radius: var(--radio-sm);
  font-family: inherit;
  font-size: 16px !important;
  color: var(--texto);
  background: var(--rojo-soft);
  outline: none;
  margin-bottom: 14px;
}
.login-card input:focus { border-color: var(--rojo); background: white; }
.login-card .btn-primary { width: 100%; padding: 14px; }
.login-card .link-back {
  display: block;
  text-align: center;
  margin-top: 14px;
  color: var(--rojo);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

/* Pantalla de error de config */
.error-config {
  background: white;
  color: var(--texto);
  border-radius: var(--radio);
  padding: 24px;
  max-width: 480px;
  margin: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.error-config h2 { font-family: 'Fraunces', serif; color: var(--rojo-dark); margin-bottom: 10px; }
.error-config p { font-size: 14px; line-height: 1.6; margin-bottom: 10px; }
.error-config code {
  background: var(--rojo-soft);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
}
.error-config ol { padding-left: 22px; margin-top: 10px; font-size: 13px; }
.error-config li { margin-bottom: 6px; }
