/* Ajustes responsive para adaptar PediYun a distintos tamaños de pantalla. */
/* ==========================================================================
   PEDIYUN — Correcciones móviles globales
   ========================================================================== */

/* Evita desplazamiento horizontal de la página completa. */
html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

/* Menú móvil: cerrado de verdad por defecto, visible solo al abrirlo. */
@media (max-width: 959px) {
  body.mobile-menu-open {
    overflow: hidden;
  }

  .navbar {
    overflow: visible;

    /*
      IMPORTANTE:
      backdrop-filter crea un containing block para descendientes position:fixed
      en varios navegadores. Eso hacía que el menú quedara limitado a la altura
      de la navbar y se viera como una franja muy fina.
    */
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .navbar-inner {
    position: relative;
  }

  .mobile-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    color: var(--dark);
    z-index: 102;
  }

  .navbar-links {
    display: none;
    position: fixed;
    top: 66px;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100vw;
    z-index: 101;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 14px 16px 28px;
    background: #fff;
    color: var(--dark);
    box-shadow: 0 18px 32px rgba(16,35,55,.12);
    overflow-y: auto;
    overflow-x: hidden;
    transform: none;
  }

  .navbar-links.is-open {
    display: flex;
    transform: none;
  }

  .navbar-links > .nav-link {
    display: block;
    width: 100%;
    padding: 14px 4px;
    color: var(--dark);
    border-bottom: 1px solid var(--gray-100);
  }

  .navbar-links > .nav-link.is-active {
    color: var(--sky-dark);
  }

  .navbar-search {
    order: initial;
    display: flex;
    width: 100%;
    max-width: none;
    min-height: 46px;
    margin: 12px 0;
    flex: 0 0 auto;
  }

  .navbar-search input {
    width: 100%;
    min-width: 0;
    color: var(--dark);
  }

  .navbar-right {
    display: flex;
    width: 100%;
    flex: 0 0 auto;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin: 4px 0 0;
  }

  .navbar-right > .nav-link {
    display: block;
    width: 100%;
    padding: 14px 4px;
    color: var(--dark);
    border-bottom: 1px solid var(--gray-100);
  }

  .user-menu {
    width: 100%;
  }

  .user-menu-btn {
    width: 100%;
    min-height: 46px;
    justify-content: flex-start;
    color: var(--dark);
  }

  .user-menu-dropdown {
    position: static;
    width: 100%;
    margin-top: 6px;
    box-shadow: none;
    border: 1px solid var(--gray-200);
  }

  .user-menu-dropdown a,
  .user-menu-dropdown button {
    color: var(--dark);
  }
}

/* Panel del repartidor */
body[data-page="panel-repartidor"] main.container,
body[data-page="panel-repartidor"] main.container > *,
body[data-page="panel-repartidor"] section,
body[data-page="panel-repartidor"] #stats-grid,
body[data-page="panel-repartidor"] #active-orders,
body[data-page="panel-repartidor"] #available-orders,
body[data-page="panel-repartidor"] #courier-history,
body[data-page="panel-repartidor"] .order-row,
body[data-page="panel-repartidor"] .order-row > div {
  min-width: 0;
  max-width: 100%;
}

body[data-page="panel-repartidor"] .order-row {
  overflow: hidden;
}

body[data-page="panel-repartidor"] .order-row h4,
body[data-page="panel-repartidor"] .order-row small,
body[data-page="panel-repartidor"] .order-row .meta {
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

body[data-page="panel-repartidor"] #available-orders .order-row,
body[data-page="panel-repartidor"] #courier-history .order-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

body[data-page="panel-repartidor"] #available-orders .btn {
  width: 100%;
}

@media (min-width: 560px) {
  body[data-page="panel-repartidor"] #available-orders .order-row,
  body[data-page="panel-repartidor"] #courier-history .order-row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  body[data-page="panel-repartidor"] #available-orders .btn {
    width: auto;
  }
}

/* ==========================================================================
   PEDIYUN — Responsive mobile first
   Base: teléfonos. Los breakpoints solo amplían el layout.
   ========================================================================== */

/* Teléfonos grandes / tablets pequeñas */
@media (min-width: 560px) {
  .container { padding-left: 20px; padding-right: 20px; }
  .section.container, .section-sm.container { padding-left: 20px; padding-right: 20px; }

  .grid-locales,
  .grid-products { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

  .local-card-image { height: 130px; }
  .product-card-image { height: 105px; }

  .footer-inner { grid-template-columns: 1fr 1fr; }

  .form-row { grid-template-columns: 1fr 1fr; }
  .social-buttons { flex-direction: row; }
  .auth-card { max-width: 440px; margin: 40px auto; padding: 30px; }
  .modal-overlay { align-items: center; padding: 20px; }
  .modal-box { max-width: 440px; border-radius: 18px; padding: 26px; }
  .modal-actions { flex-direction: row; }

  .checkout-step { flex-basis: 0; min-width: 0; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }

  .benefits-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .profile-header { flex-direction: row; align-items: center; }
  .addr-card { flex-direction: row; align-items: center; }
  .addr-card .btn { width: auto; }

  .promo-hero { padding: 62px 20px; }
  .promo-hero h1 { font-size: 36px; }
}

/* Tablets / desktop compacto */
@media (min-width: 860px) {
  .section { padding: 44px 0; }
  .section-head { align-items: center; }

  .footer-inner { grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 30px; }

  .hero, .hero-inner { min-height: 470px; }
  .hero-inner > div:first-child { padding: 102px 20px 76px; }
  .hero h1 { font-size: clamp(38px, 4vw, 52px); }
  .hero p.hero-sub { font-size: 17px; max-width: 460px; }
  .hero-search { max-width: 480px; flex-direction: row; gap: 0; padding: 6px; }
  .hero-search .btn { width: auto; }
  .hero-order-card { max-width: 380px; padding: 22px; border-radius: 24px; transform: rotate(2deg); }
  .hero-food-image { width: 86px; height: 86px; flex-basis: 86px; }
  .hero-order-main { margin: 20px 0; }
  .hero-order-footer { align-items: center; flex-direction: row; gap: 10px; }
  .hero-animation-visual { min-height: 360px; margin-top: 0; }
  .hero-map-stage { height: 300px; border-radius: 17px; }
  .hero-map-card { padding: 12px; border-radius: 24px; transform: rotate(1deg); }
  .hero-map-foot { padding: 10px 8px 3px; font-size: 10px; }
  .hero-map-foot span:nth-child(2) { display: inline-flex; }
  .hero-map-visual::after { background: linear-gradient(90deg, rgba(247,252,254,.97) 0%, rgba(247,252,254,.84) 25%, rgba(247,252,254,.18) 52%, rgba(255,255,255,.04) 100%); }

  .grid-locales,
  .grid-products { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
  .how-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 30px; padding: 50px 0; }

  .cart-item { flex-wrap: nowrap; padding: 14px 16px; }
  .cart-item-emoji { width: 46px; flex-basis: 46px; font-size: 28px; }
  .cart-item-info { flex: 1; }
  .qty-control, .cart-item-price, .cart-item-remove { order: initial; }
  .cart-item-price { width: 70px; }

  .panel-header { flex-direction: row; align-items: center; }
  .order-row-top { flex-direction: row; align-items: flex-start; }
  .available-order-card { flex-direction: row; align-items: center; }
  .available-order-card .btn { width: auto; }

  .promo-hero { padding: 70px 20px; }
}


/* Barra superior en modo escritorio: desde 960px (antes 860px). Entre 860 y 960 los
   botones de "Iniciar sesión / Registrarse" o el menú de usuario quedaban fuera de la pantalla. */
@media (min-width: 960px) {
  .mobile-toggle { display: none; }
  .navbar-inner { padding: 14px 20px; gap: 18px; }
  .navbar-links {
    position: static;
    inset: auto;
    z-index: auto;
    flex: 1;
    flex-direction: row;
    align-items: center;
    gap: 18px;
    padding: 0;
    background: transparent;
    box-shadow: none;
    overflow: visible;
    transform: none;
    transition: none;
  }
  .navbar-search { max-width: 380px; order: initial; }
  .navbar-right { width: auto; flex-direction: row; align-items: center; margin-left: auto; gap: 10px; }
  .navbar-right .btn { width: auto; }
  .user-menu-dropdown { position: absolute; width: 200px; margin-top: 0; box-shadow: var(--shadow-md); }
  .notif-panel { position: absolute; top: 60px; right: 20px; left: auto; width: 300px; max-height: 340px; }
}

/* Desktop */
@media (min-width: 1024px) {
  .section { padding: 48px 0; }

  .grid-locales,
  .grid-products { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }

  .hero-inner > div:first-child { padding: 118px 20px 86px; }
  .hero-order-card { max-width: 410px; }
  .hero-animation-visual { min-height: 400px; }
  .hero-map-stage { height: 330px; }

  .cart-layout { grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); gap: 26px; }
  .summary-box { position: sticky; top: 90px; padding: 20px; }

  .stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
  .demo-panel-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .benefits-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }

  .local-detail-inner { align-items: center; padding-top: 36px; padding-bottom: 36px; gap: 20px; }
  .local-detail-icon { width: 88px; height: 88px; font-size: 44px; border-radius: 24px; }
}

/* ==========================================================================
   Barra superior flexible: el buscador se encoge y nada se sale de la pantalla
   ========================================================================== */
@media (min-width: 960px) {
  .navbar-inner > *,
  .navbar-links > *,
  .navbar-right > * { min-width: 0; }
  .navbar-search { flex: 1 1 140px; min-width: 120px; }
  .navbar-search input { width: 100%; min-width: 0; }
  .navbar-right { flex-shrink: 0; flex-wrap: nowrap; }
  .navbar-right .btn,
  .nav-link { white-space: nowrap; }
  .user-menu-btn { max-width: 100%; }
}

/* ==========================================================================
   Tablas en tarjetas (pantallas de hasta 900px)
   Antes las tablas tenían un ancho mínimo de 620 a 860px y la columna de
   "Acciones" quedaba escondida a la derecha. Ahora cada fila es una tarjeta.
   ========================================================================== */
@media (max-width: 900px) {
  body .table-panel { overflow-x: visible; padding: 12px; }

  body table.data-table,
  body[data-page="admin"] table.data-table {
    display: block;
    min-width: 0;
    width: 100%;
    font-size: 14px;
  }

  body table.data-table thead { display: none; }
  body table.data-table tbody { display: block; }

  body table.data-table tr {
    display: block;
    margin: 0 0 12px;
    padding: 6px 14px;
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: 14px;
  }

  body table.data-table td,
  body[data-page="admin"] table.data-table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    min-width: 0 !important;
    padding: 9px 0;
    border-top: 1px solid var(--gray-100);
    text-align: right;
    word-break: break-word;
    white-space: normal !important;
  }

  body table.data-table td:first-child { border-top: 0; }

  body table.data-table td::before {
    content: attr(data-label);
    flex: 0 0 38%;
    max-width: 38%;
    text-align: left;
    font-size: 11.5px;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--gray-500);
  }

  /* Celdas sin título (fotos, acciones): ocupan todo el ancho. */
  body table.data-table td[data-label=""]::before { display: none; }
  body table.data-table td[data-label=""] { justify-content: flex-start; text-align: left; }

  /* Mensajes tipo "No hay productos." (celda única). */
  body table.data-table td[colspan] { display: block; text-align: center; }
  body table.data-table td[colspan]::before { display: none; }

  body table.data-table td .btn { margin: 2px 0 2px 6px; }
  body table.data-table td:last-child { flex-wrap: wrap; justify-content: flex-end; }
  body table.data-table tr:hover td { background: transparent; }
  body table.data-table img { max-width: 56px; height: auto; border-radius: 10px; }
}

/* Títulos de paneles con aire debajo y pestañas que se acomodan en varias filas en vez de cortarse. */
.panel-greeting { margin-bottom: 14px; }
@media (max-width: 700px) {
  .tabs { flex-wrap: wrap; overflow-x: visible; }
}

/* ==========================================================================
   Ajustes de detalle (imágenes sin foto, ficha del local, carrito, checkout)
   ========================================================================== */
/* Producto sin foto: el emoji va centrado en el recuadro (antes quedaba arriba a la izquierda). */
.product-detail-fallback { display: flex; }
/* Local sin foto: se muestra el emoji de la categoría en lugar de un cuadro blanco vacío. */
.local-detail-icon:not(:has(img)) .local-detail-fallback { display: inline; }

/* Ficha del local en celular: el ícono arriba y el texto debajo, con todo el ancho disponible. */
@media (max-width: 559px) {
  .local-detail-inner { flex-direction: column; align-items: flex-start; }
  .local-detail-inner > div[style*="flex:1"] { width: 100%; }
}

/* Carrito: producto, cantidad y precio en una sola fila desde 560px. */
@media (min-width: 560px) {
  .cart-item { flex-wrap: nowrap; }
  .cart-item-info { flex: 1; min-width: 0; }
}

/* Checkout: el título de la tarjeta no se pega al recuadro de la dirección. */
body[data-page="checkout"] .summary-box h3,
body[data-page="checkout"] .summary-box h2 { margin-bottom: 12px; }
.order-summary-card > h3:first-child { margin-bottom: 12px; }

/* Celda de acciones en tarjeta: sin título, botones a todo el ancho y alineados a la derecha. */
@media (max-width: 900px) {
  body table.data-table td[data-label="Acciones"],
  body table.data-table td[data-label="Acción"] { justify-content: flex-end; flex-wrap: wrap; }
  body table.data-table td[data-label="Acciones"]::before,
  body table.data-table td[data-label="Acción"]::before { display: none; }
}

/* Menú móvil: el ícono del carrito lleva su nombre para que se entienda. */
@media (max-width: 959px) {
  .navbar-right a[href="carrito.html"]::after { content: " Carrito"; font-weight: 700; margin-left: 8px; }
}

/* ==========================================================================
   Categorías (en TODAS las pantallas): una sola fila ordenada que se desliza
   (dedo, rueda, trackpad o las flechas). Así no ocupan media pantalla y los
   locales quedan a la vista enseguida.
   ========================================================================== */
.category-wrap { position: relative; }
.category-scroll {
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  gap: 8px;
  padding: 4px 4px 10px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.category-scroll::-webkit-scrollbar { display: none; }
.category-wrap.has-more-right .category-scroll {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent);
          mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent);
}
.category-wrap.has-more-left.has-more-right .category-scroll {
  -webkit-mask-image: linear-gradient(to right, transparent, #000 48px, #000 calc(100% - 48px), transparent);
          mask-image: linear-gradient(to right, transparent, #000 48px, #000 calc(100% - 48px), transparent);
}
.category-wrap.has-more-left:not(.has-more-right) .category-scroll {
  -webkit-mask-image: linear-gradient(to right, transparent, #000 48px);
          mask-image: linear-gradient(to right, transparent, #000 48px);
}
.category-chip {
  flex: 0 0 auto;
  min-width: 76px;
  padding: 10px 14px;
  gap: 4px;
  scroll-snap-align: start;
}
.category-chip span.emoji { font-size: 24px; }
.category-chip span.label { font-size: 12px; white-space: nowrap; }
.category-arrow {
  position: absolute; top: 50%; transform: translateY(-60%);
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--gray-200); background: #fff; color: var(--dark);
  box-shadow: 0 4px 14px rgba(16,35,55,.14);
  font-size: 18px; line-height: 1; cursor: pointer; z-index: 2;
  display: none; align-items: center; justify-content: center; font-family: inherit;
}
.category-arrow.is-left { left: -6px; }
.category-arrow.is-right { right: -6px; }
.category-wrap.has-more-left .category-arrow.is-left,
.category-wrap.has-more-right .category-arrow.is-right { display: flex; }
@media (hover: none) { .category-arrow { display: none !important; } }
@media (max-width: 959px) {
  .category-scroll { margin-right: -16px; padding-right: 36px; }
  .category-chip { padding: 10px 12px; }
}

/* Sin foto del local: texto "Imagen del local" */
.local-card-fallback, .local-detail-fallback {
  font-size: 13px; font-weight: 700; color: var(--gray-500); text-align: center; line-height: 1.25;
}
.local-detail-icon .local-detail-fallback { font-size: 11px; padding: 0 6px; }
/* Local cerrado sin foto: el cartel "Cerrado" va abajo para no pisar el texto del centro */
.local-card-closed { align-items: flex-end; padding-bottom: 10px; }
.local-card-image:has(.local-card-closed) .local-card-fallback { color: #fff; }

/* ==========================================================================
   Ventanas medianas (700–959px): los enlaces (Locales, Ayuda, etc.) se ven
   SIEMPRE, en una segunda fila bajo el logo, en vez de esconderse en la
   hamburguesa. Menos de 700px (celular) sigue el menú hamburguesa.
   ========================================================================== */
@media (min-width: 700px) and (max-width: 959px) {
  .mobile-toggle { display: none; }
  .navbar-inner { flex-wrap: wrap; padding: 10px 20px 8px; row-gap: 4px; }
  .navbar-links,
  .navbar-links.is-open {
    display: flex;
    position: static;
    inset: auto;
    z-index: auto;
    order: 3;
    flex: 1 1 100%;
    width: 100%;
    max-width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 16px;
    padding: 0 0 6px;
    background: transparent;
    box-shadow: none;
    overflow: visible;
  }
  .navbar-links > .nav-link { width: auto; padding: 6px 2px; border-bottom: 0; }
  .navbar-search { order: 5; flex: 1 1 200px; width: auto; min-width: 160px; margin: 0; }
  .navbar-right { order: 6; width: auto; flex-direction: row; flex-wrap: wrap; align-items: center; margin-left: auto; gap: 8px; }
  .navbar-right .btn { width: auto; }
  .user-menu-dropdown { position: absolute; width: 200px; margin-top: 0; box-shadow: var(--shadow-md); }
  .notif-panel { position: absolute; top: 100px; right: 20px; left: auto; width: 300px; max-height: 340px; }
}

/* ==========================================================================
   Celular (< 700px): la barra se ve como en la compu, sin hamburguesa.
   Fila 1: logo + (carrito / usuario o botones). Fila 2: Inicio · Locales ·
   Ayuda. Fila 3: buscador.
   ========================================================================== */
@media (max-width: 699px) {
  .mobile-toggle { display: none !important; }
  .navbar-inner { flex-wrap: wrap; padding: 8px 14px 10px; gap: 6px 8px; }
  .navbar-inner > .brand { margin-right: auto; order: 0; }
  .navbar-inner::after { content: ''; order: 2; flex: 1 0 100%; height: 0; }

  /* Los hijos pasan a ser parte de la barra para poder ordenarlos */
  .navbar-links,
  .navbar-links.is-open,
  .navbar-right { display: contents; }

  .navbar-links > .nav-link,
  .navbar-right > .nav-link {
    order: 3;
    display: inline-block;
    width: auto;
    padding: 6px 12px 6px 0;
    border-bottom: 0;
    font-size: 14.5px;
  }
  .navbar-search {
    order: 4;
    flex: 1 0 100%;
    width: 100%;
    margin: 2px 0 0;
    min-height: 40px;
  }
  .navbar-right > .btn,
  .navbar-right > .icon-btn,
  .navbar-right > .user-menu { order: 1; width: auto; }
  .navbar-right > .btn { padding: 8px 12px; font-size: 13px; min-height: 0; }
  .user-menu { width: auto; }
  .user-menu-btn { width: auto; min-height: 0; }
  .user-menu-dropdown {
    position: absolute; right: 0; left: auto; top: calc(100% + 6px);
    width: 210px; margin-top: 0; box-shadow: var(--shadow-md);
  }
  .notif-panel { position: fixed; top: 60px; left: 10px; right: 10px; width: auto; max-height: calc(100vh - 80px); }
}
@media (max-width: 380px) {
  .navbar-right > .btn { padding: 7px 9px; font-size: 12.5px; }
  .brand-name { font-size: 18px; }
}
