/* ==========================================================================
   Haya Al Tamayuz — enquiry assistant widget
   Self-contained. Pairs with assets/js/haya-chat.js.
   Sits above the scroll-progress ring; mirrors itself on RTL pages.
   ========================================================================== */

.haya-chat {
    --chat-navy: #0B4B79;
    --chat-navy-deep: #073A5E;
    --chat-red: #D3131C;
    --chat-ink: #1C2539;
    --chat-line: #E4E9EE;

    position: fixed;
    right: 30px;
    bottom: 92px;
    z-index: 1800;
    font-family: "Red Hat Display", "DM Sans", system-ui, sans-serif;
}

.haya-chat.is-rtl {
    right: auto;
    left: 30px;
    font-family: "Tajawal", "Segoe UI", Tahoma, sans-serif;
}

@media only screen and (max-width: 575px) {
    .haya-chat { right: 16px; bottom: 84px; }
    .haya-chat.is-rtl { right: auto; left: 16px; }
}

/* ------------------------------------------------------------------ launcher */
.haya-chat__launcher {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    height: 52px;
    padding: 0 22px;
    border: 0;
    border-radius: 26px;
    background: var(--chat-navy);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 10px 26px rgba(11, 75, 121, .30);
    transition: background .25s ease, transform .25s ease, box-shadow .25s ease;
}

.haya-chat__launcher:hover {
    background: var(--chat-navy-deep);
    transform: translateY(-2px);
    box-shadow: 0 14px 32px rgba(11, 75, 121, .38);
}

.haya-chat__launcher-icon {
    display: inline-flex;
    line-height: 0;
}

.haya-chat.is-open .haya-chat__launcher-text {
    display: none;
}

.haya-chat.is-open .haya-chat__launcher {
    width: 52px;
    padding: 0;
    justify-content: center;
    background: var(--chat-red);
}

@media only screen and (max-width: 420px) {
    .haya-chat__launcher-text { display: none; }
    .haya-chat__launcher { width: 52px; padding: 0; justify-content: center; }
}

/* --------------------------------------------------------------------- panel */
.haya-chat__panel {
    position: absolute;
    right: 0;
    bottom: 66px;
    width: 358px;
    max-width: calc(100vw - 32px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--chat-line);
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 24px 60px rgba(28, 37, 57, .20);
    opacity: 0;
    transform: translateY(12px);
    transition: opacity .2s ease, transform .2s ease;
}

.haya-chat.is-rtl .haya-chat__panel {
    right: auto;
    left: 0;
}

.haya-chat.is-open .haya-chat__panel {
    opacity: 1;
    transform: translateY(0);
}

/* --------------------------------------------------------------------- head */
.haya-chat__head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    background: var(--chat-navy);
    color: #fff;
}

.haya-chat__avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border-radius: 11px;
    background: rgba(255, 255, 255, .12);
}

.haya-chat__head-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1 1 auto;
    min-width: 0;
}

.haya-chat__head-text strong {
    font-size: 15px;
    font-weight: 700;
}

.haya-chat__head-text small {
    font-size: 12px;
    color: rgba(255, 255, 255, .72);
}

.haya-chat__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #fff;
    cursor: pointer;
    transition: background .2s ease;
}

.haya-chat__close:hover {
    background: rgba(255, 255, 255, .16);
}

/* ---------------------------------------------------------------------- log */
.haya-chat__log {
    max-height: 300px;
    min-height: 132px;
    overflow-y: auto;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #F7F9FB;
}

.haya-chat__msg {
    max-width: 88%;
    padding: 11px 15px;
    border-radius: 14px;
    font-size: 14.5px;
    line-height: 1.75;
    color: var(--chat-ink);
    background: #fff;
    border: 1px solid var(--chat-line);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.haya-chat.is-rtl .haya-chat__msg--bot {
    border-bottom-left-radius: 14px;
    border-bottom-right-radius: 4px;
}

.haya-chat__msg--user {
    align-self: flex-end;
    background: var(--chat-navy);
    border-color: var(--chat-navy);
    color: #fff;
    border-bottom-left-radius: 14px;
    border-bottom-right-radius: 4px;
}

.haya-chat.is-rtl .haya-chat__msg--user {
    border-bottom-right-radius: 14px;
    border-bottom-left-radius: 4px;
}

.haya-chat__msg a {
    color: inherit;
    text-decoration: underline;
    word-break: break-word;
}

.haya-chat__msg--bot a {
    color: var(--chat-navy);
    font-weight: 600;
}

/* typing indicator */
.haya-chat__dots {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    height: 12px;
}

.haya-chat__dots i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #9AA5B1;
    animation: haya-chat-dot 1.1s infinite ease-in-out;
}

.haya-chat__dots i:nth-child(2) { animation-delay: .16s; }
.haya-chat__dots i:nth-child(3) { animation-delay: .32s; }

@keyframes haya-chat-dot {
    0%, 60%, 100% { opacity: .3; transform: translateY(0); }
    30%           { opacity: 1;  transform: translateY(-3px); }
}

/* ------------------------------------------------------------------ actions */
.haya-chat__actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px 18px 18px;
    border-top: 1px solid var(--chat-line);
    background: #fff;
    max-height: 232px;
    overflow-y: auto;
}

.haya-chat__actions:empty {
    display: none;
}

.haya-chat__action {
    display: block;
    width: 100%;
    padding: 11px 16px;
    border: 1px solid var(--chat-line);
    border-radius: 10px;
    background: #fff;
    color: var(--chat-ink);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.5;
    text-align: start;
    cursor: pointer;
    transition: border-color .2s ease, background .2s ease, color .2s ease;
}

.haya-chat__action:hover {
    border-color: var(--chat-navy);
    background: #EAF1F7;
    color: var(--chat-navy);
}

.haya-chat__action.is-primary {
    background: var(--chat-navy);
    border-color: var(--chat-navy);
    color: #fff;
}

.haya-chat__action.is-primary:hover {
    background: var(--chat-navy-deep);
    color: #fff;
}

.haya-chat__action.is-ghost {
    border-style: dashed;
    font-weight: 500;
    color: #5D666F;
}

/* --------------------------------------------------------------- a11y focus */
.haya-chat__launcher:focus-visible,
.haya-chat__close:focus-visible,
.haya-chat__action:focus-visible {
    outline: 2px solid var(--chat-red);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .haya-chat__launcher,
    .haya-chat__panel { transition: none; }
    .haya-chat__dots i { animation: none; }
}
