/* ============================================================
   SanPedroYa – Menú Inferior  |  nav.css  v1.1.0
============================================================ */

:root {
  --spya-primary:   #1a73e8;
  --spya-muted:     #6e6e73;
  --spya-bg:        #ffffff;
  --spya-border:    #e0e0e0;
  --spya-badge-bg:  #e63946;
  --spya-panel-bg:  #f5f5f5;
  --spya-nav-h:     60px;
  --spya-topbar-h:  52px;
  --spya-radius:    14px;
  --spya-z-nav:     99000;
  --spya-z-panel:   99100;
  --spya-z-overlay: 99050;
}

/* ── Padding del body para no quedar tapado por el nav ── */
body.spya-has-nav {
  padding-bottom: calc(var(--spya-nav-h) + env(safe-area-inset-bottom)) !important;
}

/* ── SVG base ── */
.spya-svg {
  display: block;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

/* ============================================================
   OVERLAY — queda DEBAJO del nav
============================================================ */
#spya-overlay {
  display: none;
  position: fixed;
  inset: 0;
  /* El overlay NO tapa el nav: bottom = nav-h */
  bottom: var(--spya-nav-h);
  background: rgba(0,0,0,.5);
  z-index: var(--spya-z-overlay);
  opacity: 0;
  transition: opacity .25s ease;
}
#spya-overlay.spya-show {
  display: block;
  opacity: 1;
}

/* ============================================================
   PANELES (deslizables desde la derecha)
============================================================ */
.spya-panel {
  position: fixed;
  /* Panel ocupa toda la pantalla EXCEPTO el nav inferior */
  top: 0;
  left: 0;
  right: 0;
  bottom: var(--spya-nav-h);
  background: var(--spya-panel-bg);
  z-index: var(--spya-z-panel);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  will-change: transform;
  /* Safe area arriba (notch iPhone) */
  padding-top: env(safe-area-inset-top);
}
.spya-panel.spya-open {
  transform: translateX(0);
}

/* Topbar del panel */
.spya-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--spya-topbar-h);
  background: var(--spya-primary);
  color: #fff;
  padding: 0 16px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.spya-topbar-title {
  font-size: .95rem;
  font-weight: 700;
  letter-spacing: -.01em;
}
.spya-back-btn {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 6px;
  margin-left: -6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  transition: background .15s;
  -webkit-tap-highlight-color: transparent;
}
.spya-back-btn:hover  { background: rgba(255,255,255,.15); }
.spya-back-btn .spya-svg { stroke: #fff; width: 22px; height: 22px; }

/* ============================================================
   PANEL CATEGORÍAS
============================================================ */
.spya-cat-wrap {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar izquierda */
.spya-cat-sidebar {
  width: 110px;
  background: #fff;
  border-right: 1px solid var(--spya-border);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex-shrink: 0;
}
.spya-cat-sidebar::-webkit-scrollbar { display: none; }

.spya-sidebar-btn {
  display: block;
  width: 100%;
  padding: 13px 10px;
  font-size: .77rem;
  font-weight: 600;
  color: var(--spya-muted);
  background: none;
  border: none;
  border-left: 3px solid transparent;
  text-align: left;
  cursor: pointer;
  line-height: 1.3;
  transition: background .12s, color .12s, border-color .12s;
  -webkit-tap-highlight-color: transparent;
}
.spya-sidebar-btn:active { background: #f0f4ff; }
.spya-sidebar-btn.spya-active {
  color: var(--spya-primary);
  border-left-color: var(--spya-primary);
  background: #e8f0fe;
  font-weight: 800;
}

/* Grilla de subcategorías */
.spya-cat-grid {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 6px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  align-content: start;
}
.spya-cat-grid::-webkit-scrollbar { display: none; }

.spya-cat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 4px;
  border-radius: 10px;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background .12s;
}
.spya-cat-item:active { background: #e8f0fe; }

.spya-cat-thumb {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #e8e8e8;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.spya-cat-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.spya-cat-thumb .spya-svg {
  width: 28px;
  height: 28px;
  stroke: #aaa;
}

.spya-cat-label {
  font-size: .69rem;
  font-weight: 700;
  text-align: center;
  color: #1c1c1e;
  line-height: 1.25;
}

/* ============================================================
   PANEL MÁS
============================================================ */
.spya-mas-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 20px;
}
.spya-mas-title {
  font-size: .68rem;
  font-weight: 700;
  color: var(--spya-muted);
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 18px 16px 8px;
}
.spya-mas-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 0 16px;
}
.spya-mas-item {
  background: #fff;
  border-radius: var(--spya-radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 8px 14px;
  text-decoration: none;
  box-shadow: 0 1px 5px rgba(0,0,0,.07);
  transition: transform .12s, box-shadow .12s;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}
.spya-mas-item:active {
  transform: scale(.94);
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
}
.spya-mas-item .spya-svg {
  width: 26px;
  height: 26px;
  stroke: var(--spya-primary);
}
.spya-mas-item-label {
  font-size: .72rem;
  font-weight: 700;
  color: #1c1c1e;
  text-align: center;
  line-height: 1.2;
}

/* ============================================================
   MENÚ INFERIOR FIJO
============================================================ */
.spya-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--spya-nav-h);
  /* Safe area iPhone con notch inferior */
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--spya-bg);
  border-top: 1px solid var(--spya-border);
  display: flex;
  align-items: stretch;
  z-index: var(--spya-z-nav);  /* siempre encima del overlay y paneles */
  box-shadow: 0 -2px 12px rgba(0,0,0,.07);
}

/* Cada tab */
.spya-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--spya-muted);
  position: relative;
  -webkit-tap-highlight-color: transparent;
  transition: background .1s;
}
.spya-tab:active { background: #f0f4ff; }

/* SVG del tab */
.spya-tab-icon {
  stroke: var(--spya-muted);
  transition: stroke .15s, transform .2s cubic-bezier(.34,1.56,.64,1);
}

/* Etiqueta */
.spya-tab-label {
  font-size: .6rem;
  font-weight: 700;
  color: var(--spya-muted);
  letter-spacing: .01em;
  transition: color .15s;
  line-height: 1;
}

/* ── Tab ACTIVO ── */
.spya-tab--active .spya-tab-icon {
  stroke: var(--spya-primary);
  transform: translateY(-2px) scale(1.1);
}
/* Para filled (fill en vez de stroke) */
.spya-tab--active .spya-tab-icon[fill="currentColor"],
.spya-tab--active svg[fill="currentColor"] {
  fill: var(--spya-primary);
  stroke: none;
}
.spya-tab--active .spya-tab-label {
  color: var(--spya-primary);
}
/* Punto indicador */
.spya-tab--active::after {
  content: '';
  position: absolute;
  top: 5px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--spya-primary);
}

/* Badge carrito */
.spya-cart-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.spya-badge {
  position: absolute;
  top: -5px;
  right: -9px;
  background: var(--spya-badge-bg);
  color: #fff;
  font-size: .58rem;
  font-weight: 800;
  min-width: 17px;
  height: 17px;
  border-radius: 99px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid #fff;
  line-height: 1;
}

/* ── Ocultar el nav mientras scrolleás hacia abajo ── */
.spya-nav.spya-nav--hidden {
  transform: translateY(100%);
  transition: transform .3s ease;
}
.spya-nav.spya-nav--visible {
  transform: translateY(0);
  transition: transform .25s ease;
}

/* ── Ítem de Más sin página asignada ── */
.spya-mas-item--inactivo {
  opacity: .45;
  cursor: default;
  pointer-events: none;
}
