/* =====================================================
   WhatsApp Floating Button v2.0 – Frontend Styles
   ===================================================== */

/* ── CSS Custom Properties ────────────────────────── */
:root {
    --wafb-color:          #25D366;
    --wafb-rgb:            37, 211, 102;
    --wafb-shadow:         0 8px 24px rgba(0, 0, 0, 0.12);
    --wafb-shadow-hover:   0 12px 32px rgba(0, 0, 0, 0.18);
    --wafb-transition:     0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --wafb-font:           -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, sans-serif;
}

/* ════════════════════════════════════════════════════
   FLOATING BUTTON
   ════════════════════════════════════════════════════ */

.wafb-floating-btn {
    position:            fixed;
    bottom:              24px;
    z-index:             9999;

    display:             inline-flex;
    align-items:         center;
    justify-content:     center;
    gap:                 0;

    border-radius:       50px;
    background-color:    var(--wafb-color);
    color:               #fff;
    text-decoration:     none;
    overflow:            hidden;
    cursor:              pointer;
    padding:             0;
    border:              none;
    line-height:         0;
    outline:             none;

    box-shadow:          var(--wafb-shadow);
    animation:           
        wafb-pop-in 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) both,
        wafb-float 3s ease-in-out infinite;
    transition:
        transform       var(--wafb-transition),
        box-shadow      var(--wafb-transition),
        max-width       0.35s ease,
        padding         0.35s ease,
        background-color var(--wafb-transition);
}

@media (prefers-reduced-motion: reduce) {
    .wafb-floating-btn, .wafb-bubble, .wafb-label, .wafb-tooltip {
        transition: none !important;
        animation: none !important;
    }
}

/* ── Positions ─────────────────────────────────────── */
.wafb-floating-btn.wafb--right { right: 24px; }
.wafb-floating-btn.wafb--left  { left:  24px; }

/* ── Sizes ─────────────────────────────────────────── */
.wafb-floating-btn.wafb--small  { width: 48px; height: 48px; }
.wafb-floating-btn.wafb--medium { width: 60px; height: 60px; }
.wafb-floating-btn.wafb--large  { width: 72px; height: 72px; }

/* Icon sizing */
.wafb-floating-btn.wafb--small  svg { width: 22px; height: 22px; }
.wafb-floating-btn.wafb--medium svg { width: 28px; height: 28px; }
.wafb-floating-btn.wafb--large  svg { width: 34px; height: 34px; }

.wafb-floating-btn svg {
    flex-shrink: 0;
    transition: margin 0.35s ease, transform var(--wafb-transition);
    display: block;
    /* Optical centering: nudge by default */
    margin-left: 1px;
    margin-top: -1px;
}
.wafb-floating-btn.wafb--has-label:hover svg {
    margin-left: 18px;
    margin-top: 0;
}

/* ── Hover ─────────────────────────────────────────── */
.wafb-floating-btn:hover {
    filter:          brightness(1.08);
    transform:       scale(1.08) translateY(-3px);
    box-shadow:      var(--wafb-shadow-hover);
    color:           #fff;
    text-decoration: none;
}
.wafb-floating-btn:hover svg {
    transform: scale(1.1);
}

/* ── Active ────────────────────────────────────────── */
.wafb-floating-btn:active {
    transform: scale(0.93) translateY(0);
}

/* ── Pill Label (expand on hover) ──────────────────── */
.wafb-label {
    font-family:     var(--wafb-font);
    font-size:       14px;
    font-weight:     600;
    white-space:     nowrap;
    max-width:       0;
    opacity:         0;
    overflow:        hidden;
    transition:
        max-width  0.4s ease,
        opacity    0.3s ease,
        margin     0.35s ease;
    pointer-events:  none;
    color:           #fff;
}

/* Override fixed width when label is present */
.wafb-floating-btn.wafb--has-label.wafb--small  { width: auto; min-width: 48px; height: 48px; }
.wafb-floating-btn.wafb--has-label.wafb--medium { width: auto; min-width: 60px; height: 60px; }
.wafb-floating-btn.wafb--has-label.wafb--large  { width: auto; min-width: 72px; height: 72px; }

/* Add left padding to icon so it doesn't hug the edge */
/* Margin is now handled dynamically in the .wafb-floating-btn svg rules above */

/* Expand on hover */
.wafb-floating-btn.wafb--has-label:hover {
    padding-right: 18px;
}
.wafb-floating-btn.wafb--has-label:hover .wafb-label {
    max-width:  220px;
    opacity:    1;
    margin-left: 8px;
}

/* ── Tooltip ───────────────────────────────────────── */
.wafb-tooltip {
    position:    absolute;
    bottom:      calc(100% + 12px);
    white-space: nowrap;

    background:  #1a1a1a;
    color:       #fff;
    font-family: var(--wafb-font);
    font-size:   12px;
    font-weight: 500;
    padding:     6px 12px;
    border-radius: 6px;

    opacity:     0;
    visibility:  hidden;
    transform:   translateY(8px);
    transition:  opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
    pointer-events: none;
    box-shadow:  0 2px 10px rgba(0, 0, 0, 0.22);
}
.wafb-tooltip::after {
    content:     '';
    position:    absolute;
    top:         100%;
    left:        50%;
    transform:   translateX(-50%);
    border:      6px solid transparent;
    border-top-color: #1a1a1a;
}

/* Hide tooltip when label is shown (redundant info) */
.wafb-floating-btn.wafb--has-label .wafb-tooltip { display: none; }

.wafb-floating-btn.wafb--right .wafb-tooltip { right: 0; }
.wafb-floating-btn.wafb--left  .wafb-tooltip { left:  0; }

.wafb-floating-btn:hover .wafb-tooltip {
    opacity:    1;
    visibility: visible;
    transform:  translateY(0);
}

/* ── Animation: Pulse Ring ─────────────────────────── */
.wafb-floating-btn.wafb--anim-pulse::before {
    content:      '';
    position:     absolute;
    inset:        -4px;
    border-radius: 50%;
    border:       3px solid rgba(var(--wafb-rgb), 0.55);
    animation:    wafb-pulse 2.4s ease-out infinite;
    pointer-events: none;
}
.wafb-floating-btn.wafb--has-label.wafb--anim-pulse::before {
    border-radius: 50px;
    inset:        -4px;
}

/* ── Animation: Bounce ─────────────────────────────── */
.wafb-floating-btn.wafb--anim-bounce {
    animation:
        wafb-pop-in 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) both,
        wafb-bounce 2.2s ease-in-out 1s infinite;
}

/* ── Animation: Shake ──────────────────────────────── */
.wafb-floating-btn.wafb--anim-shake {
    animation:
        wafb-pop-in 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) both,
        wafb-shake  3.5s ease-in-out 2s infinite;
}

/* ── Mobile hide ───────────────────────────────────── */
@media (max-width: 767px) {
    .wafb-floating-btn.wafb--hide-mobile { display: none !important; }
    .wafb-bubble.wafb--hide-mobile       { display: none !important; }
}

/* ════════════════════════════════════════════════════
   CHAT BUBBLE POPUP
   ════════════════════════════════════════════════════ */

.wafb-bubble {
    position:     fixed;
    bottom:       104px;
    z-index:      9998;
    width:        90vw;
    max-width:    300px;

    background:   rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border:       1px solid rgba(255, 255, 255, 0.4);
    border-radius: 24px;
    box-shadow:   
        0 20px 50px rgba(0, 0, 0, 0.15), 
        0 0 0 1px rgba(255, 255, 255, 0.1) inset,
        0 0 15px rgba(0, 0, 0, 0.05);
    overflow:     hidden;
    font-family:  var(--wafb-font);

    /* Hidden state */
    opacity:          0;
    transform:        translateY(20px) scale(0.92);
    transform-origin: var(--wafb-bubble-origin, bottom right);
    pointer-events:   none;
    transition:
        opacity   0.35s ease,
        transform 0.4s  cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.wafb-bubble.wafb-bubble--right { right: 24px; --wafb-bubble-origin: bottom right; }
.wafb-bubble.wafb-bubble--left  { left:  24px; --wafb-bubble-origin: bottom left; }

/* Visible state (toggled by JS) */
.wafb-bubble.is-visible {
    opacity:        1;
    transform:      translateY(0) scale(1);
    pointer-events: auto;
}

.wafb-bubble__close {
    position:    absolute;
    top:         12px;
    right:       12px;
    z-index:     2;
    width:       28px;
    height:      28px;
    padding:     0;
    background:  rgba(255, 255, 255, 0.2);
    border:      1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color:       #fff;
    font-size:   18px;
    line-height: 1;
    cursor:      pointer;
    display:     flex;
    align-items: center;
    justify-content: center;
    transition:  all 0.3s ease;
}
.wafb-bubble__close:hover { 
    background: rgba(255, 255, 255, 0.35); 
    transform: rotate(90deg);
}

/* ── Header ────────────────────────────────────────── */
.wafb-bubble__header {
    background:  var(--wafb-color, #25D366);
    padding:     16px;
    display:     flex;
    align-items: center;
    gap:         12px;
}

.wafb-bubble__avatar {
    width:        44px;
    height:       44px;
    border-radius: 50%;
    overflow:     hidden;
    background:   rgba(255, 255, 255, 0.2);
    flex-shrink:  0;
    display:      flex;
    align-items:  center;
    justify-content: center;
}
.wafb-bubble__avatar img {
    width:        100%;
    height:       100%;
    object-fit:   cover;
    display:      block;
}

.wafb-bubble__name {
    display:     block;
    color:       #fff;
    font-size:   14px;
    font-weight: 700;
    line-height: 1.3;
}
.wafb-bubble__status {
    display:    flex;
    align-items: center;
    gap:        5px;
    color:      rgba(255, 255, 255, 0.85);
    font-size:  11px;
    margin-top: 2px;
}
.wafb-status-dot {
    width:      8px;
    height:     8px;
    background: #25D366;
    border-radius: 50%;
    box-shadow: 0 0 5px rgba(37, 211, 102, 0.5);
    animation:  wafb-status-blink 1.5s infinite ease-in-out;
}
@keyframes wafb-status-blink {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.85); }
    100% { opacity: 1; transform: scale(1); }
}

/* ── Message body ──────────────────────────────────── */
.wafb-bubble__body {
    padding:    14px 14px 10px;
    background: #f0f2f5;
}
.wafb-bubble__msg {
    background:    #fff;
    border-radius: 0 12px 12px 12px;
    padding:       12px 16px;
    font-size:     14px;
    line-height:   1.55;
    color:         #333;
    box-shadow:    0 1px 3px rgba(0, 0, 0, 0.08);
    position:      relative;
}

/* ── Typing Indicator ──────────────────────────────── */
.wafb-bubble__typing {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #fff;
    width: fit-content;
    padding: 12px 16px;
    border-radius: 0 12px 12px 12px;
}
.wafb-bubble__typing span {
    width: 6px;
    height: 6px;
    background: #999;
    border-radius: 50%;
    animation: wafb-typing 1.4s infinite ease-in-out both;
}
.wafb-bubble__typing span:nth-child(1) { animation-delay: -0.32s; }
.wafb-bubble__typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes wafb-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

@keyframes wafb-typing {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1.1); opacity: 1; }
}
.wafb-bubble__msg::before {
    content:          '';
    position:         absolute;
    top:              0;
    left:             -8px;
    border:           8px solid transparent;
    border-top-color: #fff;
    border-right-color: #fff;
}

/* ── CTA button ────────────────────────────────────── */
.wafb-bubble__cta {
    display:         flex;
    align-items:     center;
    justify-content: center;
    gap:             8px;
    padding:         13px 16px;
    background:      var(--wafb-color, #25D366);
    color:           #fff !important;
    text-decoration: none !important;
    font-size:       13px;
    font-weight:     700;
    letter-spacing:  0.3px;
    transition:      filter 0.2s;
}
.wafb-bubble__cta:hover {
    filter: brightness(0.9);
}

/* ════════════════════════════════════════════════════
   KEYFRAMES
   ════════════════════════════════════════════════════ */

@keyframes wafb-pop-in {
    0%   { opacity: 0; transform: scale(0.45); }
    70%  { transform: scale(1.08); }
    100% { opacity: 1; transform: scale(1); }
}

@keyframes wafb-pulse {
    0%   { opacity: 0.75; transform: scale(1); }
    70%  { opacity: 0;    transform: scale(1.6); }
    100% { opacity: 0;    transform: scale(1.6); }
}

@keyframes wafb-bounce {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-10px); }
}

@keyframes wafb-shake {
    0%, 80%, 100% { transform: rotate(0deg); }
    82%           { transform: rotate(-14deg); }
    85%           { transform: rotate(14deg); }
    88%           { transform: rotate(-10deg); }
    91%           { transform: rotate(10deg); }
    94%           { transform: rotate(-5deg); }
    97%           { transform: rotate(5deg); }
}

@keyframes wafb-msg-in {
    0%   { opacity: 0; transform: translateY(6px); }
    100% { opacity: 1; transform: translateY(0); }
}
