/* ============================================================
   COMPONENTS.CSS  – Botones flotantes, cookies, widget WhatsApp
   El Mana Supermercado v2 - versión limpia
   ============================================================ */

/* -------- FLOATING BUTTONS -------- */
.floating-btn {
    position: fixed;
    right: 22px;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 16px rgba(0,0,0,0.25);
    cursor: pointer;
    z-index: 999;
    transition: transform .3s ease, box-shadow .3s ease, opacity .3s ease;
    text-decoration: none;
    overflow: visible;
}
.floating-btn:hover {
    transform: translateY(-3px) scale(1.06);
    box-shadow: 0 10px 22px rgba(0,0,0,0.30);
}

.floating-wa    { bottom: 22px;  background: #25D366; }
.floating-up    { bottom: 88px;  background: var(--primary); opacity: 0; pointer-events: none; }
.floating-up.is-visible { opacity: 1; pointer-events: auto; }
.floating-theme { bottom: 154px; background: var(--accent-orange); }

body.theme-dark .floating-theme { background: #f5b642; color: #1e293b; }

/* Cuando no hay WA, mover el resto */
body:not(.has-whatsapp) .floating-up    { bottom: 22px; }
body:not(.has-whatsapp) .floating-theme { bottom: 88px; }

@media (max-width: 600px) {
    .floating-btn {
        width: 48px;
        height: 48px;
        font-size: 1.3rem;
        right: 14px;
    }
    .floating-wa    { bottom: 14px; }
    .floating-up    { bottom: 74px; }
    .floating-theme { bottom: 134px; }
}

/* -------- COOKIE BANNER -------- */
.cookie-banner {
    position: fixed;
    left: 20px;
    right: 20px;
    bottom: 20px;
    max-width: 640px;
    margin: 0 auto;
    background: #fff;
    color: #182B42;
    box-shadow: 0 12px 32px rgba(0,0,0,0.20);
    border-radius: 14px;
    padding: 1rem 1.4rem;
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    z-index: 998;
    animation: cookieUp .6s ease;
    border-left: 5px solid var(--accent-green);
}
.cookie-banner.is-visible { display: flex; }
.cookie-banner p { font-size: .95rem; margin: 0; }
.cookie-banner button {
    background: var(--accent-green);
    color: #fff;
    border: none;
    padding: .6rem 1.2rem;
    border-radius: 30px;
    font-weight: 700;
    cursor: pointer;
    transition: background .2s;
    flex-shrink: 0;
}
.cookie-banner button:hover { background: #4e9024; }
body.theme-dark .cookie-banner { background: #1e293b; color: #e2e8f0; }

@keyframes cookieUp {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

@media (max-width: 500px) {
    .cookie-banner {
        flex-direction: column;
        text-align: center;
        left: 10px; right: 10px; bottom: 10px;
    }
}

/* -------- ALERTS COMUNES -------- */
.alert-message {
    padding: .95rem 1.1rem;
    border-radius: 10px;
    margin-bottom: 1.2rem;
    font-weight: 600;
    text-align: center;
    border-left: 5px solid;
}
.alert-success { background:#d1fae5; color:#065f46; border-color:#10b981; }
.alert-error   { background:#fee2e2; color:#991b1b; border-color:#ef4444; }
.alert-info    { background:#dbeafe; color:#1e40af; border-color:#3b82f6; }


/* ============================================================
   WIDGET DE CHAT WHATSAPP
   ============================================================ */

/* Pulso alrededor del ícono (SIN sobreescribir position:fixed) */
.wa-pulse {
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: #25D366;
    opacity: .55;
    z-index: -1;
    animation: waPulse 2s infinite;
    pointer-events: none;
}
@keyframes waPulse {
    0%   { transform: scale(1);   opacity: .55; }
    70%  { transform: scale(1.5); opacity: 0;   }
    100% { transform: scale(1.5); opacity: 0;   }
}

/* Punto de notificación */
.wa-notif-dot {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 2px #fff;
    animation: waPop .6s ease .5s both;
}
.wa-notif-dot.is-hidden { display: none; }
@keyframes waPop {
    from { transform: scale(0); }
    to   { transform: scale(1); }
}

/* Burbuja invitación (tooltip) */
.wa-invite-bubble {
    position: fixed;
    right: 88px;
    bottom: 30px;
    background: #fff;
    color: #182B42;
    padding: 12px 40px 12px 16px;
    border-radius: 24px 24px 4px 24px;
    box-shadow: 0 10px 24px rgba(0,0,0,0.18);
    font-size: .95rem;
    font-weight: 600;
    max-width: 260px;
    z-index: 999;
    cursor: pointer;
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: opacity .35s ease, transform .35s ease;
}
.wa-invite-bubble.is-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.wa-invite-bubble::before {
    content: '';
    position: absolute;
    right: -8px;
    bottom: 10px;
    width: 0;
    height: 0;
    border-left: 10px solid #fff;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
}
.wa-invite-close {
    position: absolute;
    top: 4px;
    right: 10px;
    font-size: 1.2rem;
    color: #94a3b8;
    line-height: 1;
    cursor: pointer;
}
.wa-invite-close:hover { color: #ef4444; }

body.theme-dark .wa-invite-bubble { background: #1e293b; color: #e2e8f0; }
body.theme-dark .wa-invite-bubble::before { border-left-color: #1e293b; }

/* Ventana de chat (OCULTA por defecto) */
.wa-chat-widget {
    position: fixed;
    right: 22px;
    bottom: 88px;
    width: 340px;
    max-height: 500px;
    background: #ECE5DD;
    border-radius: 16px;
    box-shadow: 0 20px 45px rgba(0,0,0,0.30);
    overflow: hidden;
    display: none;
    flex-direction: column;
    z-index: 1000;
    animation: waSlideUp .35s ease;
    font-family: 'Poppins', system-ui, -apple-system, sans-serif;
}
.wa-chat-widget.is-open { display: flex; }
@keyframes waSlideUp {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

.wa-chat-header {
    background: #128C7E;
    color: #fff;
    padding: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-shrink: 0;
}
.wa-agent {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}
.wa-avatar {
    position: relative;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
}
.wa-avatar img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.4);
    display: block;
}
.wa-online-dot {
    position: absolute;
    right: -2px;
    bottom: 0;
    width: 12px;
    height: 12px;
    background: #4ade80;
    border-radius: 50%;
    border: 2px solid #128C7E;
    box-shadow: 0 0 0 0 rgba(74,222,128,.6);
    animation: waOnline 2s infinite;
}
@keyframes waOnline {
    0%   { box-shadow: 0 0 0 0   rgba(74,222,128,.7); }
    100% { box-shadow: 0 0 0 10px rgba(74,222,128,0); }
}
.wa-agent-meta { min-width: 0; }
.wa-agent-meta strong {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
    color: #fff;
}
.wa-agent-meta span {
    font-size: .78rem;
    opacity: .85;
    display: block;
    margin-top: 3px;
    color: #fff;
}
.wa-status { font-style: normal; font-weight: 600; }

.wa-chat-close {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    transition: background .2s;
    flex-shrink: 0;
}
.wa-chat-close:hover { background: rgba(255,255,255,0.30); }

/* Fondo tipo WhatsApp */
.wa-chat-body {
    background: #ECE5DD;
    background-image:
        radial-gradient(rgba(0,0,0,0.03) 1px, transparent 1px),
        radial-gradient(rgba(0,0,0,0.03) 1px, transparent 1px);
    background-size: 24px 24px;
    background-position: 0 0, 12px 12px;
    padding: 16px 12px;
    overflow-y: auto;
    flex: 1;
    min-height: 180px;
    max-height: 300px;
}
.wa-msg-row { display: flex; margin-bottom: 10px; }
.wa-msg {
    max-width: 82%;
    padding: 9px 12px 7px;
    border-radius: 8px;
    font-size: .9rem;
    line-height: 1.35;
    box-shadow: 0 1px 1px rgba(0,0,0,0.06);
    position: relative;
    word-wrap: break-word;
}
.wa-msg p { margin: 0; }
.wa-msg-in {
    background: #fff;
    color: #182B42;
    border-top-left-radius: 2px;
    animation: waIn .4s ease;
}
.wa-msg-in::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 0;
    width: 0;
    height: 0;
    border-top: 6px solid #fff;
    border-left: 6px solid transparent;
}
.wa-msg-info {
    background: #FFF3C4;
    color: #713f12;
    font-size: .78rem;
    text-align: center;
    margin: 0 auto;
    border-radius: 8px;
    padding: 6px 12px;
    box-shadow: none;
}
.wa-msg-time {
    display: block;
    text-align: right;
    font-size: .68rem;
    color: #64748b;
    margin-top: 4px;
}
.wa-msg-time .fa-check-double { color: #4a99e9; }

@keyframes waIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0);   }
}

.wa-chat-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    background: #F0F0F0;
    border-top: 1px solid #d5d5d5;
    flex-shrink: 0;
}
#waChatInput {
    flex: 1;
    border: none;
    background: #fff;
    border-radius: 22px;
    padding: 10px 14px;
    font-size: .92rem;
    outline: none;
    font-family: inherit;
    box-shadow: inset 0 0 0 1px transparent;
    transition: box-shadow .2s;
    min-width: 0;
}
#waChatInput:focus { box-shadow: inset 0 0 0 2px #25D366; }
.wa-send-btn {
    background: #25D366;
    color: #fff;
    border: none;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    box-shadow: 0 3px 8px rgba(37,211,102,0.35);
    transition: transform .15s, background .2s;
    flex-shrink: 0;
}
.wa-send-btn:hover  { background: #1ebe5a; }
.wa-send-btn:active { transform: scale(.94); }

/* Dark mode */
body.theme-dark .wa-chat-widget { background: #0f1a24; }
body.theme-dark .wa-chat-body   { background-color: #0f1a24; }
body.theme-dark .wa-msg-in      { background: #202c36; color: #e2e8f0; }
body.theme-dark .wa-msg-in::before { border-top-color: #202c36; }
body.theme-dark .wa-chat-footer { background: #1e293b; border-top-color: #334155; }
body.theme-dark #waChatInput    { background: #0f1a24; color: #e2e8f0; }
body.theme-dark .wa-msg-time    { color: #94a3b8; }

/* Responsive */
@media (max-width: 480px) {
    .wa-chat-widget {
        right: 12px;
        left: 12px;
        bottom: 78px;
        width: auto;
        max-height: 70vh;
    }
    .wa-invite-bubble {
        right: 74px;
        bottom: 24px;
        max-width: 200px;
        font-size: .85rem;
    }
    .wa-agent-meta strong { max-width: 150px; }
}
