@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&display=swap');

/* ── Root container ─────────────────────────────────────────────────────── */
#wahp-root {
    position: fixed;
    bottom: 24px;
    z-index: 99999;
    font-family: 'DM Sans', -apple-system, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}
#wahp-root.wahp-left  { left: 24px;  align-items: flex-start; }
#wahp-root.wahp-right { right: 24px; align-items: flex-end; }

/* ── Widget popup ───────────────────────────────────────────────────────── */
.wahp-widget {
    width: 340px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 16px 60px rgba(0,0,0,.18), 0 4px 16px rgba(0,0,0,.1);
    overflow: hidden;
    transform-origin: bottom right;
    animation: wahp-pop-in .3s cubic-bezier(.34,1.56,.64,1);
}
#wahp-root.wahp-left .wahp-widget { transform-origin: bottom left; }

@keyframes wahp-pop-in {
    from { opacity:0; transform:scale(.85) translateY(12px); }
    to   { opacity:1; transform:scale(1)   translateY(0); }
}
.wahp-widget.wahp-hiding {
    animation: wahp-pop-out .2s ease forwards;
}
@keyframes wahp-pop-out {
    from { opacity:1; transform:scale(1) translateY(0); }
    to   { opacity:0; transform:scale(.85) translateY(12px); }
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.wahp-widget-header {
    padding: 18px 20px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--wahp-header-bg, #075e54) !important;
    color: var(--wahp-header-text, #fff) !important;
    position: relative;
}
.wahp-company-logo {
    width: 46px; height: 46px; border-radius: 12px;
    overflow: hidden; flex-shrink: 0;
    background: rgba(255,255,255,.2);
    display: flex; align-items: center; justify-content: center;
}
.wahp-company-logo img { width: 100%; height: 100%; object-fit: contain; }
.wahp-company-logo-text { font-size: 1.2rem; font-weight: 700; color: #fff !important; }
.wahp-company-info { flex: 1; }
.wahp-company-name { font-size: .95rem; font-weight: 700; display: block; color: var(--wahp-header-text, #fff) !important; }
.wahp-company-tagline { font-size: .78rem; opacity: .8; display: block; margin-top: 2px; color: var(--wahp-header-text, #fff) !important; }
.wahp-close-btn {
    position: absolute !important;
    top: 12px !important;
    right: 14px !important;
    width: 28px !important;
    height: 28px !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: 28px !important;
    max-height: 28px !important;
    padding: 0 !important;
    margin: 0 !important;
    line-height: 1 !important;
    background: rgba(255,255,255,.15) !important;
    border: none !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    color: var(--wahp-header-text, #fff) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background .15s !important;
    box-shadow: none !important;
    outline: none !important;
    flex-shrink: 0 !important;
}
.wahp-close-btn:hover { background: rgba(255,255,255,.3) !important; }
.wahp-close-btn svg {
    width: 14px !important;
    height: 14px !important;
    display: block !important;
    flex-shrink: 0 !important;
}

/* ── Status bar ─────────────────────────────────────────────────────────── */
.wahp-status-bar {
    padding: 10px 20px;
    font-size: .8rem;
    font-weight: 600;
    display: flex; align-items: center; gap: 7px;
}
.wahp-status-bar.status-open   { background: #f0faf7; color: #064e45; }
.wahp-status-bar.status-closed { background: #fff8f1; color: #92400e; }
.wahp-status-bar .s-dot {
    width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
}
.status-open   .s-dot { background: #22c55e; }
.status-closed .s-dot { background: #f59e0b; }

/* ── Welcome message ────────────────────────────────────────────────────── */
.wahp-welcome {
    padding: 14px 20px 6px;
    display: flex; gap: 10px; align-items: flex-start;
}
.wahp-welcome-bubble-wrap { flex: 1; }
.wahp-welcome-bubble {
    background: #f1f5f9;
    border-radius: 4px 14px 14px 14px;
    padding: 10px 14px;
    font-size: .88rem;
    line-height: 1.5;
    color: #374151;
    display: inline-block;
    max-width: 100%;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity .35s ease .2s, transform .35s ease .2s;
}
.wahp-welcome-bubble.visible { opacity: 1; transform: translateY(0); }
.wahp-bot-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--wahp-primary, #075e54);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; overflow: hidden;
}
.wahp-bot-avatar svg { width: 18px; height: 18px; fill: #fff; }
.wahp-bot-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ── Agents list ────────────────────────────────────────────────────────── */
.wahp-agents-list { padding: 8px 16px 20px; display: flex; flex-direction: column; gap: 10px; }
.wahp-agent-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px;
    border: 1.5px solid #eef0f6;
    border-radius: 14px;
    text-decoration: none;
    color: inherit;
    transition: all .2s;
    background: #fafbfc;
    cursor: pointer;
}
.wahp-agent-item:hover {
    border-color: var(--wahp-accent, #25d366);
    background: #fff;
    transform: translateX(3px);
    box-shadow: 0 4px 16px rgba(0,0,0,.08);
}
.wahp-agent-item.offline { opacity: .55; cursor: default; pointer-events: none; }
.wahp-item-avatar {
    width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
    overflow: hidden; position: relative;
}
.wahp-item-avatar img { width: 100%; height: 100%; object-fit: cover; }
.wahp-item-avatar-placeholder {
    width: 100%; height: 100%;
    background: linear-gradient(135deg, var(--wahp-primary,#075e54), var(--wahp-accent,#25d366));
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem; font-weight: 700; color: #fff;
}
.wahp-item-status-dot {
    position: absolute; bottom: 1px; right: 1px;
    width: 11px; height: 11px; border-radius: 50%; border: 2px solid #fff;
}
.wahp-item-status-dot.online  { background: #22c55e; }
.wahp-item-status-dot.offline { background: #d1d5db; }
.wahp-item-info { flex: 1; min-width: 0; }
.wahp-item-name { font-weight: 700; font-size: .9rem; display: block; }
.wahp-item-role { font-size: .76rem; color: #64748b; display: block; margin-top: 2px; }
.wahp-item-status-text { font-size: .72rem; margin-top: 3px; display: block; }
.wahp-item-status-text.t-online  { color: #22c55e; font-weight: 600; }
.wahp-item-status-text.t-offline { color: #94a3b8; }
.wahp-item-arrow {
    width: 28px; height: 28px;
    background: var(--wahp-accent, #25d366);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; opacity: 0; transform: scale(.8);
    transition: opacity .2s, transform .2s;
}
.wahp-agent-item:hover .wahp-item-arrow { opacity: 1; transform: scale(1); }
.wahp-item-arrow svg { width: 13px; height: 13px; fill: #fff; }

/* ── Offline message in popup ───────────────────────────────────────────── */
.wahp-offline-notice {
    margin: 0 16px 16px;
    padding: 12px 14px;
    background: #fff8f1;
    border: 1px solid #fed7aa;
    border-radius: 10px;
    font-size: .83rem;
    color: #92400e;
    line-height: 1.5;
}

/* ── FAB button ─────────────────────────────────────────────────────────── */
.wahp-fab {
    width: 60px; height: 60px;
    border-radius: 50%;
    background: var(--wahp-btn-bg, #25d366) !important;
    color: var(--wahp-btn-text, #fff) !important;
    border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 6px 28px rgba(0,0,0,.2);
    transition: transform .2s, box-shadow .2s;
    position: relative;
    overflow: visible;
}
.wahp-fab:hover { transform: scale(1.08); box-shadow: 0 10px 36px rgba(0,0,0,.25); }
.wahp-fab:active { transform: scale(.95); }
.wahp-fab svg {
    width: 30px; height: 30px;
    transition: transform .3s;
    display: block;
    flex-shrink: 0;
}

/* Pulse ring */
.wahp-fab::before {
    content: '';
    position: absolute; inset: -5px;
    border-radius: 50%;
    border: 3px solid var(--wahp-btn-bg, #25d366) !important;
    opacity: 0;
    animation: wahp-fab-ring 2.5s ease-out infinite;
}
@keyframes wahp-fab-ring {
    0%   { transform:scale(1);   opacity:.6; }
    70%  { transform:scale(1.4); opacity:0; }
    100% { transform:scale(1.4); opacity:0; }
}

/* Notification badge */
.wahp-badge-count {
    position: absolute; top: -4px; right: -4px;
    width: 20px; height: 20px; border-radius: 50%;
    background: #ef4444; color: #fff;
    font-size: .65rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid #fff;
    animation: wahp-badge-pop .3s cubic-bezier(.34,1.56,.64,1);
}
@keyframes wahp-badge-pop { from{transform:scale(0)} to{transform:scale(1)} }

/* ── Mobile ─────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .wahp-widget { width: calc(100vw - 32px); max-width: 340px; }
    #wahp-root.wahp-right { right: 16px; }
    #wahp-root.wahp-left  { left: 16px; }
}
