/* WhatsApp Business Chat — Frontend */

/* ── Variables ───────────────────────────────────────────────────── */
:root {
    --wbc-color:      #25D366;
    --wbc-icon-color: #ffffff;
    --wbc-size:       60px;
    --wbc-font:       inherit;
}

/* ── Botón flotante ──────────────────────────────────────────────── */
#wbc {
    position: fixed;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: opacity .4s ease, transform .4s ease;
}
#wbc.right { bottom: 24px; right: 24px; align-items: flex-end; }
#wbc.left  { bottom: 24px; left:  24px; align-items: flex-start; }
#wbc.hidden  { opacity: 0; transform: scale(.5); pointer-events: none; }
#wbc.visible { opacity: 1; transform: scale(1); }

/* Botón principal */
#wbc-btn {
    width:  var(--wbc-size);
    height: var(--wbc-size);
    background: var(--wbc-color);
    color:      var(--wbc-icon-color);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 5px 22px rgba(0,0,0,.25);
    position: relative;
    font-family: var(--wbc-font);
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
    transition: transform .2s ease, box-shadow .2s ease;
    flex-shrink: 0;
}
#wbc-btn:hover  { transform: scale(1.08); box-shadow: 0 8px 28px rgba(0,0,0,.32); }
#wbc-btn:active { transform: scale(.96); }

/* Estilos del botón */
#wbc-btn.style-round  { border-radius: 50%; padding: 0; }
#wbc-btn.style-pill   { border-radius: 100px; width: auto; padding: 0 20px 0 8px; }
#wbc-btn.style-square { border-radius: 16px; padding: 0; }

/* Ícono dentro del botón */
#wbc-btn .wbc-btn-icon {
    width:  calc(var(--wbc-size) * .7);
    height: calc(var(--wbc-size) * .7);
    border-radius: 50%;
    background: rgba(255,255,255,.18);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
#wbc-btn .wbc-btn-icon svg {
    width:  calc(var(--wbc-size) * .42);
    height: calc(var(--wbc-size) * .42);
    fill: var(--wbc-icon-color);
}

/* Animación de pulso */
#wbc-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: var(--wbc-color);
    opacity: .35;
    animation: wbc-pulse 2.8s ease-out infinite;
    pointer-events: none;
}
@keyframes wbc-pulse {
    0%   { transform: scale(1);    opacity: .35; }
    70%  { transform: scale(1.2);  opacity: 0;   }
    100% { transform: scale(1.2);  opacity: 0;   }
}

/* ── Popup de selección ──────────────────────────────────────────── */
#wbc-popup {
    width: 310px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,.16);
    overflow: hidden;
    transform-origin: bottom right;
    transition: transform .3s cubic-bezier(.34,1.56,.64,1), opacity .22s ease;
    transform: scale(.85);
    opacity: 0;
    pointer-events: none;
}
#wbc.left #wbc-popup { transform-origin: bottom left; }
#wbc-popup.open      { transform: scale(1); opacity: 1; pointer-events: all; }

/* Header del popup */
#wbc-popup-head {
    padding: 16px 18px;
    color: #fff;
    position: relative;
}
#wbc-popup-head h3 { margin: 0 0 2px; font-size: 16px; font-weight: 700; }
#wbc-popup-head p  { margin: 0; font-size: 12px; opacity: .85; }
#wbc-popup-close {
    position: absolute; top: 12px; right: 14px;
    background: rgba(255,255,255,.22);
    border: none; border-radius: 50%;
    width: 26px; height: 26px;
    color: #fff; font-size: 14px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .2s;
}
#wbc-popup-close:hover { background: rgba(255,255,255,.38); }

/* Lista de agentes */
#wbc-popup-list {
    padding: 10px;
    max-height: 360px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
#wbc-popup-list::-webkit-scrollbar { width: 4px; }
#wbc-popup-list::-webkit-scrollbar-thumb { background: #e0e0e0; border-radius: 4px; }

/* Tarjeta de agente */
.wbc-agent-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1.5px solid #f0f0f0;
    text-decoration: none;
    color: inherit;
    background: #fafafa;
    transition: border-color .2s, background .2s, transform .15s;
}
.wbc-agent-card:hover {
    border-color: var(--wbc-color);
    background: #fff;
    box-shadow: 0 3px 12px rgba(37,211,102,.15);
    transform: translateX(3px);
}
.wbc-agent-avatar {
    width: 44px; height: 44px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; font-weight: 800;
    color: #fff;
    overflow: hidden;
    position: relative;
}
.wbc-agent-avatar img { width:100%; height:100%; object-fit:cover; border-radius:50%; }
.wbc-agent-avatar::after {
    content: '';
    position: absolute; bottom: 1px; right: 1px;
    width: 11px; height: 11px;
    background: #25D366;
    border-radius: 50%;
    border: 2px solid #fff;
}
.wbc-agent-info { flex: 1; min-width: 0; }
.wbc-agent-name { font-weight: 700; font-size: 13px; color: #1a1a1a; margin: 0 0 2px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wbc-agent-role { font-size: 11px; color: #888; margin: 0; display: block; }
.wbc-agent-arrow { color: #ccc; font-size: 20px; flex-shrink: 0; transition: color .2s; }
.wbc-agent-card:hover .wbc-agent-arrow { color: var(--wbc-color); }

/* Footer del popup */
#wbc-popup-foot {
    padding: 8px;
    text-align: center;
    font-size: 11px;
    color: #c0c0c0;
    border-top: 1px solid #f5f5f5;
}

/* ── Shortcode popup ─────────────────────────────────────────────── */
.wbc-sc-wrap { position: relative; display: inline-block; }
.wbc-sc-trigger { cursor: pointer; }

.wbc-sc-popup {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    width: 300px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 6px 32px rgba(0,0,0,.15);
    overflow: hidden;
    transform: scale(.9) translateY(8px);
    transform-origin: bottom left;
    opacity: 0;
    pointer-events: none;
    transition: transform .25s cubic-bezier(.34,1.56,.64,1), opacity .2s ease;
    z-index: 9998;
}
.wbc-sc-wrap.open .wbc-sc-popup { transform: scale(1) translateY(0); opacity: 1; pointer-events: all; }
.wbc-sc-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 16px; color: #fff;
}
.wbc-sc-head strong { font-size: 15px; }
.wbc-sc-head button { background: rgba(255,255,255,.2); border: none; border-radius: 50%; width: 24px; height: 24px; color: #fff; cursor: pointer; font-size: 13px; }
.wbc-sc-list { padding: 8px; display: flex; flex-direction: column; gap: 5px; }
.wbc-sc-agent {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 8px;
    text-decoration: none; color: inherit;
    border: 1px solid #f0f0f0; background: #fafafa;
    transition: border-color .2s, background .2s;
}
.wbc-sc-agent:hover { border-color: var(--wbc-color); background: #fff; }
.wbc-sc-avatar {
    width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 800; color: #fff; overflow: hidden;
}
.wbc-sc-avatar img { width:100%; height:100%; object-fit:cover; border-radius:50%; }
.wbc-sc-info { flex: 1; display: flex; flex-direction: column; }
.wbc-sc-info strong { font-size: 13px; color: #1a1a1a; }
.wbc-sc-info small  { font-size: 11px; color: #888; }
.wbc-sc-arrow { color: #ccc; font-size: 18px; }
.wbc-sc-agent:hover .wbc-sc-arrow { color: var(--wbc-color); }

/* ── Modo oscuro automático ──────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
    #wbc-popup, .wbc-sc-popup { background: #1e1e2e; }
    .wbc-agent-card, .wbc-sc-agent { background: #2a2a3e; border-color: #313244; color: #cdd6f4; }
    .wbc-agent-card:hover, .wbc-sc-agent:hover { background: #313244; }
    .wbc-agent-name, .wbc-sc-info strong { color: #cdd6f4; }
    .wbc-agent-role, .wbc-sc-info small  { color: #a6adc8; }
    #wbc-popup-foot { border-top-color: #313244; }
}

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 480px) {
    #wbc.right { right: 14px; bottom: 14px; }
    #wbc.left  { left:  14px; bottom: 14px; }
    #wbc-popup { width: calc(100vw - 28px); }
    .wbc-sc-popup { width: calc(100vw - 32px); }
}
