/* ── Header: fondo acorde al sistema de diseño ─────────────────────── */

/*
 * Blocksy puede aplicar un fondo oscuro vía sus propias variables/clases.
 * Aquí lo reemplazamos con el gradient de parchment del sistema de tokens.
 * Se aplica a todas las filas del header para cubrir cualquier estructura
 * que Blocksy use (top-row, middle-row, bottom-row, etc.)
 */
#header,
#header [data-row],
#header [data-row] > div {
    background: var(--rb-gradient-header) !important;
    color: var(--rb-text) !important;
}

/* Borde inferior sutil para separar el header del contenido */
#header {
    border-bottom: 1px solid var(--rb-border-soft) !important;
    box-shadow: 0 2px 12px rgba(4, 16, 24, 0.06) !important;
}

/* Cuando el header se fija al hacer scroll, sombra más pronunciada */
.rhystic-header-fixed #header {
    box-shadow: 0 4px 24px rgba(4, 16, 24, 0.12) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    background: linear-gradient(
        180deg,
        rgba(var(--rb-surface-elevated-rgb), 0.97) 0%,
        rgba(var(--rb-bg-rgb), 0.95) 100%
    ) !important;
}

/* ── Contenedor ancho máximo ────────────────────────────────────────── */
#header .ct-container {
    max-width: min(1240px, calc(100vw - 32px));
}

@media (max-width: 999px) {
    #header .ct-container {
        max-width: min(100vw - 20px, 1240px);
    }
}

/* ── Tipografía del menú: navy sobre fondo parchment ───────────────── */
#header .menu > li > a,
#header .ct-header-account a,
#header .ct-header-cart a,
#header .ct-header-search,
#header .ct-header-trigger {
    color: var(--rb-text-secondary) !important;
}

#header .menu > li.current-menu-item > a,
#header .menu > li.current_page_item > a,
#header .menu > li > a:hover,
#header .ct-header-account a:hover,
#header .ct-header-cart a:hover,
#header .ct-header-search:hover,
#header .ct-header-trigger:hover {
    color: var(--rb-primary-dark) !important;
}

/* Indicador de página activa */
#header .menu > li.current-menu-item > a,
#header .menu > li.current_page_item > a {
    position: relative;
}

#header .menu > li.current-menu-item > a::after,
#header .menu > li.current_page_item > a::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -14px;
    height: 2px;
    border-radius: 999px;
    background: var(--rb-primary-crystal);
    box-shadow: var(--rb-glow-cyan);
}

/* ── Íconos (cart, search, account, hamburger) ─────────────────────── */
#header .ct-header-account .ct-icon,
#header .ct-header-cart .ct-icon,
#header .ct-header-search .ct-icon,
#header .ct-header-trigger .ct-icon {
    color: currentColor !important;
}

/* Badge del carrito */
#header .ct-dynamic-count-cart {
    background: var(--rb-gradient-primary);
    color: var(--rb-text-on-primary);
    box-shadow: var(--rb-glow-cyan);
    font-weight: 800;
}

/* ── Hover state para íconos ───────────────────────────────────────── */
#header .ct-cart-item .ct-icon-container,
#header .ct-account-item,
#header .ct-header-search,
#header .ct-header-trigger {
    border-radius: 999px;
    transition:
        background-color 0.18s ease,
        border-color 0.18s ease,
        color 0.18s ease,
        box-shadow 0.18s ease,
        transform 0.18s ease;
}

#header .ct-cart-item:hover .ct-icon-container,
#header .ct-account-item:hover,
#header .ct-header-search:hover,
#header .ct-header-trigger:hover {
    background: rgba(var(--rb-primary-rgb), 0.08);
    box-shadow: inset 0 0 0 1px rgba(var(--rb-primary-rgb), 0.18);
    transform: translateY(-1px);
}

/* ── Peso y espaciado del menú ─────────────────────────────────────── */
#header .menu > li > a {
    font-weight: 600;
    letter-spacing: -0.01em;
}

/* ── Tamaños mínimos de tap ────────────────────────────────────────── */
#header .ct-header-cart .ct-cart-item,
#header .ct-header-account .ct-account-item,
#header .ct-header-search,
#header .ct-header-trigger {
    min-height: 40px;
}

/* ── Focus visible ─────────────────────────────────────────────────── */
#header .menu > li > a:focus-visible,
#header .ct-header-account a:focus-visible,
#header .ct-header-cart a:focus-visible,
#header .ct-header-search:focus-visible,
#header .ct-header-trigger:focus-visible {
    outline: 2px solid var(--rb-primary);
    outline-offset: 4px;
    color: var(--rb-primary-dark);
}

/* ── Fondo del main en páginas que no son home ─────────────────────── */
body:not(.rhystic-home-page) #main {
    background:
        radial-gradient(circle at top center, rgba(var(--rb-primary-rgb), 0.1), transparent 28%),
        linear-gradient(180deg, var(--rb-surface-elevated) 0%, var(--rb-bg) 100%);
    color: var(--rb-text);
}

/* ── Header flotante (scroll-based) — aplica en TODO el sitio ──────── */

/* Neutraliza el sticky propio de Blocksy: en reposo el header fluye normal */
[data-sticky] {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    z-index: auto !important;
    width: auto !important;
    transform: none !important;
}

/* Cuando JS detecta scroll, fija el header al tope */
html.rhystic-header-fixed #header {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 1200 !important;
    width: 100% !important;
}

/* Las filas internas del header fijo vuelven a flujo normal (no se re-fijan) */
html.rhystic-header-fixed [data-sticky] {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    z-index: auto !important;
    width: auto !important;
}

/* Compensación genérica para todas las páginas */
html.rhystic-header-fixed body {
    padding-top: var(--rhystic-header-height, 80px);
}

/* Home y cartas manejan su propio offset, evitar doble padding */
html.rhystic-header-fixed body.rhystic-home-page,
html.rhystic-header-fixed body.rhystic-cartas-page {
    padding-top: 0;
}


/* ── WhatsApp floating button (todas las páginas) ─────────────────── */
.rhystic-whatsapp-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #25d366;
    color: #fff;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.rhystic-whatsapp-btn svg {
    width: 28px;
    height: 28px;
}

.rhystic-whatsapp-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(37, 211, 102, 0.4);
}

.rhystic-whatsapp-btn:active {
    transform: scale(0.98);
}

@media (max-width: 640px) {
    .rhystic-whatsapp-btn {
        bottom: 16px;
        right: 16px;
        width: 52px;
        height: 52px;
    }

    .rhystic-whatsapp-btn svg {
        width: 24px;
        height: 24px;
    }
}

/* ── Free shipping progress bar (mini cart / cart / checkout) ──── */
.rhystic-shipping-progress {
    margin: 10px 0 4px;
    padding: 10px 12px;
    background: rgba(var(--rb-primary-rgb, 53,200,242), 0.06);
    border: 1px solid rgba(var(--rb-primary-rgb, 53,200,242), 0.18);
    border-radius: 10px;
}

.rhystic-shipping-progress.is-free {
    background: rgba(57, 217, 138, 0.08);
    border-color: rgba(57, 217, 138, 0.3);
}

.rhystic-shipping-progress__track {
    height: 5px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.08);
    overflow: hidden;
    margin-bottom: 7px;
}

.rhystic-shipping-progress__fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--rb-primary, #35C8F2), var(--rb-primary-dark, #0C5E9E));
    transition: width 0.4s ease;
}

.rhystic-shipping-progress.is-free .rhystic-shipping-progress__fill {
    background: #39d98a;
}

.rhystic-shipping-progress__msg {
    margin: 0;
    font-size: 0.78rem;
    color: var(--rb-text-secondary, #0B2A42);
    line-height: 1.4;
}

/* Cart & checkout page version: slightly more breathing room */
.woocommerce-cart .rhystic-shipping-progress,
.woocommerce-checkout .rhystic-shipping-progress {
    margin: 0 0 20px;
    padding: 12px 16px;
}

/* ── Free shipping floating tooltip ───────────────────────────── */
.rhystic-ship-tooltip {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 9999;
    width: min(300px, calc(100vw - 40px));
    padding: 14px 36px 14px 14px;
    background: var(--rb-surface-elevated, #FFFDF7);
    border: 1px solid rgba(var(--rb-primary-rgb, 53,200,242), 0.25);
    border-radius: 12px;
    box-shadow: 0 8px 28px rgba(4, 16, 24, 0.14);
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.28s ease, transform 0.28s ease;
    pointer-events: none;
}

.rhystic-ship-tooltip.is-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.rhystic-ship-tooltip .rhystic-shipping-progress__track {
    margin-bottom: 8px;
}

.rhystic-ship-tooltip__msg {
    margin: 0;
    font-size: 0.82rem;
    color: var(--rb-text-secondary, #0B2A42);
    line-height: 1.4;
}

.rhystic-ship-tooltip__fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--rb-primary, #35C8F2), var(--rb-primary-dark, #0C5E9E));
    transition: width 0.4s ease;
}

.rhystic-ship-tooltip.is-free .rhystic-ship-tooltip__fill {
    background: #39d98a;
}

.rhystic-ship-tooltip__track {
    height: 5px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.08);
    overflow: hidden;
    margin-bottom: 8px;
}

.rhystic-ship-tooltip__close {
    position: absolute;
    top: 8px;
    right: 10px;
    background: none;
    border: none;
    font-size: 0.78rem;
    color: var(--rb-text-muted, #255C78);
    cursor: pointer;
    line-height: 1;
    padding: 2px 4px;
    opacity: 0.6;
    transition: opacity 0.15s;
}

.rhystic-ship-tooltip__close:hover {
    opacity: 1;
}

@media (max-width: 480px) {
    .rhystic-ship-tooltip {
        right: auto;
        left: 50%;
        transform: translateX(-50%) translateY(-8px);
        width: calc(100vw - 24px);
        border-radius: 10px;
    }

    .rhystic-ship-tooltip.is-visible {
        transform: translateX(-50%) translateY(0);
    }
}
