/* Layout base compartido por temas 5-8.
   Cada styleN.css solo redefine colores/tipografia/efectos sobre estas reglas. */

.ng-cloak, [ng-cloak] { display: none !important; }

.th-base {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  padding-bottom: 100px;
}

.th-loader {
  display: flex; align-items: center; justify-content: center;
  width: 100vw; height: 100vh;
}

.th-shell {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}

/* navbar */
.th-navbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--navbar);
  color: var(--navbar-text);
  margin: 0 calc(-1 * var(--space-4));
  padding: var(--space-3) var(--space-4) var(--space-2);
  box-shadow: var(--shadow-sm);
}
.th-navbar__row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.th-navbar__brand { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; text-decoration: none; color: inherit; min-width: 0; }
.th-navbar__logo { display: block; }
.th-navbar__logo--square { width: 32px; height: 32px; object-fit: contain; border-radius: 6px; }
.th-navbar__logo--wide { height: 28px; width: auto; max-width: 180px; object-fit: contain; }
.th-navbar__title { font-size: 17px; font-weight: 700; margin: 0; cursor: pointer; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.th-navbar__mesa { font-size: 14px; opacity: 0.8; }
.th-navbar__badges { display: flex; gap: var(--space-2); margin-top: var(--space-2); flex-wrap: wrap; }
.th-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
  background: rgba(0,0,0,0.05); color: var(--text-muted);
}
.th-badge--ok { background: rgba(34,197,94,0.12); color: #16a34a; }

.th-iconbtn {
  background: transparent; border: 1px solid var(--border);
  width: 40px; height: 40px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text);
}
.th-iconbtn:hover { background: rgba(0,0,0,0.04); }

/* hero */
.th-hero {
  margin-top: var(--space-4);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-sm);
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.th-hero__img {
  width: 100%; max-height: 110px; object-fit: contain;
  display: block; margin: 0 auto;
}
.th-hero__img--square { max-width: 200px; max-height: 200px; }
.th-hero__carousel {
  display: flex; gap: var(--space-3);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin: 0 calc(-1 * var(--space-3));
  padding: 0 var(--space-3);
}
.th-hero__carousel::-webkit-scrollbar { display: none; }
.th-hero__promo {
  position: relative;
  flex: 0 0 100%;
  scroll-snap-align: center;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: rgba(0,0,0,0.04);
}
.th-hero__promo img {
  width: 100%; height: 160px;
  object-fit: cover; display: block;
}
.th-hero__promo p {
  position: absolute; bottom: 8px; left: 8px; right: 8px;
  background: rgba(0,0,0,0.6); color: white; padding: 6px 10px;
  border-radius: var(--radius-sm); font-size: 13px; margin: 0;
}

/* search (sticky bajo navbar, sobre chip-tabs) */
.th-search {
  position: sticky; top: 90px; z-index: 35;
  margin: 0 calc(-1 * var(--space-4));
  padding: var(--space-3) var(--space-4) var(--space-2);
  background: var(--bg);
}
.th-search i {
  position: absolute; left: calc(var(--space-4) + 16px); top: 50%; transform: translateY(-50%);
  color: var(--text-muted);
}
.th-search input {
  width: 100%; padding: 14px 16px 14px 42px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  font-size: 15px; color: var(--text);
  outline: none;
  transition: border-color var(--transition);
}
.th-search input:focus { border-color: var(--accent); }

/* categorias scrollspy horizontal */
.th-cats {
  position: sticky; top: 154px; z-index: 40;
  display: flex; gap: var(--space-2);
  margin: 0 calc(-1 * var(--space-4)) var(--space-3);
  padding: var(--space-2) var(--space-4);
  background: linear-gradient(var(--bg) 80%, transparent);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.th-cats::-webkit-scrollbar { display: none; }
.th-cats .tk-chip { flex-shrink: 0; }

/* productos */
.th-products {
  list-style: none; padding: 0; margin: 0;
  display: grid; gap: var(--space-3);
}
.th-product {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  display: grid;
  grid-template-columns: 110px 1fr;
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}
.th-product:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.th-product__img {
  width: 110px; height: 110px; object-fit: cover; cursor: pointer; background: #f0f0f0;
}
.th-product__body { padding: var(--space-3); display: flex; flex-direction: column; gap: 4px; }
.th-product__name { font-weight: 600; font-size: 15px; color: var(--text); line-height: 1.3; }
.th-product__desc {
  font-size: 13px; color: var(--text-muted); margin: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.th-product__row {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: auto; padding-top: var(--space-2);
}
.th-product__price { font-size: 16px; color: var(--text); font-weight: 700; }

/* stepper */
.th-stepper {
  display: inline-flex; align-items: center;
  background: rgba(0,0,0,0.04); border-radius: 999px;
  padding: 2px;
}
.th-stepper button {
  width: 30px; height: 30px; border-radius: 999px; border: none;
  background: transparent; color: var(--text); font-size: 18px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
}
.th-stepper button:hover:not(:disabled) { background: rgba(0,0,0,0.08); }
.th-stepper button:disabled { opacity: 0.35; cursor: not-allowed; }
.th-stepper input {
  width: 36px; text-align: center; border: none; background: transparent;
  font-size: 14px; font-weight: 600; color: var(--text); outline: none;
  -moz-appearance: textfield;
}
.th-stepper input::-webkit-outer-spin-button,
.th-stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* secciones genericas */
.th-section { padding: var(--space-4) 0; }
.th-section h2 { font-size: 18px; margin: var(--space-4) 0 var(--space-3); }
.th-muted { color: var(--text-muted); }
.th-ok { color: #16a34a; }
.th-rechazado { color: #dc2626; font-weight: 600; }
.th-enviado { color: #16a34a; font-weight: 600; }

/* checkout */
.th-checkout .th-input,
.th-input {
  width: 100%; padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  font-size: 15px; color: var(--text);
  outline: none;
  font-family: inherit;
}
.th-input:focus { border-color: var(--accent); }
textarea.th-input { resize: vertical; min-height: 60px; }

.th-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: var(--space-3); }
.th-field label { font-size: 13px; color: var(--text-muted); font-weight: 500; }

.th-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
@media (max-width: 480px) { .th-grid { grid-template-columns: 1fr; } }

.th-list { list-style: none; padding: 0; margin: var(--space-3) 0; }
.th-list li {
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.th-list li:last-child { border-bottom: none; }
.th-list li i { margin-right: 6px; color: var(--text-muted); }

.th-promo {
  display: flex; justify-content: space-between;
  padding: var(--space-2) 0; border-bottom: 1px dashed var(--border);
  font-size: 14px;
}

/* carrito resumen */
.th-cart-summary { margin-top: var(--space-5); }
.th-cart-item {
  display: grid; grid-template-columns: auto 1fr auto;
  gap: var(--space-3); align-items: center;
  padding: var(--space-3) 0; border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.th-cart-item__qty {
  background: rgba(0,0,0,0.05); border-radius: 6px;
  padding: 2px 8px; font-weight: 600; min-width: 28px; text-align: center;
}
.th-cart-item__name { color: var(--text); }
.th-cart-item__price { font-weight: 600; white-space: nowrap; }

.th-cart-item--editable {
  grid-template-columns: auto 1fr auto auto;
}
.th-cart-stepper {
  display: inline-flex; align-items: center;
  background: rgba(0,0,0,0.05); border-radius: 999px; padding: 2px;
}
.th-cart-stepper button {
  width: 26px; height: 26px; border-radius: 999px; border: none;
  background: transparent; color: var(--text); font-size: 16px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.th-cart-stepper button:hover { background: rgba(0,0,0,0.08); }
.th-cart-stepper span {
  min-width: 22px; text-align: center; font-weight: 600; font-size: 14px;
  color: var(--text);
}
.th-cart-item__del {
  width: 28px; height: 28px; border-radius: 999px; border: none;
  background: transparent; color: var(--text-muted);
  font-size: 20px; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.th-cart-item__del:hover {
  background: rgba(220,38,38,0.1); color: #dc2626;
}

.th-cart-item__main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.th-cart-item__opcs {
  font-size: 12px; color: var(--text-muted); line-height: 1.3;
}
.th-cart-item__edit {
  align-self: flex-start;
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: transparent; border: 1px solid var(--border); color: var(--text-muted);
  cursor: pointer; margin-top: 2px;
}
.th-cart-item__edit:hover { color: var(--accent); border-color: var(--accent); }

/* ===== Bottom sheet de opcionales ===== */
.th-sheet {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: flex-end; justify-content: center;
  animation: th-sheet-fade 200ms ease-out;
}
@keyframes th-sheet-fade { from { opacity: 0 } to { opacity: 1 } }

.th-sheet__panel {
  width: 100%; max-width: 520px;
  background: var(--card); color: var(--text);
  border-radius: var(--radius) var(--radius) 0 0;
  max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: 0 -8px 32px rgba(0,0,0,0.18);
  animation: th-sheet-slide 280ms cubic-bezier(.22,1,.36,1);
}
@keyframes th-sheet-slide { from { transform: translateY(100%) } to { transform: translateY(0) } }

@media (min-width: 768px) {
  .th-sheet { align-items: center; }
  .th-sheet__panel {
    border-radius: var(--radius);
    max-height: 80vh;
  }
}

.th-sheet__header {
  position: relative;
  padding: var(--space-4);
  border-bottom: 1px solid var(--border);
}
.th-sheet__close {
  position: absolute; top: var(--space-3); right: var(--space-3);
  width: 32px; height: 32px; border-radius: 999px;
  background: rgba(0,0,0,0.05); border: none; color: var(--text);
  font-size: 22px; line-height: 1; cursor: pointer;
}
.th-sheet__close:hover { background: rgba(0,0,0,0.1); }
.th-sheet__img {
  width: 100%; max-height: 160px; object-fit: cover;
  border-radius: var(--radius-sm); margin-bottom: var(--space-3);
}
.th-sheet__title { margin: 0 0 4px; font-size: 18px; padding-right: 36px; }
.th-sheet__desc { margin: 0 0 var(--space-2); color: var(--text-muted); font-size: 13px; line-height: 1.4; }
.th-sheet__price { font-size: 16px; color: var(--accent); font-weight: 700; }

.th-sheet__body {
  flex: 1; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.th-sheet__group { padding: var(--space-4); border-bottom: 1px solid var(--border); }
.th-sheet__group:last-child { border-bottom: none; }
.th-sheet__group-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--space-3); margin-bottom: var(--space-3);
}
.th-sheet__group-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.th-sheet__group-hint {
  display: block; font-size: 12px; color: var(--text-muted); margin-top: 2px;
}
.th-sheet__group-progress {
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
  background: rgba(0,0,0,0.05); color: var(--text-muted); white-space: nowrap;
  font-weight: 600;
}
.th-sheet__group-progress.is-ok { background: rgba(34,197,94,0.12); color: #16a34a; }
.th-sheet__group-progress.is-required { background: rgba(245,158,11,0.12); color: #b45309; }

.th-sheet__options { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.th-sheet__options li {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.th-sheet__options li:hover { border-color: var(--accent); }
.th-sheet__options li.is-selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}
.th-sheet__opt-name { flex: 1; font-size: 14px; }
.th-sheet__opt-price { font-size: 13px; color: var(--text-muted); white-space: nowrap; font-weight: 600; }

.th-sheet__radio {
  width: 20px; height: 20px; border-radius: 999px;
  border: 2px solid var(--border);
  flex-shrink: 0; position: relative;
  transition: all var(--transition);
}
.th-sheet__options li.is-selected .th-sheet__radio {
  border-color: var(--accent); background: var(--accent);
}
.th-sheet__options li.is-selected .th-sheet__radio::after {
  content: ''; position: absolute; inset: 4px;
  background: var(--card); border-radius: 999px;
}

.th-sheet__stepper { cursor: default; }
.th-sheet__stepper input { width: 28px; }

.th-sheet__error {
  margin: 0 var(--space-4) var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: rgba(220,38,38,0.1); color: #991b1b;
  border-radius: var(--radius-sm); white-space: pre-line;
  font-size: 13px;
}

.th-sheet__footer {
  display: flex; gap: var(--space-3); align-items: center;
  padding: var(--space-3) var(--space-4);
  padding-bottom: max(var(--space-3), env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--card);
}
.th-sheet__qty { flex-shrink: 0; }
.th-sheet__confirm {
  flex: 1; display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3);
  padding: 14px var(--space-4); font-size: 15px;
}
.th-sheet__confirm b { font-weight: 700; }

.th-total {
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--space-4) 0; font-size: 18px; font-weight: 700;
}

.th-actions {
  display: flex; gap: var(--space-3); margin-top: var(--space-4);
}
.th-actions .tk-btn { flex: 1; }

.th-alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  background: rgba(59,130,246,0.1); color: #1e40af;
  margin: var(--space-3) 0; font-size: 14px;
}
.th-alert--err { background: rgba(220,38,38,0.1); color: #991b1b; }

.th-success {
  background: var(--card); padding: var(--space-5);
  border-radius: var(--radius); text-align: center;
  margin-top: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.th-pedido {
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--space-4); margin-bottom: var(--space-3);
}

.th-info { padding: var(--space-4); margin-bottom: var(--space-3); }

/* Timeline horizontal de estado del pedido */
.th-timeline {
  list-style: none; padding: 0;
  margin: var(--space-4) 0 var(--space-5);
  display: grid; grid-auto-flow: column;
  grid-auto-columns: 1fr;
  position: relative;
}
.th-timeline__step {
  display: flex; flex-direction: column; align-items: center;
  gap: var(--space-2);
  position: relative; text-align: center;
  font-size: 12px; color: var(--text-muted);
  line-height: 1.25;
}
.th-timeline__step::before {
  content: ''; position: absolute;
  top: 18px; right: 50%; width: 100%; height: 2px;
  background: var(--border);
  z-index: 0;
}
.th-timeline__step:first-child::before { display: none; }
.th-timeline__dot {
  width: 36px; height: 36px; border-radius: 999px;
  background: var(--card); border: 2px solid var(--border);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  font-size: 14px; font-weight: 700;
  position: relative; z-index: 1;
  transition: all var(--transition);
}
.th-timeline__step.is-done .th-timeline__dot {
  background: var(--accent); border-color: var(--accent);
  color: var(--accent-contrast);
}
.th-timeline__step.is-done::before { background: var(--accent); }
.th-timeline__step.is-done .th-timeline__label { color: var(--text); font-weight: 600; }
.th-timeline__step.is-active .th-timeline__dot {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent);
  animation: th-pulse 1.6s ease-in-out infinite;
}
@keyframes th-pulse {
  0%,100% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent); }
  50% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--accent) 12%, transparent); }
}
.th-timeline__label { display: block; max-width: 90px; }

.th-timeline--rechazado .th-timeline__dot {
  background: rgba(220,38,38,0.1); border-color: #dc2626; color: #dc2626;
}
.th-timeline--rechazado::after {
  content: 'Pedido rechazado';
  display: block; text-align: center;
  margin-top: var(--space-3); padding: var(--space-2);
  border-radius: var(--radius-sm);
  background: rgba(220,38,38,0.1); color: #991b1b;
  font-weight: 600; font-size: 13px;
}

/* sticky cart bar */
.th-cartbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  z-index: 100;
  padding: var(--space-3);
  background: linear-gradient(to top, var(--bg) 60%, transparent);
  pointer-events: none;
}
.th-cartbar__btn {
  pointer-events: auto;
  width: 100%; max-width: 656px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; font-size: 15px;
  box-shadow: var(--shadow-lg);
}
.th-cartbar__count {
  background: rgba(255,255,255,0.25); border-radius: 999px;
  padding: 2px 10px; font-weight: 700;
}

/* FAB */
.th-fab {
  position: fixed; right: 16px; bottom: 88px;
  z-index: 90;
  width: 52px; height: 52px; border-radius: 999px;
  background: #25d366; color: white; border: none;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-lg);
  transition: transform var(--transition);
}
.th-fab:hover { transform: scale(1.05); }
.th-fab--alt { bottom: 152px; background: var(--accent); }

/* footer */
.th-footer {
  text-align: center; padding: var(--space-5) 0 var(--space-7);
  font-size: 12px; color: var(--text-muted);
}
.th-footer a { display: inline-flex; vertical-align: middle; margin: 0 4px; }

/* loader spinner */
.lds-ring { display: inline-block; position: relative; width: 64px; height: 64px; }
.lds-ring div {
  box-sizing: border-box; display: block; position: absolute;
  width: 51px; height: 51px; margin: 6px;
  border: 6px solid var(--accent);
  border-radius: 50%;
  animation: lds-ring 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
  border-color: var(--accent) transparent transparent transparent;
}
.lds-ring div:nth-child(1) { animation-delay: -0.45s; }
.lds-ring div:nth-child(2) { animation-delay: -0.3s; }
.lds-ring div:nth-child(3) { animation-delay: -0.15s; }
@keyframes lds-ring { 0% {transform: rotate(0)} 100% {transform: rotate(360deg)} }

.ng-cloak { display: none !important; }
[ng-cloak] { display: none !important; }
