/* ============================================================
   Lead Funnel Widget — стили компонентов.

   Цвета/радиусы/тени брать НЕ ОТСЮДА, а из theme.css.
   ============================================================ */

/* ============================================================
   OVERLAY + MODAL
   ============================================================ */
.lf-overlay {
    position: fixed;
    inset: 0;
    background: var(--lf-overlay);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: var(--lf-z-modal);
    font-family: var(--lf-font);
    animation: lf-fade-in 0.2s ease;
}
.lf-overlay.lf-open { display: flex; }

@keyframes lf-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes lf-slide-up { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.lf-modal {
    background: var(--lf-surface);
    border-radius: var(--lf-radius-modal);
    width: 100%;
    max-width: 420px;
    padding: 24px;
    box-shadow: var(--lf-shadow-modal);
    animation: lf-slide-up 0.3s ease;
    color: var(--lf-text);
    box-sizing: border-box;
    position: relative;
    font-family: var(--lf-font);
}

.lf-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    font-size: var(--lf-font-size-sm);
    color: var(--lf-text-faint);
}
.lf-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--lf-success);
}
.lf-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--lf-success);
}

.lf-close {
    position: absolute;
    top: 14px;
    right: 14px;
    background: none;
    border: none;
    color: var(--lf-text-faint);
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
    padding: 0 4px;
}
.lf-close:hover { color: var(--lf-text); }

/* ============================================================
   ЗАГОЛОВКИ
   ============================================================ */
.lf-title {
    margin: 0 0 6px;
    font-size: 20px;
    font-weight: 600;
    color: var(--lf-text);
}
.lf-subtitle {
    margin: 0 0 18px;
    font-size: 14px;
    color: var(--lf-text-muted);
}

/* ============================================================
   ФОРМА (inline + modal используют одни и те же классы полей)
   ============================================================ */
.lf-form { font-family: var(--lf-font); color: var(--lf-text); }

/* Inline-вариант: форма «как карточка» прямо на странице */
.lf-form--inline {
    background: var(--lf-surface);
    border-radius: var(--lf-radius-modal);
    padding: var(--lf-inline-padding);
    box-shadow: var(--lf-shadow-modal);
}
.lf-form--inline .lf-title    { font-size: 24px; margin-bottom: 8px; }
.lf-form--inline .lf-subtitle { margin-bottom: 24px; }
.lf-form--inline .lf-btn      { margin-top: 8px; padding: 14px 16px; font-size: 16px; }

/* ----- Сетка полей ----- */
.lf-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--lf-gap-form);
    margin-bottom: 12px;
}
.lf-col-full { grid-column: span 2; }
.lf-col-half { grid-column: span 1; }

@media (max-width: 480px) {
    .lf-grid { grid-template-columns: 1fr; }
    .lf-col-full, .lf-col-half { grid-column: span 1; }
}

/* ----- Поле (label + input + help/error) ----- */
.lf-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.lf-label {
    font-size: var(--lf-font-size-sm);
    font-weight: 500;
    color: var(--lf-text);
}
.lf-optional {
    font-weight: 400;
    color: var(--lf-text-faint);
}
.lf-help {
    display: none !important;
}

@keyframes lf-autofill-start {
    from { opacity: 1; }
    to   { opacity: 1; }
}

.lf-search-select-input:-webkit-autofill {
    animation-name: lf-autofill-start;
    animation-duration: 0.01s;
}

.lf-form-banner {
    margin: 0 0 1rem;
    padding: 0.75rem 1rem;
    border-left: 3px solid var(--lf-danger);
    background: color-mix(in srgb, var(--lf-danger) 8%, transparent);
    color: var(--lf-text);
    font-size: var(--lf-font-size-sm);
    line-height: 1.45;
}

.lf-error {
    font-size: var(--lf-font-size-xs);
    color: var(--lf-danger);
    min-height: 1em;
}

/* ----- Checkbox / Radio ----- */
.lf-checkbox,
.lf-radio {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    font-size: var(--lf-font-size-sm);
    line-height: 1.4;
}
.lf-checkbox input,
.lf-radio input {
    margin-top: 3px;
    flex-shrink: 0;
    accent-color: var(--lf-accent, #b00020);
}
.lf-checkbox-label { color: var(--lf-text); }
.lf-radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.lf-field-error .lf-checkbox,
.lf-field-error .lf-radio-group {
    outline: 1px solid var(--lf-danger);
    outline-offset: 4px;
    border-radius: 2px;
}

.lf-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ----- File upload ----- */
.lf-file-zone {
    position: relative;
    border: 2px dashed var(--lf-border, #ccc);
    border-radius: 2px;
    padding: 20px 16px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    background: var(--lf-bg-soft, #fafafa);
}
.lf-file-zone:hover,
.lf-file-zone--hover {
    border-color: var(--lf-accent, #b00020);
    background: #fff;
}
.lf-file-zone--done {
    border-style: solid;
    border-color: var(--lf-success, #2e7d32);
}
.lf-file-zone--loading { opacity: 0.6; pointer-events: none; }
.lf-file-input-native {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    pointer-events: none;
}
.lf-file-preview { font-size: 1.5rem; margin-bottom: 6px; }
.lf-file-hint { font-size: var(--lf-font-size-sm); color: var(--lf-text-faint); }
.lf-file-name { font-size: var(--lf-font-size-xs); color: var(--lf-text); margin-top: 6px; word-break: break-all; }

/* ----- Card number + brand badge ----- */
.lf-card-row {
    position: relative;
    display: flex;
    align-items: stretch;
}
.lf-card-input {
    flex: 1;
    padding-right: 110px;
}
.lf-card-brand {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: var(--lf-font-size-xs);
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--lf-text-faint);
    pointer-events: none;
    max-width: 100px;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.lf-card-brand--known {
    color: var(--lf-accent, #b00020);
}
.lf-card-brand[data-brand="visa"]       { color: #1a1f71; }
.lf-card-brand[data-brand="mastercard"] { color: #eb001b; }
.lf-card-brand[data-brand="amex"]       { color: #006fcf; }
.lf-card-brand[data-brand="discover"]   { color: #ff6000; }

/* ----- Инпуты (text, email, tel, select, textarea) ----- */
.lf-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--lf-border);
    border-radius: var(--lf-radius-input);
    font-size: var(--lf-font-size);
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    font-family: inherit;
    color: var(--lf-text);
    background: var(--lf-surface);
}
.lf-input::placeholder { color: var(--lf-text-faint); }
.lf-input:focus {
    border-color: var(--lf-primary);
    box-shadow: var(--lf-shadow-focus);
}
.lf-input.lf-input-error { border-color: var(--lf-danger); }
.lf-input:disabled {
    background: var(--lf-surface-muted);
    color: var(--lf-text-muted);
    cursor: not-allowed;
}

.lf-select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%2394a3b8' d='M1 1l5 5 5-5'/></svg>");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

/* Searchable select (country picker) */
.lf-search-select {
    position: relative;
}
.lf-search-select-input {
    width: 100%;
    box-sizing: border-box;
}
.lf-search-select-list {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    z-index: 20;
    max-height: 220px;
    overflow-y: auto;
    margin: 0;
    padding: 4px 0;
    list-style: none;
    background: var(--lf-surface);
    border: 1px solid var(--lf-border);
    border-radius: var(--lf-radius-input);
    box-shadow: var(--lf-shadow-modal);
}
.lf-search-select--open .lf-search-select-list {
    display: block;
}
.lf-search-select-option {
    padding: 10px 14px;
    cursor: pointer;
    font-size: var(--lf-font-size-sm);
    color: var(--lf-text);
}
.lf-search-select-option:hover,
.lf-search-select-option:focus {
    background: var(--lf-surface-muted);
}
.lf-search-select-empty {
    padding: 10px 14px;
    color: var(--lf-text-muted);
    font-size: var(--lf-font-size-sm);
}

.lf-textarea {
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
    line-height: 1.4;
}

/* ============================================================
   КНОПКИ
   ============================================================ */
.lf-btn {
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-radius: var(--lf-radius-input);
    background: var(--lf-primary);
    color: var(--lf-on-primary);
    font-size: var(--lf-font-size);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, transform 0.05s;
    font-family: inherit;
}
.lf-btn:hover    { background: var(--lf-primary-hover); }
.lf-btn:active   { transform: scale(0.98); }
.lf-btn:disabled { opacity: 0.7; cursor: not-allowed; }

.lf-btn-secondary {
    background: var(--lf-surface-muted);
    color: var(--lf-text);
    border: 1px solid var(--lf-border);
    text-align: left;
}
.lf-btn-secondary:hover { background: var(--lf-surface-hover); }

/* ============================================================
   CHOICE / WAIT / DONE / POLICY
   ============================================================ */
.lf-choices { display: flex; flex-direction: column; gap: 8px; }

.lf-wait { text-align: center; padding: 18px 0 8px; }
.lf-dots { display: inline-flex; gap: 6px; }
.lf-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--lf-text-faint);
    animation: lf-pulse 1.4s infinite ease-in-out;
}
.lf-dots span:nth-child(2) { animation-delay: 0.2s; }
.lf-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes lf-pulse {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.7); }
    40%           { opacity: 1;   transform: scale(1); }
}

.lf-done { text-align: center; padding: 10px 0; }
.lf-done-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1.25rem;
    align-items: stretch;
}
.lf-done-note { margin: 0; }
a.lf-btn.lf-btn-download {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}
.lf-done-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--lf-success-soft);
    color: var(--lf-success);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin-bottom: 12px;
}

.lf-policy {
    font-size: var(--lf-font-size-xs);
    color: var(--lf-text-faint);
    text-align: center;
    margin-top: 12px;
}

/* ============================================================
   VERIFY (экран ввода кода — SMS / Email)
   ============================================================ */
.lf-verify {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.lf-verify .lf-title {
    margin-bottom: 4px;
}
.lf-verify-subtitle {
    margin-bottom: 16px;
    min-height: 1.4em; /* чтобы не было прыжков высоты при апдейте текста */
}
.lf-verify-input {
    font-size: 1.4rem;
    letter-spacing: 0.5em;
    text-align: center;
    padding: 14px 16px;
    font-family: ui-monospace, "SFMono-Regular", Consolas, Menlo, monospace;
    text-indent: 0.5em; /* компенсируем letter-spacing справа */
}
.lf-verify-error {
    margin: -6px 0 4px;
    text-align: center;
    min-height: 1em;
}

.lf-verify-loading {
    display: flex;
    justify-content: center;
    padding: 4px 0;
}

.lf-verify-loading[hidden] {
    display: none;
}

.lf-btn--loading {
    opacity: 0.75;
    cursor: wait;
}

.lf-modal-abandon {
    display: block;
    width: 100%;
    margin-top: 16px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--lf-muted, #666);
    font-size: 0.875rem;
    text-decoration: underline;
    cursor: pointer;
}

.lf-modal-abandon[hidden],
.lf-modal-abandon.lf-is-hidden {
    display: none !important;
    visibility: hidden;
    pointer-events: none;
}

.lf-modal-abandon:hover {
    color: var(--lf-text, #111);
}

/* ============================================================
   ПЛАВАЮЩАЯ КНОПКА (если inline не используется)
   ============================================================ */
.lf-trigger {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--lf-primary);
    color: var(--lf-on-primary);
    border: none;
    border-radius: var(--lf-radius-pill);
    padding: 14px 22px;
    font-size: var(--lf-font-size);
    font-weight: 500;
    box-shadow: var(--lf-shadow-trigger);
    cursor: pointer;
    z-index: var(--lf-z-trigger);
    font-family: var(--lf-font);
}
.lf-trigger:hover { background: var(--lf-primary-hover); }

@media (max-width: 480px) {
    .lf-modal           { max-width: 100%; margin: 12px; padding: 20px; }
    .lf-trigger         { bottom: 16px; right: 16px; padding: 12px 18px; }
    .lf-form--inline    { padding: 20px; }
    .lf-form--inline .lf-title { font-size: 20px; }
}

/* ============================================================
   SUPPORT CHAT
   ============================================================ */
.lf-chat {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: calc(var(--lf-z-modal, 999999) - 1);
    font-family: var(--lf-font, inherit);
}

.lf-chat-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 20px;
    border: none;
    border-radius: var(--lf-radius-pill, 999px);
    background: var(--lf-primary, #1a1a1a);
    color: var(--lf-on-primary, #fff);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--lf-shadow-lg, 0 8px 24px rgba(0,0,0,.15));
}

.lf-chat-toggle:hover { transform: translateY(-1px); }

.lf-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: #c0392b;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
}

.lf-chat-badge[hidden] { display: none; }

.lf-chat-panel {
    position: absolute;
    right: 0;
    bottom: calc(100% + 12px);
    width: min(360px, calc(100vw - 32px));
    max-height: min(480px, calc(100vh - 120px));
    display: none;
    flex-direction: column;
    background: var(--lf-surface, #fff);
    border: 1px solid var(--lf-border, #ddd);
    box-shadow: var(--lf-shadow-modal, 0 20px 60px rgba(0,0,0,.2));
    border-radius: var(--lf-radius-modal, 12px);
    overflow: hidden;
}

.lf-chat-panel--open { display: flex; }

.lf-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--lf-border, #eee);
    background: var(--lf-surface-2, #fafafa);
}

.lf-chat-title { font-weight: 600; font-size: 0.9375rem; }

.lf-chat-close {
    border: 0;
    background: none;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: var(--lf-muted, #666);
}

.lf-chat-blocked {
    padding: 10px 16px;
    background: #fff3cd;
    color: #856404;
    font-size: 0.8125rem;
    border-bottom: 1px solid #ffeeba;
}

.lf-chat-blocked[hidden] { display: none; }

.lf-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 200px;
}

.lf-chat-empty {
    color: var(--lf-muted, #888);
    font-size: 0.875rem;
    text-align: center;
    padding: 24px 8px;
}

.lf-chat-msg {
    max-width: 88%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 0.875rem;
    line-height: 1.4;
}

.lf-chat-msg--user {
    align-self: flex-end;
    background: var(--lf-primary, #1a1a1a);
    color: var(--lf-on-primary, #fff);
    border-bottom-right-radius: 4px;
}

.lf-chat-msg--operator {
    align-self: flex-start;
    background: var(--lf-surface-2, #f0f0f0);
    color: var(--lf-text, #111);
    border-bottom-left-radius: 4px;
}

.lf-chat-msg-meta {
    font-size: 0.6875rem;
    opacity: 0.75;
    margin-bottom: 4px;
}

.lf-chat-compose {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--lf-border, #eee);
}

.lf-chat-input {
    width: 100%;
    resize: none;
    border: 1px solid var(--lf-border, #ccc);
    border-radius: 8px;
    padding: 10px 12px;
    font: inherit;
    font-size: 0.875rem;
    box-sizing: border-box;
}

.lf-chat-send {
    align-self: flex-end;
    padding: 10px 18px;
    font-size: 0.875rem;
}

@media (max-width: 480px) {
    .lf-chat { bottom: 16px; right: 16px; }
    .lf-chat-panel { width: calc(100vw - 32px); right: 0; }
}
