/* Locpit Vehicle Chat — visitor widget (Phase 3.1).
   Launcher is floating-only. Inline placements are deliberately removed.
   All selectors are namespaced under .vc-* so this CSS cannot leak. */

:root {
    --vc-primary:        #1976d2;   /* Locpit blue */
    --vc-primary-hover:  #1565c0;
    --vc-primary-text:   #ffffff;
    --vc-bg:             #ffffff;
    --vc-bg-soft:        #f5f7fa;
    --vc-bg-bubble:      #eef3fb;
    --vc-border:         #e3e8ef;
    --vc-text:           #1f2a37;
    --vc-text-muted:     #6b7280;
    --vc-radius:         12px;
    --vc-shadow:         0 8px 28px rgba(13, 71, 161, .25);
    --vc-shadow-soft:    0 6px 20px rgba(0, 0, 0, .12);
}

/* Defensive cleanup: hide any cached/legacy round launcher from prior
   builds AND any cached inline CTA the previous Phase-3 build may have
   injected next to product buttons. The current JS no longer creates them,
   this rule guarantees a clean page even before the new JS runs. */
.vc-widget__toggle,
.vc-cta--inline { display: none !important; }

/* ─── Floating CTA — the ONLY launcher ────────────────────────────────── */
.vc-cta {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: var(--vc-primary);
    color: var(--vc-primary-text);
    font-family: inherit;
    font-weight: 700;
    font-size: 15px;
    line-height: 1.2;
    letter-spacing: .2px;
    padding: 14px 22px;
    min-height: 52px;
    border: 0;
    border-radius: var(--vc-radius);
    cursor: pointer;
    text-decoration: none;
    transition: background-color .15s ease, transform .12s ease, box-shadow .15s ease;
    white-space: nowrap;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.vc-cta:hover  { background: var(--vc-primary-hover); transform: translateY(-1px); }
.vc-cta:active { transform: translateY(0); }
.vc-cta:focus  { outline: none; }
.vc-cta:focus-visible {
    outline: 3px solid rgba(25, 118, 210, .35);
    outline-offset: 2px;
}
.vc-cta__icon  { font-size: 18px; line-height: 1; }
.vc-cta__label { font-weight: 700; }

.vc-cta--floating {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 2147483000;
    box-shadow: var(--vc-shadow);
    /* Respect device safe areas (iOS notch / nav bar). */
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    right:  calc(24px + env(safe-area-inset-right,  0px));
}

/* ─── Mobile: <= 575px ─ near full-width floating bottom bar ──────────── */
/* IMPORTANT: Martfury's product detail page renders a sticky bottom action
   bar (`.navigation--mobile-product`) carrying the product CTAs
   "Узнать цену под ключ" + "Посмотреть оригинал". That bar is ~64px tall.
   We push our floating chat CTA above it (88px + safe area) so it never
   overlaps. The chat panel sits above BOTH bars (150px + safe area). */
@media (max-width: 575.98px) {
    .vc-cta--floating {
        left:  12px;
        right: 12px;
        bottom: 88px;
        bottom: calc(88px + env(safe-area-inset-bottom, 0px));
        left:   calc(12px + env(safe-area-inset-left,   0px));
        right:  calc(12px + env(safe-area-inset-right,  0px));
        width: auto;
        justify-content: center;
        font-size: 15px;
        padding: 14px 18px;
        min-height: 52px;
        border-radius: var(--vc-radius);
        box-shadow: var(--vc-shadow);
    }
}

/* ─── Chat panel ──────────────────────────────────────────────────────── */
.vc-widget {
    position: fixed;
    right: 24px;
    bottom: 92px;            /* sits above the floating CTA */
    z-index: 2147483000;
    width: 380px;
    max-width: calc(100vw - 36px);
    height: 540px;
    max-height: calc(100vh - 140px);
    background: var(--vc-bg);
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
    display: none;
    flex-direction: column;
    overflow: hidden;
    color: var(--vc-text);
    font-family: inherit;
    bottom: calc(92px + env(safe-area-inset-bottom, 0px));
    right:  calc(24px + env(safe-area-inset-right,  0px));
}
.vc-widget--open { display: flex; }

@media (max-width: 575.98px) {
    .vc-widget {
        left:   8px;
        right:  8px;
        /* Stack above BOTH the product sticky bar (~64px) and the chat CTA
           (which now sits at 88px + safe-area). Total clearance = 150px. */
        bottom: 150px;
        width:  auto;
        height: calc(100vh - 170px);
        max-height: calc(100vh - 170px);
        border-radius: 12px;
        bottom: calc(150px + env(safe-area-inset-bottom, 0px));
        left:   calc(8px   + env(safe-area-inset-left,   0px));
        right:  calc(8px   + env(safe-area-inset-right,  0px));
    }
}

.vc-widget__header {
    background: var(--vc-primary);
    color: var(--vc-primary-text);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 0 0 auto;
}
.vc-widget__header-title { font-size: 15px; font-weight: 700; line-height: 1.2; }
.vc-widget__header-sub   { font-size: 12px; opacity: .85; margin-top: 2px; line-height: 1.2; }
.vc-widget__close {
    background: transparent; border: 0; color: #fff; cursor: pointer;
    font-size: 24px; line-height: 1; padding: 0 6px;
}
.vc-widget__close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.vc-widget__messages {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 14px;
    background: var(--vc-bg-soft);
    font-size: 14px;
}
.vc-widget__msg { margin-bottom: 12px; display: flex; }
.vc-widget__msg-bubble {
    padding: 9px 13px;
    border-radius: 12px;
    max-width: 82%;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
    line-height: 1.45;
    background: var(--vc-bg);
    border: 1px solid var(--vc-border);
}
.vc-widget__msg--visitor { justify-content: flex-end; }
.vc-widget__msg--visitor .vc-widget__msg-bubble {
    background: var(--vc-primary);
    color: var(--vc-primary-text);
    border: 0;
    border-bottom-right-radius: 4px;
}
.vc-widget__msg--vendor .vc-widget__msg-bubble,
.vc-widget__msg--admin  .vc-widget__msg-bubble {
    background: var(--vc-bg-bubble);
    border-color: #d6e4f5;
    border-bottom-left-radius: 4px;
}
.vc-widget__msg--system .vc-widget__msg-bubble {
    background: transparent;
    border: 0;
    color: var(--vc-text-muted);
    font-style: italic;
    margin: 0 auto;
    text-align: center;
    max-width: 92%;
    padding: 4px 8px;
}
.vc-widget__msg-meta {
    font-size: 11px;
    color: var(--vc-text-muted);
    margin-top: 4px;
}
.vc-widget__msg--visitor .vc-widget__msg-meta { text-align: right; }

.vc-widget__form {
    border-top: 1px solid var(--vc-border);
    padding: 10px;
    display: flex;
    gap: 8px;
    background: var(--vc-bg);
    align-items: stretch;
    flex: 0 0 auto;
}
.vc-widget__input {
    flex: 1 1 auto;
    min-width: 0;
    resize: none;
    border: 1px solid var(--vc-border);
    border-radius: 8px;
    padding: 9px 10px;
    font: inherit;
    line-height: 1.35;
    color: var(--vc-text);
    /* iOS Safari keyboard: prevent automatic zoom on focus by sizing >= 16px. */
    font-size: 16px;
}
.vc-widget__input:focus {
    outline: 2px solid var(--vc-primary);
    outline-offset: -1px;
    border-color: var(--vc-primary);
}
.vc-widget__send {
    flex: 0 0 auto;
    border: 0;
    background: var(--vc-primary);
    color: var(--vc-primary-text);
    border-radius: 8px;
    padding: 0 16px;
    cursor: pointer;
    font-weight: 700;
    min-width: 56px;
}
.vc-widget__send:hover { background: var(--vc-primary-hover); }
.vc-widget__send[disabled] { opacity: .55; cursor: wait; }

.vc-widget__spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, .55);
    border-top-color: #fff;
    border-radius: 50%;
    animation: vc-spin .8s linear infinite;
}
@keyframes vc-spin { to { transform: rotate(360deg); } }

.vc-widget__error {
    background: #fdecea;
    color: #8a1f1f;
    padding: 8px 14px;
    font-size: 13px;
    border-bottom: 1px solid #f5c6c2;
}

/* ─── Phase 4B additions ──────────────────────────────────────────────── */

/* Greeting action buttons (Yes / No) inside the local greeting bubble. */
.vc-widget .vc-action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 8px;
    margin: 8px 0 4px;
}
.vc-widget .vc-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    color: var(--vc-text);
    border: 1px solid var(--vc-border);
    border-radius: 6px;
    padding: 8px 12px;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    line-height: 1.2;
    transition: background-color .15s ease, border-color .15s ease;
}
.vc-widget .vc-action:hover { background: var(--vc-bg-soft); border-color: #c6d2e0; }
.vc-widget .vc-action--primary {
    background: var(--vc-primary);
    color: var(--vc-primary-text);
    border-color: var(--vc-primary);
}
.vc-widget .vc-action--primary:hover {
    background: var(--vc-primary-hover);
    border-color: var(--vc-primary-hover);
}

/* AI typing indicator (three animated dots). */
.vc-widget .vc-widget__msg--ai-typing .vc-widget__msg-bubble {
    background: var(--vc-bg-bubble);
    border: 1px solid #d6e4f5;
    color: var(--vc-text-muted);
    padding: 10px 14px;
}
.vc-widget .vc-typing {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    height: 12px;
}
.vc-widget .vc-typing span {
    width: 6px; height: 6px;
    background: var(--vc-text-muted);
    border-radius: 50%;
    display: inline-block;
    opacity: .35;
    animation: vc-typing-dot 1.2s infinite ease-in-out;
}
.vc-widget .vc-typing span:nth-child(2) { animation-delay: .15s; }
.vc-widget .vc-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes vc-typing-dot {
    0%, 60%, 100% { opacity: .35; transform: translateY(0); }
    30%           { opacity: 1;   transform: translateY(-2px); }
}

/* Lead capture form. */
.vc-widget .vc-lead-form {
    background: var(--vc-bg);
    border: 1px solid var(--vc-border);
    border-radius: 10px;
    padding: 12px;
    margin: 10px 0 6px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.vc-widget .vc-lead-form__label {
    display: flex;
    flex-direction: column;
    font-size: 12px;
    color: var(--vc-text-muted);
    gap: 4px;
}
.vc-widget .vc-lead-form__input {
    border: 1px solid var(--vc-border);
    border-radius: 6px;
    padding: 9px 10px;
    font: inherit;
    /* iOS Safari: prevent zoom-on-focus by sizing >= 16px. */
    font-size: 16px;
    color: var(--vc-text);
    background: #fff;
    min-width: 0;
    width: 100%;
}
.vc-widget .vc-lead-form__input:focus {
    outline: 2px solid var(--vc-primary);
    outline-offset: -1px;
    border-color: var(--vc-primary);
}
.vc-widget .vc-consent {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 12px;
    color: var(--vc-text);
    line-height: 1.3;
    cursor: pointer;
}
.vc-widget .vc-consent input[type="checkbox"] {
    margin-top: 2px;
    flex: 0 0 auto;
}
.vc-widget .vc-lead-form__error {
    color: #842029;
    background: #fdecea;
    border: 1px solid #f5c6c2;
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 12px;
}
.vc-widget .vc-lead-form__submit { align-self: flex-start; }
