/* Arabic Site Assistant - chat widget (right-to-left for Arabic, left-to-right for English).
   Everything is scoped under #asa-root (an ID beats almost any theme rule); the accent colour comes
   from --asa-color, set from the plugin's settings. Layout uses logical directions and follows the dir attribute. */

#asa-root, #asa-root * { box-sizing: border-box; }
#asa-root[dir="rtl"] { direction: rtl; }
#asa-root[dir="ltr"] { direction: ltr; }
#asa-root {
    --asa-color: #0f766e;
    text-align: start;
    font-family: "Segoe UI", Tahoma, "Noto Sans Arabic", "Noto Naskh Arabic", "Geeza Pro", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.7;
    color: #1f2937;
}

/* ---------- launcher ---------- */
#asa-root .asa-launcher {
    position: fixed; bottom: 20px; z-index: 99998;
    width: 58px; height: 58px; padding: 0; margin: 0;
    display: flex; align-items: center; justify-content: center;
    border: none; border-radius: 50%; cursor: pointer;
    background: var(--asa-color); color: #fff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
    transition: transform .2s ease, box-shadow .2s ease;
}
#asa-root .asa-launcher:hover { transform: scale(1.06); box-shadow: 0 10px 28px rgba(0, 0, 0, .3); }
#asa-root .asa-launcher:focus-visible,
#asa-root .asa-icon-btn:focus-visible,
#asa-root .asa-send:focus-visible,
#asa-root .asa-chip:focus-visible { outline: 3px solid rgba(15, 118, 110, .45); outline-offset: 2px; }
#asa-root.asa-pos-left .asa-launcher { left: 20px; }
#asa-root.asa-pos-right .asa-launcher { right: 20px; }
#asa-root .asa-launcher.asa-launcher-hidden { display: none; }

/* ---------- panel ---------- */
#asa-root .asa-panel {
    position: fixed; bottom: 92px; z-index: 99999;
    width: 370px; max-width: calc(100vw - 24px);
    height: 560px; max-height: calc(100vh - 116px);
    display: flex; flex-direction: column;
    background: #fff; border-radius: 16px; overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .28);
    animation: asa-in .22s ease-out;
}
#asa-root .asa-panel[hidden] { display: none; }
#asa-root.asa-pos-left .asa-panel { left: 20px; }
#asa-root.asa-pos-right .asa-panel { right: 20px; }
@keyframes asa-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- header ---------- */
#asa-root .asa-head {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 16px; background: var(--asa-color); color: #fff;
}
#asa-root .asa-avatar {
    width: 40px; height: 40px; flex: 0 0 40px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255, 255, 255, .22); font-weight: 700; font-size: 18px;
}
#asa-root .asa-titles { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#asa-root .asa-titles strong { font-size: 16px; font-weight: 700; color: #fff; line-height: 1.4; }
#asa-root .asa-titles span { font-size: 12.5px; opacity: .9; color: #fff; line-height: 1.4; }
#asa-root .asa-icon-btn {
    width: 34px; height: 34px; flex: 0 0 34px; padding: 0; margin: 0; border: none; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    background: transparent; color: #fff; cursor: pointer;
}
#asa-root .asa-icon-btn:hover { background: rgba(255, 255, 255, .18); }

#asa-root .asa-lang-btn {
    flex: 0 0 auto; height: 30px; min-width: 42px; padding: 0 10px; margin: 0;
    border: 1px solid rgba(255, 255, 255, .55); border-radius: 999px; cursor: pointer;
    background: rgba(255, 255, 255, .14); color: #fff;
    font: inherit; font-size: 13px; font-weight: 700; line-height: 1;
}
#asa-root .asa-lang-btn:hover { background: rgba(255, 255, 255, .28); }
#asa-root .asa-lang-btn:focus-visible { outline: 3px solid rgba(255, 255, 255, .7); outline-offset: 2px; }

/* ---------- messages ---------- */
#asa-root .asa-body {
    flex: 1; overflow-y: auto; padding: 16px 14px;
    background: #f5f7f9; display: flex; flex-direction: column; gap: 10px;
}
#asa-root .asa-msg { display: flex; justify-content: flex-start; }      /* assistant: start side (right in RTL) */
#asa-root .asa-msg.asa-user { justify-content: flex-end; }               /* visitor: end side (left in RTL) */
#asa-root .asa-bubble {
    max-width: 86%; padding: 10px 14px; border-radius: 16px;
    white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere;
    text-align: start;
}
#asa-root .asa-assistant .asa-bubble {
    background: #fff; color: #1f2937; border: 1px solid #e5e7eb; border-start-start-radius: 4px;
}
#asa-root .asa-user .asa-bubble {
    background: var(--asa-color); color: #fff; border-start-end-radius: 4px;
}
#asa-root .asa-bubble a { color: inherit; text-decoration: underline; word-break: break-all; unicode-bidi: isolate; }
#asa-root .asa-assistant .asa-bubble a { color: var(--asa-color); }
#asa-root .asa-error .asa-bubble { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

/* typing dots */
#asa-root .asa-typing .asa-bubble { display: flex; gap: 4px; padding: 14px 15px; }
#asa-root .asa-typing .asa-bubble span {
    width: 7px; height: 7px; border-radius: 50%; background: #9ca3af;
    animation: asa-dot 1.2s infinite ease-in-out;
}
#asa-root .asa-typing .asa-bubble span:nth-child(2) { animation-delay: .15s; }
#asa-root .asa-typing .asa-bubble span:nth-child(3) { animation-delay: .3s; }
@keyframes asa-dot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-4px); } }

/* ---------- quick questions ---------- */
#asa-root .asa-chips {
    display: flex; flex-wrap: wrap; gap: 8px; padding: 0 14px 12px; background: #f5f7f9;
}
#asa-root .asa-chip {
    padding: 7px 13px; margin: 0; border-radius: 999px; cursor: pointer;
    border: 1px solid var(--asa-color); background: #fff; color: var(--asa-color);
    font: inherit; font-size: 13.5px; font-weight: 600; line-height: 1.5;
}
#asa-root .asa-chip:hover { background: var(--asa-color); color: #fff; }

/* ---------- input ---------- */
#asa-root .asa-form {
    display: flex; align-items: flex-end; gap: 8px; margin: 0;
    padding: 10px 12px; background: #fff; border-top: 1px solid #e5e7eb;
}
#asa-root .asa-input {
    flex: 1; min-height: 42px; max-height: 96px; margin: 0; padding: 9px 12px;
    border: 1px solid #d1d5db; border-radius: 12px; resize: none; outline: none;
    font: inherit; font-size: 15px; line-height: 1.5; color: #1f2937; background: #fff;
    text-align: start; box-shadow: none;
}
#asa-root .asa-input:focus { border-color: var(--asa-color); }
#asa-root .asa-send {
    width: 42px; height: 42px; flex: 0 0 42px; padding: 0; margin: 0; border: none; border-radius: 12px;
    display: flex; align-items: center; justify-content: center; cursor: pointer;
    background: var(--asa-color); color: #fff;
}
#asa-root[dir="rtl"] .asa-send svg { transform: scaleX(-1); }   /* the paper plane points the way text flows */
#asa-root .asa-send:disabled { opacity: .5; cursor: not-allowed; }
#asa-root .asa-foot {
    padding: 0 12px 9px; background: #fff; color: #9ca3af; font-size: 11.5px; text-align: center; line-height: 1.5;
}

/* ---------- phones ---------- */
@media (max-width: 480px) {
    #asa-root .asa-panel,
    #asa-root.asa-pos-left .asa-panel,
    #asa-root.asa-pos-right .asa-panel {
        left: 8px; right: 8px; bottom: 8px; width: auto; max-width: none;
        height: calc(100vh - 16px); height: calc(100dvh - 16px); max-height: none;
    }
    #asa-root .asa-input { font-size: 16px; } /* stops iOS zooming into the field */
}

@media (prefers-reduced-motion: reduce) {
    #asa-root .asa-panel, #asa-root .asa-launcher,
    #asa-root .asa-typing .asa-bubble span { animation: none; transition: none; }
}
