




/* ===== Modo móvil tipo Kemik (<= 768px) ===== */
@media (max-width: 768px) {
  /* Layout general */
  :root{
    --brand-blue:#1473e6;
    --accent:#ff6f00;
    --surface:#ffffff;
    --bg:#f6f7fb;
    --muted:#6b7280;
    --radius:16px;
    --shadow:0 10px 30px rgba(0,0,0,.06);
  }

  html, body {
    background: var(--bg);
    overscroll-behavior-y: none;
  }

  /* Header compacto */
  .header,
  header,
  .topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--brand-blue);
    box-shadow: var(--shadow);
  }

  /* Contenedor del header en grid */
  .header-inner,
  .topbar .inner,
  .nav-wrap {
    display: grid;
    grid-template-columns: auto 1fr auto; /* logo | buscador | botones */
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
  }

  /* Logo reducido */
  .logo, .brand, .site-logo { height: 34px; display: flex; align-items:center; }

  /* Botón Categorías + buscador en cápsula */
  .search-shell{
    display:flex; align-items:center; gap:8px;
    background:#fff; border-radius:999px; padding:8px 10px;
    box-shadow: var(--shadow);
  }
  .btn-cats{
    display:inline-flex; align-items:center; gap:6px;
    background:#f0f3ff; color:#1f2937; font-weight:600;
    border-radius:14px; padding:6px 10px;
    border: 1px solid rgba(20,115,230,.12);
  }
  .search-shell input[type="search"],
  .search-shell input[type="text"]{
    border:none; outline:none; width:100%;
    font-size:15px; color:#111; background:transparent;
  }
  .search-shell .btn-search{
    width:34px; height:34px; border-radius:50%;
    display:grid; place-items:center; background:var(--brand-blue);
    color:#fff; border:0;
  }

  /* Botones de sesión / carrito */
  .header-actions{ display:flex; align-items:center; gap:8px; }
  .btn-sign, .btn-cart{
    border-radius:14px; padding:8px 10px; font-weight:600;
    border:1px solid rgba(0,0,0,.06); background:#fff; color:#111;
    box-shadow: var(--shadow);
  }
  .btn-sign{ background:#ff6f00; color:#fff; border:0; }
  .btn-cart{ background:#111; color:#fff; border:0; }

  /* ======= BANNERS ======= */
  /* Oculta laterales en móvil */
  .banner-side{ display:none !important; }

  /* El héroe a full, con bordes suaves */
  .banner-hero{
    margin: 12px; border-radius: var(--radius); overflow:hidden;
    background:#fff; box-shadow: var(--shadow);
  }
  .banner-hero img{ width:100%; display:block; }

  /* ======= FLASH SALE ======= */
  .flash-sale, .solo-x-horas, .sale-box{
    margin: 12px;
    border-radius: 22px;
    background: #5b21b6; /* púrpura */
    color:#fff;
    box-shadow: var(--shadow);
    overflow: hidden;
  }
  .flash-sale .timer, .solo-x-horas .timer{
    display:flex; gap:10px; padding:12px;
  }
  .flash-sale .timer .pill,
  .solo-x-horas .timer .pill{
    background:#fff; color:#1f2937; border-radius:12px;
    padding:10px 14px; font-weight:800; min-width:70px; text-align:center;
    box-shadow: var(--shadow);
  }

  /* ======= PRODUCTOS (1 columna) ======= */
  .products-grid, .grid-products, .cards{
    display:grid; grid-template-columns: 1fr; gap:12px;
    padding: 0 12px 20px;
  }
  .product-card, .card, .item{
    border-radius:16px; overflow:hidden; background:#fff;
    box-shadow: var(--shadow); border:1px solid rgba(0,0,0,.04);
  }
  .product-card .media, .card .media{
    aspect-ratio: 1/1; background:#fff; display:grid; place-items:center;
  }
  .product-card img, .card img{ width:100%; height:100%; object-fit:cover; }
  .product-card .body, .card .body{ padding:12px; }
  .product-card .title{ font-weight:700; color:#111; margin-bottom:6px; }
  .product-card .price-row{
    display:flex; align-items:center; justify-content:space-between; gap:8px;
  }
  .product-card .price{ font-weight:800; color:#111; font-size:18px; }
a  .product-card .badge{
    background:#fffaeb; color:#b45309; border:1px solid #fde68a;
    padding:4px 8px; border-radius:10px; font-size:12px; font-weight:700;
  }

  /* ======= ESPACIADOS ======= */
  .section{ margin: 14px 0; }
  .container{ padding: 0 12px; }
}

/* ====== OVERRIDES MÓVIL ====== */
@media (max-width:768px){
  html, body {
    max-width: 100%;
    overflow-x: hidden;              /* NO más “desbordes” hacia la derecha */
  }

  /* padding general de páginas */
  .container { padding-left: 12px; padding-right: 12px; }

  /* HEADER compacto y sin desbordes */
  .header .container { padding: 10px 12px; }
  .header__inner { display:flex; align-items:center; gap:10px; }
  .brand { flex:0 0 auto; }
  .header__search { flex:1 1 auto; min-width:0; }   /* el buscador toma el ancho disponible */
  #searchForm { display:flex; gap:8px; }
  #searchForm input { flex:1 1 auto; min-width:0; }
  #searchForm button { flex:0 0 auto; }

  .header__actions{
    display:flex; align-items:center; gap:8px;
    flex:0 0 auto;                 /* evita que salte a otra línea raro */
  }
  .btn, .btn-login-orange, .header__cart {
    padding: 10px 12px; border-radius:14px; font-size:14px; line-height:1;
    white-space: nowrap;
  }

  /* HÉROE: 1 sola columna y sin laterales */
  .home-hero,
  .home-hero[style]{
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  .sides, #sideBanner1, #sideBanner2, .banner-side { display:none !important; }
  .banner-slider { width:100%; border-radius:14px; }

  /* FLASH SALE – que no se salga */
  .flash-sale{ margin: 12px; border-radius:16px; }
  .fs-bar{ display:flex; align-items:center; gap:10px; justify-content:space-between; flex-wrap:wrap; }
  .fs-countdown{ display:flex; gap:8px; }
  .fs-time{ min-width:62px; padding:6px 8px; }  /* más compacto */

  /* DESTACADOS/GRIDS – columnas móviles */
  .grid.cards-5 { grid-template-columns: 1fr 1fr; gap:12px; }
  /* si en alguna vista quieres una sola columna, usa .grid-1 */
  .grid-1 { grid-template-columns: 1fr !important; }

  /* Imágenes centradas y contenidas */
  img, .card img, .p-mini img, .fs-thumb img {
    max-width:100%;
    height:auto;
    display:block;
    margin:0 auto;
    object-fit: contain;
  }
}
/* ======= MÓVIL (≤ 768px) ======= */
@media (max-width:768px){
  /* Ocultar buscador/categorías */
  .header__left,
  .header__search,
  .btn-cat,
  form[data-role="search"]{
    display:none !important;
  }

  /* Contenedor del header móvil */
  .header-mobile{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:10px;
    padding:10px 14px;
  }

  /* Botones */
  .icon-btn{
    background:#fff;
    color:#0f172a;
    border:0;
    border-radius:14px;
    padding:10px 12px;
    font-size:16px;
    line-height:1;
    box-shadow:0 8px 20px rgba(0,0,0,.10);
  }

  /* Menú a la izquierda, carrito a la derecha */
  .menu-btn{ order:1; }
  .brand-mobile{ order:2; margin:0 auto; }
  .cart-btn{ order:3; }

  /* Marca al centro */
  .brand-mobile{
    display:flex;
    align-items:center;
    gap:8px;
    text-decoration:none;
  }
  .brand-mobile img{ width:34px; height:34px; }
  .brand-mobile .brand__name{
    font-size:18px; font-weight:800; color:#fff;
  }

  /* Badge carrito */
  .badge{
    display:inline-block;
    min-width:18px; height:18px;
    padding:0 5px;
    margin-left:4px;
    background:#ff5a00; color:#fff;
    border-radius:999px; font-size:12px;
    vertical-align:top;
  }
}
/* ====== FIJAR HEADER MÓVIL ARRIBA DE TODO ====== */
@media (max-width: 768px){
  /* el header móvil debe existir con esta clase */
  .header-mobile{
    position: fixed;        /* queda pegado arriba */
    top: env(safe-area-inset-top, 0);
    left: 0;
    right: 0;
    height: 64px;           /* ajusta si tu barra es más alta */
    display: flex;
    align-items: center;
    padding: 0 12px;
    background: var(--brand-blue,#1473e6);
    z-index: 9999;          /* por encima de TODO */
    isolation: isolate;     /* crea nuevo stacking context para seguridad */
    box-shadow: 0 2px 10px rgba(0,0,0,.1);
  }

  /* Dale espacio al contenido para que no quede tapado por el header fijo */
  body{
    padding-top: calc(64px + env(safe-area-inset-top, 0));
  }

  /* ===== Drawer (menú lateral) ===== */
  #mDrawer{
    position: fixed;
    inset: 0;               /* top/right/bottom/left:0 */
    z-index: 9998;          /* justo debajo del header */
    display: none;          /* cerrado por defecto */
  }
  #mDrawer.open{ display: block; }

  /* fondo oscuro clicable */
  #mDrawer .drawer-backdrop{
    position: absolute; inset: 0;
    background: rgba(0,0,0,.35);
    backdrop-filter: blur(2px);
  }

  /* panel deslizante */
  #mDrawer .drawer-panel{
    position: absolute; top: 0; bottom: 0; left: 0; /* menú a la izquierda */
    width: 84vw; max-width: 360px;
    background: #fff;
    box-shadow: 0 10px 30px rgba(0,0,0,.2);
    transform: translateX(-100%);
    transition: transform .25s ease;
    will-change: transform;
    padding: 16px;
  }
  #mDrawer.open .drawer-panel{ transform: translateX(0); }

  /* Evitar que algo del main se “suba” por efectos/transform */
  main, .container, .section{
    position: relative;
    z-index: 1;
  }
}

/* En escritorio, NO mostrar el header/drawer móvil */
  @media (min-width: 769px){
  .header-mobile, #mDrawer{ display: none !important; }
}
/* ===== SOLO MÓVIL (no toca desktop) ===== */
@media (max-width:768px){

  /* Oculta header de desktop */
  .header .header__inner { display:none !important; }

  /* Barra móvil */
  .mobile-bar{
    display:flex; align-items:center; gap:10px;
    padding:10px 12px; background:transparent;
  }
  .mobile-bar .m-icon{
    width:44px; height:44px; border:0; border-radius:12px;
    background:#0b5bd3; color:#fff; font-size:20px; box-shadow:0 8px 20px rgba(0,0,0,.15);
  }
  .mobile-bar .m-brand{ display:flex; align-items:center; gap:10px; color:#fff; text-decoration:none; }
  .mobile-bar .m-brand img{ height:38px; }
  .mobile-bar .m-brand span{ font-size:22px; font-weight:800; }
  .mobile-bar .m-spacer{ flex:1; }

  .m-chip{
    border:0; border-radius:28px; padding:10px 14px;
    font-weight:800; box-shadow:0 10px 24px rgba(0,0,0,.15);
  }
  .m-chip--accent{ background:#ff7a00; color:#fff; }
  .m-chip--dark{ background:#0f172a; color:#fff; }

  /* Drawer */
  #mDrawer{ position:fixed; inset:0; display:none; z-index:9999; }
  #mDrawer.open{ display:block; }
  #mDrawer .m-backdrop{ position:absolute; inset:0; background:rgba(0,0,0,.35); }
  #mDrawer .m-panel{
    position:absolute; top:0; bottom:0; left:0; width:82vw; max-width:360px;
    background:#fff; border-radius:0 12px 12px 0; padding:16px;
    box-shadow:0 10px 30px rgba(0,0,0,.35);
    transform:translateX(-100%); transition:transform .25s ease;
  }
  #mDrawer.open .m-panel{ transform:translateX(0); }

  .m-panel-head{ display:flex; align-items:center; justify-content:space-between; margin-bottom:10px; }
  .m-close{ width:36px;height:36px;border-radius:10px;border:1px solid var(--line); background:#fff; }

  .m-nav a, .m-nav button{
    display:flex; align-items:center; gap:10px; width:100%;
    padding:10px 8px; text-align:left; border:0; background:transparent;
    border-radius:10px; color:#111; text-decoration:none; font-weight:600;
  }
  .m-nav a:hover, .m-nav button:hover{ background:#f5f7fb; }
  .m-nav hr{ border:none; border-top:1px solid var(--line); margin:8px 0; }
}

/* Desktop: oculta barra móvil */
@media (min-width:769px){
  .mobile-bar, #mDrawer{ display:none !important; }
}
/* ======= Mejoras visuales y correcciones SOLO MÓVIL ======= */
@media (max-width:768px){

  /* Botón del menú ☰ centrado y con mejor look */
  .m-icon{
    display:flex;
    align-items:center;
    justify-content:center;
    background:linear-gradient(145deg,#0a57cc,#0b5bd3);
    box-shadow:0 6px 16px rgba(0,0,0,.2);
    border-radius:14px;
    width:50px;
    height:50px;
    font-size:26px;
    color:#fff;
  }
  .m-icon::before{
    content:"≡";
    font-weight:900;
    font-size:26px;
    line-height:1;
  }

  /* Flash sale centrada */
  .flash-sale .fs-card{
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    text-align:center;
  }
  .flash-sale .fs-thumb{
    display:flex;
    align-items:center;
    justify-content:center;
  }
  .flash-sale .fs-thumb img{
    object-fit:contain;
    width:auto;
    max-width:100%;
    height:auto;
  }
}

/* Mostrar productos recientes en 2 columnas SOLO en móvil */
@media (max-width:768px){
  #grid.cards-5{
    display:grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap:14px !important;
    padding:0 12px !important;
  }
  #grid.cards-5 .p-mini img{
    height:120px !important;
  }
  #grid.cards-5 .p-mini h3{
    font-size:.9rem !important;
  }
}
/* ===== SOLO MÓVIL ===== */
@media (max-width:768px){

  /* 1) Header móvil fijo arriba (sin mover nada de desktop) */
  .mobile-bar{
    position: sticky;          /* se queda pegado al top al hacer scroll */
    top: 0;
    z-index: 3000;
    background: var(--brand-blue); /* por si algún estilo externo lo volvía transparente */
    box-shadow: 0 6px 20px rgba(0,0,0,.12);
  }
  /* Reservar espacio debajo para que no “pise” el contenido en algunos navegadores */
  body{ padding-top: env(safe-area-inset-top, 0); }

  /* 2) Productos recientes: 2 por fila en móvil */
  /* Fuerza el grid a 2 columnas aunque brand.css tenga otro layout */
  #grid.cards-5{
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 14px !important;
    padding: 0 12px !important;
  }

  /* Ajustes de las tarjetas para que respiren bien en 2 columnas */
  #grid.cards-5 > *{
    min-width: 0;
  }
  #grid.cards-5 .p-mini img{ height: 120px !important; object-fit: contain; }
  #grid.cards-5 .p-mini h3{ font-size: .9rem !important; line-height: 1.2; }
  #grid.cards-5 .p-mini .desc{ -webkit-line-clamp: 2; }
}
/* ===== Mini-carrito móvil ===== */
@media (max-width:768px){
  /* Asegura que el panel se muestre como overlay fijo en móvil */
  #miniCart{
    position: fixed !important;
    right: 12px;
    top: 66px;                      /* justo debajo de la barra móvil */
    width: calc(100vw - 24px);
    max-width: 420px;
    z-index: 4000;
    border-radius: 16px;
    box-shadow: 0 18px 36px rgba(0,0,0,.25);
  }
}
/* ===== Mini-carrito móvil (no afecta desktop) ===== */
@media (max-width:768px){
  #miniCart{
    position: fixed !important;
    right: 12px;
    top: 66px;                       /* bajo la barra móvil */
    width: calc(100vw - 24px);
    max-width: 420px;
    z-index: 5001;
    border-radius: 16px;
    box-shadow: 0 18px 36px rgba(0,0,0,.25);
    display: none;                   /* lo controlamos por clase */
  }
  .mc-backdrop{
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.35);
    z-index: 5000;
    display: none;
  }
  #miniCart.mc-open{ display:block; }
  .mc-backdrop.mc-open{ display:block; }
}
