/* =========================================================
   Wamda Dashboard - Floating Buttons (frontend only)
   v9.18.0 — ملف واحد مشترك لزر الواتساب (.wfb--whatsapp) وزر الاتصال (.wfb--call)
   كان whatsapp-float.css (.wafb*) — الصنف الجذري .wafb ما زال يُضاف على زر
   الواتساب كاسم بديل حفاظاً على CSS المخصص للمستخدمين.
   ========================================================= */

.wfb {
    --wfb-accent: #25D366;
    --wfb-icon: #ffffff;
    --wfb-x: 20px;
    --wfb-y: 20px;
    --wfb-size: 58px;
    --wfb-stack: 0px; /* إزاحة التكديس عند وجود زرين في نفس الجهة */
    position: fixed;
    bottom: calc(var(--wfb-y) + var(--wfb-stack));
    z-index: 99990;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    line-height: 1.5;
}

.wfb--call { --wfb-accent: #0EA5E9; }

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

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

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

/* النافذة المفتوحة تعلو أي زر مكدَّس فوقها */
.wfb-open { z-index: 99991; }

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

.wfb-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: var(--wfb-size);
    height: var(--wfb-size);
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--wfb-accent);
    color: var(--wfb-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;
}

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

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

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

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

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

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

/* glass: زجاجي شفاف */
.wfb-style-glass .wfb-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(--wfb-accent);
    box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .35);
}

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

/* ---------- الشريحة (زر الاتصال: نمط bubble = اتصال مباشر + نص اختياري) ---------- */

.wfb-chip {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 999px;
    background: #fff;
    color: #111827;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    box-shadow: 0 8px 22px -10px rgba(0, 0, 0, .35);
}

.wfb-chip:hover { color: var(--wfb-accent); }

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

.wfb-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;
}

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

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

.wfb-tip {
    position: absolute;
    bottom: calc(var(--wfb-size) / 2 - 17px);
    inset-inline-end: calc(var(--wfb-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;
}

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

/* خارج الدوام: التلميح مرئي دائماً (زر الاتصال) */
.wfb--call.wfb-offline .wfb-tip { opacity: 1; transform: translateX(0); }

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

/* v9.18.0: حلقة النبض تأخذ لون الزر نفسه (كانت خضراء ثابتة) */
@keyframes wfb-pulse {
    0%   { transform: scale(1); opacity: .55; }
    70%  { transform: scale(1.65); opacity: 0; }
    100% { transform: scale(1.65); opacity: 0; }
}

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

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

.wfb-anim-pulse .wfb-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: var(--wfb-accent);
    z-index: -1;
    animation: wfb-pulse 2.4s ease-out infinite;
}
.wfb-anim-bounce .wfb-btn { animation: wfb-bounce 2.2s ease-in-out infinite; }
.wfb-anim-shake .wfb-btn  { animation: wfb-shake 4s ease-in-out infinite; }
.wfb-open .wfb-btn,
.wfb-btn:hover { animation: none; }
.wfb-open .wfb-btn::after,
.wfb-btn:hover::after { animation: none; opacity: 0; }

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

/* ---------- لوحة المحادثة (واتساب فقط) ---------- */

.wfb-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;
}

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

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

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

.wfb-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;
}

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

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

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

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

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

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

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

.wfb-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;
}

.wfb-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);
}

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

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

.wfb-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;
}

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

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

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

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

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

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

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

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