/* ============================================================
   BARWA - ASK BARWA FLOATING CHAT WIDGET
   File: ask-barwa.css

   - Works for English (LTR) and Arabic (RTL).
     Direction comes from dir="ltr|rtl" on #barwa-ask-root,
     which ask-barwa.js sets automatically.
   - Uses CSS logical properties (inset-inline-end,
     margin-inline-end) so the widget sits bottom-right in
     English and bottom-left in Arabic without duplicate rules.
   ============================================================ */

#barwa-ask-root {
    --barwa-primary: #00205b;
    --barwa-primary-dark: #001640;
    --barwa-primary-light: #173b78;
    --barwa-primary-rgb: 0, 32, 91;
    --barwa-text: #252525;
    --barwa-muted: #737373;
    --barwa-border: #e5e5e5;
    --barwa-background: #ffffff;
    --barwa-shadow: 0 12px 40px rgba(var(--barwa-primary-rgb), 0.18);
    --barwa-gap: 28px;

    /* Height of Copilot Studio's own name bar inside the iframe.
       The iframe is shifted up by this amount so the bar is cropped off.
       Set to 0px to show the bar again. */
    --barwa-iframe-crop: 48px;

    font-family:
        "Lusail",
        "Segoe UI",
        Tahoma,
        Arial,
        sans-serif;

    box-sizing: border-box;
}

#barwa-ask-root *,
#barwa-ask-root *::before,
#barwa-ask-root *::after {
    box-sizing: inherit;
}

/* ------------------------------------------------------------
   Isolation from site-wide styles
   The host site styles generic elements (div, button, iframe,
   headings...). These resets stop those rules from shrinking
   or re-aligning the widget.
   ------------------------------------------------------------ */

#barwa-ask-root div,
#barwa-ask-root span,
#barwa-ask-root iframe,
#barwa-ask-root img {
    float: none;
    max-width: none;
    letter-spacing: normal;
    text-transform: none;
}

#barwa-ask-root .barwa-ask-window,
#barwa-ask-root .barwa-ask-header,
#barwa-ask-root .barwa-ask-content,
#barwa-ask-root .barwa-ask-footer {
    margin: 0;
    max-width: none;
}

/* Every row of the window spans its full width */
#barwa-ask-root .barwa-ask-window {
    align-items: stretch;
    justify-content: flex-start;
    flex-wrap: nowrap;
}

#barwa-ask-root .barwa-ask-window > .barwa-ask-header,
#barwa-ask-root .barwa-ask-window > .barwa-ask-content,
#barwa-ask-root .barwa-ask-window > .barwa-ask-footer {
    width: 100%;
    align-self: stretch;
}

#barwa-ask-root .barwa-ask-brand {
    flex: 1 1 auto;
}

#barwa-ask-root .barwa-ask-brand-text {
    flex: 1 1 auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#barwa-ask-root .barwa-ask-title,
#barwa-ask-root .barwa-ask-subtitle {
    overflow: hidden;
    text-overflow: ellipsis;
}

#barwa-ask-root .barwa-ask-iframe {
    min-width: 0;
    max-width: none;
    margin: 0;
    padding: 0;
}

/* ------------------------------------------------------------
   Floating Button
   ------------------------------------------------------------ */

#barwa-ask-root .barwa-ask-button {
    position: fixed;
    inset-inline-end: var(--barwa-gap);
    bottom: var(--barwa-gap);

    z-index: 2147483000;

    height: 56px;
    min-width: 56px;

    padding: 0 16px;

    border: 0;
    border-radius: 999px;

    background: var(--barwa-primary);
    color: #ffffff;

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;

    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    line-height: 1;

    cursor: pointer;

    box-shadow: 0 6px 20px rgba(var(--barwa-primary-rgb), 0.30);

    transition:
        background-color 0.2s ease,
        transform 0.2s ease,
        box-shadow 0.2s ease;
}

#barwa-ask-root .barwa-ask-button:hover {
    background: var(--barwa-primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 9px 25px rgba(var(--barwa-primary-rgb), 0.38);
}

#barwa-ask-root .barwa-ask-button:active {
    transform: translateY(0);
}

#barwa-ask-root .barwa-ask-button:focus-visible {
    outline: 3px solid rgba(var(--barwa-primary-rgb), 0.35);
    outline-offset: 3px;
}

/* ------------------------------------------------------------
   Button Icon
   ------------------------------------------------------------ */

#barwa-ask-root .barwa-ask-button-icon {
    width: 25px;
    height: 25px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    flex-shrink: 0;
}

#barwa-ask-root .barwa-ask-button-icon svg {
    width: 24px;
    height: 24px;
    display: block;
}

/* Label: hidden until hover / keyboard focus, then slides out */
#barwa-ask-root .barwa-ask-button-label {
    display: inline-block;
    max-width: 0;
    overflow: hidden;
    white-space: nowrap;
    opacity: 0;

    transition:
        max-width 0.28s ease,
        margin 0.28s ease,
        opacity 0.2s ease;
}

#barwa-ask-root .barwa-ask-button:hover .barwa-ask-button-label,
#barwa-ask-root .barwa-ask-button:focus-visible .barwa-ask-button-label {
    max-width: 160px;
    margin-inline-start: 10px;
    opacity: 1;
}

/* Status dot (navy with a white ring) */
#barwa-ask-root .barwa-ask-dot {
    position: absolute;
    top: 1px;
    inset-inline-end: 1px;

    width: 14px;
    height: 14px;

    border-radius: 50%;
    border: 2.5px solid #ffffff;

    background: var(--barwa-primary);

    pointer-events: none;
}

/* Mirror the chat-bubble tail in Arabic */
#barwa-ask-root[dir="rtl"] .barwa-ask-welcome-icon svg {
    transform: scaleX(-1);
}

/* ------------------------------------------------------------
   Chat Window
   ------------------------------------------------------------ */

#barwa-ask-root .barwa-ask-window {
    position: fixed;

    inset-inline-end: var(--barwa-gap);
    bottom: 98px;

    z-index: 2147482999;

    width: 430px;
    height: min(690px, calc(100vh - 125px));

    min-height: 500px;

    background: var(--barwa-background);

    border-radius: 14px;
    overflow: hidden;

    box-shadow: var(--barwa-shadow);

    border: 1px solid rgba(0, 0, 0, 0.08);

    display: flex;
    flex-direction: column;

    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    transform: translateY(15px) scale(0.98);
    transform-origin: bottom right;

    transition:
        opacity 0.22s ease,
        transform 0.22s ease,
        visibility 0.22s ease;
}

#barwa-ask-root[dir="rtl"] .barwa-ask-window {
    transform-origin: bottom left;
}

#barwa-ask-root .barwa-ask-window.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;

    transform: translateY(0) scale(1);
}

/* ------------------------------------------------------------
   Window Header
   ------------------------------------------------------------ */

#barwa-ask-root .barwa-ask-header {
    position: relative;

    height: 72px;
    min-height: 72px;

    padding: 0 16px;

    background: #ffffff;

    border-top: 3px solid var(--barwa-primary);
    border-bottom: 1px solid var(--barwa-border);

    display: flex;
    align-items: center;
    justify-content: space-between;

    flex-shrink: 0;
}

#barwa-ask-root .barwa-ask-brand {
    display: flex;
    align-items: center;
    min-width: 0;
}

#barwa-ask-root .barwa-ask-logo {
    width: 43px;
    height: 43px;

    margin-inline-end: 11px;

    border-radius: 50%;

    background: var(--barwa-primary);
    color: #ffffff;

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 22px;
    font-weight: 700;

    flex-shrink: 0;
}

#barwa-ask-root .barwa-ask-logo img {
    max-width: 28px;
    max-height: 28px;
    width: auto;
    height: auto;
    display: block;
}

#barwa-ask-root .barwa-ask-brand-text {
    min-width: 0;
}

#barwa-ask-root .barwa-ask-title {
    margin: 0;

    color: var(--barwa-text);

    font-family: inherit;
    font-size: 17px;
    line-height: 22px;
    font-weight: 700;
}

#barwa-ask-root .barwa-ask-subtitle {
    margin: 1px 0 0;

    color: var(--barwa-muted);

    font-size: 11px;
    line-height: 16px;
    font-weight: 400;
}

/* ------------------------------------------------------------
   Close Button
   ------------------------------------------------------------ */

#barwa-ask-root .barwa-ask-close {
    width: 36px;
    height: 36px;

    padding: 0;

    border: 0;
    border-radius: 50%;

    background: transparent;
    color: #555555;

    display: flex;
    align-items: center;
    justify-content: center;

    flex-shrink: 0;

    cursor: pointer;

    transition:
        background-color 0.2s ease,
        color 0.2s ease;
}

#barwa-ask-root .barwa-ask-close:hover {
    background: #f3f3f3;
    color: var(--barwa-primary);
}

#barwa-ask-root .barwa-ask-close:focus-visible {
    outline: 2px solid var(--barwa-primary);
    outline-offset: 2px;
}

#barwa-ask-root .barwa-ask-close svg {
    width: 20px;
    height: 20px;
}

/* ------------------------------------------------------------
   Welcome / Loading Area
   ------------------------------------------------------------ */

#barwa-ask-root .barwa-ask-content {
    position: relative;

    flex: 1;
    min-height: 0;

    background: #ffffff;

    overflow: hidden;
}

#barwa-ask-root .barwa-ask-welcome {
    position: absolute;

    inset: 0;

    z-index: 2;

    background: #ffffff;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 30px;

    text-align: center;

    transition:
        opacity 0.2s ease,
        visibility 0.2s ease;
}

#barwa-ask-root .barwa-ask-welcome.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

#barwa-ask-root .barwa-ask-welcome-inner {
    max-width: 320px;
}

#barwa-ask-root .barwa-ask-welcome-icon {
    width: 68px;
    height: 68px;

    margin: 0 auto 18px;

    border-radius: 50%;

    background: rgba(var(--barwa-primary-rgb), 0.09);
    color: var(--barwa-primary);

    display: flex;
    align-items: center;
    justify-content: center;
}

#barwa-ask-root .barwa-ask-welcome-icon svg {
    width: 34px;
    height: 34px;
}

#barwa-ask-root .barwa-ask-welcome-title {
    margin: 0 0 8px;

    color: var(--barwa-text);

    font-family: inherit;
    font-size: 22px;
    line-height: 29px;
    font-weight: 700;
}

#barwa-ask-root .barwa-ask-welcome-text {
    margin: 0;

    color: var(--barwa-muted);

    font-size: 14px;
    line-height: 22px;
}

/* Arabic script needs a little more line height */
#barwa-ask-root[dir="rtl"] .barwa-ask-welcome-title {
    line-height: 34px;
}

#barwa-ask-root[dir="rtl"] .barwa-ask-welcome-text {
    line-height: 25px;
}

/* ------------------------------------------------------------
   Copilot iframe
   ------------------------------------------------------------ */

#barwa-ask-root .barwa-ask-iframe {
    position: absolute;
    top: calc(-1 * var(--barwa-iframe-crop));
    left: 0;

    width: 100%;
    height: calc(100% + var(--barwa-iframe-crop));

    border: 0;

    display: block;

    background: #ffffff;
}

/* ------------------------------------------------------------
   Loading Indicator
   ------------------------------------------------------------ */

#barwa-ask-root .barwa-ask-loading {
    position: absolute;

    inset: 0;

    z-index: 3;

    background: rgba(255, 255, 255, 0.96);

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    opacity: 0;
    visibility: hidden;

    transition:
        opacity 0.2s ease,
        visibility 0.2s ease;
}

#barwa-ask-root .barwa-ask-loading.is-visible {
    opacity: 1;
    visibility: visible;
}

#barwa-ask-root .barwa-ask-spinner {
    width: 32px;
    height: 32px;

    border: 3px solid #eeeeee;
    border-top-color: var(--barwa-primary);

    border-radius: 50%;

    animation: barwaAskSpin 0.8s linear infinite;
}

#barwa-ask-root .barwa-ask-loading-text {
    margin-top: 12px;

    color: var(--barwa-muted);

    font-size: 13px;
}

@keyframes barwaAskSpin {
    to {
        transform: rotate(360deg);
    }
}

/* ------------------------------------------------------------
   Footer
   ------------------------------------------------------------ */

#barwa-ask-root .barwa-ask-footer {
    height: 31px;
    min-height: 31px;

    padding: 0 12px;

    background: #fafafa;

    border-top: 1px solid var(--barwa-border);

    color: #999999;

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 10px;
    line-height: 1;

    flex-shrink: 0;
}

/* ------------------------------------------------------------
   Reduced Motion
   ------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
    #barwa-ask-root .barwa-ask-button,
    #barwa-ask-root .barwa-ask-window,
    #barwa-ask-root .barwa-ask-welcome,
    #barwa-ask-root .barwa-ask-loading {
        transition: none;
    }

    #barwa-ask-root .barwa-ask-spinner {
        animation: none;
    }
}

/* ------------------------------------------------------------
   Tablet
   ------------------------------------------------------------ */

@media (max-width: 700px) {

    #barwa-ask-root {
        --barwa-gap: 20px;
    }

    #barwa-ask-root .barwa-ask-window {
        inset-inline-end: 16px;
        bottom: 88px;

        width: calc(100vw - 32px);
        height: calc(100vh - 110px);

        min-height: 450px;
    }
}

/* ------------------------------------------------------------
   Mobile
   ------------------------------------------------------------ */

@media (max-width: 480px) {

    #barwa-ask-root {
        --barwa-gap: 15px;
    }

    #barwa-ask-root .barwa-ask-button {
        min-width: 56px;
        width: 56px;
        height: 56px;

        padding: 0;
    }

    #barwa-ask-root .barwa-ask-button-label {
        display: none;
    }

    #barwa-ask-root .barwa-ask-window {
        inset: 8px;

        width: auto;
        height: auto;
        min-height: 0;

        border-radius: 12px;
    }

    #barwa-ask-root .barwa-ask-header {
        height: 66px;
        min-height: 66px;
    }

    #barwa-ask-root .barwa-ask-logo {
        width: 39px;
        height: 39px;

        margin-inline-end: 9px;

        font-size: 20px;
    }

    #barwa-ask-root .barwa-ask-title {
        font-size: 16px;
    }

    #barwa-ask-root .barwa-ask-subtitle {
        font-size: 10px;
    }
}
