/* WhatsApp Float Button — frontend.css */

/* ---- Wrapper ---- */
#waf-button-wrap {
    position: fixed;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    /* align-items and position injected by PHP waf_dynamic_css() */
    transition: opacity 0.4s ease, transform 0.4s ease;
}
#waf-button-wrap.waf-hidden  { opacity: 0; transform: scale(0.6); pointer-events: none; }
#waf-button-wrap.waf-visible { opacity: 1; transform: scale(1);   pointer-events: auto; }

/* ---- Main button ---- */
#waf-main-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #25D366;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(37,211,102,0.55);
    transition: transform 0.25s cubic-bezier(.34,1.56,.64,1),
                box-shadow 0.25s ease, background 0.2s ease;
    outline: none;
    padding: 0;
    flex-shrink: 0;
    /* width/height injected by PHP */
}
#waf-main-btn:hover,
#waf-main-btn:focus-visible {
    transform: scale(1.12);
    box-shadow: 0 6px 24px rgba(37,211,102,0.7);
    background: #20ba58;
}
#waf-main-btn:active { transform: scale(0.96); }
#waf-main-btn svg { display: block; transition: transform 0.3s ease; }
#waf-main-btn.waf-open svg { transform: rotate(90deg); }

/* ---- Pulse ring ---- */
.waf-pulse {
    position: absolute; inset: 0;
    border-radius: 50%;
    background: rgba(37,211,102,0.45);
    animation: waf-pulse 2.4s ease-out infinite;
    pointer-events: none;
}
@keyframes waf-pulse {
    0%   { transform: scale(1);    opacity: 0.7; }
    70%  { transform: scale(1.65); opacity: 0;   }
    100% { transform: scale(1.65); opacity: 0;   }
}

/* ---- Tooltip ---- */
#waf-main-btn[data-tooltip]::before {
    content: attr(data-tooltip);
    position: absolute;
    right: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%);
    white-space: nowrap;
    background: rgba(0,0,0,0.78);
    color: #fff;
    font-size: 13px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    padding: 5px 10px;
    border-radius: 6px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 1;
}
#waf-main-btn[data-tooltip]:hover::before,
#waf-main-btn[data-tooltip]:focus-visible::before { opacity: 1; }

/* ---- Custom icon ---- */
.waf-custom-icon { width: 65%; height: 65%; object-fit: contain; border-radius: 50%; }

/* ---- Agent panel ---- */
#waf-agent-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.35s ease, opacity 0.3s ease;
}
#waf-agent-panel.waf-panel-open { max-height: 600px; opacity: 1; }

.waf-agent-btn {
    display: flex; align-items: center; gap: 8px;
    border-radius: 30px;
    background: #25D366;
    border: none; cursor: pointer;
    padding: 0 16px 0 8px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.18);
    color: #fff; font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-weight: 500;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    white-space: nowrap; flex-shrink: 0;
}
.waf-agent-btn:hover,
.waf-agent-btn:focus-visible {
    transform: translateX(-4px);
    box-shadow: 0 5px 14px rgba(0,0,0,0.24);
    background: #20ba58;
}
.waf-agent-btn svg { width: 28px !important; height: 28px !important; flex-shrink: 0; }
.waf-agent-label { max-width: 180px; overflow: hidden; text-overflow: ellipsis; }

/* =============================================================
   PRE-CHAT POPUP
   NOTE: top/bottom/left/right are injected by PHP waf_dynamic_css()
   for each position variant. Do NOT hardcode them here.
   ============================================================= */
#waf-prechat-popup {
    position: absolute;
    /* position coords set by PHP — see waf_dynamic_css() */
    width: 320px;
    max-width: calc(100vw - 28px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: scale(0.95);
    pointer-events: none;
    transition: opacity 0.28s ease, transform 0.28s cubic-bezier(.34,1.2,.64,1);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
#waf-prechat-popup.waf-prechat-open {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

/* Header */
.waf-prechat-header {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 16px;
    background: #25D366; color: #fff;
}
.waf-prechat-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: rgba(255,255,255,0.25);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.waf-prechat-avatar svg { width: 22px; height: 22px; }
.waf-prechat-title { flex: 1; display: flex; flex-direction: column; line-height: 1.3; }
.waf-prechat-title strong { font-size: 14px; }
.waf-prechat-title span   { font-size: 12px; opacity: 0.85; }
.waf-prechat-close {
    width: 27px;
    height: 27px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 15px;
    border-radius: 50%;
    padding: 0;
    flex-shrink: 0;
    transition: background 0.15s;
    line-height: 1;
}
.waf-prechat-close:hover { background: rgba(255,255,255,0.3); }

button.waf-prechat-close
 {
    width: 27px !important;
    height: 27px !important;
}


/* Messages */
.waf-prechat-messages {
    flex: 1; min-height: 130px; max-height: 240px;
    overflow-y: auto; padding: 12px 14px;
    display: flex; flex-direction: column; gap: 8px;
    background: #f0f2f5; scroll-behavior: smooth;
}
.waf-msg {
    max-width: 82%; padding: 9px 13px; border-radius: 12px;
    font-size: 13.5px; line-height: 1.45; word-break: break-word;
    animation: waf-bubble-in 0.2s ease;
}
@keyframes waf-bubble-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.waf-msg-agent {
    background: #fff; color: #1a1a1a;
    border-radius: 12px 12px 12px 2px;
    align-self: flex-start;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.waf-msg-user {
    background: #dcf8c6; color: #1a1a1a;
    border-radius: 12px 12px 2px 12px;
    align-self: flex-end;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* Typing dots */
.waf-typing { display: flex; align-items: center; gap: 4px; padding: 10px 14px !important; }
.waf-typing span {
    width: 7px; height: 7px; border-radius: 50%; background: #aaa;
    display: inline-block;
    animation: waf-bounce 1.2s infinite ease-in-out both;
}
.waf-typing span:nth-child(1) { animation-delay: 0s; }
.waf-typing span:nth-child(2) { animation-delay: 0.18s; }
.waf-typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes waf-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%            { transform: translateY(-5px); }
}

/* Input area */
.waf-prechat-input-area {
    padding: 10px 12px 8px;
    border-top: 1px solid #eee; background: #fff;
}
.waf-prechat-name {
    width: 100%; border: 1px solid #ddd; border-radius: 8px;
    padding: 7px 10px; font-size: 13px; margin-bottom: 7px;
    outline: none; box-sizing: border-box; font-family: inherit;
    transition: border-color 0.2s;
}
.waf-prechat-name:focus { border-color: #25D366; }
.waf-prechat-input-row { display: flex; align-items: flex-end; gap: 8px; }
.waf-prechat-textarea {
    flex: 1; border: 1px solid #ddd; border-radius: 10px;
    padding: 8px 11px; font-size: 13.5px; font-family: inherit;
    resize: none; outline: none; transition: border-color 0.2s; line-height: 1.4;
    box-sizing: border-box;
}
.waf-prechat-textarea:focus { border-color: #25D366; }

/* ---- Send button — perfect green circle with white arrow ---- */
.waf-prechat-send-btn {
    position: relative;
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    border-radius: 50% !important;
    background: #25D366 !important;
    border: none !important;
    cursor: pointer;
    flex-shrink: 0 !important;
    padding: 0 !important;
    margin: 0;
    box-sizing: border-box !important;
    transition: background 0.2s, transform 0.15s;
    overflow: hidden;
    /* Pure CSS send arrow — completely theme-proof */
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}
/* Paper-plane shape using ::before and ::after pseudo-elements */
.waf-prechat-send-btn::before {
    content: '';
    display: block;
    width: 0;
    height: 0;
    border-style: solid;
    /* Right-pointing triangle (arrow head) */
    border-width: 7px 0 7px 13px;
    border-color: transparent transparent transparent #ffffff;
    margin-left: 3px;
}
.waf-prechat-send-btn:hover  { background: #20ba58 !important; transform: scale(1.08); }
.waf-prechat-send-btn:active { transform: scale(0.94); }
.waf-prechat-send-btn:disabled { background: #aaa !important; cursor: not-allowed; transform: none; }
.waf-prechat-send-btn svg { display: none !important; }

.waf-prechat-footer-note {
    font-size: 11px; color: #888; margin: 6px 0 0;
    display: flex; align-items: center; gap: 4px;
}

/* ---- Responsive ---- */
@media (max-width: 480px) {
    #waf-main-btn[data-tooltip]::before { display: none; }
    #waf-prechat-popup { width: calc(100vw - 24px); }
}
