/*
 * Floating AI price chat (resources/views/partials/landing/ai-chat.blade.php).
 * Self-contained: used on the landing page and inside the Metronic dashboard,
 * so it carries its own copy of the landing design tokens.
 */
.lx-chat {
    --c-brand: #1c368a;
    --c-brand-dark: #13245e;
    --c-violet: #5d78ff;
    --c-sky: #94daff;
    --c-success: #0abb87;
    --c-warn: #ffb822;
    --c-danger: #fd397a;
    --c-ink: #1e2340;
    --c-text: #3b4058;
    --c-label: #565c78;
    --c-line: #eceff8;
    --c-soft: #f5f7fe;
    --c-radius: 18px;
    --c-shadow: 0 2px 4px rgba(20, 30, 70, .05), 0 22px 48px rgba(20, 30, 70, .18);
    --c-gap: 24px;

    position: fixed;
    right: var(--c-gap);
    bottom: var(--c-gap);
    z-index: 1035; /* above fixed headers (1030), below Bootstrap modals (1040+) */
    font-family: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--c-text);
}

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

.lx-chat svg { width: 22px; height: 22px; fill: currentColor; display: block; }
.lx-chat [hidden] { display: none !important; }
.lx-chat__sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Metronic's scroll-to-top button shares the bottom-right corner: move it above the launcher. */
body:has(.lx-chat) .kt-scrolltop { bottom: 100px; }

/* ---------- Launcher ---------- */
.lx-chat__launcher {
    position: relative;
    width: 62px;
    height: 62px;
    border: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--c-brand), var(--c-violet));
    color: #fff;
    display: grid;
    place-items: center;
    cursor: pointer;
    box-shadow: 0 10px 28px rgba(28, 54, 138, .38);
    transition: transform .2s ease, box-shadow .2s ease;
    margin-left: auto;
}
.lx-chat__launcher:hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 14px 34px rgba(28, 54, 138, .45); }
.lx-chat__launcher:focus-visible { outline: 3px solid var(--c-sky); outline-offset: 3px; }
.lx-chat__launcher svg { width: 28px; height: 28px; }
.lx-chat__launcher .lx-chat__icon-close { display: none; }
.lx-chat.is-open .lx-chat__launcher .lx-chat__icon-open { display: none; }
.lx-chat.is-open .lx-chat__launcher .lx-chat__icon-close { display: block; }
.lx-chat:not(.is-open) .lx-chat__launcher::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--c-violet);
    animation: lx-chat-pulse 2.4s ease-out infinite;
}
@keyframes lx-chat-pulse {
    0% { transform: scale(1); opacity: .7; }
    80%, 100% { transform: scale(1.45); opacity: 0; }
}

/* ---------- Nudge bubble ---------- */
.lx-chat__nudge {
    position: absolute;
    right: 0;
    bottom: 76px;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    background: #fff;
    color: var(--c-ink);
    font-weight: 500;
    font-size: 14px;
    padding: 10px 12px 10px 16px;
    border-radius: 14px 14px 4px 14px;
    box-shadow: var(--c-shadow);
    animation: lx-chat-rise .35s ease both;
}
.lx-chat__nudge-close {
    border: 0;
    background: var(--c-soft);
    color: var(--c-label);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    line-height: 1;
    font-size: 16px;
}

/* ---------- Panel ---------- */
.lx-chat__panel {
    position: absolute;
    right: 0;
    bottom: 78px;
    width: min(50vw, 720px);
    min-width: 380px;
    /* Leave the site header visible above the panel. */
    height: min(calc(100vh - 230px), 720px);
    min-height: 420px;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: var(--c-radius);
    box-shadow: var(--c-shadow);
    overflow: hidden;
    animation: lx-chat-rise .25s ease both;
}
@keyframes lx-chat-rise {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: none; }
}

.lx-chat__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    background: linear-gradient(135deg, var(--c-brand), var(--c-brand-dark));
    color: #fff;
}
.lx-chat__avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(255, 255, 255, .14);
    display: grid;
    place-items: center;
    color: var(--c-sky);
    flex: none;
}
.lx-chat__title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lx-chat__title strong { font-size: 16px; font-weight: 600; color: #fff; }
.lx-chat__title span { font-size: 12.5px; opacity: .8; }
.lx-chat__close {
    border: 0;
    background: transparent;
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    cursor: pointer;
}
.lx-chat__close:hover { background: rgba(255, 255, 255, .12); }

.lx-chat__body {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    background: var(--c-soft);
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.lx-chat__messages { display: flex; flex-direction: column; gap: 12px; }

.lx-chat__bubble {
    margin: 0;
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 16px;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.lx-chat__bubble--ai {
    align-self: flex-start;
    background: #fff;
    color: var(--c-ink);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(20, 30, 70, .06);
}
.lx-chat__bubble--user {
    align-self: flex-end;
    background: var(--c-brand);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.lx-chat__bubble--error { background: #fff4f7; color: #b4204f; }
.lx-chat__bubble-file {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    opacity: .85;
    margin-top: 4px;
}
.lx-chat__bubble-file svg { width: 15px; height: 15px; }

.lx-chat__chips { display: flex; flex-wrap: wrap; gap: 8px; }
.lx-chat__chip {
    border: 1px solid #d9def2;
    background: #fff;
    color: var(--c-brand);
    font: inherit;
    font-size: 13.5px;
    font-weight: 500;
    padding: 7px 14px;
    border-radius: 999px;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}
.lx-chat__chip:hover { background: #eef1ff; border-color: var(--c-violet); }

/* ---------- Estimate card ---------- */
.lx-chat__card {
    align-self: flex-start;
    width: min(100%, 520px);
    background: #fff;
    border: 1px solid var(--c-line);
    border-radius: 16px;
    padding: 14px 16px;
    box-shadow: 0 1px 2px rgba(20, 30, 70, .06);
}
.lx-chat__card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}
.lx-chat__card-head strong { color: var(--c-ink); font-size: 14px; font-weight: 600; }
.lx-chat__pill {
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
    padding: 3px 9px;
    border-radius: 999px;
    background: #eef1ff;
    color: var(--c-violet);
}
.lx-chat__pill--high { background: #e6f8f2; color: #078a64; }
.lx-chat__pill--medium { background: #fff6e3; color: #a87300; }
.lx-chat__pill--low { background: #fff0f5; color: #c42660; }

.lx-chat__range { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.lx-chat__range div { background: var(--c-soft); border-radius: 12px; padding: 8px 10px; text-align: center; }
.lx-chat__range span { display: block; font-size: 11.5px; color: var(--c-label); text-transform: uppercase; letter-spacing: .03em; }
.lx-chat__range b { display: block; color: var(--c-ink); font-size: 15px; font-weight: 600; }
.lx-chat__range .is-typical { background: #eef1ff; }
.lx-chat__range .is-typical b { color: var(--c-brand); }

.lx-chat__items { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; }
.lx-chat__items li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-top: 1px solid var(--c-line);
    font-size: 13.5px;
}
.lx-chat__items li span:first-child { color: var(--c-ink); min-width: 0; }
.lx-chat__items small { display: block; color: var(--c-label); font-size: 12px; }
.lx-chat__items li span:last-child { text-align: right; white-space: nowrap; color: var(--c-text); }
.lx-chat__items .is-missing { color: var(--c-label); font-style: italic; }
.lx-chat__verdict { display: inline-block; margin-left: 6px; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; }
.lx-chat__verdict--high { background: #fff0f5; color: #c42660; }
.lx-chat__verdict--low { background: #fff6e3; color: #a87300; }
.lx-chat__verdict--in_range { background: #e6f8f2; color: #078a64; }

.lx-chat__cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    padding: 9px 16px;
    border-radius: 12px;
    background: var(--c-brand);
    color: #fff !important;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none !important;
    transition: background .15s;
}
.lx-chat__cta:hover { background: var(--c-violet); }

/* ---------- Waiting progress (one line; each step replaces the previous) ---------- */
.lx-chat__progress {
    align-self: flex-start;
    max-width: 90%;
    background: #fff;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    padding: 10px 14px;
    box-shadow: 0 1px 2px rgba(20, 30, 70, .06);
}
.lx-chat__steps { list-style: none; margin: 0; padding: 0; }
.lx-chat__steps li {
    display: none;
    position: relative;
    padding-left: 24px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--c-ink);
}
.lx-chat__steps li.is-active { display: block; animation: lx-chat-step .3s ease both; }
.lx-chat__steps li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    width: 14px;
    height: 14px;
    margin-top: -7px;
    border-radius: 50%;
    border: 2px solid #dfe3f1;
    border-top-color: var(--c-violet);
    box-sizing: border-box;
    animation: lx-chat-spin .8s linear infinite;
}
@keyframes lx-chat-spin { to { transform: rotate(360deg); } }
@keyframes lx-chat-step {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: none; }
}

/* ---------- Form ---------- */
.lx-chat__form { border-top: 1px solid var(--c-line); padding: 12px 14px 10px; background: #fff; }
.lx-chat__row { display: flex; align-items: flex-end; gap: 8px; }
.lx-chat__form textarea {
    flex: 1;
    resize: none;
    border: 1px solid #dfe3f1;
    border-radius: 14px;
    padding: 10px 14px;
    font: inherit;
    color: var(--c-ink);
    max-height: 140px;
    background: #fff;
}
.lx-chat__form textarea:focus { outline: none; border-color: var(--c-violet); box-shadow: 0 0 0 3px rgba(93, 120, 255, .15); }
.lx-chat__attach,
.lx-chat__send {
    flex: none;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    cursor: pointer;
    border: 0;
    margin: 0;
}
.lx-chat__attach { background: var(--c-soft); color: var(--c-label); }
.lx-chat__attach:hover { color: var(--c-brand); }
.lx-chat__send { background: var(--c-brand); color: #fff; }
.lx-chat__send:hover { background: var(--c-violet); }
.lx-chat__send:disabled { opacity: .5; cursor: default; }
.lx-chat__file {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    padding: 4px 6px 4px 12px;
    background: #eef1ff;
    color: var(--c-brand);
    border-radius: 999px;
    font-size: 13px;
    max-width: 100%;
}
.lx-chat__file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lx-chat__file-remove {
    border: 0;
    background: #fff;
    color: var(--c-brand);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    line-height: 1;
    font-size: 16px;
}
.lx-chat__disclaimer { margin: 8px 2px 0; font-size: 11.5px; color: var(--c-label); }

/* ---------- Phones: full screen ---------- */
@media (max-width: 768px) {
    .lx-chat { --c-gap: 16px; }
    .lx-chat.is-open .lx-chat__panel {
        position: fixed;
        inset: 0;
        width: 100%;
        min-width: 0;
        height: 100%;
        min-height: 0;
        border-radius: 0;
    }
    .lx-chat.is-open .lx-chat__launcher { display: none; }
    .lx-chat__bubble { max-width: 90%; }
    .lx-chat__range b { font-size: 13.5px; }
}

@media (prefers-reduced-motion: reduce) {
    .lx-chat *, .lx-chat *::after { animation: none !important; transition: none !important; }
}
