/* ============================================================
   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 {
    font-size: var(--lf-font-size-xs);
    color: var(--lf-text-faint);
}
.lf-error {
    font-size: var(--lf-font-size-xs);
    color: var(--lf-danger);
    min-height: 1em;
}

/* ----- Инпуты (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;
}

.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-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;
}

/* ============================================================
   CHAT (двусторонняя переписка)
   ============================================================ */
.lf-chat {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.lf-chat-log {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 320px;
    min-height: 180px;
    overflow-y: auto;
    padding: 6px 2px;
    background: var(--lf-surface-muted, #f5f7fb);
    border: 1px solid var(--lf-border);
    border-radius: var(--lf-radius-input);
}
.lf-chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 88%;
    padding: 0 8px;
}
.lf-chat-msg-user     { align-self: flex-end;   align-items: flex-end; }
.lf-chat-msg-operator { align-self: flex-start; align-items: flex-start; }
.lf-chat-msg-system   { align-self: center;     align-items: center; opacity: 0.7; }

.lf-chat-bubble {
    display: inline-block;
    padding: 8px 12px;
    border-radius: 14px;
    font-size: var(--lf-font-size-sm);
    line-height: 1.4;
    word-wrap: break-word;
    white-space: pre-wrap;
}
.lf-chat-msg-user .lf-chat-bubble {
    background: var(--lf-primary);
    color: var(--lf-on-primary);
    border-bottom-right-radius: 4px;
}
.lf-chat-msg-operator .lf-chat-bubble {
    background: var(--lf-surface);
    color: var(--lf-text);
    border: 1px solid var(--lf-border);
    border-bottom-left-radius: 4px;
}
.lf-chat-msg-system .lf-chat-bubble {
    background: transparent;
    color: var(--lf-text-faint);
    font-size: var(--lf-font-size-xs);
    font-style: italic;
}

.lf-chat-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 6px;
    width: 100%;
}
.lf-chat-options .lf-btn {
    padding: 8px 12px;
    font-size: var(--lf-font-size-sm);
}

.lf-chat-input-row {
    display: flex;
    gap: 8px;
}
.lf-chat-input {
    flex: 1;
    margin: 0;
}
.lf-chat-send {
    width: auto;
    padding: 10px 18px;
    margin: 0;
}

/* ============================================================
   ПЛАВАЮЩАЯ КНОПКА (если 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; }
}
