/* =============================================
   MedBuy Custom Shortcodes & Page Layouts
   ============================================= */

.medbuy-category-banners .medbuy-banner-item:hover img,
.medbuy-large-banners > div:hover img {
    transform: scale(1.02);
    transition: transform 0.3s ease;
}

.medbuy-tabs-buttons .medbuy-tab-btn:hover {
    opacity: 0.9;
}

.categories-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

@media (max-width: 768px) {
    .medbuy-category-banners,
    .medbuy-large-banners {
        flex-direction: column;
    }
    .medbuy-hero-slider h1 {
        font-size: 32px !important;
    }
}

/* =============================================
   Hero Slider Dots Navigation
   ============================================= */
.med-slider-dots {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 10;
}

.med-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: background 0.3s ease, transform 0.3s ease, width 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
}

.med-dot:hover {
    background: rgba(255, 255, 255, 0.8);
    transform: scale(1.1);
}

.med-dot.active {
    background: #67c6ed; /* Celeste theme accent */
    width: 24px;
    border-radius: 6px;
    border-color: #67c6ed;
}

/* Make sure the slider images span from edge to edge (100vw) while keeping the height controlled and centered */
.med-hero-banner {
    width: 100vw !important;
    margin-left: calc(-50vw + 50%) !important;
    margin-right: calc(-50vw + 50%) !important;
    margin-bottom: 40px !important;
    position: relative !important;
}

.med-slider-container {
    height: 450px !important;
    width: 100% !important;
    max-width: 100vw !important;
    margin: 0 !important;
}

@media (max-width: 922px) {
    .med-slider-container {
        height: 350px !important;
    }
}

@media (max-width: 768px) {
    .med-slider-container {
        height: 250px !important;
    }
}

@media (max-width: 480px) {
    .med-slider-container {
        height: 180px !important;
    }
}

.med-slider-wrapper {
    height: 100% !important;
}

.med-slide {
    height: 100% !important;
}

.med-slide a {
    display: block;
    width: 100%;
    height: 100% !important;
}

.med-slide img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important; /* Fills the container, cropping overflow */
    object-position: center center !important; /* Centers the banner graphic */
    display: block;
    /* Optimize image scaling rendering for sharpness */
    image-rendering: -webkit-optimize-contrast !important; /* Improves sharpness in Chrome/Safari */
    image-rendering: auto !important;
    backface-visibility: hidden !important;
    -webkit-backface-visibility: hidden !important;
    transform: translate3d(0, 0, 0) !important; /* Prevents blur during hardware-accelerated transitions */
}

/* =============================================
   Sticky WhatsApp Button
   ============================================= */
.medbuy-whatsapp-sticky {
    position: fixed;
    bottom: 25px;
    right: 25px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    animation: slideUpFade 0.6s ease-out forwards;
}

@keyframes slideUpFade {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.whatsapp-btn-link {
    background-color: #25D366;
    color: white;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 16px rgba(37, 211, 102, 0.4);
    transition: all 0.3s ease;
    text-decoration: none;
    position: relative;
}

.whatsapp-btn-link:hover {
    background-color: #67c6ed;
    color: white;
    transform: scale(1.1);
    box-shadow: 0 8px 24px rgba(14, 219, 250, 0.5);
}

.whatsapp-btn-link svg {
    width: 34px;
    height: 34px;
}

/* Tooltip on hover (optional but looks premium) */
.whatsapp-btn-link::before {
    content: "¿Necesitas ayuda?";
    position: absolute;
    right: 75px;
    background: white;
    color: #333;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    opacity: 0;
    visibility: hidden;
    white-space: nowrap;
    transition: all 0.3s ease;
    pointer-events: none;
}

.whatsapp-btn-link:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.whatsapp-close-btn {
    background: white;
    color: #999;
    border: 1px solid #eee;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: all 0.2s ease;
    padding: 0;
    margin-right: 18px; /* align center with the big button */
}

.whatsapp-close-btn:hover {
    background: #f5f5f5;
    color: #333;
    transform: scale(1.1);
}

@media (max-width: 768px) {
    .medbuy-whatsapp-sticky {
        bottom: 20px;
        right: 20px;
    }
    .whatsapp-btn-link {
        width: 50px;
        height: 50px;
    }
    .whatsapp-btn-link svg {
        width: 28px;
        height: 28px;
    }
    .whatsapp-btn-link::before {
        display: none; /* Hide tooltip on mobile to avoid issues */
    }
    .whatsapp-close-btn {
        margin-right: 13px;
    }
}

/* =============================================
   Move Astra Scroll to Top Button to Left
   ============================================= */
#ast-scroll-top {
    right: auto !important;
    left: 25px !important;
}

@media (max-width: 768px) {
    #ast-scroll-top {
        left: 20px !important;
    }
}

/* =============================================
   Brands Bar (Footer)
   ============================================= */
.medbuy-brands-bar {
    background-color: #144667;
    color: #ffffff;
    padding: 30px 0;
    display: block;
    overflow: hidden;
    border-bottom: 3px solid #ffffff;
}

.medbuy-brands-inner {
    width: 100%;
    overflow: hidden;
    white-space: nowrap;
}

.medbuy-brands-track {
    display: inline-flex;
    width: max-content;
    align-items: center;
    gap: 80px;
    padding-right: 80px; /* Same as gap to keep spacing even */
    animation: medbuyMarquee 25s linear infinite;
}

.medbuy-brands-track:hover {
    animation-play-state: paused;
}

@keyframes medbuyMarquee {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(calc(-33.333333% - 26.666px)); /* 1/3 of the width. The px adjustment is for the gap padding */
    }
}

/* Fallback for exact gap calculation */
@keyframes medbuyMarquee {
    0% { transform: translateX(0); }
    100% { transform: translateX(-33.333333%); }
}

.medbuy-brands-track .brand-logo {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    opacity: 0.9;
    transition: opacity 0.3s ease, transform 0.3s ease;
    cursor: default;
}

.medbuy-brands-track .brand-logo:hover {
    opacity: 1;
    transform: translateY(-2px);
}

.medbuy-brands-track .brand-text {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
    font-family: inherit;
    text-transform: none;
}

@media (max-width: 768px) {
    .medbuy-brands-track {
        gap: 50px;
        padding-right: 50px;
    }
}

/* =============================================
   Dispatch Announcement Bar (Top Fixed)
   ============================================= */
.medbuy-dispatch-bar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 999;
    background-color: #0edbfa; /* Celeste de la pagina */
    color: #ffffff; /* Letras blancas */
    font-size: 13px;
    font-weight: 500;
    width: 100%;
    height: 34px;
    box-sizing: border-box;
    display: block;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.admin-bar .medbuy-dispatch-bar {
    top: 32px;
}

/* Hide dispatch bar when quick view modal is open */
body.medbuy-qv-open .medbuy-dispatch-bar {
    display: none !important;
}

/* Force Masthead down to make room for fixed dispatch bar */
header#masthead {
    margin-top: 34px !important;
}
.admin-bar header#masthead {
    margin-top: 34px !important;
}

/* Push down Astra sticky/fixed headers */
#ast-fixed-header, 
#masthead.ast-header-sticked,
.ast-mobile-header-wrap.ast-header-sticked,
.ast-header-sticky-active,
.ast-primary-header-bar--sticky,
.ast-mobile-header-wrap.ast-mobile-header-wrap-sticky {
    top: 34px !important;
}
.admin-bar #ast-fixed-header, 
.admin-bar #masthead.ast-header-sticked,
.admin-bar .ast-mobile-header-wrap.ast-header-sticked,
.admin-bar .ast-header-sticky-active,
.admin-bar .ast-primary-header-bar--sticky,
.admin-bar .ast-mobile-header-wrap.ast-mobile-header-wrap-sticky {
    top: calc(34px + 32px) !important;
}

.medbuy-dispatch-bar-inner {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    width: 100%;
    min-height: 34px;
}

.medbuy-dispatch-text {
    grid-column: 2;
    text-align: center;
}

.medbuy-dispatch-social {
    grid-column: 3;
    justify-self: end;
    display: flex;
    gap: 12px;
    align-items: center;
}

.medbuy-dispatch-social a {
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
}

.medbuy-dispatch-social a:hover {
    opacity: 0.8;
}

@media (max-width: 782px) {
    .admin-bar .medbuy-dispatch-bar {
        top: 46px;
    }
    .admin-bar header#masthead {
        margin-top: 26px !important;
    }
    .admin-bar #ast-fixed-header, 
    .admin-bar #masthead.ast-header-sticked,
    .admin-bar .ast-mobile-header-wrap.ast-header-sticked,
    .admin-bar .ast-header-sticky-active,
    .admin-bar .ast-primary-header-bar--sticky,
    .admin-bar .ast-mobile-header-wrap.ast-mobile-header-wrap-sticky {
        top: calc(26px + 46px) !important;
    }
}

@media (max-width: 768px) {
    .medbuy-dispatch-bar {
        height: 26px;
        font-size: 10px;
        font-weight: 400;
        padding: 0 10px;
    }
    .medbuy-dispatch-bar-inner {
        display: flex;
        justify-content: space-between;
    }
    .medbuy-dispatch-text {
        text-align: left;
        max-width: 75%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .medbuy-dispatch-social {
        position: static;
        gap: 6px;
        right: 0;
    }
    .medbuy-dispatch-social svg {
        width: 12px !important;
        height: 12px !important;
    }
    
    /* Push down for mobile height (26px) */
    header#masthead {
        margin-top: 26px !important;
    }
    
    #ast-fixed-header, 
    #masthead.ast-header-sticked,
    .ast-mobile-header-wrap.ast-header-sticked,
    .ast-header-sticky-active,
    .ast-primary-header-bar--sticky,
    .ast-mobile-header-wrap.ast-mobile-header-wrap-sticky {
        top: 26px !important;
    }
}

