/* Website chat widget (app/Views/inc/chatbot.php) */
.ecb {
    --ecb-navy: #042c4d;
    --ecb-navy-deep: #021a2e;
    --ecb-gold: #94824f;
    --ecb-gold-deep: #6f6039;
    --ecb-gold-light: #c2ac7a;
    --ecb-bg: #f7f4ee;
    --ecb-line: #e5ddc9;
    --ecb-ink: #16232f;
    --ecb-muted: #5d6b78;
    font-family: Inter, system-ui, -apple-system, sans-serif;
    font-size: 14.5px;
    line-height: 1.5;
    color: var(--ecb-ink);
}

.ecb *, .ecb *::before, .ecb *::after { box-sizing: border-box; }

/* The theme's scroll-to-top button shares this corner; lift it above the launcher,
   and hide it while the chat is open so it doesn't peek out under the panel. */
.scroll-top { bottom: 98px; }
body:has(.ecb.is-open) .scroll-top { opacity: 0; visibility: hidden; }

/* The theme animates every button over .4s; keep the widget's controls snappy. */
.ecb-panel button { transition: background-color .15s ease, opacity .15s ease, border-color .15s ease; }

.ecb-launcher {
    position: fixed;
    right: 26px;
    bottom: 26px;
    z-index: 10001;
    width: 58px;
    height: 58px;
    border: 0;
    border-radius: 50%;
    background: linear-gradient(160deg, var(--ecb-navy), var(--ecb-navy-deep));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 12px 28px -8px rgba(4, 44, 77, .55);
    transition: transform .25s ease, box-shadow .25s ease;
}
.ecb-launcher:hover { transform: scale(1.06); box-shadow: 0 16px 34px -8px rgba(4, 44, 77, .7); }
.ecb-launcher:focus-visible { outline: 3px solid var(--ecb-gold-light); outline-offset: 3px; }
.ecb-launcher svg {
    position: absolute;
    width: 31px;
    height: 31px;
    fill: currentColor;
    transition: opacity .2s ease, transform .3s cubic-bezier(.2, .9, .3, 1.2);
}
/* AI sparkle icon: outlined bubble, gold sparkles. */
.ecb-icon-bubble { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; }
.ecb-icon-spark { fill: var(--ecb-gold-light); transform-box: fill-box; transform-origin: center; }
.ecb-launcher:hover .ecb-icon-spark-sm,
.ecb.is-teasing .ecb-icon-spark-sm { animation: ecb-twinkle 1.6s ease-in-out infinite; }
@keyframes ecb-twinkle {
    0%, 100% { transform: scale(1) rotate(0); opacity: 1; }
    50% { transform: scale(.45) rotate(45deg); opacity: .6; }
}
.ecb-launcher::after {
    /* Gold ring that marks the launcher as the brand's assistant. */
    content: "";
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    border: 2px solid var(--ecb-gold);
    opacity: .9;
}
.ecb-icon-close { opacity: 0; transform: rotate(-90deg) scale(.6); }
.ecb.is-open .ecb-icon-chat { opacity: 0; transform: rotate(90deg) scale(.6); }
.ecb.is-open .ecb-icon-close { opacity: 1; transform: none; }

/* Soft gold pulse that draws the eye to the launcher while the greeting is up. */
.ecb.is-teasing .ecb-launcher::before {
    content: "";
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    border: 2px solid var(--ecb-gold);
    animation: ecb-pulse 1.6s ease-out infinite;
}
@keyframes ecb-pulse {
    from { opacity: .8; transform: scale(1); }
    to { opacity: 0; transform: scale(1.45); }
}

/* Greeting bubble beside the launcher (left of it, so it never covers the theme's scroll-top button). */
.ecb-teaser {
    position: fixed;
    right: 98px;
    bottom: 30px;
    z-index: 10001;
    width: max-content;
    max-width: min(290px, calc(100vw - 120px));
    display: flex;
    align-items: flex-start;
    background: #fff;
    border: 1px solid var(--ecb-line);
    border-radius: 16px 16px 4px 16px;
    overflow: hidden;
    box-shadow: 0 18px 40px -14px rgba(2, 26, 46, .4);
    opacity: 0;
    visibility: hidden;
    transform: translateX(14px) scale(.9);
    transform-origin: right bottom;
    transition: opacity .2s ease, transform .25s ease, visibility 0s linear .25s;
}
.ecb-teaser.is-visible {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: opacity .25s ease, transform .4s cubic-bezier(.2, .9, .3, 1.25), visibility 0s;
}
.ecb-teaser button { transition: background-color .15s ease, color .15s ease; }
.ecb-teaser-body {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 4px 14px 12px;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.ecb-teaser-body:focus-visible { outline: 2px solid var(--ecb-gold); outline-offset: -4px; border-radius: 12px; }
.ecb-teaser-avatar { width: 34px; height: 34px; }
.ecb-teaser-avatar img { width: 20px; height: 20px; }
.ecb-teaser-text { min-width: 0; }
.ecb-teaser-text strong { display: block; font-size: 12.5px; font-weight: 600; color: var(--ecb-gold-deep); letter-spacing: .01em; }
.ecb-teaser-msg { display: block; margin-top: 2px; font-size: 14px; line-height: 1.4; color: var(--ecb-ink); }
.ecb-teaser-dots { display: none; gap: 4px; padding: 8px 0 4px; }
.ecb-teaser-dots i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--ecb-muted);
    animation: ecb-dot 1.1s infinite ease-in-out;
}
.ecb-teaser-dots i:nth-child(2) { animation-delay: .15s; }
.ecb-teaser-dots i:nth-child(3) { animation-delay: .3s; }
.ecb-teaser.is-typing .ecb-teaser-dots { display: flex; }
.ecb-teaser.is-typing .ecb-teaser-msg { display: none; }
.ecb-teaser-close {
    flex: none;
    width: 26px;
    height: 26px;
    margin: 6px 6px 0 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--ecb-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.ecb-teaser-close:hover { background: var(--ecb-bg); color: var(--ecb-ink); }
.ecb-teaser-close:focus-visible { outline: 2px solid var(--ecb-gold); }
.ecb-teaser-close svg { width: 14px; height: 14px; fill: currentColor; }
/* Countdown bar: when it runs out, chatbot.js hides the greeting. Hovering or focusing pauses it. */
.ecb-teaser-timer {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--ecb-gold-light), var(--ecb-gold));
    transform-origin: left;
    transform: scaleX(0);
}
.ecb-teaser.is-counting .ecb-teaser-timer { animation: ecb-countdown 8s linear forwards; }
.ecb-teaser:hover .ecb-teaser-timer,
.ecb-teaser:focus-within .ecb-teaser-timer { animation-play-state: paused; }
@keyframes ecb-countdown {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

.ecb-panel {
    position: fixed;
    right: 26px;
    bottom: 100px;
    z-index: 10001;
    width: 380px;
    height: min(580px, calc(100vh - 130px));
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid var(--ecb-line);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 24px 60px -18px rgba(2, 26, 46, .45);
    animation: ecb-in .2s ease-out;
}
.ecb-panel[hidden] { display: none; }

@keyframes ecb-in {
    from { opacity: 0; transform: translateY(12px) scale(.98); }
    to { opacity: 1; transform: none; }
}

.ecb-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 14px 14px 16px;
    background: linear-gradient(160deg, var(--ecb-navy-deep), var(--ecb-navy));
    color: #fff;
}
.ecb-avatar {
    flex: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--ecb-gold-light);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.ecb-avatar img { width: 24px; height: 24px; object-fit: contain; }
.ecb-head-text { flex: 1; min-width: 0; }
.ecb-head-text strong { display: block; font-size: 15px; font-weight: 600; color: #fff; }
.ecb-head-text span { display: block; font-size: 12px; color: rgba(255, 255, 255, .7); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ecb-close {
    flex: none;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.ecb-close:hover { background: rgba(255, 255, 255, .12); }
.ecb-close:focus-visible { outline: 2px solid var(--ecb-gold-light); }
.ecb-close svg { width: 20px; height: 20px; fill: currentColor; }

.ecb-messages {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px 14px 8px;
    background: var(--ecb-bg);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.ecb-msg {
    max-width: 86%;
    padding: 10px 13px;
    border-radius: 14px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.ecb-msg-bot {
    align-self: flex-start;
    background: #fff;
    border: 1px solid var(--ecb-line);
    border-bottom-left-radius: 4px;
}
.ecb-msg-user {
    align-self: flex-end;
    background: var(--ecb-navy);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.ecb-msg a { color: var(--ecb-navy); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.ecb-msg-user a { color: #fff; }
.ecb-msg-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    padding: 7px 14px;
    border-radius: 999px;
    background: var(--ecb-gold);
    color: #fff !important;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none !important;
    white-space: nowrap;
}
.ecb-msg-link:hover { background: var(--ecb-gold-deep); }
.ecb-msg-error { border-color: #fecdca; background: #fef3f2; color: #b42318; }

.ecb-typing { display: inline-flex; gap: 4px; padding: 13px 14px; }
.ecb-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ecb-muted);
    opacity: .4;
    animation: ecb-dot 1.1s infinite ease-in-out;
}
.ecb-typing span:nth-child(2) { animation-delay: .15s; }
.ecb-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes ecb-dot {
    0%, 80%, 100% { opacity: .35; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-3px); }
}

.ecb-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 14px 10px;
    background: var(--ecb-bg);
}
.ecb-chips:empty { display: none; }
.ecb-chip {
    border: 1px solid var(--ecb-gold-light);
    background: #fff;
    color: var(--ecb-navy);
    border-radius: 999px;
    padding: 6px 12px;
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
}
.ecb-chip:hover { background: #fdf6e7; border-color: var(--ecb-gold); }
.ecb-chip:focus-visible { outline: 2px solid var(--ecb-gold); outline-offset: 1px; }

.ecb-form {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--ecb-line);
    background: #fff;
}
.ecb-form input {
    flex: 1;
    min-width: 0;
    height: 42px;
    padding: 0 14px;
    border: 1px solid var(--ecb-line);
    border-radius: 999px;
    font: inherit;
    font-size: 16px; /* stops iOS zooming into the field */
    color: var(--ecb-ink);
    background: #fff;
}
.ecb-form input:focus { outline: none; border-color: var(--ecb-gold); box-shadow: 0 0 0 3px rgba(148, 130, 79, .18); }
.ecb-send {
    flex: none;
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 50%;
    background: var(--ecb-gold);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.ecb-send:hover { background: var(--ecb-gold-deep); }
.ecb-send:disabled { opacity: .55; cursor: default; }
.ecb-send:focus-visible { outline: 2px solid var(--ecb-navy); outline-offset: 2px; }
.ecb-send svg { width: 19px; height: 19px; fill: currentColor; }

.ecb-powered {
    margin: 0;
    padding: 0 12px 10px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    background: #fff;
    text-align: center;
    font-size: 11.5px;
    line-height: 1.4;
    color: var(--ecb-muted);
}
.ecb-powered a { color: var(--ecb-gold-deep); font-weight: 600; text-decoration: none; }
.ecb-powered a:hover { text-decoration: underline; text-underline-offset: 2px; }
.ecb-powered a:focus-visible { outline: 2px solid var(--ecb-gold); outline-offset: 2px; border-radius: 2px; }

.ecb-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

@media (max-width: 767px) {
    .scroll-top { bottom: 86px; }
    .ecb-launcher { right: 16px; bottom: 16px; width: 52px; height: 52px; }
    .ecb-launcher svg { width: 28px; height: 28px; }
    .ecb-teaser { right: 80px; bottom: 18px; max-width: calc(100vw - 100px); }
    /* Full-screen sheet on phones; the header's close button replaces the launcher. */
    .ecb-panel {
        inset: 0;
        width: auto;
        height: auto;
        border: 0;
        border-radius: 0;
    }
    .ecb.is-open .ecb-launcher { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .ecb-panel, .ecb-typing span, .ecb-teaser-dots i, .ecb-icon-spark-sm { animation: none !important; }
    .ecb.is-teasing .ecb-launcher::before { display: none; }
    .ecb-launcher, .ecb-launcher svg { transition: none; }
    .ecb-teaser, .ecb-teaser.is-visible { transform: none; transition: opacity .2s ease, visibility 0s linear .2s; }
    .ecb-teaser.is-visible { transition: opacity .2s ease, visibility 0s; }
}
