/* =========================================================
   chat-widget.css  —  ИИ-чат блок на главной странице
   Встроен в поток страницы (не floating), под карточками.
   Переменные из index.html: --bg-primary, --accent-gold и др.
   ========================================================= */

/* ─── Позиционирование в grid карточек ─────────────────────────────────────
   #chat-section — последний дочерний элемент .cards-grid.
   На десктопе: занимает всю ширину второго ряда.
   На мобильном: через order встаёт после первой карточки.
   ─────────────────────────────────────────────────────────────────────────── */

#chat-section {
    grid-column: 1 / -1;
    justify-self: stretch;
    width: 100%;
    max-width: 860px;
    margin: 8px auto 0;
}

@media (max-width: 768px) {
    .cards-grid .card:nth-child(1) { order: 1; }
    #chat-section                  { order: 2; }
    .cards-grid .card:nth-child(2) { order: 3; }
    .cards-grid .card:nth-child(3) { order: 4; }
}

/* ─── Контейнер чата ────────────────────────────────────────────────────── */

.chat-container {
    background: rgba(17, 24, 39, 0.85);
    border: 1px solid rgba(212, 168, 83, 0.2);
    border-radius: 24px;
    padding: 24px 28px 20px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* ─── Шапка ─────────────────────────────────────────────────────────────── */

.chat-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(212, 168, 83, 0.15);
}

.chat-header-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #d4a853 0%, #f4d793 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(212, 168, 83, 0.3);
}

.chat-header-icon svg {
    width: 20px;
    height: 20px;
    stroke: #0a0f1c;
    stroke-width: 2;
    fill: none;
}

.chat-header-title {
    font-size: 1rem;
    font-weight: 700;
    color: #f8fafc;
    line-height: 1.3;
}

.chat-header-subtitle {
    font-size: 0.78rem;
    color: #94a3b8;
    margin-top: 2px;
}

/* ─── Область сообщений ─────────────────────────────────────────────────── */

#chat-messages {
    min-height: 160px;
    max-height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 2px 0 16px;
    scrollbar-width: thin;
    scrollbar-color: rgba(212, 168, 83, 0.25) transparent;
}

#chat-messages::-webkit-scrollbar { width: 4px; }
#chat-messages::-webkit-scrollbar-thumb {
    background: rgba(212, 168, 83, 0.25);
    border-radius: 4px;
}

/* Пузырьки */
.chat-bubble {
    max-width: 76%;
    padding: 11px 16px;
    border-radius: 18px;
    font-size: 0.875rem;
    line-height: 1.55;
    word-break: break-word;
}

.chat-bubble.bot {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.09);
    color: #f1f5f9;
    border-bottom-left-radius: 4px;
}

.chat-bubble.user {
    align-self: flex-end;
    background: rgba(212, 168, 83, 0.12);
    border: 1px solid rgba(212, 168, 83, 0.28);
    color: #f8fafc;
    border-bottom-right-radius: 4px;
}

/* Typing indicator */
.chat-bubble.typing {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.09);
    padding: 14px 18px;
    border-bottom-left-radius: 4px;
}

.typing-dots {
    display: flex;
    gap: 5px;
    align-items: center;
}

.typing-dots span {
    width: 7px;
    height: 7px;
    background: #94a3b8;
    border-radius: 50%;
    animation: typing-bounce 1.3s infinite ease-in-out;
}

.typing-dots span:nth-child(2) { animation-delay: 0.18s; }
.typing-dots span:nth-child(3) { animation-delay: 0.36s; }

@keyframes typing-bounce {
    0%, 70%, 100% { transform: scale(0.75); opacity: 0.4; }
    35%           { transform: scale(1);    opacity: 1;   }
}

/* ─── QUICK_ACTIONS ─────────────────────────────────────────────────────── */

.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.quick-btn {
    background: rgba(212, 168, 83, 0.07);
    border: 1px solid rgba(212, 168, 83, 0.22);
    border-radius: 20px;
    color: #d4a853;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 6px 14px;
    cursor: pointer;
    transition: background 0.18s, border-color 0.18s, color 0.18s;
    white-space: nowrap;
}

.quick-btn:hover {
    background: rgba(212, 168, 83, 0.16);
    border-color: #d4a853;
    color: #f4d793;
}

/* ─── Поле ввода (Gemini-стиль) ─────────────────────────────────────────── */

.chat-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(212, 168, 83, 0.22);
    border-radius: 16px;
    padding: 10px 12px;
    transition: border-color 0.2s;
}

.chat-input-wrap:focus-within {
    border-color: rgba(212, 168, 83, 0.55);
}

.chat-attach-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #64748b;
    padding: 4px;
    flex-shrink: 0;
    align-self: flex-end;
    margin-bottom: 2px;
    transition: color 0.2s;
    line-height: 0;
}

.chat-attach-btn:hover { color: #d4a853; }

#chat-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: #f8fafc;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.875rem;
    line-height: 1.5;
    resize: none;
    max-height: 120px;
    overflow-y: auto;
    scrollbar-width: none;
    padding: 2px 0;
}

#chat-input::placeholder { color: #475569; }

#chat-send-btn {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #d4a853 0%, #f4d793 100%);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    align-self: flex-end;
    transition: transform 0.18s, box-shadow 0.18s, opacity 0.18s;
}

#chat-send-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(212, 168, 83, 0.4);
}

#chat-send-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#chat-send-btn svg {
    width: 16px;
    height: 16px;
    stroke: #0a0f1c;
    stroke-width: 2.5;
    fill: none;
}

/* ─── Превью файла ──────────────────────────────────────────────────────── */

#chat-file-preview {
    display: none;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    padding: 8px 12px;
    background: rgba(212, 168, 83, 0.07);
    border: 1px solid rgba(212, 168, 83, 0.2);
    border-radius: 10px;
}

#chat-file-preview.visible { display: flex; }

#chat-file-thumb {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}

.file-preview-name {
    flex: 1;
    font-size: 0.8rem;
    color: #94a3b8;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-preview-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: #64748b;
    font-size: 1rem;
    padding: 2px 6px;
    transition: color 0.2s;
    flex-shrink: 0;
}

.file-preview-remove:hover { color: #ef4444; }

/* ─── CTA при лимите ────────────────────────────────────────────────────── */

#chat-limit-cta {
    text-align: center;
    padding: 20px;
    background: rgba(212, 168, 83, 0.05);
    border: 1px solid rgba(212, 168, 83, 0.18);
    border-radius: 14px;
    margin-top: 12px;
}

#chat-limit-cta p {
    color: #94a3b8;
    font-size: 0.875rem;
    margin-bottom: 14px;
    line-height: 1.6;
}

.cta-phones {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.cta-phones a {
    color: #f4d793;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: color 0.2s;
}

.cta-phones a:hover { color: #d4a853; }

.whatsapp-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #25d366;
    color: #fff;
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 0.875rem;
    padding: 11px 24px;
    border-radius: 12px;
    text-decoration: none;
    transition: background 0.2s, transform 0.18s;
}

.whatsapp-btn:hover {
    background: #1ebe5d;
    transform: scale(1.04);
}

/* ─── Кнопки подтверждения (Да / Внести правки) ────────────────────────── */

.chat-confirm-wrap {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding: 4px 0 8px;
}

.confirm-btn {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.84rem;
    font-weight: 600;
    padding: 9px 20px;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.16s, box-shadow 0.16s, background 0.16s;
    border: none;
}

.confirm-btn--yes {
    background: linear-gradient(135deg, #d4a853 0%, #f4d793 100%);
    color: #0a0f1c;
}

.confirm-btn--yes:hover {
    transform: scale(1.04);
    box-shadow: 0 4px 16px rgba(212, 168, 83, 0.4);
}

.confirm-btn--edit {
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #94a3b8;
}

.confirm-btn--edit:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #f8fafc;
}

/* Пузырёк ошибки */
.chat-bubble--error {
    border-color: rgba(239, 68, 68, 0.35) !important;
    background: rgba(239, 68, 68, 0.08) !important;
    color: #fca5a5 !important;
}

/* ─── Мобильные правки ──────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .chat-container {
        padding: 18px 16px 16px;
        border-radius: 18px;
    }

    #chat-messages {
        max-height: 260px;
        min-height: 120px;
    }

    .chat-bubble {
        max-width: 88%;
        font-size: 0.84rem;
    }

    .quick-btn {
        font-size: 0.74rem;
        padding: 5px 11px;
    }

    .chat-header-title { font-size: 0.92rem; }
    .chat-header-subtitle { font-size: 0.73rem; }
}
