/**
 * Klever_VidurAi — storefront chat widget.
 *
 * Layout, spacing and component anatomy follow the reference screens in
 * klever-md/chat/. Every colour and the type family come from the storefront
 * theme (Kleverup/automotive-*): brand green #00843D, accent yellow #FFC300,
 * ink #222222, hairline #DBDBDB, and the GothamW05 face used on body copy.
 * Anything lighter than those is the same brand colour at reduced alpha, so the
 * widget never introduces a colour the site doesn't already ship.
 */

.klv-chat {
    /* Brand palette — theme tokens only. #00843D is the site's primary, exposed
       by tailwind.config.js under the (misleading) name "theme-blue"; #5E7F65 is
       the sage it pairs with on the floating footer buttons. */
    --klv-green: #00843D;
    --klv-green-deep: #005E2C;
    --klv-sage: #5E7F65;
    --klv-yellow: #FFC300;
    --klv-ink: #222222;
    --klv-white: #fff;
    --klv-line: #DBDBDB;

    /* Brand-derived tints (same hue, lower alpha). */
    --klv-green-05: rgba(0, 132, 61, .05);
    --klv-green-08: rgba(0, 132, 61, .08);
    --klv-green-12: rgba(0, 132, 61, .12);
    --klv-green-20: rgba(0, 132, 61, .2);
    --klv-ink-55: rgba(34, 34, 34, .55);
    --klv-ink-70: rgba(34, 34, 34, .7);
    --klv-surface: #F7FAF8;
    --klv-hairline: rgba(34, 34, 34, .1);

    position: fixed;
    /* Sits in the theme's floating button stack (Magento_Theme/html/footer.phtml):
       .whats-app-btn at bottom .563rem and #header-search-full-icon at 4.5rem are
       both 3.438rem tall at right 1.625rem, spaced .5rem apart. This is the next
       slot up: 4.5 + 3.438 + .5 = 8.438rem. */
    right: 1.625rem;
    bottom: 8.438rem;
    z-index: 9999;
    font-family: 'GothamW05', sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--klv-ink);
}

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

/* The widget toggles visibility with the `hidden` attribute, but the UA rule for
   it is weaker than the class rules below that set `display: flex`. Restore it. */
.klv-chat [hidden] {
    display: none !important;
}

/* ---------------------------------------------------------------- launcher */

.klv-chat__launcher {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3.438rem;
    height: 3.438rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: linear-gradient(140deg, var(--klv-green) 0%, var(--klv-green-deep) 100%);
    color: var(--klv-white);
    cursor: pointer;
    box-shadow: 0 8px 22px rgba(0, 94, 44, .35);
    transition: transform .15s ease, box-shadow .15s ease;
}

.klv-chat__launcher:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(0, 94, 44, .42);
}

.klv-chat__launcher svg {
    /* 1.75rem matches the tyre-finder icon's w-7 inside the same 3.438rem button. */
    width: 1.75rem;
    height: 1.75rem;
}

.klv-chat--open .klv-chat__launcher {
    display: none;
}

/* ------------------------------------------------------------------- panel */

/* The launcher sits up in the stack, but the open panel should not float 8rem
   off the floor — bring the container down to the stack's base while it is open. */
.klv-chat--open {
    bottom: 0.563rem;
}

.klv-chat__panel {
    display: flex;
    flex-direction: column;
    width: 384px;
    max-width: calc(100vw - 24px);
    height: 620px;
    max-height: calc(100vh - 40px);
    background: var(--klv-white);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 18px 48px rgba(0, 0, 0, .22);
}

/* ------------------------------------------------------------------ header */

.klv-chat__header {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
    padding: 14px 14px 14px 16px;
    background: var(--klv-white);
    border-bottom: 1px solid var(--klv-hairline);
}

.klv-chat__brand {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    margin-right: auto;
}

.klv-chat__brand svg {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
}

.klv-chat__title {
    font-size: 16px;
    font-weight: 700;
    line-height: 1.2;
    color: var(--klv-ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.klv-chat__icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--klv-ink);
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.klv-chat__icon-btn:hover {
    background: var(--klv-green-08);
    color: var(--klv-green-deep);
}

.klv-chat__icon-btn svg {
    width: 18px;
    height: 18px;
}

/* Header kebab menu. */

.klv-chat__menu {
    position: absolute;
    top: 48px;
    right: 12px;
    z-index: 2;
    min-width: 172px;
    padding: 6px;
    background: var(--klv-white);
    border: 1px solid var(--klv-line);
    border-radius: 10px;
    box-shadow: 0 10px 26px rgba(0, 0, 0, .16);
}

.klv-chat__menu-item {
    display: block;
    width: 100%;
    padding: 9px 10px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--klv-ink);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
}

.klv-chat__menu-item:hover {
    background: var(--klv-green-08);
    color: var(--klv-green-deep);
}

/* -------------------------------------------------------------------- body */

.klv-chat__body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 16px;
    background: linear-gradient(180deg, var(--klv-green-05) 0%, var(--klv-white) 45%, var(--klv-green-05) 100%);
}

.klv-chat__body::-webkit-scrollbar {
    width: 6px;
}

.klv-chat__body::-webkit-scrollbar-thumb {
    background: var(--klv-green-20);
    border-radius: 3px;
}

/* ------------------------------------------------------------------- hero */

.klv-chat__hero {
    align-self: stretch;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.klv-chat__hero-eyebrow {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--klv-ink);
}

.klv-chat__hero-eyebrow svg {
    width: 18px;
    height: 18px;
}

.klv-chat__hero-title {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -.01em;
    color: var(--klv-ink);
}

.klv-chat__hero-title em {
    font-style: normal;
    color: var(--klv-green);
}

/* ------------------------------------------------------------------ chips */

.klv-chat__chips {
    align-self: stretch;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    margin-top: 2px;
}

.klv-chat__chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    max-width: 100%;
    padding: 9px 16px;
    border: 0;
    border-radius: 999px;
    background: var(--klv-green-08);
    color: var(--klv-green-deep);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    text-align: left;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.klv-chat__chip:hover:not(:disabled) {
    background: var(--klv-green);
    color: var(--klv-white);
}

.klv-chat__chip:disabled {
    opacity: .55;
    cursor: default;
}

.klv-chat__chip-icon {
    flex: 0 0 auto;
    display: inline-flex;
}

.klv-chat__chip-icon svg {
    width: 14px;
    height: 14px;
}

/* --------------------------------------------------------------- messages */

.klv-chat__msg {
    padding: 11px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.55;
    word-wrap: break-word;
}

.klv-chat__msg--user {
    align-self: flex-end;
    max-width: 86%;
    background: var(--klv-green-12);
    color: var(--klv-ink);
}

.klv-chat__msg--assistant {
    align-self: stretch;
    background: var(--klv-surface);
    color: var(--klv-ink);
}

.klv-chat__msg a {
    color: var(--klv-green);
    font-weight: 500;
    text-decoration: underline;
}

/* Loading row — sparkle + label, no bubble (see reference screens). */

.klv-chat__loading {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 2px 0;
    font-size: 14px;
    color: var(--klv-ink-70);
}

.klv-chat__loading svg {
    width: 16px;
    height: 16px;
    animation: klv-pulse 1.4s ease-in-out infinite;
}

@keyframes klv-pulse {
    0%, 100% { opacity: .35; transform: scale(.9); }
    50%      { opacity: 1;   transform: scale(1.08); }
}

/* ----------------------------------------------------------- product cards */

.klv-chat__cards {
    align-self: stretch;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.klv-chat__card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
    background: var(--klv-white);
    border: 1px solid var(--klv-line);
    border-radius: 10px;
    color: var(--klv-ink);
    transition: border-color .15s ease, box-shadow .15s ease;
}

/* The card is a container, not a link — it highlights on hover to group its
   two actions, but only the actions themselves are clickable. */
.klv-chat__card:hover {
    border-color: var(--klv-green);
    box-shadow: 0 4px 14px var(--klv-green-12);
}

.klv-chat__card-main {
    display: flex;
    gap: 12px;
    align-items: center;
    min-width: 0;
}

.klv-chat__card-img {
    flex: 0 0 auto;
    width: 64px;
    height: 64px;
    object-fit: contain;
}

.klv-chat__card-body {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.klv-chat__card-name {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.35;
    color: var(--klv-green);
}

.klv-chat__card-brand {
    font-size: 12px;
    color: var(--klv-ink-55);
}

.klv-chat__card-was {
    font-size: 13px;
    color: var(--klv-ink-55);
    text-decoration: line-through;
}

.klv-chat__card-price {
    display: flex;
    align-items: baseline;
    gap: 3px;
    line-height: 1.1;
}

.klv-chat__card-currency {
    font-size: 13px;
    font-weight: 500;
    color: var(--klv-ink-70);
}

.klv-chat__card-amount {
    font-size: 22px;
    font-weight: 700;
    color: var(--klv-ink);
}

.klv-chat__card-cents {
    align-self: flex-start;
    margin-top: 2px;
    font-size: 12px;
    font-weight: 700;
    color: var(--klv-ink);
}

.klv-chat__card-save {
    align-self: flex-start;
    margin-top: 2px;
    padding: 3px 8px;
    border-radius: 3px;
    background: var(--klv-yellow);
    color: var(--klv-ink);
    font-size: 11px;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: .01em;
}

/* Two actions per card: keep chatting, or open the product page. */

.klv-chat__card-actions {
    display: flex;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--klv-line);
}

.klv-chat__card-action {
    flex: 1 1 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 34px;
    padding: 7px 10px;
    border: 1px solid var(--klv-line);
    border-radius: 6px;
    background: var(--klv-white);
    color: var(--klv-ink);
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

.klv-chat__card-action--ask {
    border-color: var(--klv-green);
    background: var(--klv-green);
    color: var(--klv-white);
}

.klv-chat__card-action--ask:hover,
.klv-chat__card-action--ask:focus-visible {
    background: var(--klv-green-deep);
    border-color: var(--klv-green-deep);
}

.klv-chat__card-action--view:hover,
.klv-chat__card-action--view:focus-visible {
    border-color: var(--klv-green);
    color: var(--klv-green);
}

.klv-chat__card-action-icon {
    display: inline-flex;
    flex: 0 0 auto;
}

.klv-chat__card-action-icon svg {
    width: 13px;
    height: 13px;
}

/* Narrow widgets stack the actions so neither label wraps mid-word. */
@media (max-width: 360px) {
    .klv-chat__card-actions {
        flex-direction: column;
    }
}

/* Reveal-the-rest control under a truncated card list. */

.klv-chat__cards-more {
    align-self: center;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    margin-top: 2px;
    padding: 0;
    border: 1px solid var(--klv-line);
    border-radius: 50%;
    background: var(--klv-white);
    color: var(--klv-ink);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .1);
    transition: border-color .15s ease, color .15s ease;
}

.klv-chat__cards-more:hover {
    border-color: var(--klv-green);
    color: var(--klv-green);
}

.klv-chat__cards-more svg {
    width: 16px;
    height: 16px;
    transition: transform .2s ease;
}

.klv-chat__cards-more[aria-expanded="true"] svg {
    transform: rotate(180deg);
}

/* -------------------------------------------------------------- feedback */

.klv-chat__rate {
    display: flex;
    align-items: center;
    gap: 4px;
}

.klv-chat__rate-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--klv-ink-55);
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.klv-chat__rate-btn:hover {
    background: var(--klv-green-08);
    color: var(--klv-green-deep);
}

.klv-chat__rate-btn.is-active {
    color: var(--klv-ink);
}

.klv-chat__rate-btn svg {
    width: 17px;
    height: 17px;
}

.klv-chat__note {
    align-self: stretch;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--klv-surface);
    font-size: 14px;
    color: var(--klv-ink);
}

.klv-chat__note svg {
    flex: 0 0 auto;
    width: 17px;
    height: 17px;
}

.klv-chat__rate-form {
    align-self: stretch;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
    border-radius: 12px;
    background: var(--klv-surface);
}

.klv-chat__rate-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0;
    font-size: 14px;
    font-weight: 500;
    color: var(--klv-ink);
}

.klv-chat__rate-title svg {
    width: 17px;
    height: 17px;
}

.klv-chat__rate-reasons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.klv-chat__rate-reason {
    padding: 7px 18px;
    border: 1px solid var(--klv-line);
    border-radius: 999px;
    background: var(--klv-white);
    color: var(--klv-ink);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease, color .15s ease;
}

.klv-chat__rate-reason:hover {
    border-color: var(--klv-green);
    color: var(--klv-green);
}

.klv-chat__rate-reason.is-selected {
    border-color: var(--klv-green);
    background: var(--klv-green-08);
    color: var(--klv-green-deep);
}

.klv-chat__rate-details {
    width: 100%;
    min-height: 66px;
    padding: 10px 12px;
    border: 1px solid var(--klv-line);
    border-radius: 8px;
    background: var(--klv-white);
    color: var(--klv-ink);
    font-family: inherit;
    font-size: 13px;
    line-height: 1.5;
    resize: vertical;
}

.klv-chat__rate-details::placeholder {
    color: var(--klv-ink-55);
}

.klv-chat__rate-details:focus {
    outline: none;
    border-color: var(--klv-green);
}

.klv-chat__rate-submit {
    align-self: stretch;
    padding: 11px 16px;
    border: 0;
    border-radius: 999px;
    background: var(--klv-green);
    color: var(--klv-white);
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

.klv-chat__rate-submit:disabled {
    background: var(--klv-line);
    color: var(--klv-ink-55);
    cursor: default;
}

/* --------------------------------------------------------------- composer */

.klv-chat__composer {
    flex: 0 0 auto;
    padding: 12px;
    background: var(--klv-white);
}

/* The gradient rim is the wrapper's background; the field paints over it. */
.klv-chat__composer-frame {
    padding: 2px;
    border-radius: 16px;
    background: linear-gradient(120deg, var(--klv-green) 0%, var(--klv-sage) 45%, var(--klv-yellow) 100%);
}

.klv-chat__composer-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px 12px 10px;
    background: var(--klv-white);
    border-radius: 14px;
}

.klv-chat__input {
    width: 100%;
    max-height: 120px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--klv-ink);
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    overflow-y: auto;
}

.klv-chat__input:focus {
    outline: none;
}

.klv-chat__input::placeholder {
    color: var(--klv-ink-55);
}

.klv-chat__send {
    align-self: flex-end;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: var(--klv-green);
    color: var(--klv-white);
    cursor: pointer;
    transition: background .15s ease;
}

.klv-chat__send:hover:not(:disabled) {
    background: var(--klv-green-deep);
}

.klv-chat__send:disabled {
    background: var(--klv-green-08);
    color: var(--klv-ink-55);
    cursor: default;
}

.klv-chat__send svg {
    width: 18px;
    height: 18px;
}

/* ------------------------------------------- lead gate / returning visitor */

.klv-chat__lead,
.klv-chat__resume {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 18px 16px;
    background: linear-gradient(180deg, var(--klv-green-05) 0%, var(--klv-white) 45%);
}

.klv-chat__lead-intro,
.klv-chat__resume-intro {
    margin: 0 0 4px;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.35;
    color: var(--klv-ink);
}

.klv-chat__lead-sub {
    margin: -6px 0 6px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--klv-ink-55);
}

.klv-chat__lead-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--klv-ink-55);
}

.klv-chat__lead-input {
    padding: 11px 13px;
    border: 1px solid var(--klv-line);
    border-radius: 10px;
    background: var(--klv-white);
    color: var(--klv-ink);
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
}

.klv-chat__lead-input:focus {
    outline: none;
    border-color: var(--klv-green);
}

.klv-chat__lead-error {
    margin: 0;
    font-size: 13px;
    font-weight: 500;
    color: var(--klv-green);
}

.klv-chat__lead-submit,
.klv-chat__resume-new {
    margin-top: 6px;
    padding: 12px 16px;
    border: 0;
    border-radius: 999px;
    background: var(--klv-green);
    color: var(--klv-white);
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s ease;
}

.klv-chat__lead-submit:hover:not(:disabled),
.klv-chat__resume-new:hover:not(:disabled) {
    background: var(--klv-green-deep);
}

.klv-chat__lead-submit:disabled,
.klv-chat__resume-new:disabled {
    opacity: .6;
    cursor: default;
}

.klv-chat__resume-new {
    border: 1px solid var(--klv-line);
    background: var(--klv-white);
    color: var(--klv-ink);
}

.klv-chat__resume-new:hover:not(:disabled) {
    border-color: var(--klv-green);
    background: var(--klv-white);
    color: var(--klv-green);
}

.klv-chat__resume-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.klv-chat__resume-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 11px 13px;
    border: 1px solid var(--klv-line);
    border-radius: 10px;
    background: var(--klv-white);
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.klv-chat__resume-item:hover {
    border-color: var(--klv-green);
    box-shadow: 0 4px 14px var(--klv-green-12);
}

.klv-chat__resume-item:disabled {
    opacity: .5;
    cursor: default;
}

.klv-chat__resume-date {
    font-size: 12px;
    font-weight: 700;
    color: var(--klv-green);
}

.klv-chat__resume-preview {
    font-size: 13px;
    line-height: 1.4;
    color: var(--klv-ink-55);
}

/* ----------------------------------------------------------------- mobile */

/* Below the theme's md breakpoint both neighbours are `hidden md:block`, and the
   bottom of the viewport belongs to .mobile-bar. 5rem is the offset the theme's
   own mobile popover uses to clear it. */
@media (max-width: 767px) {
    .klv-chat {
        right: 0.625rem;
        bottom: 5rem;
    }

    .klv-chat__launcher {
        width: 2.812rem;
        height: 2.812rem;
    }

    .klv-chat__launcher svg {
        width: 1.5rem;
        height: 1.5rem;
    }
}

@media (max-width: 480px) {

    .klv-chat--open {
        right: 0;
        bottom: 0;
        left: 0;
        top: 0;
    }

    .klv-chat--open .klv-chat__panel {
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
}

/* -------------------------------------------------------------------- RTL */

[dir="rtl"] .klv-chat {
    right: auto;
    left: 1.625rem;
}

@media (max-width: 767px) {
    [dir="rtl"] .klv-chat {
        left: 0.625rem;
    }
}

[dir="rtl"] .klv-chat__header {
    padding: 14px 16px 14px 14px;
}

[dir="rtl"] .klv-chat__menu {
    right: auto;
    left: 12px;
}

[dir="rtl"] .klv-chat__body,
[dir="rtl"] .klv-chat__chips {
    align-items: flex-end;
}

[dir="rtl"] .klv-chat__msg--user {
    align-self: flex-start;
}

[dir="rtl"] .klv-chat__menu-item,
[dir="rtl"] .klv-chat__chip,
[dir="rtl"] .klv-chat__resume-item {
    text-align: right;
}

[dir="rtl"] .klv-chat__send {
    align-self: flex-start;
}

[dir="rtl"] .klv-chat__send svg {
    transform: scaleX(-1);
}

@media (max-width: 480px) {
    [dir="rtl"] .klv-chat--open {
        left: 0;
    }
}
