/* ═══════════════════════════════════════════════════════════
   مساعد الموقع العام — فقاعة محادثة
   ألوان علامة كوديكس: أزرق #2563eb + أخضر #0f766e
   ═══════════════════════════════════════════════════════════ */

.sax-fab {
    position: fixed;
    inset-block-end: 24px;
    inset-inline-end: 24px;
    z-index: 2000;
    width: 58px; height: 58px;
    border: 0; border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #0f766e);
    color: #fff; font-size: 1.35rem; cursor: pointer;
    display: grid; place-items: center;
    box-shadow: 0 10px 28px rgba(37,99,235,.40);
    transition: transform .16s, box-shadow .16s;
}

.sax-fab:hover { transform: translateY(-2px) scale(1.05); box-shadow: 0 14px 34px rgba(37,99,235,.5); }
.sax-fab.is-open { background: #334155; box-shadow: 0 8px 22px rgba(51,65,85,.4); }
.sax-fab:focus-visible { outline: 3px solid #93c5fd; outline-offset: 3px; }

/* ── Panel ── */
.sax-panel {
    position: fixed;
    inset-block-end: 94px;
    inset-inline-end: 24px;
    z-index: 2000;
    width: min(392px, calc(100vw - 32px));
    height: min(560px, calc(100vh - 130px));
    display: flex; flex-direction: column;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 18px;
    box-shadow: 0 24px 64px rgba(15,23,42,.26), 0 4px 12px rgba(15,23,42,.10);
    overflow: hidden;
    animation: sax-in .18s cubic-bezier(.2,.9,.3,1);
    font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
}

@keyframes sax-in { from { opacity: 0; transform: translateY(14px) scale(.97); } }

/* ── Header ── */
.sax-head {
    display: flex; align-items: center; gap: 11px;
    padding: 14px 16px; flex: none;
    background: linear-gradient(135deg, #2563eb, #0f766e);
    color: #fff;
}

.sax-head__avatar {
    width: 36px; height: 36px; flex: none; border-radius: 50%;
    background: rgba(255,255,255,.2);
    display: grid; place-items: center; font-size: 1rem;
}

.sax-head__text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.sax-head__title { font-weight: 700; font-size: .96rem; }
.sax-head__sub { font-size: .74rem; opacity: .85; }

.sax-head__close {
    width: 30px; height: 30px; flex: none;
    border: 0; border-radius: 8px; cursor: pointer;
    background: rgba(255,255,255,.15); color: #fff;
    display: grid; place-items: center; font-size: .8rem;
}
.sax-head__close:hover { background: rgba(255,255,255,.28); }

/* ── Messages ── */
.sax-body {
    flex: 1; min-height: 0; overflow-y: auto;
    padding: 14px; background: #f8fafc;
    display: flex; flex-direction: column; gap: 10px;
    overscroll-behavior: contain;
}

.sax-msg { display: flex; }
.sax-msg--user { justify-content: flex-end; }
.sax-msg--bot { justify-content: flex-start; }

.sax-bubble {
    max-width: 86%;
    padding: 10px 13px;
    border-radius: 14px;
    font-size: .875rem;
    line-height: 1.75;
    background: #fff;
    border: 1px solid #e2e8f0;
    color: #1e293b;
}

.sax-bubble p { margin: 0 0 6px; }
.sax-bubble p:last-child { margin-bottom: 0; }

.sax-msg--user .sax-bubble {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

.sax-cta {
    display: inline-flex; align-items: center; gap: 4px;
    margin-top: 9px; padding: 7px 13px;
    border-radius: 9px;
    background: #eff6ff; color: #1d4ed8;
    font-size: .82rem; font-weight: 600; text-decoration: none;
}
.sax-cta:hover { background: #dbeafe; color: #1e40af; }

.sax-related { margin-top: 10px; padding-top: 9px; border-top: 1px solid #e2e8f0; }
.sax-related__label { display: block; font-size: .72rem; color: #64748b; margin-bottom: 5px; }
.sax-related__link {
    display: block; font-size: .8rem; color: #0f766e;
    text-decoration: none; padding: 3px 0;
}
.sax-related__link:hover { text-decoration: underline; }

/* ── Typing dots ── */
.sax-typing { display: flex; gap: 4px; align-items: center; padding: 13px; }
.sax-typing span {
    width: 7px; height: 7px; border-radius: 50%; background: #94a3b8;
    animation: sax-blink 1.2s infinite ease-in-out;
}
.sax-typing span:nth-child(2) { animation-delay: .18s; }
.sax-typing span:nth-child(3) { animation-delay: .36s; }
@keyframes sax-blink { 0%,80%,100% { opacity: .28; } 40% { opacity: 1; } }

/* ── Suggested questions ── */
.sax-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }

.sax-chip {
    padding: 7px 12px;
    border: 1px solid #cbd5e1; border-radius: 20px;
    background: #fff; color: #334155;
    font: inherit; font-size: .8rem; cursor: pointer;
    text-align: start;
}
.sax-chip:hover { border-color: #2563eb; color: #1d4ed8; background: #eff6ff; }

/* ── Composer ── */
.sax-input {
    display: flex; align-items: center; gap: 8px;
    padding: 11px 12px; flex: none;
    border-top: 1px solid #e2e8f0; background: #fff;
}

.sax-input__box {
    flex: 1; min-width: 0;
    padding: 10px 13px;
    border: 1px solid #cbd5e1; border-radius: 22px;
    font: inherit; font-size: .875rem; color: #0f172a;
    outline: none;
}
.sax-input__box:focus { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.14); }

.sax-input__send {
    width: 40px; height: 40px; flex: none;
    border: 0; border-radius: 50%; cursor: pointer;
    background: #2563eb; color: #fff;
    display: grid; place-items: center; font-size: .9rem;
}
.sax-input__send:hover:not(:disabled) { background: #1d4ed8; }
.sax-input__send:disabled { background: #cbd5e1; cursor: not-allowed; }

/* الأيقونة تشير لاتجاه الإرسال حسب اتجاه الصفحة */
[dir="rtl"] .sax-input__send i { transform: scaleX(-1); }
[dir="ltr"] .sax-cta i { transform: scaleX(-1); }

@media (max-width: 575.98px) {
    .sax-panel {
        inset-block-end: 84px;
        inset-inline-end: 12px;
        width: calc(100vw - 24px);
        height: min(70vh, 480px);
    }
    .sax-fab { width: 52px; height: 52px; inset-block-end: 18px; inset-inline-end: 18px; }
}

@media (prefers-reduced-motion: reduce) {
    .sax-panel { animation: none; }
    .sax-fab { transition: none; }
    .sax-typing span { animation: none; opacity: .6; }
}
