/* ============================================================
   Qafilet Al-Nour — AI Chat Widget (RTL)
   Brand green: #0a7f11
   ============================================================ */

.qn-chat-launcher {
    position: fixed;
    bottom: 85px;
    right: 20px;
    z-index: 1001;
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #0a7f11, #0c9a14);
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 18px rgba(10, 127, 17, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.qn-chat-launcher:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(10, 127, 17, 0.6);
}
.qn-chat-launcher .qn-chat-launcher-icon {
    font-size: 26px;
    line-height: 1;
}
/* AI robot icon (Font Awesome 5 Pro solid — the family bundled with the site) */
.qn-chat-launcher .qn-chat-launcher-icon::before {
    content: "\f544";
    font-family: "Font Awesome 5 Pro";
    font-weight: 900;
}
.qn-chat-launcher[aria-expanded="true"] .qn-chat-launcher-icon::before {
    content: "\f00d"; /* × */
    font-family: "Font Awesome 5 Pro";
    font-weight: 900;
    font-size: 22px;
}

/* Typing indicator inside the launcher while waiting for a reply */
.qn-chat-launcher.qn-chat-loading .qn-chat-launcher-icon {
    animation: qn-pulse 1s infinite;
}
@keyframes qn-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

/* New-message dot on the launcher */
.qn-chat-launcher .qn-chat-dot {
    position: absolute;
    top: 0;
    left: 0;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #e53e3e;
    border: 2px solid #fff;
    display: none;
}
.qn-chat-launcher.has-unread .qn-chat-dot {
    display: block;
}

/* ---------- Panel ---------- */
.qn-chat-panel {
    position: fixed;
    bottom: 150px;
    right: 20px;
    z-index: 1002;
    width: 360px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 180px);
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: "Droid Arabic Kufi", "Outfit", Tahoma, sans-serif;
}
.qn-chat-panel.open {
    display: flex;
    animation: qn-slide-up 0.25s ease;
}
@keyframes qn-slide-up {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Header */
.qn-chat-header {
    background: linear-gradient(135deg, #0a7f11, #0c9a14);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.qn-chat-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.qn-chat-header-titles {
    flex: 1;
    min-width: 0;
}
.qn-chat-header-title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.3;
}
.qn-chat-header-status {
    margin: 0;
    font-size: 12px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 5px;
}
.qn-chat-header-status .qn-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #7dffb0;
    display: inline-block;
}
.qn-chat-header-close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    opacity: 0.85;
}
.qn-chat-header-close:hover {
    opacity: 1;
}

/* Messages area */
.qn-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    background: #f5f7f5;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.qn-msg {
    max-width: 82%;
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-wrap: break-word;
    text-align: right;
}
.qn-msg.user {
    align-self: flex-start; /* in RTL page, flex-start = right side visually handled below */
    background: #0a7f11;
    color: #fff;
    border-bottom-left-radius: 4px;
}
.qn-msg.bot {
    align-self: flex-end;
    background: #fff;
    color: #1a1a1a;
    border: 1px solid #e2e6e2;
    border-bottom-right-radius: 4px;
    white-space: normal; /* markdown renders as real HTML, not pre-wrapped text */
}
/* Markdown elements inside bot replies */
.qn-msg.bot ol,
.qn-msg.bot ul {
    margin: 4px 0;
    padding-inline-start: 22px;
}
.qn-msg.bot li {
    margin-bottom: 2px;
}
.qn-msg.bot .qn-md-h {
    margin: 4px 0 2px;
    font-size: 15px;
}
.qn-msg.bot code {
    background: #eef1ee;
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 13px;
}
.qn-msg.bot a {
    color: #0a7f11;
    text-decoration: underline;
    word-break: break-all;
}
.qn-msg.error {
    background: #fdecec;
    color: #9b2c2c;
    border: 1px solid #f5c2c2;
    align-self: flex-end;
}

/* Typing bubbles */
.qn-typing {
    align-self: flex-end;
    background: #fff;
    border: 1px solid #e2e6e2;
    border-radius: 14px;
    border-bottom-right-radius: 4px;
    padding: 12px 16px;
    display: none;
}
.qn-typing span {
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-inline-start: 4px;
    background: #9aa89a;
    border-radius: 50%;
    animation: qn-blink 1.2s infinite;
}
.qn-typing span:nth-child(2) { animation-delay: 0.2s; }
.qn-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes qn-blink {
    0%, 80%, 100% { opacity: 0.3; }
    40% { opacity: 1; }
}

/* Quick-reply chips */
.qn-chat-quick {
    padding: 8px 14px 2px;
    background: #f5f7f5;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.qn-chat-quick button {
    background: #fff;
    border: 1px solid #0a7f11;
    color: #0a7f11;
    font-size: 12px;
    padding: 5px 11px;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    font-family: inherit;
}
.qn-chat-quick button:hover {
    background: #0a7f11;
    color: #fff;
}

/* ---------- Booking form ---------- */
.qn-booking-msg {
    max-width: 92%;
    background: #f0faf1;
    border: 1px solid #bfe4c3;
}
.qn-booking-title {
    font-weight: 700;
    font-size: 14px;
    color: #0a7f11;
    margin-bottom: 2px;
}
.qn-booking-sub {
    font-size: 12px;
    color: #4a6b4d;
    margin-bottom: 8px;
}
.qn-booking-form label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #2f4a32;
    margin: 7px 0 3px;
}
.qn-booking-form input,
.qn-booking-form select {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #cdd8ce;
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 13px;
    font-family: inherit;
    background: #fff;
    color: #1a1a1a;
    outline: none;
}
.qn-booking-form input:focus,
.qn-booking-form select:focus {
    border-color: #0a7f11;
    box-shadow: 0 0 0 2px rgba(10, 127, 17, 0.12);
}
.qn-booking-send {
    width: 100%;
    margin-top: 10px;
    border: none;
    border-radius: 999px;
    padding: 9px 12px;
    font-size: 13px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    color: #fff;
    background: linear-gradient(135deg, #0a7f11, #0c9a14);
    transition: filter 0.15s ease;
}
.qn-booking-send:hover { filter: brightness(1.1); }
.qn-booking-err {
    color: #b91c1c;
    font-size: 12px;
    margin-top: 6px;
    min-height: 0;
}
.qn-booking-err:empty { display: none; }
.qn-booking-success {
    font-size: 13px;
    color: #14532d;
    line-height: 1.6;
}
.qn-booking-again {
    display: inline-block;
    margin-top: 6px;
    font-size: 12px;
    color: #0a7f11;
    text-decoration: underline;
}

/* Input row */
.qn-chat-input-row {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    background: #fff;
    border-top: 1px solid #e7ebe7;
}
.qn-chat-input-row input {
    flex: 1;
    border: 1px solid #d8ded8;
    border-radius: 999px;
    padding: 9px 15px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    background: #fafbfa;
}
.qn-chat-input-row input:focus {
    border-color: #0a7f11;
    background: #fff;
}
.qn-chat-send {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: #0a7f11;
    color: #fff;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s ease;
}
.qn-chat-send:hover { background: #0c9a14; }
.qn-chat-send:disabled {
    background: #a9c7ab;
    cursor: not-allowed;
}

/* WhatsApp hint under the panel header */
.qn-chat-wa-hint {
    display: block;
    color: #fff;
    text-decoration: underline;
    font-size: 12px;
    opacity: 0.9;
}
.qn-chat-wa-hint:hover { opacity: 1; }

/* Mobile: full-width sheet */
@media (max-width: 480px) {
    .qn-chat-panel {
        right: 10px;
        left: 10px;
        bottom: 140px;
        width: auto;
    }
    .qn-chat-launcher {
        bottom: 80px;
    }
}
