/* ColRider Home 2.0 — Fase 3
   Encabezado, hero y categorías móviles.
   Se carga después de los estilos inline del Blade.
   Solo modifica body.cr-home-v2 hasta 760px.
*/

/* Elementos exclusivos de la Home móvil: ocultos por defecto. */
body.cr-home-v2 .cr-header-favorites,
body.cr-home-v2 .cr-cart-icon-mobile {
  display: none;
}

@media (max-width: 760px) {
  body.cr-home-v2 {
    --cr-home-mobile-gradient:
      radial-gradient(circle at 16% 0%, rgba(128,208,48,.38), transparent 30%),
      linear-gradient(135deg, #183d14 0%, #306020 52%, #70c030 140%);
  }

  /* Decoración tecnológica discreta: el degradado de marca NO se modifica. */
  body.cr-home-v2 .cr-home-v2-header::before {
    content: "";
    position: absolute;
    inset: 0 0 auto auto;
    width: 42%;
    height: 100%;
    pointer-events: none;
    opacity: .10;
    background-image: radial-gradient(circle, #e5ffcd 1px, transparent 1.6px);
    background-size: 17px 17px;
    -webkit-mask-image: linear-gradient(to left, #000, transparent 95%);
    mask-image: linear-gradient(to left, #000, transparent 95%);
  }
  body.cr-home-v2 .cr-home-v2-header .cr-home-v2-header-inner {
    isolation: isolate;
  }

  /* Encabezado */
  body.cr-home-v2 .cr-home-v2-header {
    position: relative;
    z-index: 20;
    background: var(--cr-home-mobile-gradient) !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
  }
  body.cr-home-v2 .cr-home-v2-header::after { display: none !important; }
  body.cr-home-v2 .cr-home-v2-header .cr-home-v2-header-inner {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 12px !important;
    min-height: 58px !important;
    height: auto !important;
    padding: 10px 0 4px !important;
  }
  body.cr-home-v2 .cr-home-v2-header .brand-logo-link,
  body.cr-home-v2 .cr-home-v2-header .nav { display: none !important; }

  /* Selector de sede: mantiene el botón y su listener originales */
  body.cr-home-v2 .cr-home-v2-header .mobile-location-top {
    display: flex !important;
    position: static !important;
    transform: none !important;
    order: 1 !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
    width: auto !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  body.cr-home-v2 .cr-home-v2-header .mobile-location-chip {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    justify-content: center !important;
    gap: 3px !important;
    width: 100% !important;
    min-width: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    color: #fff !important;
    text-align: left !important;
    cursor: pointer;
  }
  body.cr-home-v2 .cr-home-v2-header .mobile-location-chip::before { content: none !important; }
  body.cr-home-v2 .cr-home-v2-header .cr-location-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #e4f6df;
    font-size: 10px;
    font-weight: 650;
    line-height: 1.15;
  }
  body.cr-home-v2 .cr-home-v2-header .cr-location-label .mobile-location-pin {
    display: block !important;
    width: 12px !important;
    height: 12px !important;
    flex: none;
    color: currentColor;
  }
  body.cr-home-v2 .cr-home-v2-header .cr-location-city {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    max-width: 100%;
    color: #fff;
    font-size: clamp(14px, 3.8vw, 17px);
    line-height: 1.15;
    font-weight: 800;
    letter-spacing: -.02em;
  }
  body.cr-home-v2 .cr-home-v2-header .cr-location-city-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  body.cr-home-v2 .cr-home-v2-header .cr-location-chevron {
    width: 14px;
    height: 14px;
    flex: none;
    opacity: .9;
  }

  /* Acciones: botones equilibrados, funcionalidad intacta */
  body.cr-home-v2 .cr-home-v2-header .header-actions {
    order: 2 !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    flex: 0 0 auto !important;
    width: auto !important;
    margin: 0 !important;
  }
  body.cr-home-v2 .cr-home-v2-header .cr-header-favorites,
  body.cr-home-v2 .cr-home-v2-header .cr-cart-trigger {
    position: relative;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 42px !important;
    min-width: 42px !important;
    height: 42px !important;
    min-height: 42px !important;
    padding: 0 !important;
    border-radius: 14px !important;
    background: rgba(255,255,255,.09) !important;
    border: 1px solid rgba(255,255,255,.12) !important;
    box-shadow: none !important;
    color: #fff !important;
  }
  body.cr-home-v2 .cr-home-v2-header .cr-header-favorites {
    opacity: 1 !important;
    cursor: pointer;
  }
  body.cr-home-v2 .cr-home-v2-header .cr-header-favorites svg,
  body.cr-home-v2 .cr-home-v2-header .cr-cart-icon-mobile {
    display: block !important;
    width: 24px !important;
    height: 24px !important;
    flex: none;
    color: #fff !important;
  }
  /* La imagen 3D permanece en el Blade para escritorio y tiendas. */
  body.cr-home-v2 .cr-home-v2-header .cr-cart-icon {
    display: none !important;
  }
  body.cr-home-v2 .cr-home-v2-header .cr-cart-count {
    position: absolute !important;
    top: -6px !important;
    right: -5px !important;
    z-index: 2;
    min-width: 19px;
    height: 19px;
    padding: 0 4px;
    border-radius: 999px;
    background: #ef3340 !important;
    color: #fff !important;
    border: 2px solid #fff !important;
    font-size: 10px !important;
    font-weight: 800 !important;
    line-height: 15px !important;
    text-align: center;
  }
  body.cr-home-v2 .cr-home-v2-header .cr-cart-count:empty { display: none !important; }

  /* Unión visual de cabecera y hero */
  body.cr-home-v2 main.public-wrap {
    padding-top: 0 !important;
    margin-top: 0 !important;
  }
  body.cr-home-v2 .cr-discovery {
    padding-top: 0 !important;
    margin-top: 0 !important;
  }
  body.cr-home-v2 .cr-search-card {
    display: block !important;
    min-height: 0 !important;
    margin: 0 -10px !important;
    padding: 8px 20px 18px !important;
    border-radius: 0 0 26px 26px !important;
    border: 0 !important;
    background: var(--cr-home-mobile-gradient) !important;
    box-shadow: 0 12px 26px rgba(16,77,35,.12) !important;
  }
  /* Circuitos geométricos solo en el lateral derecho del hero.
     La capa es decorativa: no intercepta clics ni altera el degradado. */
  body.cr-home-v2 .cr-search-card {
    position: relative !important;
    isolation: isolate;
    overflow: hidden;
  }
  body.cr-home-v2 .cr-search-card::before {
    content: "";
    position: absolute;
    top: 4px;
    right: -16px;
    width: min(55%, 235px);
    height: 115px;
    pointer-events: none;
    z-index: -1;
    opacity: .16;
    background-repeat: no-repeat;
    background-position: right top;
    background-size: contain;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 230 120' fill='none' stroke='%23e5ffcd' stroke-width='1.5'%3E%3Cpath d='M230 12H169l-24 24h-40M230 42h-37l-21 21h-48M230 88h-70l-19-19h-22M230 111h-34l-18-18h-37'/%3E%3Ccircle cx='105' cy='36' r='4'/%3E%3Ccircle cx='124' cy='63' r='4'/%3E%3Ccircle cx='119' cy='69' r='3'/%3E%3Ccircle cx='141' cy='93' r='4'/%3E%3C/svg%3E");
    -webkit-mask-image: linear-gradient(to left, #000 20%, transparent 100%);
    mask-image: linear-gradient(to left, #000 20%, transparent 100%);
  }
  body.cr-home-v2 .cr-search-copy .cr-kicker,
  body.cr-home-v2 .cr-search-copy p { display: none !important; }
  body.cr-home-v2 .cr-search-copy h1 {
    max-width: 340px !important;
    margin: 0 !important;
    color: #fff !important;
    font-family: 'Inter', sans-serif !important;
    font-size: clamp(24px, 6.2vw, 29px) !important;
    font-weight: 800 !important;
    line-height: 1.12 !important;
    letter-spacing: -.04em !important;
  }

  /* Buscador existente */
  body.cr-home-v2 .cr-search-box {
    display: grid !important;
    grid-template-columns: 1fr auto !important;
    align-items: center !important;
    gap: 6px !important;
    width: 100% !important;
    max-width: none !important;
    min-height: 48px !important;
    margin-top: 12px !important;
    padding: 5px !important;
    border-radius: 999px !important;
    background: #fff !important;
    border: 1px solid #e5ece3 !important;
    box-shadow: 0 5px 14px rgba(0,0,0,.09) !important;
  }
  body.cr-home-v2 .cr-search-box-icon input {
    min-width: 0 !important;
    padding: 0 0 0 12px !important;
    color: #17251b !important;
    font-size: 13px !important;
    font-weight: 400 !important;
    background: transparent !important;
  }
  body.cr-home-v2 .cr-search-box-icon input::placeholder {
    color: #777f7a !important;
    opacity: 1;
  }
  body.cr-home-v2 .cr-search-box-icon button {
    grid-column: auto !important;
    display: grid !important;
    place-items: center !important;
    width: 38px !important;
    height: 38px !important;
    min-height: 38px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    background: #eef5ea !important;
    border: 0 !important;
    box-shadow: none !important;
    color: #306020 !important;
  }
  body.cr-home-v2 .cr-search-box-icon button svg {
    width: 19px !important;
    height: 19px !important;
    margin: 0 !important;
    color: currentColor !important;
  }
  body.cr-home-v2 .cr-hero-art { display: none !important; }

  /* Categorías comerciales existentes */
  body.cr-home-v2 .cr-category-showcase {
    margin-top: 18px !important;
    gap: 10px !important;
  }
  body.cr-home-v2 .cr-category-tile {
    min-width: 126px !important;
    min-height: 142px !important;
    border-radius: 18px !important;
    padding: 10px 8px !important;
  }
  body.cr-home-v2 .cr-category-img {
    width: 94px !important;
    height: 82px !important;
    border-radius: 18px !important;
  }
  body.cr-home-v2 .cr-category-img img {
    width: 92px !important;
    height: 80px !important;
  }
  body.cr-home-v2 .cr-category-tile strong { font-size: 13px !important; }
  body.cr-home-v2 .cr-category-tile small { font-size: 10px !important; }
}

@media (max-width: 360px) {
  body.cr-home-v2 .cr-search-card {
    margin: 0 -6px !important;
    padding-inline: 16px !important;
  }
  body.cr-home-v2 .cr-home-v2-header .cr-location-city { font-size: 13px !important; }
  body.cr-home-v2 .cr-search-copy h1 { font-size: 23px !important; }
}
