/* ================================================================
   WhatsApp QR Button v2.0.0 — wqrb.css
   Estilos: bubble | bar | widget | auto + QR popup compartido
   ================================================================ */

/* ── Variables ─────────────────────────────────────────────────── */
:root {
    --wqrb-green:   #25D366;
    --wqrb-green-d: #1da851;
    --wqrb-radius:  16px;
    --wqrb-shadow:  0 8px 32px rgba(0,0,0,.18);
    --wqrb-z:       99998;
}

/* ── Posiciones flotantes ──────────────────────────────────────── */
.pos-bottom-right { position:fixed; bottom:24px; right:24px; z-index:var(--wqrb-z); }
.pos-bottom-left  { position:fixed; bottom:24px; left:24px;  z-index:var(--wqrb-z); }
.pos-top-right    { position:fixed; top:24px;    right:24px; z-index:var(--wqrb-z); }
.pos-top-left     { position:fixed; top:24px;    left:24px;  z-index:var(--wqrb-z); }

/* ════════════════════════════════════════════════════════════════
   POPUP QR (compartido por todos los estilos)
   ════════════════════════════════════════════════════════════════ */
#wqrb-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 100000;
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    animation: wqrb-fade-in .2s ease;
}
#wqrb-overlay.active { display: flex; }

#wqrb-popup {
    background: #fff;
    border-radius: 20px;
    padding: 36px 28px 24px;
    max-width: 360px;
    width: 92%;
    text-align: center;
    position: relative;
    box-shadow: 0 24px 64px rgba(0,0,0,.28);
    animation: wqrb-pop-in .3s cubic-bezier(.34,1.56,.64,1);
}

.wqrb-popup-logo {
    width: 52px; height: 52px;
    object-fit: contain;
    border-radius: 10px;
    margin: 0 auto 12px;
    display: block;
}

.wqrb-device-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #f0faf4;
    color: #1a7a3c;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 20px;
    margin-bottom: 14px;
}

#wqrb-popup h2 { margin: 0 0 6px; font-size: 20px; color: #111; line-height: 1.3; }
#wqrb-popup > p { margin: 0 0 18px; font-size: 14px; color: #666; line-height: 1.6; }

#wqrb-close-btn {
    position: absolute;
    top: 12px; right: 14px;
    background: none;
    border: none;
    color: #aaa;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    line-height: 0;
    transition: color .15s, background .15s;
}
#wqrb-close-btn:hover { color: #333; background: #f0f0f0; }

/* QR Box */
#wqrb-qr-wrap   { display:flex; justify-content:center; margin:0 auto 18px; }
#wqrb-qr-box    { border:3px solid var(--wqrb-green); border-radius:12px; padding:8px; background:#fff;
                   display:flex; align-items:center; justify-content:center; min-width:60px; min-height:60px; }
#wqrb-qr-box img,
#wqrb-qr-box canvas { display:block; border-radius:6px; }

.wqrb-popup-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    padding: 11px 22px;
    border-radius: 50px;
    background: var(--wqrb-green);
    box-shadow: 0 4px 14px rgba(37,211,102,.3);
    transition: transform .15s, box-shadow .15s;
}
.wqrb-popup-link:hover { transform:scale(1.04); box-shadow:0 6px 20px rgba(37,211,102,.45); }

.wqrb-config-warn {
    color: #b00; font-size:13px; line-height:1.5;
    background:#fff5f5; border:1px solid #fcc;
    border-radius:8px; padding:12px 16px;
    margin:0 auto 18px; max-width:240px;
}

/* ════════════════════════════════════════════════════════════════
   ESTILO 1: BURBUJA DE CHAT
   ════════════════════════════════════════════════════════════════ */
#wqrb-bubble-wrap { z-index: var(--wqrb-z); }

/* Botón circular */
#wqrb-bubble-btn {
    width: 60px; height: 60px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 24px rgba(0,0,0,.25);
    transition: transform .2s, box-shadow .2s;
    position: relative;
    animation: wqrb-bounce-in .5s cubic-bezier(.34,1.56,.64,1) both;
}
#wqrb-bubble-btn:hover { transform:scale(1.1); box-shadow:0 10px 30px rgba(0,0,0,.3); }

/* Badge de notificación */
.wqrb-bubble-badge {
    position: absolute;
    top: -4px; right: -4px;
    background: #ff3b30;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    width: 20px; height: 20px;
    border-radius: 50%;
    display: flex; align-items:center; justify-content:center;
    border: 2px solid #fff;
    transition: transform .2s;
}
.wqrb-bubble-badge.pulse { animation: wqrb-badge-pulse 1s ease 3; }

/* Panel expandible */
#wqrb-chat-panel {
    position: absolute;
    bottom: 72px;
    width: 300px;
    background: #fff;
    border-radius: var(--wqrb-radius);
    box-shadow: var(--wqrb-shadow);
    overflow: hidden;
    transform: scale(.85) translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: transform .25s cubic-bezier(.34,1.4,.64,1), opacity .2s ease;
    transform-origin: bottom center;
}
.pos-bottom-right #wqrb-chat-panel { right: 0; }
.pos-bottom-left  #wqrb-chat-panel { left:  0; }
.pos-top-right    #wqrb-chat-panel { bottom:auto; top:72px; right:0; transform-origin:top center; }
.pos-top-left     #wqrb-chat-panel { bottom:auto; top:72px; left:0;  transform-origin:top center; }

#wqrb-chat-panel.active {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

#wqrb-chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    color: #fff;
}

#wqrb-chat-avatar-wrap { position:relative; flex-shrink:0; }
#wqrb-chat-avatar,
#wqrb-chat-avatar-placeholder {
    width: 44px; height: 44px;
    border-radius: 50%;
    object-fit: cover;
    background: rgba(255,255,255,.25);
    display:flex; align-items:center; justify-content:center;
    border: 2px solid rgba(255,255,255,.5);
}

.wqrb-online-dot {
    position: absolute;
    bottom: 1px; right: 1px;
    width: 11px; height: 11px;
    background: #4cff72;
    border-radius: 50%;
    border: 2px solid #fff;
}

#wqrb-chat-info { flex:1; }
#wqrb-chat-name   { display:block; font-weight:700; font-size:15px; }
#wqrb-chat-status { display:block; font-size:12px; opacity:.85; }

#wqrb-chat-close {
    background: rgba(255,255,255,.2);
    border: none;
    color: #fff;
    cursor: pointer;
    border-radius: 50%;
    width: 30px; height: 30px;
    display:flex; align-items:center; justify-content:center;
    line-height:0;
    transition: background .15s;
}
#wqrb-chat-close:hover { background:rgba(255,255,255,.35); }

#wqrb-chat-body {
    padding: 16px;
    background: #f5f5f5;
    min-height: 80px;
}

.wqrb-chat-bubble-msg {
    background: #fff;
    border-radius: 4px 14px 14px 14px;
    padding: 10px 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
    display: inline-block;
    max-width: 100%;
    text-align: left;
}
.wqrb-chat-bubble-msg p { margin:0 0 4px; font-size:14px; color:#222; line-height:1.5; }
.wqrb-chat-time { font-size:11px; color:#aaa; }

#wqrb-chat-footer { padding: 12px 16px; }
#wqrb-chat-cta {
    width: 100%;
    border: none;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    padding: 12px;
    border-radius: 50px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: filter .15s, transform .15s;
}
#wqrb-chat-cta:hover { filter:brightness(1.1); transform:scale(1.02); }

/* ════════════════════════════════════════════════════════════════
   ESTILO 2: BARRA FIJA
   ════════════════════════════════════════════════════════════════ */
.wqrb-bar-bottom,
.wqrb-bar-top {
    position: fixed;
    left: 0; right: 0;
    z-index: var(--wqrb-z);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 12px 24px;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    flex-wrap: wrap;
    animation: wqrb-slide-in-bottom .4s ease both;
}
.wqrb-bar-bottom { bottom:0; animation-name: wqrb-slide-in-bottom; }
.wqrb-bar-top    { top:0;    animation-name: wqrb-slide-in-top; }

.wqrb-bar-text { flex:1; min-width:160px; text-align:center; }

.wqrb-bar-btn {
    background: rgba(255,255,255,.15);
    border: 2px solid rgba(255,255,255,.6);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    padding: 8px 18px;
    border-radius: 50px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 7px;
    transition: background .15s;
    white-space: nowrap;
}
.wqrb-bar-btn:hover { background:rgba(255,255,255,.28); }

.wqrb-bar-dismiss {
    background: none;
    border: none;
    color: rgba(255,255,255,.7);
    cursor: pointer;
    line-height: 0;
    padding: 4px;
    border-radius: 50%;
    transition: color .15s, background .15s;
    flex-shrink:0;
}
.wqrb-bar-dismiss:hover { color:#fff; background:rgba(255,255,255,.15); }

/* ════════════════════════════════════════════════════════════════
   ESTILO 3: WIDGET INLINE
   ════════════════════════════════════════════════════════════════ */
.wqrb-widget-box {
    border-radius: var(--wqrb-radius);
    overflow: hidden;
    box-shadow: var(--wqrb-shadow);
    max-width: 320px;
    font-family: inherit;
}

.wqrb-widget-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    color: #fff;
}

.wqrb-widget-avatar,
.wqrb-widget-avatar-placeholder {
    width: 42px; height: 42px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,.5);
    background: rgba(255,255,255,.2);
    display: flex; align-items:center; justify-content:center;
    flex-shrink:0;
}

.wqrb-widget-name   { font-weight:700; font-size:15px; }
.wqrb-widget-online { font-size:12px; opacity:.85; }

.wqrb-widget-body { padding:18px; background:#fff; }
.wqrb-widget-msg  { margin:0 0 14px; font-size:14px; color:#444; line-height:1.6; }

.wqrb-widget-cta {
    width: 100%;
    border: none;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    padding: 13px;
    border-radius: 50px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    transition: filter .15s, transform .15s;
}
.wqrb-widget-cta:hover { filter:brightness(1.1); transform:scale(1.02); }

/* ════════════════════════════════════════════════════════════════
   ESTILO 4: BOTÓN FLOTANTE (auto / fallback)
   ════════════════════════════════════════════════════════════════ */
#wqrb-float-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 22px;
    border: none;
    border-radius: 50px;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 6px 24px rgba(0,0,0,.25);
    transition: transform .2s, box-shadow .2s;
    animation: wqrb-bounce-in .5s cubic-bezier(.34,1.56,.64,1) both;
}
#wqrb-float-btn:hover { transform:scale(1.06) translateY(-2px); box-shadow:0 10px 30px rgba(0,0,0,.32); }

/* ════════════════════════════════════════════════════════════════
   SHARED — Spinner, animaciones, responsive
   ════════════════════════════════════════════════════════════════ */
.wqrb-spinner {
    width:36px; height:36px;
    border:4px solid #e0f5ea;
    border-top-color: var(--wqrb-green);
    border-radius:50%;
    animation: wqrb-spin .7s linear infinite;
}

@keyframes wqrb-spin       { to { transform:rotate(360deg); } }
@keyframes wqrb-fade-in    { from { opacity:0; } to { opacity:1; } }
@keyframes wqrb-pop-in     { from { opacity:0; transform:scale(.82) translateY(30px); } to { opacity:1; transform:scale(1) translateY(0); } }
@keyframes wqrb-bounce-in  { from { opacity:0; transform:scale(.6) translateY(20px); } to { opacity:1; transform:scale(1) translateY(0); } }
@keyframes wqrb-badge-pulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.35)} }
@keyframes wqrb-slide-in-bottom { from { transform:translateY(100%); } to { transform:translateY(0); } }
@keyframes wqrb-slide-in-top    { from { transform:translateY(-100%); } to { transform:translateY(0); } }
@keyframes wqrb-slide-out-bottom{ from { transform:translateY(0); } to { transform:translateY(120%); } }
@keyframes wqrb-slide-out-top   { from { transform:translateY(0); } to { transform:translateY(-120%); } }

/* Responsive */
@media (max-width:480px) {
    #wqrb-popup { padding:28px 16px 20px; border-radius:16px; }
    #wqrb-chat-panel { width:280px; }
    .wqrb-bar-text { display:none; }
    .pos-bottom-right,
    .pos-bottom-left { bottom:16px; }
    .pos-bottom-right { right:16px; }
    .pos-bottom-left  { left:16px; }
    #wqrb-float-btn .wqrb-label { display:none; }
}

@media (prefers-reduced-motion:reduce) {
    *, *::before, *::after { animation-duration:.01ms !important; transition-duration:.01ms !important; }
}

/* ================================================================
   v3.0.0 — FASE 2: Comportamiento
   Nuevos componentes: Toast fuera de horario | Formulario previo
   | Selector multi-agente
   ================================================================ */

/* ════════════════════════════════════════════════════════════════
   TOAST — Fuera de horario
   ════════════════════════════════════════════════════════════════ */
#wqrb-offline-toast {
    position: fixed;
    bottom: 96px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #1a1a2e;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    padding: 12px 20px;
    border-radius: 50px;
    box-shadow: 0 8px 28px rgba(0,0,0,.3);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 100001;
    opacity: 0;
    transition: opacity .3s ease, transform .3s ease;
    white-space: nowrap;
    max-width: 90vw;
}
#wqrb-offline-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ════════════════════════════════════════════════════════════════
   FORMULARIO PREVIO AL CHAT
   ════════════════════════════════════════════════════════════════ */
#wqrb-form-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 100000;
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}
#wqrb-form-overlay.active { display: flex; }

#wqrb-form-box {
    background: #fff;
    border-radius: 20px;
    overflow: hidden;
    width: 92%;
    max-width: 380px;
    box-shadow: 0 24px 64px rgba(0,0,0,.28);
    position: relative;
    animation: wqrb-pop-in .3s cubic-bezier(.34,1.56,.64,1) both;
}

#wqrb-form-close {
    position: absolute;
    top: 12px; right: 14px;
    background: rgba(255,255,255,.25);
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    line-height: 0;
    transition: background .15s;
    z-index: 1;
}
#wqrb-form-close:hover { background: rgba(255,255,255,.4); }

#wqrb-form-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 18px;
    color: #fff;
    font-size: 16px;
    font-weight: 700;
}

#wqrb-form-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 0;
}

#wqrb-form-body label {
    font-size: 13px;
    font-weight: 600;
    color: #555;
    margin-bottom: 5px;
    margin-top: 12px;
    display: block;
}
#wqrb-form-body label:first-child { margin-top: 0; }

#wqrb-fi-name,
#wqrb-fi-msg {
    width: 100%;
    border: 1.5px solid #ddd;
    border-radius: 10px;
    padding: 10px 13px;
    font-size: 14px;
    font-family: inherit;
    color: #222;
    box-sizing: border-box;
    transition: border-color .2s;
    resize: vertical;
}
#wqrb-fi-name:focus,
#wqrb-fi-msg:focus {
    outline: none;
    border-color: var(--wqrb-green);
    box-shadow: 0 0 0 3px rgba(37,211,102,.15);
}

#wqrb-form-send {
    margin-top: 18px;
    width: 100%;
    border: none;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    padding: 13px;
    border-radius: 50px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    box-shadow: 0 4px 14px rgba(37,211,102,.3);
    transition: filter .15s, transform .15s;
}
#wqrb-form-send:hover { filter: brightness(1.08); transform: scale(1.02); }

/* ════════════════════════════════════════════════════════════════
   SELECTOR MULTI-AGENTE
   ════════════════════════════════════════════════════════════════ */
#wqrb-agents-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 100000;
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}
#wqrb-agents-overlay.active { display: flex; }

#wqrb-agents-box {
    background: #fff;
    border-radius: 20px;
    overflow: hidden;
    width: 92%;
    max-width: 380px;
    box-shadow: 0 24px 64px rgba(0,0,0,.28);
    position: relative;
    animation: wqrb-pop-in .3s cubic-bezier(.34,1.56,.64,1) both;
}

#wqrb-agents-close {
    position: absolute;
    top: 12px; right: 14px;
    background: rgba(255,255,255,.25);
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    line-height: 0;
    transition: background .15s;
    z-index: 1;
}
#wqrb-agents-close:hover { background: rgba(255,255,255,.4); }

#wqrb-agents-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    color: #fff;
}

#wqrb-agents-list {
    padding: 8px 0;
    max-height: 340px;
    overflow-y: auto;
}

.wqrb-agent-card {
    width: 100%;
    background: none;
    border: none;
    border-bottom: 1px solid #f0f0f0;
    padding: 13px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    text-align: left;
    transition: background .15s;
    font-family: inherit;
}
.wqrb-agent-card:last-child { border-bottom: none; }
.wqrb-agent-card:hover { background: #f7fdf9; }

.wqrb-agent-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.wqrb-agent-name {
    font-size: 15px;
    font-weight: 700;
    color: #111;
}
.wqrb-agent-role {
    font-size: 12px;
    color: #888;
}
.wqrb-agent-arrow {
    font-size: 22px;
    color: #ccc;
    line-height: 1;
    font-weight: 300;
}
.wqrb-agent-card:hover .wqrb-agent-arrow { color: var(--wqrb-green); }

/* ── Scrollbar sutil en lista de agentes ── */
#wqrb-agents-list::-webkit-scrollbar { width: 4px; }
#wqrb-agents-list::-webkit-scrollbar-track { background: transparent; }
#wqrb-agents-list::-webkit-scrollbar-thumb { background: #ddd; border-radius: 4px; }

/* ── Responsive Fase 2 ─────────────────────────────────────────── */
@media (max-width: 480px) {
    #wqrb-offline-toast {
        bottom: 80px;
        font-size: 13px;
        padding: 10px 16px;
        white-space: normal;
        text-align: center;
        border-radius: 16px;
    }
    #wqrb-form-box,
    #wqrb-agents-box { border-radius: 16px; }
    .wqrb-agent-card { padding: 12px 16px; }
}


/* === FIX v3.2.0: Alineaciones de barra === */
.wqrb-bar-align-left { justify-content: flex-start !important; padding-left: 24px; }
.wqrb-bar-align-right { justify-content: flex-end !important; padding-right: 24px; }


/* === v3.2.0: Estilos para agentes con horario === */
.wqrb-agent-card {
    position: relative;
}
.wqrb-agent-schedule {
    display: block;
    font-size: 11px;
    color: #666;
    margin-top: 2px;
}
.wqrb-agent-status {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
    white-space: nowrap;
}
.wqrb-agent-online .wqrb-agent-status {
    background: #d4edda;
    color: #155724;
}
.wqrb-agent-offline .wqrb-agent-status {
    background: #f8d7da;
    color: #721c24;
}
.wqrb-agent-offline {
    cursor: not-allowed;
}
.wqrb-agent-offline .wqrb-agent-name,
.wqrb-agent-offline .wqrb-agent-role {
    opacity: 0.6;
}
