/*
Theme Name: Ecuapro Optimized v31 Custom
Description: Encabezado personalizable, barra superior configurable, buscador opcional y acciones móviles con botón MENÚ ocultable.
Version: 31.10
Author: Ecuaprobioticos
Text Domain: ecuapro
*/

:root { --primary:#1247ff; --wa:#25D366; --border:#e5e7eb; --ink:#0f172a; --topbar-bg:#c81e1e; --background:#fff; --shadow:rgba(0,0,0,.06); }
*{box-sizing:border-box}
body{margin:0;font:14px/1.6 system-ui,-apple-system,Segoe UI,Roboto,Arial;color:var(--ink);background:var(--background)}
a{color:var(--primary);text-decoration:none}
a:hover{text-decoration:underline}

/* Top bar */
.top-header{
  position:fixed;top:0;left:0;right:0;z-index:9999;
  background:var(--topbar-bg);
  color:var(--topbar-color,#fff);
  font-weight:var(--topbar-fw,700);
  text-align:center;
  padding:0;
  display:flex;align-items:center;justify-content:center;
  height:var(--topbar-h,30px);
  line-height:1;
  font-size:var(--topbar-fs,14px);
}

/* Header */
.main-header{
  position:relative;padding:16px 0;min-height:160px;display:flex;align-items:center;background:transparent!important;overflow:hidden;
  padding-top:0 !important; /* evita franja blanca */
}
.header-inner{display:flex;gap:16px;align-items:center;max-width:1360px;margin:0 auto;padding:0 16px;width:100%}
.custom-logo{margin-top:22px;max-height:72px;height:auto}
.site-title{margin:0;font-size:28px;font-weight:900;color:var(--ink)}
.site-description{margin:4px 0 0;font-weight:600;color:var(--ink)}
.header-search{flex:1;max-width:820px}
.header-search form{display:flex;background:var(--background);border:1px solid var(--border);border-radius:12px;overflow:hidden;box-shadow:0 6px 18px var(--shadow)}
.header-search input[type=search]{flex:1;border:0;outline:0;padding:1rem 1.1rem;font-size:16px}
.header-search button{border:0;padding:1rem 1.1rem;background:var(--primary);color:#fff;font-weight:800}

/* Submenu */
.top-submenu{background:var(--background);border-bottom:1px solid var(--border)}
.submenu-list{display:flex;gap:24px;justify-content:center;list-style:none;margin:0;padding:10px 0}
.submenu-list a{color:var(--ink);font-weight:700}

/* Containers */
.container{max-width:1360px;margin:0 auto;padding:0 16px}

/* Catalog */
.catalog{display:grid;grid-template-columns:280px 1fr;gap:24px;margin:24px 0}
.catalog-card{border:1px solid var(--border);border-radius:14px;overflow:hidden;box-shadow:0 8px 24px var(--shadow);background:var(--background)}
.catalog-title{background:var(--primary);color:#fff;font-weight:800;padding:1rem}
.catalog-list{list-style:none;margin:0;padding:0}
.catalog-list li{border-top:1px solid #eef2f7}
.catalog-list a{display:block;padding:.9rem 1rem;color:var(--ink);font-weight:600}

/* Single product layout */
.product-layout{display:grid;grid-template-columns:280px 1fr;gap:24px;margin:24px 0}
.product-main{background:var(--background);border-radius:14px}
.single-product .product-flex{display:flex;gap:24px;align-items:flex-start;padding:16px}

/* Layout fijo 30% / 70% */
.single-product .woocommerce-product-gallery{flex:0 0 30%;max-width:30%}
.single-product .summary{flex:0 0 70%;max-width:70%}

/* Galería */
.woocommerce div.product div.images,
.woocommerce div.product div.images .woocommerce-product-gallery__wrapper,
.woocommerce div.product div.images .woocommerce-product-gallery__image,
.single-product .woocommerce-product-gallery,
.single-product .woocommerce-product-gallery__wrapper,
.single-product .woocommerce-product-gallery__image{width:100%!important;max-width:100%!important;float:none!important;display:block}
.woocommerce div.product div.images img,
.single-product .woocommerce-product-gallery img{width:100%!important;height:auto!important;max-width:none!important;object-fit:contain;border-radius:12px;box-shadow:0 8px 24px var(--shadow);background:var(--background)}

/* Price */
.single-product .summary .price{color:#c2410c;font-weight:900;font-size:22px;margin:.25rem 0 .75rem}

/* Extras */
.single-product .product-extra{padding:0 16px 24px}
.single-product .woocommerce-tabs{margin-top:8px}
.single-product .related,
.single-product .upsells,
.single-product .recently-viewed-products,
.single-product .yith-wcan-related,
.single-product .cross-sells{clear:both;width:100%}

/* Qty */
.quantity input.qty{font-size:18px;padding:.6rem .8rem;border:1px solid var(--border)!important;border-radius:10px;min-width:82px;text-align:center}
.qty-wrapper{display:inline-flex;align-items:center;gap:6px;margin:8px 0}
.qty-btn{width:38px;height:38px;border:1px solid var(--border);border-radius:10px;background:var(--background);font-weight:900}
.btn-whatsapp{display:inline-flex;align-items:center;gap:.6rem;background:var(--wa);color:#fff!important;border:none;border-radius:12px;padding:.9rem 1.2rem;font-weight:900;margin-top:10px;box-shadow:0 8px 24px rgba(37,211,102,.35)}

/* Ocultar ordering & count */
.woocommerce-result-count,.woocommerce-ordering{display:none!important}

/* Desktop */
@media (min-width:961px){.catalog-title{display:block}}

/* ======= Móvil ======= */
@media (max-width:960px){
  .top-submenu{display:none}
  .container{padding-left:10px;padding-right:10px}
  .catalog,.product-layout{grid-template-columns:1fr}
  .single-product .product-flex{flex-direction:column;padding:12px}
  .single-product .woocommerce-product-gallery,.single-product .summary{max-width:100%;flex:0 0 100%}
  .catalog-title{display:none}
}

/* Hero */
.hero{display:none;padding:12px 16px 0}
.hero__search form{display:flex;gap:.5rem;background:var(--background);border:1px solid var(--border);border-radius:12px;align-items:center;padding:.35rem;box-shadow:0 6px 18px var(--shadow)}
.hero__search input[type=search]{flex:1;border:0;outline:0;padding:.8rem 1rem}
.hero__search button{border:0;border-radius:10px;padding:.8rem 1rem;background:var(--primary);color:#fff;font-weight:700}

/* Asegurar z-index */
.main-header{position:relative;z-index:1}
.top-submenu, main, .product-layout, .product-main{position:relative;z-index:0}
.header-inner, .site-branding, .header-search form{background:transparent!important}

/* Bloque móvil pedido por el usuario */
@media (max-width:960px){
  .site-branding{display:flex;align-items:center;gap:10px}
  .custom-logo, .custom-logo-link img{height:44px!important;width:auto!important;border-radius:0!important;object-fit:contain!important}
  .site-branding > div{min-width:0;display:flex;flex-direction:column}
  .site-title{margin:0;font-size:22px;line-height:1.2;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .site-description{margin:0;font-size:13px}
}

/* Mobile: header + buscador */
@media (max-width:960px){
  .header-inner{display:flex;flex-direction:column;align-items:stretch;gap:10px}
  .site-branding{order:1}
  .header-search{order:2;width:100%;margin-top:4px;display:block!important}
  .main-header{padding-top:0!important;padding-bottom:16px}
  .header-search form{width:100%!important;max-width:100%!important}
  .header-search input[type=search]{flex:1 1 auto;min-width:0;font-size:17px;padding:.9rem 1rem}
  .header-search button{flex:0 0 auto;white-space:nowrap;padding:.9rem 1.2rem;font-size:16px}
}

/* FIX Cantidad + Añadir al carrito móvil */
@media (max-width:960px){
  .single-product .summary form.cart{display:flex!important;align-items:center!important;gap:8px!important;width:100%!important}
  .single-product .quantity{flex:0 0 92px!important;margin:0!important;display:flex!important;align-items:center;justify-content:center}
  .single-product .quantity input.qty{width:48px!important;min-width:0!important;text-align:center;padding:.35rem!important;margin:0 2px}
  .single-product .qty-btn{width:24px!important;height:24px!important;font-size:14px!important;line-height:1}
  .single-product button.single_add_to_cart_button{flex:1 1 auto!important;min-width:0!important;margin:0!important;display:inline-flex!important;justify-content:center;align-items:center;white-space:nowrap!important;padding:.6rem 1rem!important;font-size:15px!important;box-sizing:border-box}
  .single-product .btn-whatsapp{display:block!important;width:100%!important;margin-top:12px!important}
}

/* Compactar márgenes laterales */
.container,.catalog,.product-layout{padding-left:6px!important;padding-right:6px!important}

/* Mobile actions (compact) */
.mobile-actions{display:none;gap:var(--ma-gap,60px);max-width:1360px;margin:6px auto 8px;padding:0 10px}
.ma-btn{flex:1;display:inline-flex;align-items:center;gap:8px;border:1px solid var(--border);border-radius:var(--ma-rad,5px);padding:0 .7rem;height:var(--ma-h,20px);font-weight:700;background:#fff;color:var(--ink);justify-content:flex-start;box-shadow:none}
.ma-btn .ma-icon{font-size:var(--ma-ico,16px);line-height:1}
.ma-btn .ma-text{font-size:var(--ma-fs,12px)}
.ma-btn.ma-menu{background:#fff;border-color:var(--border);color:var(--ink)}
.ma-btn[aria-expanded="true"]{background:#f3f4f6}
@media (max-width:960px){.mobile-actions{display:flex}}

/* Drawer base */
.mobile-drawer{position:fixed;inset:0;z-index:9998;background:rgba(0,0,0,.4);display:block}
.mobile-drawer[hidden]{display:none}
.mobile-drawer .md-inner{position:absolute;right:0;top:0;height:100%;width:min(84vw,360px);background:#fff;box-shadow:-8px 0 24px rgba(0,0,0,.2);padding:14px 14px 24px;overflow:auto;transform:translateX(100%);transition:transform .25s ease}
.mobile-drawer.open .md-inner{transform:translateX(0)}
.md-close{border:0;background:#111827;color:#fff;border-radius:10px;padding:.5rem .8rem;font-weight:800;margin-bottom:10px}

@media (max-width:960px){
  .mobile-drawer .md-close{margin-top:calc(var(--topbar-h,30px) + 10px)}
}

/* Mejora de drawers móviles + lista */
.mobile-drawer .md-inner{padding:16px 16px 28px}
.mobile-drawer .md-title{font-weight:900;font-size:18px;margin:4px 0 12px}
.mobile-drawer .md-search{display:flex;gap:.5rem;margin:0 0 12px}
.mobile-drawer .md-search input{flex:1;border:1px solid var(--border);border-radius:10px;padding:.6rem .8rem}
.mobile-drawer .md-search button{border:0;border-radius:10px;padding:.6rem .9rem;background:var(--primary);color:#fff;font-weight:800}
.md-list{list-style:none;margin:0;padding:0}
.md-list li{border-bottom:1px solid #eee}
.md-list a{display:flex;justify-content:space-between;align-items:center;padding:8px 6px;font-weight:700;color:#111827;text-decoration:none}
.md-list a::after{content:"›";font-weight:900;transition:transform .15s ease}
.md-list li.open > a::after{transform:rotate(90deg)}
.md-list .children{display:none;padding-left:10px;border-left:2px solid #f1f5f9;margin-left:4px}
.md-list li.open > .children{display:block}
.md-list .children a{font-weight:600}
@media (max-width:960px){.catalog-sidebar{display:none}}
@media (hover:hover){.ma-btn:hover{background:#f8fafc}}

/* Buscador móvil parametrizable */
@media (max-width:960px){
  .header-search form,.hero__search form{border-radius:var(--ms-rad,12px)}
  .header-search input[type=search],.hero__search input[type=search]{font-size:var(--ms-fs,17px);min-height:var(--ms-h,44px)}
  .header-search button,.hero__search button{min-height:var(--ms-h,44px);font-size:calc(var(--ms-fs,17px) - 1px)}
}

/* Forzar aplicación buscador móvil */
@media (max-width:960px){
  .header-search form,.hero__search form{border-radius:var(--ms-rad,12px)!important;overflow:hidden}
  .header-search input[type=search],.hero__search input[type=search]{
    -webkit-appearance:none;appearance:none;
    height:var(--ms-h,44px)!important;
    line-height:calc(var(--ms-h,44px) - 2px)!important;
    font-size:var(--ms-fs,17px)!important;
    padding:0 12px!important;
  }
  .header-search button,.hero__search button{
    height:var(--ms-h,44px)!important;
    line-height:var(--ms-h,44px)!important;
    font-size:calc(var(--ms-fs,17px) - 1px)!important;
    padding:0 14px!important;
  }
}

/* Espacio inferior del buscador en móvil */
@media (max-width:960px){
  .main-header .header-search{margin-bottom:var(--ms-gap,8px)}
  .main-header{padding-bottom:var(--ms-gap,8px)!important}
}

.ma-btn.ma-catalogo{background:#fff;border-color:var(--border);color:var(--ink)}

/* Footer móvil: menú superior vertical */
.mobile-footer-topmenu{display:block;padding:12px 16px;background:#f0f0f0}
.mobile-footer-topmenu .ecuapro-vertical-menu__list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:8px}
.mobile-footer-topmenu .ecuapro-vertical-menu__list li{list-style:none;margin:0;padding:0}
.mobile-footer-topmenu .ecuapro-vertical-menu__list a{color:#333;text-decoration:none;font-weight:500}
.mobile-footer-topmenu .ecuapro-vertical-menu__list a:hover,
.mobile-footer-topmenu .ecuapro-vertical-menu__list a:focus{text-decoration:underline;color:#000}
@media (min-width:769px){.mobile-footer-topmenu{display:none}}

/* Footer móvil forzado dentro de .site-footer cuando aplique */
.site-footer .mobile-footer-topmenu{display:block;padding:12px 16px;background:#f0f0f0!important}
.site-footer .mobile-footer-topmenu .ecuapro-vertical-menu__list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:8px}
.site-footer .mobile-footer-topmenu .ecuapro-vertical-menu__list a,
.site-footer .mobile-footer-topmenu .ecuapro-vertical-menu__list a:visited{color:#333!important;text-decoration:none}
.site-footer .mobile-footer-topmenu .ecuapro-vertical-menu__list a:hover,
.site-footer .mobile-footer-topmenu .ecuapro-vertical-menu__list a:focus{color:#000!important;text-decoration:underline}
@media (min-width:769px){.site-footer .mobile-footer-topmenu{display:none!important}}

/* Fix tipografía h1 dentro de article/section/aside/nav */
article h1,section h1,aside h1,nav h1{
  font-size:clamp(1.25rem,2.5vw,1.75rem);
  line-height:1.25;
  margin:.5rem 0;
}

/* Contraste de precios en listados */
.woocommerce ul.products li.product .price,
.woocommerce ul.products li.product .price ins,
.woocommerce ul.products li.product .price del,
.woocommerce .related ul.products li.product .price,
.woocommerce .upsells ul.products li.product .price,
.woocommerce .recently-viewed-products ul.products li.product .price{
  color:#111!important;font-weight:700!important;
}

/* Logo cuadrado */
.custom-logo,.custom-logo-link img{
  width:72px!important;height:72px!important;aspect-ratio:1/1;object-fit:contain;
}
@media (max-width:960px){
  .custom-logo,.custom-logo-link img{width:44px!important;height:44px!important}
}

/* Compensar altura de la barra superior fija */
body{padding-top:var(--topbar-h,30px)!important}

/* WP Admin Bar */
@media (min-width:783px){
  body.admin-bar .top-header{top:32px!important}
  body.admin-bar{padding-top:calc(var(--topbar-h,30px) + 32px)!important}
}
@media (max-width:782px){
  body.admin-bar .top-header{top:46px!important}
  body.admin-bar{padding-top:calc(var(--topbar-h,30px) + 46px)!important}
}

/* Botón cerrar de drawers en móvil bajo la topbar */
@media (max-width:960px){
  .mobile-drawer .md-close{margin-top:calc(var(--topbar-h,30px) + 10px)!important}
}

/* Animación de vibración horizontal en hover */
@keyframes horizontal-shaking{
  0%{transform:translateX(0)}
  25%{transform:translateX(1px)}
  50%{transform:translateX(-5px)}
  75%{transform:translateX(1px)}
  100%{transform:translateX(0)}
}
.top-header:hover{animation:horizontal-shaking .6s ease}

/* Ocultar barra superior cuando tiene clase hide-on-scroll */
.top-header{transition:transform .3s ease;will-change:transform}
.top-header.hide-on-scroll{transform:translateY(-100%)}

/* ===== Botón Añadir al carrito: mismo tamaño en todos los dispositivos ===== */
.single-product .summary .single_add_to_cart_button{
  width:155px !important;          /* ancho fijo */
  height:45px !important;          /* alto fijo */
  line-height:45px !important;
  display:inline-flex !important;
  align-items:center;
  justify-content:center;
  padding:0 16px !important;
  flex:0 0 auto !important;        /* evita que se estire */
}
