/* =========================================================
   Wamda Dashboard - Floating WhatsApp Button (frontend only)
   v9.15.0
   ========================================================= */

.wafb {
    --wafb-accent: #25D366;
    --wafb-icon: #ffffff;
    --wafb-x: 20px;
    --wafb-y: 20px;
    --wafb-size: 58px;
    position: fixed;
    bottom: var(--wafb-y);
    z-index: 99990;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    line-height: 1.5;
}

.wafb-pos-right { right: var(--wafb-x); align-items: flex-end; }
.wafb-pos-left  { left: var(--wafb-x); align-items: flex-start; }

.wafb-size-sm { --wafb-size: 48px; }
.wafb-size-md { --wafb-size: 58px; }
.wafb-size-lg { --wafb-size: 68px; }

.wafb-pending { opacity: 0; visibility: hidden; transform: translateY(14px); }
.wafb { transition: opacity .35s ease, transform .35s ease, visibility .35s ease; }

/* ---------- الزر ---------- */

.wafb-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: var(--wafb-size);
    height: var(--wafb-size);
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--wafb-accent);
    color: var(--wafb-icon);
    cursor: pointer;
    text-decoration: none;
    box-shadow: 0 10px 26px -8px rgba(0, 0, 0, .45);
    transition: transform .22s ease, box-shadow .22s ease, filter .22s ease;
}

.wafb-btn:hover,
.wafb-btn:focus {
    transform: translateY(-3px) scale(1.04);
    box-shadow: 0 16px 34px -10px rgba(0, 0, 0, .5);
    color: var(--wafb-icon);
}

.wafb-btn:focus-visible { outline: 3px solid rgba(255, 255, 255, .8); outline-offset: 3px; }

.wafb-icon { display: inline-flex; }
.wafb-icon svg { width: 55%; height: 55%; min-width: 24px; min-height: 24px; fill: currentColor; }
.wafb-size-sm .wafb-icon svg { min-width: 21px; min-height: 21px; }

/* ---------- الأنماط ---------- */

/* pill: أيقونة + نص */
.wafb-style-pill .wafb-btn {
    width: auto;
    height: calc(var(--wafb-size) - 6px);
    padding: 0 22px 0 18px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 15px;
}
.wafb-style-pill .wafb-icon svg { min-width: 22px; min-height: 22px; }
.wafb-style-pill .wafb-label { white-space: nowrap; }

/* square: مربع بحواف ناعمة */
.wafb-style-square .wafb-btn { border-radius: 18px; }

/* glass: زجاجي شفاف */
.wafb-style-glass .wafb-btn {
    background: rgba(255, 255, 255, .16);
    backdrop-filter: blur(14px) saturate(160%);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, .35);
    color: var(--wafb-accent);
    box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .35);
}

/* outline: حد فقط */
.wafb-style-outline .wafb-btn {
    background: #fff;
    color: var(--wafb-accent);
    border: 2px solid var(--wafb-accent);
    box-shadow: 0 8px 22px -10px rgba(0, 0, 0, .3);
}

/* ---------- الشارة ---------- */

.wafb-badge {
    position: absolute;
    top: -4px;
    inset-inline-end: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 2px #fff;
}

.wafb-open .wafb-badge { display: none; }

/* ---------- التلميح ---------- */

.wafb-tip {
    position: absolute;
    bottom: calc(var(--wafb-size) / 2 - 17px);
    inset-inline-end: calc(var(--wafb-size) + 14px);
    padding: 8px 14px;
    border-radius: 12px;
    background: #111827;
    color: #fff;
    font-size: 13px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transform: translateX(6px);
    transition: opacity .2s ease, transform .2s ease;
}

.wafb-pos-left .wafb-tip { transform: translateX(-6px); }
.wafb:hover .wafb-tip { opacity: 1; transform: translateX(0); }
.wafb-open .wafb-tip { display: none; }

/* ---------- الحركات ---------- */

@keyframes wafb-pulse {
    0%   { box-shadow: 0 10px 26px -8px rgba(0, 0, 0, .45), 0 0 0 0 rgba(37, 211, 102, .55); }
    70%  { box-shadow: 0 10px 26px -8px rgba(0, 0, 0, .45), 0 0 0 18px rgba(37, 211, 102, 0); }
    100% { box-shadow: 0 10px 26px -8px rgba(0, 0, 0, .45), 0 0 0 0 rgba(37, 211, 102, 0); }
}

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

@keyframes wafb-shake {
    0%, 92%, 100% { transform: rotate(0); }
    94%  { transform: rotate(-12deg); }
    96%  { transform: rotate(10deg); }
    98%  { transform: rotate(-6deg); }
}

.wafb-anim-pulse .wafb-btn  { animation: wafb-pulse 2.4s infinite; }
.wafb-anim-bounce .wafb-btn { animation: wafb-bounce 2.2s ease-in-out infinite; }
.wafb-anim-shake .wafb-btn  { animation: wafb-shake 4s ease-in-out infinite; }
.wafb-open .wafb-btn,
.wafb-btn:hover { animation: none; }

@media (prefers-reduced-motion: reduce) {
    .wafb-btn { animation: none !important; }
}

/* ---------- لوحة المحادثة ---------- */

.wafb-panel {
    width: 320px;
    max-width: calc(100vw - 32px);
    border-radius: 20px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 24px 60px -18px rgba(0, 0, 0, .45);
    opacity: 0;
    visibility: hidden;
    transform: translateY(14px) scale(.96);
    transform-origin: bottom right;
    transition: opacity .25s ease, transform .25s ease, visibility .25s ease;
}

.wafb-pos-left .wafb-panel { transform-origin: bottom left; }

.wafb-open .wafb-panel {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.wafb-panel-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    background: var(--wafb-accent);
    color: #fff;
}

.wafb-avatar {
    position: relative;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .22);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
    flex: 0 0 auto;
}

.wafb-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.wafb-avatar svg { fill: #fff; }

.wafb-dot {
    position: absolute;
    bottom: 0;
    inset-inline-end: 0;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    box-shadow: 0 0 0 2px var(--wafb-accent);
}

.wafb-dot.is-online  { background: #4ade80; }
.wafb-dot.is-offline { background: #cbd5e1; }

.wafb-head-text { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.wafb-head-text strong { font-size: 15px; font-weight: 700; }
.wafb-head-text small { font-size: 12px; opacity: .9; }

.wafb-close {
    background: transparent;
    border: 0;
    color: #fff;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
    opacity: .85;
}

.wafb-close:hover { opacity: 1; }

.wafb-panel-body {
    padding: 22px 18px;
    background: #ECE5DD;
    background-image: radial-gradient(rgba(0, 0, 0, .04) 1px, transparent 1px);
    background-size: 16px 16px;
    min-height: 120px;
}

.wafb-bubble {
    position: relative;
    display: inline-block;
    max-width: 88%;
    padding: 11px 14px 20px;
    border-radius: 14px;
    background: #fff;
    color: #111827;
    font-size: 14px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .12);
}

.wafb-time {
    position: absolute;
    bottom: 5px;
    inset-inline-end: 10px;
    font-size: 10px;
    color: #94a3b8;
}

.wafb-panel-foot {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: #fff;
    border-top: 1px solid #e5e7eb;
}

.wafb-input {
    flex: 1 1 auto;
    min-width: 0;
    height: 42px;
    padding: 0 14px;
    border: 1px solid #e5e7eb;
    border-radius: 999px;
    background: #f8fafc;
    font-size: 14px;
    color: #111827;
    outline: none;
}

.wafb-input:focus { border-color: var(--wafb-accent); background: #fff; }

.wafb-send {
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 50%;
    background: var(--wafb-accent);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .2s ease;
}

.wafb-send:hover { transform: scale(1.06); }
.wafb-rtl .wafb-send svg { transform: scaleX(-1); }

/* ---------- الأجهزة ---------- */

@media (max-width: 782px) {
    .wafb-no-mobile { display: none !important; }
    .wafb { --wafb-size: 54px; bottom: calc(var(--wafb-y) + env(safe-area-inset-bottom, 0px)); }
    .wafb-style-pill .wafb-btn { padding: 0 18px 0 14px; font-size: 14px; }
    .wafb-panel { width: min(320px, calc(100vw - 28px)); }
}

@media (min-width: 783px) {
    .wafb-no-desktop { display: none !important; }
}

/* لا يظهر مطلقاً داخل لوحة التحكم */
.wp-admin .wafb { display: none !important; }

/* مراعاة شريط الأدمن في الواجهة */
.admin-bar .wafb { bottom: var(--wafb-y); }
