/* ==================================================
   AFAQ FLOATING WIDGETS — WhatsApp (bottom-left) + website assistant (bottom-right)
   Markup: inc/afaq-floating.php. Physical positions are the same in Arabic and English.
   Stacking: above page content (OceanWP scroll-top is 100), below the sticky header and its drawer (9999).
   ================================================== */
.afaq-float {
    --afaq-float-edge: 20px;
    --afaq-float-size: 56px;
    --afaq-float-z: 9000;
    font-family: 'Tajawal', sans-serif;
}

/* ---------- Shared button ---------- */
.afaq-float-btn {
    position: fixed;
    bottom: calc(var(--afaq-float-edge) + env(safe-area-inset-bottom, 0px));
    z-index: var(--afaq-float-z);
    display: inline-flex;
    align-items: center;
    gap: 10px;
    height: var(--afaq-float-size);
    min-width: var(--afaq-float-size);
    margin: 0;
    padding: 6px;
    direction: ltr; /* physical layout: icon on the outer edge in both languages; the label keeps its own bidi order */
    border-radius: 999px;
    box-sizing: border-box;
    font: 700 15px/1 'Tajawal', sans-serif;
    letter-spacing: 0;
    text-decoration: none;
    text-transform: none;
    cursor: pointer;
    box-shadow: 0 10px 28px -10px rgba(1, 39, 59, 0.45), 0 2px 6px rgba(1, 39, 59, 0.12);
    transition: transform 200ms ease, box-shadow 200ms ease, background-color 200ms ease;
}

.afaq-float-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 32px -10px rgba(1, 39, 59, 0.5), 0 2px 6px rgba(1, 39, 59, 0.14);
}

.afaq-float-btn:focus-visible {
    outline: 3px solid #0DC0C2;
    outline-offset: 3px;
}

.afaq-float-ico {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: calc(var(--afaq-float-size) - 12px);
    height: calc(var(--afaq-float-size) - 12px);
    border-radius: 50%;
}

.afaq-float-label {
    white-space: nowrap;
}

/* ---------- WhatsApp ---------- */
.afaq-float-wa {
    left: calc(var(--afaq-float-edge) + env(safe-area-inset-left, 0px));
    padding-right: 20px;
    color: #01273B;
    background: #FFFFFF;
    border: 1px solid #E1E7EB;
}

.afaq-float-wa:hover,
.afaq-float-wa:focus-visible {
    color: #01273B;
}

.afaq-float-ico--wa {
    color: #FFFFFF;
    background: #25D366;
}

/* ---------- Assistant launcher ---------- */
.afaq-agent-launcher {
    right: calc(var(--afaq-float-edge) + env(safe-area-inset-right, 0px));
    flex-direction: row-reverse;
    padding-left: 20px;
    color: #FFFFFF;
    background: #01273B;
    border: 1px solid #01273B;
}

.afaq-agent-launcher:hover,
.afaq-agent-launcher:focus-visible,
.afaq-agent.is-open .afaq-agent-launcher {
    color: #FFFFFF;
    background: #023A55;
}

.afaq-float-ico--agent {
    background: #0DC0C2;
}

.afaq-agent-launcher-ico,
.afaq-agent-avatar,
.afaq-agent-action-ico {
    display: block;
    background: currentColor;
    -webkit-mask: var(--afaq-ico) center / contain no-repeat;
    mask: var(--afaq-ico) center / contain no-repeat;
}

.afaq-agent-launcher-ico {
    width: 24px;
    height: 24px;
    color: #01273B;
}

/* ---------- Assistant panel ---------- */
.afaq-agent-panel {
    position: fixed;
    right: calc(var(--afaq-float-edge) + env(safe-area-inset-right, 0px));
    bottom: calc(var(--afaq-float-edge) + var(--afaq-float-size) + 12px + env(safe-area-inset-bottom, 0px));
    z-index: var(--afaq-float-z);
    display: flex;
    flex-direction: column;
    width: min(380px, calc(100vw - 2 * var(--afaq-float-edge)));
    max-height: min(600px, calc(100vh - var(--afaq-float-size) - 2 * var(--afaq-float-edge) - 100px));
    max-height: min(600px, calc(100dvh - var(--afaq-float-size) - 2 * var(--afaq-float-edge) - 100px));
    overflow: hidden;
    color: #17313D;
    background: #FFFFFF;
    border: 1px solid #E1E7EB;
    border-radius: 18px;
    box-shadow: 0 24px 60px -16px rgba(1, 39, 59, 0.35), 0 2px 8px rgba(1, 39, 59, 0.08);
    text-align: start;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 180ms ease, transform 180ms ease;
}

.afaq-agent-panel[hidden] {
    display: none;
}

.afaq-agent.is-open .afaq-agent-panel {
    opacity: 1;
    transform: none;
}

.afaq-agent-panel:focus {
    outline: none;
}

.afaq-agent-panel:focus-visible {
    outline: 3px solid #0DC0C2;
    outline-offset: 2px;
}

.afaq-agent-head {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 12px;
    padding: 16px 16px 16px 18px;
    padding-inline: 18px 12px;
    color: #FFFFFF;
    background: #01273B;
}

.afaq-agent-avatar {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #0DC0C2;
    -webkit-mask: none;
    mask: none;
    position: relative;
}

.afaq-agent-avatar::after {
    content: '';
    position: absolute;
    inset: 9px;
    background: #01273B;
    -webkit-mask: var(--afaq-ico) center / contain no-repeat;
    mask: var(--afaq-ico) center / contain no-repeat;
}

.afaq-agent-heading {
    flex: 1 1 auto;
    min-width: 0;
}

.afaq-agent-title,
.afaq-agent-sub,
.afaq-agent-msg,
.afaq-agent-prompt,
.afaq-agent-foot {
    margin: 0;
    font-family: 'Tajawal', sans-serif;
    letter-spacing: 0;
}

.afaq-agent-title {
    color: #FFFFFF;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.3;
}

.afaq-agent-sub {
    margin-top: 2px;
    color: rgba(255, 255, 255, 0.75);
    font-size: 13px;
    line-height: 1.4;
}

.afaq-agent-close {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin: 0;
    padding: 0;
    color: #FFFFFF;
    background: transparent;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 150ms ease;
}

.afaq-agent-close:hover {
    color: #FFFFFF;
    background: rgba(255, 255, 255, 0.12);
}

.afaq-agent-close:focus-visible {
    color: #FFFFFF;
    background: rgba(255, 255, 255, 0.12);
    outline: 2px solid #0DC0C2;
    outline-offset: 0;
}

.afaq-agent-body {
    flex: 1 1 auto;
    min-height: 0;
    padding: 18px;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: #F5F7F8;
}

.afaq-agent-msg {
    padding: 12px 14px;
    color: #17313D;
    background: #FFFFFF;
    border: 1px solid #E1E7EB;
    border-radius: 14px;
    border-start-start-radius: 4px;
    font-size: 15px;
    line-height: 1.7;
}

.afaq-agent-prompt {
    margin: 16px 0 10px;
    color: #4A5F6A;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
}

.afaq-agent-actions {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.afaq-agent-actions li {
    margin: 0;
    padding: 0;
}

.afaq-agent-action {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    padding: 10px 14px;
    color: #01273B;
    background: #FFFFFF;
    border: 1px solid #E1E7EB;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.35;
    text-decoration: none;
    transition: border-color 150ms ease, background-color 150ms ease, color 150ms ease;
}

.afaq-agent-action:hover,
.afaq-agent-action:focus-visible {
    color: #038B99;
    background: #FFFFFF;
    border-color: #0DC0C2;
}

.afaq-agent-action:focus-visible {
    outline: 2px solid #0DC0C2;
    outline-offset: 1px;
}

.afaq-agent-action-ico {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    color: #038B99;
}

.afaq-agent-foot {
    flex: 0 0 auto;
    padding: 10px 18px 12px;
    color: #5B6F79;
    background: #FFFFFF;
    border-top: 1px solid #E1E7EB;
    font-size: 12.5px;
    line-height: 1.5;
}

/* ---------- State colours: the theme/Elementor kit style button:hover/focus globally, so pin every state here ---------- */
.afaq-float .afaq-agent-launcher,
.afaq-float .afaq-agent-launcher:focus {
    color: #FFFFFF;
    background: #01273B;
    border-color: rgba(13, 192, 194, 0.55); /* keeps the launcher visible over the petrol footer */
}

.afaq-float .afaq-agent-launcher:hover,
.afaq-float .afaq-agent-launcher:focus-visible,
.afaq-float .afaq-agent.is-open .afaq-agent-launcher {
    color: #FFFFFF;
    background: #023A55;
    border-color: #023A55;
}

.afaq-float .afaq-agent-close,
.afaq-float .afaq-agent-close:focus {
    color: #FFFFFF;
    background: transparent;
}

.afaq-float .afaq-agent-close:hover,
.afaq-float .afaq-agent-close:focus-visible {
    color: #FFFFFF;
    background: rgba(255, 255, 255, 0.12);
}

/* ---------- OceanWP scroll-to-top: stacked above the assistant launcher (same right edge) ---------- */
body.afaq-has-agent #scroll-top {
    right: calc(20px + 8px + env(safe-area-inset-right, 0px)); /* centred on the 44px launcher icon */
    bottom: calc(20px + 56px + 14px + env(safe-area-inset-bottom, 0px));
}

/* Clearance under the footer copyright so the fixed controls never sit on it at the end of the page (spacing only). */
body.afaq-has-agent #footer.afaq-footer .afaq-footer-bottom {
    padding-bottom: 96px;
}

@media (min-width: 768px) and (max-width: 1024px) {
    /* The copyright spans the full row here, so also clear the stacked scroll-to-top button (90–130px). */
    body.afaq-has-agent #footer.afaq-footer .afaq-footer-bottom {
        padding-bottom: 140px;
    }
}

/* ---------- Mobile / small tablets: icon-only circles ---------- */
@media (max-width: 767px) {
    .afaq-float {
        --afaq-float-edge: 16px;
        --afaq-float-size: 52px;
    }

    .afaq-float .afaq-float-btn {
        justify-content: center;
        width: var(--afaq-float-size);
        padding: 0;
    }

    .afaq-float-ico {
        width: 100%;
        height: 100%;
    }

    .afaq-float-wa {
        background: #25D366;
        border-color: #25D366;
    }

    .afaq-float-ico--agent {
        background: transparent;
    }

    .afaq-agent-launcher-ico {
        color: #0DC0C2;
    }

    .afaq-float-label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    .afaq-agent-panel {
        border-radius: 16px;
    }

    body.afaq-has-agent #footer.afaq-footer .afaq-footer-bottom {
        padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px));
    }

    body.afaq-has-agent #scroll-top {
        right: calc(16px + 6px + env(safe-area-inset-right, 0px));
        bottom: calc(16px + 52px + 12px + env(safe-area-inset-bottom, 0px));
    }
}

@media (max-width: 480px) {
    body.afaq-has-agent #scroll-top {
        right: calc(16px + 13px + env(safe-area-inset-right, 0px)); /* OceanWP's 26px button, centred on the 52px launcher */
    }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    .afaq-float-btn,
    .afaq-agent-panel,
    .afaq-agent-action,
    .afaq-agent-close {
        transition: none;
    }

    .afaq-float-btn:hover {
        transform: none;
    }

    .afaq-agent-panel {
        transform: none;
    }
}

/* Print: no floating controls. */
@media print {
    .afaq-float {
        display: none;
    }
}
