/* 360 برمجة — واجهة الزائر v1.1.0 */
.w360-root {
    --w360-accent: #14B8A6;
    --w3-ink: #0f172a; --w3-bg: #ffffff; --w3-bg2: #f6f8fa; --w3-muted: #64748b; --w3-line: #e5e9ef; --w3-user: var(--w360-accent);
    --w3-shadow: 0 20px 60px rgba(15,23,42,.26); --w3-radius: 20px;
    position: fixed; z-index: 99990; bottom: 22px; right: 22px;
    font: 14px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Arabic", Tahoma, sans-serif;
    color: var(--w3-ink); opacity: 0; visibility: hidden; transition: opacity .25s ease, visibility 0s linear .25s;
}
.w360-root.is-ready { opacity: 1; visibility: visible; transition-delay: 0s; }
.w360-root--left { left: 22px; right: auto; }
.w360-root--right { left: auto; right: 22px; }
.w360-root *, .w360-root *::before, .w360-root *::after { box-sizing: border-box; }
.w360-root button, .w360-root input, .w360-root textarea { font: inherit; }

/* الوضع الداكن: تلقائي أو إجباري */
@media (prefers-color-scheme: dark) {
    .w360-root.w360-theme-auto { --w3-ink: #ececec; --w3-bg: var(--w360-bg-dark, #141414); --w3-bg2: color-mix(in srgb, var(--w360-bg-dark, #141414) 86%, #000); --w3-muted: #9a9a9a; --w3-line: #2a2a2a; --w3-shadow: 0 20px 60px rgba(0,0,0,.6); }
}
.w360-root.w360-theme-dark { --w3-ink: #ececec; --w3-bg: var(--w360-bg-dark, #141414); --w3-bg2: color-mix(in srgb, var(--w360-bg-dark, #141414) 86%, #000); --w3-muted: #9a9a9a; --w3-line: #2a2a2a; --w3-shadow: 0 20px 60px rgba(0,0,0,.6); }

/* الزر العائم */
.w360-root .w3-launcher { width: 58px; height: 58px; border-radius: 50%; border: 0; cursor: pointer; background: var(--w360-accent); color: #fff; box-shadow: 0 12px 32px rgba(15,23,42,.28); display: grid; place-items: center; position: relative; transition: transform .18s ease, box-shadow .18s ease; }
.w360-root .w3-launcher:hover { transform: translateY(-2px); box-shadow: 0 16px 36px rgba(15,23,42,.32); }
.w360-root .w3-launcher:focus-visible { outline: 3px solid color-mix(in srgb, var(--w360-accent) 45%, #fff); outline-offset: 2px; }
.w360-root .w3-launcher-icon, .w360-root .w3-launcher-x { position: absolute; inset: 0; display: grid; place-items: center; transition: opacity .18s, transform .18s; }
.w360-root .w3-launcher-icon.has-logo { padding: 3px; }
.w360-root .w3-launcher-icon img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; background: #111; }
.w360-root .w3-launcher-badge { position: absolute; bottom: -2px; left: -2px; width: 22px; height: 22px; border-radius: 50%; background: #fff; color: var(--w360-accent); display: grid; place-items: center; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.w360-root.is-open .w3-launcher-badge { opacity: 0; }
.w360-root .w3-launcher-tip { position: absolute; bottom: 14px; right: 70px; left: auto; background: var(--w3-bg); color: var(--w3-ink); border: 1px solid var(--w3-line); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 700; white-space: nowrap; box-shadow: 0 8px 24px rgba(0,0,0,.18); pointer-events: none; opacity: 0; transform: translateX(6px); transition: opacity .25s .6s, transform .25s .6s; }
.w360-root--left .w3-launcher-tip { right: auto; left: 70px; }
.w360-root.is-ready:not(.is-open) .w3-launcher-tip { opacity: 1; transform: none; }
.w360-root .w3-launcher-x { opacity: 0; transform: rotate(-90deg); }
.w360-root.is-open .w3-launcher-icon { opacity: 0; transform: rotate(90deg); }
.w360-root.is-open .w3-launcher-x { opacity: 1; transform: none; }

/* النافذة */
.w360-root .w3-panel { position: absolute; bottom: 72px; right: 0; left: auto; width: 380px; max-width: calc(100vw - 32px); height: 580px; max-height: calc(100vh - 120px); background: var(--w3-bg); color: var(--w3-ink); border-radius: var(--w3-radius); box-shadow: var(--w3-shadow); display: flex; flex-direction: column; overflow: hidden; opacity: 0; visibility: hidden; transform: translateY(14px) scale(.98); transition: opacity .2s ease, transform .2s ease, visibility 0s linear .2s; border: 1px solid var(--w3-line); }
.w360-root--left .w3-panel { left: 0; right: auto; }
.w360-root.is-open .w3-panel { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
.w360-root .w3-panel:focus { outline: none; }

/* الرأس */
.w360-root .w3-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--w360-accent); color: #fff; }
.w360-root .w3-avatar { width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.18); display: grid; place-items: center; overflow: hidden; flex: none; }
.w360-root .w3-avatar { width: 44px; height: 44px; border: 2px solid rgba(255,255,255,.55); }
.w360-root .w3-avatar img { width: 100%; height: 100%; object-fit: cover; background: #111; }
.w360-root .w3-head-text { flex: 1; min-width: 0; }
.w360-root .w3-head-name { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w360-root .w3-head-status { font-size: 12px; opacity: .9; display: flex; align-items: center; gap: 6px; }
.w360-root .w3-dot { width: 8px; height: 8px; border-radius: 50%; background: #86efac; box-shadow: 0 0 0 3px rgba(255,255,255,.22); }
.w360-root .w3-capped .w3-dot { background: #fbbf24; }
.w360-root .w3-head-btns { display: flex; gap: 4px; }
.w360-root .w3-icon-btn { background: rgba(255,255,255,.16); border: 0; color: #fff; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; display: grid; place-items: center; }
.w360-root .w3-icon-btn:hover { background: rgba(255,255,255,.3); }

/* الرسائل */
.w360-root .w3-msgs { flex: 1; overflow-y: auto; padding: 14px 14px 8px; display: flex; flex-direction: column; gap: 10px; background: var(--w3-bg2); scroll-behavior: smooth; }
.w360-root .w3-msg { display: flex; flex-direction: column; max-width: 88%; animation: w3-in .18s ease; }
@keyframes w3-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.w360-root .w3-msg--user { align-self: flex-end; align-items: flex-end; }
.w360-root .w3-msg--assistant { align-self: flex-start; align-items: flex-start; flex-direction: row; flex-wrap: wrap; gap: 6px; }
.w360-root .w3-msg-av { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; flex: none; align-self: flex-end; margin-bottom: 2px; }
.w360-root .w3-msg--assistant .w3-bubble { flex: 1 1 auto; max-width: calc(100% - 34px); }
.w360-root .w3-msg--assistant .w3-sources { flex-basis: 100%; padding-inline-start: 32px; }
.w360-root .w3-bubble { padding: 10px 13px; border-radius: 16px; background: var(--w3-bg); border: 1px solid var(--w3-line); word-wrap: break-word; white-space: normal; line-height: 1.65; }
.w360-root .w3-msg--assistant .w3-bubble { border-start-start-radius: 6px; }
.w360-root .w3-msg--user .w3-bubble { background: var(--w3-user); color: #fff; border-color: transparent; border-start-end-radius: 6px; }
.w360-root .w3-msg--ok .w3-bubble { border-color: color-mix(in srgb, var(--w360-accent) 50%, var(--w3-line)); background: color-mix(in srgb, var(--w360-accent) 8%, var(--w3-bg)); }
.w360-root .w3-inline-link { color: var(--w360-accent); text-decoration: underline; }
.w360-root .w3-sources { margin-top: 6px; font-size: 12px; color: var(--w3-muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.w360-root .w3-source { color: var(--w360-accent); text-decoration: none; border: 1px solid var(--w3-line); border-radius: 999px; padding: 3px 10px; background: var(--w3-bg); display: inline-flex; align-items: center; gap: 4px; max-width: 100%; }
.w360-root .w3-source span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.w360-root .w3-source:hover { border-color: var(--w360-accent); }
.w360-root .w3-typing .w3-bubble { display: flex; gap: 4px; padding: 12px 14px; }
.w360-root .w3-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--w3-muted); animation: w3-blink 1s infinite ease-in-out; }
.w360-root .w3-typing span:nth-child(2) { animation-delay: .15s; }
.w360-root .w3-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes w3-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* الأسئلة المقترحة */
.w360-root .w3-chips { display: none; flex-wrap: wrap; gap: 6px; padding: 4px 14px 10px; background: var(--w3-bg2); }
.w360-root .w3-has-chips .w3-chips { display: flex; }
.w360-root .w3-chip { border: 1px solid color-mix(in srgb, var(--w360-accent) 45%, var(--w3-line)); background: var(--w3-bg); color: var(--w360-accent); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: 13px; text-align: start; }
.w360-root .w3-chip:hover { background: color-mix(in srgb, var(--w360-accent) 10%, var(--w3-bg)); }
.w360-root .w3-chip--intent { background: var(--w360-accent); color: #fff; border-color: var(--w360-accent); font-weight: 600; }

/* أزرار التواصل */
.w360-root .w3-contact { display: none; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--w3-line); background: var(--w3-bg); flex-wrap: wrap; }
.w360-root .w3-show-contact .w3-contact { display: flex; }
.w360-root .w3-cbtn { flex: 1 1 30%; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 10px; border-radius: 12px; background: var(--w360-accent); color: #fff; text-decoration: none; font-weight: 600; font-size: 13px; border: 0; cursor: pointer; white-space: nowrap; }
.w360-root .w3-cbtn--wa { background: #1f9d55; }
.w360-root .w3-cbtn--ghost { background: transparent; color: var(--w360-accent); border: 1px solid color-mix(in srgb, var(--w360-accent) 50%, var(--w3-line)); }
.w360-root .w3-capped .w3-cbtn--ghost { display: inline-flex; }

/* بطاقة الإجراء (1.1.0) */
.w360-root .w3-action { display: none; padding: 10px 14px 12px; border-top: 1px solid var(--w3-line); background: var(--w3-bg); max-height: 52%; overflow-y: auto; }
.w360-root .w3-show-action .w3-action { display: block; }
.w360-root .w3-action-card { display: flex; flex-direction: column; gap: 8px; }
.w360-root .w3-action-title { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--w360-accent); }
.w360-root .w3-action-link { display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.w360-root .w3-action-note { color: var(--w3-muted); font-size: 11px; }
.w360-root .w3-action .w3-lead { display: block; padding: 0; border: 0; }
.w360-root .w3-action .w3-btn--link { align-self: flex-start; padding-inline: 0; }
.w360-root .w3-btn--primary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
/* نموذج اتصلوا بي */
.w360-root .w3-lead { display: none; padding: 10px 14px 12px; border-top: 1px solid var(--w3-line); background: var(--w3-bg); }
.w360-root .w3-show-lead .w3-lead { display: block; }
.w360-root .w3-lead-title { font-weight: 700; margin-bottom: 8px; }
.w360-root .w3-lead-row { display: flex; flex-direction: column; gap: 3px; margin-bottom: 8px; font-size: 12px; color: var(--w3-muted); }
.w360-root .w3-lead-row input, .w360-root .w3-lead-row textarea { font: inherit; resize: none; border: 1px solid var(--w3-line); border-radius: 10px; padding: 8px 10px; background: var(--w3-bg2); color: var(--w3-ink); outline: none; }
.w360-root .w3-lead-row input:focus, .w360-root .w3-lead-row textarea:focus { border-color: var(--w360-accent); }
.w360-root .w3-lead.is-invalid input[name="phone"] { border-color: #ef4444; }
.w360-root .w3-lead-btns { display: flex; gap: 8px; align-items: center; }
.w360-root .w3-btn { border: 0; border-radius: 10px; padding: 8px 14px; cursor: pointer; font-weight: 600; }
.w360-root .w3-btn--primary { background: var(--w360-accent); color: #fff; }
.w360-root .w3-btn--link { background: transparent; color: var(--w3-muted); }

/* الإدخال */
.w360-root .w3-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--w3-line); background: var(--w3-bg); }
.w360-root .w3-input { flex: 1; min-width: 0; border: 1px solid var(--w3-line); border-radius: 14px; padding: 10px 12px; color: var(--w3-ink); background: var(--w3-bg2); outline: none; resize: none; max-height: 120px; line-height: 1.5; }
.w360-root .w3-input:focus { border-color: var(--w360-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--w360-accent) 18%, transparent); }
.w360-root .w3-input:disabled { opacity: .5; }
.w360-root .w3-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.w360-root .w3-send { width: 42px; height: 42px; border-radius: 14px; border: 0; background: var(--w360-accent); color: #fff; cursor: pointer; display: grid; place-items: center; flex: none; }
.w360-root .w3-send:disabled { opacity: .45; cursor: default; }
[dir="rtl"] .w360-root .w3-send svg, .w360-root[dir="rtl"] .w3-send svg { transform: scaleX(-1); }
.w360-root .w3-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 11px; color: var(--w3-muted); padding: 4px 12px 8px; background: var(--w3-bg); }
.w360-root .w3-by { opacity: .8; white-space: nowrap; }
.w360-root .w3-disclaimer { flex: 1; }

/* وضع مضمّن (صندوق التجربة في اللوحة) */
.w360-root--inline { position: relative; bottom: auto; left: auto; right: auto; z-index: 1; width: 100%; max-width: 520px; }
.w360-root--inline .w3-panel { position: relative; bottom: auto; right: auto; left: auto; width: 100%; max-width: none; height: 520px; max-height: none; opacity: 1; visibility: visible; transform: none; box-shadow: 0 6px 24px rgba(15,23,42,.12); }

@media (max-width: 782px) {
    .w360-root { bottom: 16px; right: 16px; }
    .w360-root--left { left: 16px; }
    .w360-root--right { right: 16px; }
    .w360-root .w3-panel { position: fixed; inset: 0; bottom: 0; width: 100%; max-width: none; height: 100%; max-height: none; border-radius: 0; border: 0; }
    .w360-root.is-open .w3-launcher { opacity: 0; pointer-events: none; }
    .w360-root .w3-head { padding-top: max(12px, env(safe-area-inset-top)); }
    .w360-root .w3-foot { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) { .w360-root * { transition: none !important; animation: none !important; } }
@media print { .w360-root { display: none !important; } }

/* أزرار الظهور في القالب (خارج النافذة) */
.w360-btn { --w360-accent: #14B8A6; display: inline-flex; align-items: center; gap: 10px; padding: 10px 18px; border-radius: 999px; text-decoration: none; font-weight: 700; font-size: 15px; line-height: 1; border: 2px solid var(--w360-accent); background: var(--w360-accent); color: #fff; transition: transform .15s, box-shadow .15s; cursor: pointer; }
.w360-btn:hover { transform: translateY(-1px); box-shadow: 0 10px 24px color-mix(in srgb, var(--w360-accent) 35%, transparent); color: #fff; }
.w360-btn--outline { background: transparent; color: inherit; }
.w360-btn--outline:hover { background: var(--w360-accent); color: #fff; }
.w360-btn--link { background: transparent; border-color: transparent; color: var(--w360-accent); padding-inline: 4px; }
.w360-btn--link:hover { box-shadow: none; transform: none; text-decoration: underline; color: var(--w360-accent); }
.w360-btn__av { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(255,255,255,.7); flex: none; }
.w360-btn__dot { width: 10px; height: 10px; border-radius: 50%; background: #86efac; box-shadow: 0 0 0 3px rgba(134,239,172,.3); }
.w360-cta-card { --w360-accent: #14B8A6; display: flex; align-items: center; gap: 16px; padding: 16px 18px; border: 1px solid color-mix(in srgb, var(--w360-accent) 40%, #e5e7eb); border-radius: 16px; background: color-mix(in srgb, var(--w360-accent) 6%, #fff); text-decoration: none; color: #111; margin: 28px 0; transition: box-shadow .15s, transform .15s; }
.w360-cta-card:hover { transform: translateY(-2px); box-shadow: 0 14px 32px rgba(0,0,0,.08); color: #111; }
.w360-cta-card__img { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; flex: none; border: 3px solid #fff; box-shadow: 0 4px 12px rgba(0,0,0,.15); }
.w360-cta-card__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.w360-cta-card__body strong { font-size: 17px; line-height: 1.3; }
.w360-cta-card__body span { font-size: 13px; color: #6b7280; }
.w360-cta-card__btn { flex: none; background: var(--w360-accent); color: #fff; border-radius: 999px; padding: 9px 16px; font-weight: 700; font-size: 14px; white-space: nowrap; }
@media (prefers-color-scheme: dark) { .w360-cta-card { background: color-mix(in srgb, var(--w360-accent) 12%, #141414); color: #ececec; border-color: color-mix(in srgb, var(--w360-accent) 40%, #2a2a2a); } .w360-cta-card:hover { color: #ececec; } .w360-cta-card__body span { color: #9a9a9a; } }
@media (max-width: 600px) { .w360-cta-card { flex-wrap: wrap; } .w360-cta-card__btn { width: 100%; text-align: center; } }
