/*
 * Custom CSS - Renovables del Sur
 * Mejoras estéticas del tema Nova + integración InstantSearch
 * Backup original: custom.css.bak.2026-03-12
 */

/* ============================================
   1. REEMPLAZAR BUSCADOR NATIVO POR INSTANTSEARCH
   ============================================ */

#search_widget form {
    display: none !important;
}

#search_widget {
    position: relative;
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 0;
    min-height: 50px;
}

.instant-search-widget {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex !important;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

.instant-search-trigger {
    display: flex !important;
    align-items: center;
    width: 100%;
    max-width: 400px;
    padding: 8px 16px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.25s ease;
    gap: 10px;
}

.instant-search-trigger:hover {
    background: #fff;
    border-color: #2fb5d2;
    box-shadow: 0 2px 8px rgba(47, 181, 210, 0.15);
}

.instant-search-trigger i {
    font-size: 20px;
    color: #999;
    transition: color 0.2s;
}

.instant-search-trigger:hover i {
    color: #2fb5d2;
}

.instant-search-trigger::after {
    content: 'Buscar productos...';
    font-size: 14px;
    color: #999;
    flex: 1;
}

.instant-search-trigger .isearch-kbd {
    font-size: 11px;
    color: #bbb;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 1px 6px;
    font-family: monospace;
}


/* ============================================
   2. CARRITO JUNTO A "INICIAR SESIÓN"
   ============================================ */

/* Ocultar carrito original en header-top */
.header-top > .container > .row > #_desktop_cart {
    display: none !important;
}

/* Carrito clonado en el nav, junto a "Iniciar sesión" */
.nav-cart-wrapper {
    display: inline-block;
    vertical-align: middle;
    position: relative;
    margin-left: 5px;
    padding-left: 12px;
    border-left: 1px solid #444;
}

.nav-cart-wrapper .blockcart {
    float: none;
    margin: 0;
}

.nav-cart-wrapper .blockcart > .header {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    padding: 0;
    font-size: 0.8125rem;
    line-height: inherit;
    color: inherit;
    text-decoration: none;
}

.nav-cart-wrapper .fa-shopping-cart {
    font-size: 13px !important;
}

.nav-cart-wrapper .cart-label {
    font-size: 0.8125rem;
}

.nav-cart-wrapper .cart-products-count {
    background: #2fb5d2;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    min-width: 15px;
    height: 15px;
    line-height: 15px;
    text-align: center;
    border-radius: 8px;
    display: inline-block;
    padding: 0 3px;
}

/* Dropdown del carrito clonado */
.nav-cart-wrapper .cart-summary {
    position: absolute;
    top: 100%;
    right: 0;
    left: auto;
    z-index: 1000;
    margin-top: 10px;
}

/* Estilizar el carrito como el resto de elementos del nav */
#_desktop_cart .blockcart {
    float: none;
    margin: 0;
}

#_desktop_cart .blockcart > .header {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    padding: 0;
    font-size: 0.8125rem;
    line-height: 1.2;
    color: #666;
    text-decoration: none;
}

#_desktop_cart .blockcart > .header:hover {
    color: #333;
}

/* Icono del carrito: mismo tamaño que el icono de user-info */
#_desktop_cart .blockcart > .header > .fa-shopping-cart {
    font-size: 15px;
    vertical-align: -2px;
}

/* Texto "Carrito" con mismo estilo que "Iniciar sesión" */
#_desktop_cart .blockcart > .header > .cart-label {
    font-size: 0.8125rem;
}

/* Badge contador */
#_desktop_cart .cart-products-count {
    background: #2fb5d2;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    min-width: 15px;
    height: 15px;
    line-height: 15px;
    text-align: center;
    border-radius: 8px;
    display: inline-block;
    padding: 0 4px;
    vertical-align: 1px;
}

/* Dropdown del carrito */
#_desktop_cart .cart-summary {
    right: 0;
    left: auto;
}

/* Expandir buscador al espacio liberado */
#search_widget.col-lg-4 {
    flex: 0 0 66.666667%;
    max-width: 66.666667%;
}


/* ============================================
   3. ARREGLAR SCROLLBAR DEL CARRITO
   ============================================ */

#header .cart-summary {
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    overflow-x: hidden;
    border-radius: 4px;
    max-width: 350px;
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
}

#header .cart-summary::-webkit-scrollbar {
    width: 4px;
}
#header .cart-summary::-webkit-scrollbar-track {
    background: transparent;
}
#header .cart-summary::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}

.blockcart.cart-preview {
    overflow: visible;
}


/* ============================================
   4. MEJORAS ESTÉTICAS
   ============================================ */

.header-top {
    padding: 10px 0;
}

#_desktop_logo {
    display: flex;
    align-items: center;
}

#_desktop_logo .logo {
    max-height: 65px;
    width: auto;
}

#header .cart-summary .checkout .btn-primary {
    width: 100%;
    text-align: center;
    border-radius: 4px;
    font-weight: 600;
    padding: 10px;
}


/* ============================================
   5. RESPONSIVE
   ============================================ */

@media (max-width: 767px) {
    .instant-search-trigger::after {
        display: none;
    }

    .instant-search-trigger .isearch-kbd {
        display: none;
    }

    .instant-search-trigger {
        background: transparent;
        border: none;
        width: auto;
        padding: 8px;
        justify-content: center;
    }

    .instant-search-trigger:hover {
        background: transparent;
        border: none;
        box-shadow: none;
    }

    /* En móvil, ocultar el widget de búsqueda del header-top */
    #search_widget {
        display: none !important;
    }

    /* En móvil el carrito vuelve a su posición normal */
    #_desktop_cart {
        display: block !important;
    }

    /* No ocultar el carrito original en móvil */
    .header-top > .container > .row > #_desktop_cart {
        display: block !important;
    }

    /* Ocultar el carrito movido al nav en móvil */
    .nav-cart-wrapper {
        display: none !important;
    }

    /* Asegurar que el overlay del buscador funcione bien en móvil */
    .instant-search-overlay .instant-search-container {
        width: 100%;
        max-width: 100%;
        margin: 0;
        border-radius: 0;
        height: 100vh;
        max-height: 100vh;
    }
}
