/* ── LRA course adviser — homepage chat widget ─────────────────────────────
   Self-contained: no dependencies on app.css beyond the page font stack.
   Palette mirrors the site CTA gradient (#1B5182 → #52bccb).            */

.lra-chat-launcher {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 9980;
    width: 58px;
    height: 58px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: linear-gradient(180deg, #1B5182 0%, #2a8a9e 100%);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(27, 81, 130, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 200ms ease, box-shadow 200ms ease, opacity 200ms ease;
    opacity: 0;
    transform: translateY(8px);
    overflow: visible;
}
.lra-chat-launcher.is-ready {
    opacity: 1;
    transform: translateY(0);
}
.lra-chat-launcher:hover,
.lra-chat-launcher:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(27, 81, 130, 0.45);
}
.lra-chat-launcher-avatar {
    position: absolute;
    inset: 4px;
    display: block;
    overflow: hidden;
    border-radius: 50%;
    background: #14324c;
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.45);
}
.lra-chat-launcher-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}
.lra-chat-launcher-ai {
    position: absolute;
    right: 2px;
    bottom: 2px;
    padding: 1px 4px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.72);
    background: #14324c;
    color: #fff;
    font-size: 8px;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: 0.35px;
}
.lra-chat-launcher.is-hidden {
    opacity: 0;
    pointer-events: none;
}
.lra-chat-launcher .lra-chat-launcher-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #2fb377;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(27, 81, 130, 0.16);
}

.lra-chat-panel {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 9981;
    padding: 0;
    margin: 0;
    width: 384px;
    max-width: calc(100vw - 32px);
    max-height: min(620px, calc(100vh - 48px));
    display: none;
    flex-direction: column;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 18px 48px rgba(15, 35, 60, 0.28);
    overflow: hidden;
    font-size: 15px;
    line-height: 1.45;
    color: #111827;
}
.lra-chat-panel.is-open {
    display: flex;
    animation: lra-chat-in 240ms ease;
}
@keyframes lra-chat-in {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
    .lra-chat-panel.is-open { animation: none; }
    .lra-chat-launcher { transition: none; }
}

.lra-chat-header {
    background: linear-gradient(135deg, #1B5182 0%, #24648f 65%, #2a8a9e 100%);
    color: #fff;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.lra-chat-avatar {
    flex: 0 0 auto;
    width: 46px;
    height: 46px;
    padding: 0;
    border: 2px solid rgba(255, 255, 255, 0.55);
    border-radius: 50%;
    overflow: hidden;
    background: #14324c;
}
.lra-chat-avatar {
    position: relative;
}
.lra-chat-avatar-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}
/* Honest-AI disclosure on the avatar (EU AI Act Art. 50 alignment). */
.lra-chat-avatar-badge {
    position: absolute;
    bottom: -1px;
    right: -1px;
    background: #14324c;
    color: #fff;
    font-size: 8.5px;
    font-weight: 700;
    letter-spacing: 0.4px;
    padding: 1px 4px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.7);
    line-height: 1.3;
}
.lra-chat-header-text { flex: 1 1 auto; }
.lra-chat-title {
    font-weight: 700;
    font-size: 16px;
    margin: 0;
}
.lra-chat-subtitle {
    margin: 2px 0 0;
    font-size: 12.5px;
    opacity: 0.95;
}
.lra-chat-close {
    flex: 0 0 auto;
    border: none;
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.lra-chat-close:hover,
.lra-chat-close:focus-visible { background: rgba(255, 255, 255, 0.3); }

.lra-chat-thread {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f7fafc;
}
.lra-chat-msg {
    max-width: 86%;
    padding: 10px 13px;
    border-radius: 14px;
    white-space: pre-line;
}
.lra-chat-msg--bot {
    align-self: flex-start;
    background: #ffffff;
    border: 1px solid #e6ebf1;
    border-bottom-left-radius: 5px;
}
.lra-chat-msg--gift {
    position: relative;
    background: linear-gradient(135deg, #fff9dc 0%, #f0fff5 58%, #eaf7ff 100%);
    border-color: #9fe98d;
    box-shadow: inset 4px 0 0 #7bea72, 0 8px 22px rgba(27, 81, 130, 0.11);
}
.lra-chat-msg--gift::before {
    content: "";
    position: absolute;
    top: -1px;
    right: 14px;
    width: 36px;
    height: 4px;
    border-radius: 999px;
    background: linear-gradient(90deg, #f4be35 0%, #7bea72 52%, #52bccb 100%);
}
.lra-chat-msg--user {
    align-self: flex-end;
    background: #1B5182;
    color: #fff;
    border-bottom-right-radius: 5px;
}
.lra-chat-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 12px 14px;
}
.lra-chat-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #9db4c8;
    animation: lra-chat-blink 900ms infinite both;
}
.lra-chat-typing span:nth-child(2) { animation-delay: 150ms; }
.lra-chat-typing span:nth-child(3) { animation-delay: 300ms; }
@keyframes lra-chat-blink {
    0%, 80%, 100% { opacity: 0.35; }
    40% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
    .lra-chat-typing span { animation: none; }
}

.lra-chat-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-self: stretch;
    margin-top: 2px;
}
.lra-chat-chip {
    border: 1px solid #1B5182;
    background: #fff;
    color: #1B5182;
    border-radius: 999px;
    padding: 7px 14px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 150ms ease, color 150ms ease;
    text-align: left;
}
.lra-chat-chip:hover,
.lra-chat-chip:focus-visible {
    background: #1B5182;
    color: #fff;
}
.lra-chat-chip--primary {
    background: linear-gradient(180deg, #1B5182 0%, #2a8a9e 100%);
    border: none;
    color: #fff;
}
.lra-chat-chip--primary:hover,
.lra-chat-chip--primary:focus-visible {
    filter: brightness(1.08);
    background: linear-gradient(180deg, #1B5182 0%, #2a8a9e 100%);
}
.lra-chat-chip--gift {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
    position: relative;
    overflow: hidden;
    border-color: #9fe98d;
    background: linear-gradient(135deg, #fff8d7 0%, #ecfff2 54%, #e5f8ff 100%);
    color: #14324c;
    box-shadow: 0 0 0 3px rgba(127, 234, 114, 0.28), 0 10px 24px rgba(27, 81, 130, 0.14);
}
.lra-chat-chip--gift::before {
    content: "";
    flex: 0 0 22px;
    width: 22px;
    height: 8px;
    margin: 0;
    border-radius: 999px;
    background:
        radial-gradient(circle 4px at 4px 50%, #f4be35 99%, transparent 100%),
        radial-gradient(circle 4px at 16px 50%, #7bea72 99%, transparent 100%);
    box-shadow: none;
}
.lra-chat-chip--gift:hover,
.lra-chat-chip--gift:focus-visible {
    background: linear-gradient(135deg, #14324c 0%, #1f7c70 68%, #f4be35 150%);
    color: #fff;
}
.lra-chat-chip--primary.lra-chat-chip--gift {
    border: 1px solid rgba(255, 255, 255, 0.62);
    background: linear-gradient(135deg, #1B5182 0%, #23856e 62%, #f4be35 150%);
    color: #fff;
}
.lra-chat-chip--primary.lra-chat-chip--gift:hover,
.lra-chat-chip--primary.lra-chat-chip--gift:focus-visible {
    filter: brightness(1.06);
    background: linear-gradient(135deg, #14324c 0%, #1f7c70 62%, #f4be35 150%);
}
a.lra-chat-chip { text-decoration: none; display: inline-block; }
a.lra-chat-chip.lra-chat-chip--gift { display: inline-flex; }

.lra-chat-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-self: stretch;
    background: #ffffff;
    border: 1px solid #e6ebf1;
    border-radius: 14px;
    padding: 12px;
}
.lra-chat-form--gift {
    background: linear-gradient(135deg, #fff9dc 0%, #f5fff7 62%, #edf9ff 100%);
    border-color: #9fe98d;
    box-shadow: inset 4px 0 0 #7bea72, 0 8px 22px rgba(27, 81, 130, 0.11);
}
.lra-chat-form label {
    font-size: 12.5px;
    font-weight: 600;
    color: #475467;
}
.lra-chat-form input[type="text"],
.lra-chat-form input[type="email"],
.lra-chat-form select {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #cfd9e3;
    border-radius: 9px;
    padding: 9px 11px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
}
.lra-chat-form input:focus,
.lra-chat-form select:focus {
    outline: none;
    border-color: #1B5182;
    box-shadow: 0 0 0 3px rgba(27, 81, 130, 0.12);
}
.lra-chat-consent {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    font-size: 12px;
    color: #475467;
    font-weight: 400;
}
.lra-chat-consent input { margin-top: 2px; }
.lra-chat-consent a { color: #1B5182; }
.lra-chat-form .lra-chat-error {
    color: #b42318;
    font-size: 12.5px;
    display: none;
}
.lra-chat-form .lra-chat-error.is-visible { display: block; }
.lra-chat-submit {
    border: none;
    border-radius: 999px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    color: #fff;
    background: linear-gradient(180deg, #1B5182 0%, #2a8a9e 100%);
    cursor: pointer;
}
.lra-chat-submit--gift {
    background: linear-gradient(135deg, #1B5182 0%, #23856e 62%, #f4be35 150%);
    box-shadow: 0 8px 18px rgba(35, 133, 110, 0.22);
}
.lra-chat-submit:disabled { opacity: 0.6; cursor: default; }
.lra-chat-hp { position: absolute; left: -9999px; height: 0; overflow: hidden; }

/* Rich (markdown) assistant messages */
.lra-chat-msg--rich { white-space: normal; }
.lra-chat-msg--rich p { margin: 0 0 8px; }
.lra-chat-msg--rich p:last-child { margin-bottom: 0; }
.lra-chat-msg--rich ul,
.lra-chat-msg--rich ol { margin: 0 0 8px; padding-left: 18px; }
.lra-chat-msg--rich ul { list-style: disc; }
.lra-chat-msg--rich ol { list-style: decimal; }
.lra-chat-msg--rich li { margin: 2px 0; }
.lra-chat-msg--rich code {
    background: #eef3f7;
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 13px;
}
.lra-chat-msg--rich a { color: #1B5182; font-weight: 600; }
.rtl .lra-chat-msg--rich ul,
.rtl .lra-chat-msg--rich ol { padding-left: 0; padding-right: 18px; }
.rtl .lra-chat-msg--gift {
    box-shadow: inset -4px 0 0 #7bea72, 0 8px 22px rgba(27, 81, 130, 0.11);
}
.rtl .lra-chat-msg--gift::before { right: auto; left: 14px; }
.rtl .lra-chat-chip--gift::before { margin: 0; }
.rtl .lra-chat-form--gift {
    box-shadow: inset -4px 0 0 #7bea72, 0 8px 22px rgba(27, 81, 130, 0.11);
}

/* Free-chat input bar */
.lra-chat-inputbar {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    padding: 10px 12px;
    border-top: 1px solid #e6ebf1;
    background: #fff;
}
.lra-chat-inputbar[hidden] { display: none; }
.lra-chat-inputbar textarea {
    flex: 1 1 auto;
    resize: none;
    border: 1px solid #cfd9e3;
    border-radius: 12px;
    padding: 9px 12px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.4;
    max-height: 96px;
}
.lra-chat-inputbar textarea:focus {
    outline: none;
    border-color: #1B5182;
    box-shadow: 0 0 0 3px rgba(27, 81, 130, 0.12);
}
.lra-chat-inputbar button[type="submit"] {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(180deg, #1B5182 0%, #2a8a9e 100%);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.lra-chat-inputbar button[type="submit"] svg { width: 18px; height: 18px; }
.lra-chat-inputbar button[type="submit"]:disabled { opacity: 0.55; cursor: default; }
.rtl .lra-chat-inputbar button[type="submit"] svg { transform: scaleX(-1); }

.lra-chat-footer {
    padding: 9px 14px;
    border-top: 1px solid #e6ebf1;
    background: #fff;
    font-size: 12px;
    color: #667085;
    display: flex;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}
.lra-chat-footer a {
    color: #1B5182;
    font-weight: 600;
    text-decoration: none;
}
.lra-chat-footer a:hover { text-decoration: underline; }

/* Course-page re-engagement teaser — a small bubble above the launcher. */
.lra-chat-teaser {
    position: fixed;
    right: 24px;
    bottom: 92px;
    z-index: 9980;
    max-width: 290px;
    display: flex;
    align-items: flex-start;
    gap: 2px;
    background: #ffffff;
    border: 1px solid #e6ebf1;
    border-radius: 14px;
    box-shadow: 0 12px 32px rgba(15, 35, 60, 0.20);
    padding: 4px;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 220ms ease, transform 220ms ease;
}
.lra-chat-teaser.is-shown { opacity: 1; transform: translateY(0); }
.lra-chat-teaser-body {
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    font-size: 13.5px;
    line-height: 1.45;
    text-align: left;
    color: #1f3148;
    padding: 9px 4px 9px 12px;
}
.lra-chat-teaser-close {
    flex: 0 0 auto;
    border: none;
    background: transparent;
    cursor: pointer;
    color: #98a4b3;
    font-size: 18px;
    line-height: 1;
    padding: 7px 9px;
    border-radius: 8px;
}
.lra-chat-teaser-close:hover,
.lra-chat-teaser-close:focus-visible { color: #475467; background: #f1f4f8; }
.rtl .lra-chat-teaser { right: auto; left: 24px; }
.rtl .lra-chat-teaser-body { text-align: right; padding: 9px 12px 9px 4px; }
@media (max-width: 600px) {
    .lra-chat-teaser { right: 16px; bottom: 84px; max-width: calc(100vw - 92px); }
    .rtl .lra-chat-teaser { left: 16px; right: auto; }
}
@media (prefers-reduced-motion: reduce) {
    .lra-chat-teaser { transition: none; }
}

/* While the get-in-touch modal is open, the widget yields entirely —
   no stacking-context fights with the modal mask (z 500 / modal 20000). */
body.v2-modal-open #lra-chat { display: none; }

/* Mobile: bottom sheet */
@media (max-width: 600px) {
    .lra-chat-panel {
        right: 8px;
        left: 8px;
        bottom: 8px;
        width: auto;
        max-height: min(78vh, 560px);
    }
    .lra-chat-launcher { right: 16px; bottom: 16px; }
}

/* RTL (body.rtl set by base template for Arabic) */
.rtl .lra-chat-launcher { right: auto; left: 24px; }
.rtl .lra-chat-panel { right: auto; left: 24px; }
.rtl .lra-chat-msg--bot { align-self: flex-end; border-bottom-left-radius: 14px; border-bottom-right-radius: 5px; }
.rtl .lra-chat-msg--user { align-self: flex-start; border-bottom-right-radius: 14px; border-bottom-left-radius: 5px; }
.rtl .lra-chat-chip { text-align: right; }
@media (max-width: 600px) {
    .rtl .lra-chat-panel { left: 8px; right: 8px; }
    .rtl .lra-chat-launcher { left: 16px; }
}
