/* Shared compact assistant surface. Loaded after the feature-specific cards. */
:is(.sanad-assistant, .marketing-chatbot), :is(.sanad-assistant, .marketing-chatbot) * { box-sizing:border-box; }
:is(.sanad-assistant, .marketing-chatbot) {
    --chat-ink: #25334c;
    --chat-muted: #67758d;
    --chat-accent: #6554c0;
    --chat-border: #e8ebf2;
    inset-inline-end: 18px;
    bottom: calc(18px + var(--assistant-clear, 0px) + env(safe-area-inset-bottom, 0px));
    font-size: 13px;
}
:is(.sanad-assistant-toggle, .marketing-chatbot-toggle) {
    width: 46px; height: 46px; padding: 0; gap: 0;
    display: inline-flex; justify-content: center; align-items: center;
    border: 1px solid rgba(255,255,255,.6); border-radius: 16px;
    background: linear-gradient(145deg, #243a59, #6657b9);
    color: #fff; font-size: 20px; cursor: pointer;
    box-shadow: 0 5px 18px rgba(50,52,100,.2);
    transition: transform .18s ease, box-shadow .18s ease;
}
:is(.sanad-assistant-toggle, .marketing-chatbot-toggle):hover {
    transform: translateY(-2px); box-shadow: 0 8px 24px rgba(50,52,100,.26);
}
.marketing-chatbot-toggle span { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }
:is(.sanad-assistant-toggle, .marketing-chatbot-toggle) .chat-spark { position:static; display:inline; width:auto; height:auto; margin:0; overflow:visible; clip:auto; clip-path:none; }
:is(.sanad-assistant-panel, .marketing-chatbot-panel) {
    position: absolute; inset: auto; inset-inline-end: 0; bottom: 58px;
    width: min(368px, calc(100vw - 36px));
    height: min(500px, calc(var(--chat-viewport, 100dvh) - 106px - var(--assistant-clear, 0px)));
    min-height: 0; max-height: calc(var(--chat-viewport, 100dvh) - 94px - var(--assistant-clear, 0px));
    border: 1px solid #e1e6f0; border-radius: 22px;
    background: #fff; color: var(--chat-ink);
    box-shadow: 0 18px 64px rgba(27,39,69,.16), 0 3px 12px rgba(27,39,69,.05);
}
.marketing-chatbot-panel { width:min(352px, calc(100vw - 36px)); height:min(420px, calc(var(--chat-viewport, 100dvh) - 106px)); transition:height .18s ease; }
.marketing-chatbot.chat-has-messages .marketing-chatbot-panel { height:min(480px, calc(var(--chat-viewport, 100dvh) - 106px)); }
:is(.sanad-assistant-header, .marketing-chatbot-header) {
    flex-shrink:0; padding:15px 16px; gap:10px; border-bottom:1px solid var(--chat-border);
    background:linear-gradient(110deg,#fff,#f4f2fc); min-height:72px;
}
.chat-identity { display:flex; align-items:center; gap:10px; min-width:0; }
.chat-mark { width:36px; height:36px; border-radius:12px; display:inline-flex; align-items:center; justify-content:center; flex:0 0 36px;
    background:linear-gradient(145deg,#ece9fc,#e6f0fa); color:#6654b6; font-size:24px; }
:is(.sanad-assistant-header, .marketing-chatbot-header) strong { font-size:14px; font-weight:800; color:var(--chat-ink); }
:is(.sanad-assistant-header, .marketing-chatbot-header) small { font-size:10px; color:var(--chat-muted); margin-top:3px; }
:is(.sanad-assistant-close, .marketing-chatbot-close) {
    width:34px; height:34px; border-radius:10px; display:grid; place-items:center;
    font-size:22px; line-height:1; background:#fff; border:1px solid var(--chat-border); color:#778299; cursor:pointer;
}
:is(.sanad-assistant-close, .marketing-chatbot-close):hover { color:var(--chat-ink); background:#f0f2f8; }
:is(.sanad-assistant-messages, .marketing-chatbot-messages) {
    min-height:0; flex:1 1 0; padding:16px 14px 8px;
    background:linear-gradient(180deg,#fafbfe,#fff); overscroll-behavior:contain;
    scrollbar-width:thin; scrollbar-color:#dfe3ed transparent;
}
:is(.sanad-assistant-message, .marketing-chatbot-message) { margin-bottom:12px; gap:8px; }
:is(.sanad-assistant-bubble, .marketing-chatbot-bubble) {
    max-width:94%; font-size:14px; line-height:1.9; padding:10px 13px;
    border-radius:15px; border:1px solid var(--chat-border); color:var(--chat-ink); background:#fff;
    overflow-wrap:anywhere; white-space:pre-wrap; text-align:start;
}
:is(.sanad-assistant-message, .marketing-chatbot-message).assistant { justify-content:flex-start; }
:is(.sanad-assistant-message, .marketing-chatbot-message).user { justify-content:flex-end; }
:is(.sanad-assistant-message, .marketing-chatbot-message).user :is(.sanad-assistant-bubble, .marketing-chatbot-bubble) {
    background:#eef0fb; color:#3d416e; border-color:#e4e6f8; border-end-end-radius:5px;
}
:is(.sanad-assistant-message, .marketing-chatbot-message).loading :is(.sanad-assistant-bubble, .marketing-chatbot-bubble) { color:#7a7897; opacity:1; background:#f4f2fc; border-color:#ebe7fa; }
.chat-welcome { padding:4px 3px 12px; color:var(--chat-muted); font-size:13px; line-height:1.9; }
.chat-welcome .chat-mark { width:42px; height:42px; margin-bottom:9px; }
.chat-welcome strong { display:block; font-size:17px; color:var(--chat-ink); font-weight:800; margin-bottom:5px; }
.chat-welcome p { margin:0; }
:is(.sanad-assistant-suggestions, .marketing-chatbot-suggestions) {
    flex-shrink:0; padding:8px 12px; gap:6px; background:#fff; border-top:0;
    flex-wrap:nowrap; scrollbar-width:none;
}
:is(.sanad-assistant-suggestions, .marketing-chatbot-suggestions) button {
    min-height:36px; padding:5px 10px; border:1px solid #e4e6f0; color:#5e627e;
    background:#fafafe; border-radius:10px; font-family:inherit; font-size:11px; cursor:pointer;
}
:is(.sanad-assistant-suggestions, .marketing-chatbot-suggestions) button:hover { border-color:#bdb3e5; background:#f0edfb; color:#5b4e98; }
.chat-privacy { flex-shrink:0; padding:4px 14px 8px; font-size:10px; color:#717a90; border-top:0; line-height:1.7; background:#fff; }
.chat-privacy summary { cursor:pointer; list-style:none; }
.chat-privacy summary::before { content:'◈'; margin-inline-end:5px; color:#9289b7; }
.chat-privacy small { display:block; font-size:10px; padding:7px 0 0; max-height:90px; overflow-y:auto; }
:is(.sanad-assistant-form, .marketing-chatbot-form) {
    flex-shrink:0; padding:10px 12px 12px; gap:8px; align-items:center;
    border-top:1px solid var(--chat-border); background:#fff;
}
:is(.sanad-assistant-form, .marketing-chatbot-form) input {
    width:0; min-height:42px; padding:9px 12px; font-family:inherit; font-size:12px;
    border:1px solid #e5e7f0; border-radius:13px; background:#f8f9fc; color:var(--chat-ink); outline:none;
}
:is(.sanad-assistant-form, .marketing-chatbot-form) input::placeholder { color:#929bb0; }
:is(.sanad-assistant-form, .marketing-chatbot-form) input:focus { border-color:#aca0dc; background:#fff; box-shadow:0 0 0 3px #f1eefb; }
:is(.sanad-assistant-form, .marketing-chatbot-form) button {
    width:42px; height:42px; flex:0 0 42px; border-radius:13px;
    border:0; background:#6254aa; color:#fff; font-size:17px; cursor:pointer;
}
.marketing-chatbot-actions { margin:0 14px 12px; gap:6px; }
.marketing-chatbot-action { border:1px solid #ded9f0; padding:7px 10px; border-radius:10px; font-family:inherit;
    background:#f0edf9; color:#574791; font-size:11px; font-weight:700; cursor:pointer; }
.marketing-chatbot-action:hover { background:#e6e0f5; color:#574791; opacity:1; }
.sanad-assistant-message:has(> .sanad-setup-action) { flex-wrap:wrap; }
.sanad-assistant-message > .sanad-setup-action { display:inline-flex; font-size:11px; border:1px solid #ded9f0; border-radius:10px; padding:7px 10px; background:#f0edf9; color:#574791; }
:is(.sanad-assistant, .marketing-chatbot) :is(button,a,summary,input):focus-visible { outline-color:#8575c6 !important; outline-offset:2px; }
.chat-compact-viewport :is(.sanad-assistant-suggestions, .marketing-chatbot-suggestions) { display:none; }
.chat-compact-viewport :is(.sanad-assistant-header, .marketing-chatbot-header) { min-height:56px; padding:8px 12px; }
.chat-input-label { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); }
@media (max-width:576px) {
    :is(.sanad-assistant, .marketing-chatbot) { inset-inline-end:12px; bottom:calc(12px + var(--assistant-clear, 0px) + env(safe-area-inset-bottom, 0px)); }
    :is(.sanad-assistant-panel, .marketing-chatbot-panel) {
        position:absolute; inset:auto; inset-inline-end:0; bottom:58px;
        width:min(352px, calc(100vw - 24px));
        height:min(510px, calc(var(--chat-viewport, 100dvh) - 98px - var(--assistant-clear, 0px)));
        max-height:calc(var(--chat-viewport, 100dvh) - 98px - var(--assistant-clear, 0px)); border-radius:20px;
    }
    :is(.sanad-assistant-form, .marketing-chatbot-form) input { font-size:16px; } /* prevent mobile focus zoom */
    .marketing-chatbot-panel { height:min(440px, calc(var(--chat-viewport, 100dvh) - 98px)); }
    .marketing-chatbot.chat-has-messages .marketing-chatbot-panel { height:min(510px, calc(var(--chat-viewport, 100dvh) - 98px)); }
}
@media (prefers-reduced-motion:reduce) {
    :is(.sanad-assistant, .marketing-chatbot) * { transition:none !important; scroll-behavior:auto !important; }
}
@media print { :is(.sanad-assistant, .marketing-chatbot) { display:none !important; } }

.agent-preview-details { margin-block: 12px; padding: 10px; background: #f5f3fc; border-radius: 12px; overflow-wrap: anywhere; }
.agent-preview-details p { margin: 6px 0; }
.sanad-setup-action:disabled { opacity: .55; cursor: wait; }

/* Administrative intelligence cards use existing Sanad chat colors. */
.agent-report-section { margin-block:8px; border:1px solid var(--chat-border); border-radius:10px; padding:8px; }
.agent-report-section summary { cursor:pointer; font-weight:700; color:var(--chat-ink); }
.agent-kpis { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:6px; margin-block:8px; }
.agent-kpi { background:#f5f4fb; border-radius:8px; padding:7px; display:flex; flex-direction:column; gap:4px; }
.agent-kpi span { font-size:11px; color:var(--chat-muted); }
.agent-kpi bdi { font-size:17px; font-weight:700; }
.agent-table-scroll { overflow-x:auto; max-width:100%; margin-block:8px; }
.agent-table-scroll table { border-collapse:collapse; font-size:11px; white-space:nowrap; width:100%; }
.agent-table-scroll th,.agent-table-scroll td { padding:5px; text-align:start; border-bottom:1px solid var(--chat-border); }
.agent-table-scroll caption { text-align:start; color:var(--chat-muted); font-size:10px; padding-block:5px; }
.agent-limitation { font-size:10px; color:var(--chat-muted); line-height:1.6; }
.agent-priorities { border-inline-start:3px solid var(--chat-accent); padding-inline-start:8px; }
@media(min-width:700px) { .sanad-assistant-panel:has(.agent-report-section) { width:min(560px,calc(100vw - 36px)); } }
