/* ═══════════════════════════════════════════════════
   FAB КНОПКА
═══════════════════════════════════════════════════ */
#chat-fab {
    position: fixed;
    bottom: 80px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2d7d46, #4caf6f);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    border: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
#chat-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.35);
}
#chat-fab:focus-visible {
    outline: 3px solid #4caf6f;
    outline-offset: 3px;
}
#chat-fab svg {
    width: 28px;
    height: 28px;
    fill: #fff;
    pointer-events: none;
}
.chat-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    background: #e53935;
    border-radius: 50%;
    border: 2px solid #fff;
    display: none;
}

/* ═══════════════════════════════════════════════════
   ОКНО ЧАТА
═══════════════════════════════════════════════════ */
#chat-window {
    position: fixed;
    bottom: 150px;
    right: 30px;
    width: 370px;
    max-height: 560px;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 8px 48px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    z-index: 9998;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.9) translateY(16px);
    transform-origin: bottom right;
    transition: opacity 0.25s ease,
                transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#chat-window.open {
    opacity: 1;
    pointer-events: all;
    transform: scale(1) translateY(0);
}

/* ═══════════════════════════════════════════════════
   ШАПКА
═══════════════════════════════════════════════════ */
#chat-header {
    background: linear-gradient(135deg, #2d7d46, #4caf6f);
    color: #fff;
    padding: 13px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.chat-avatar {
    width: 38px;
    height: 38px;
    background: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    padding:2px;
}
.chat-header-info {
    flex: 1;
    min-width: 0;
}
.chat-title {
    font-weight: 700;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-subtitle {
    font-size: 11px;
    opacity: 0.85;
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.chat-header-actions button {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    transition: opacity 0.15s, background 0.15s;
}
.chat-header-actions button:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.18);
}
.chat-header-actions button svg {
    width: 17px;
    height: 17px;
    fill: #fff;
    pointer-events: none;
}

/* ═══════════════════════════════════════════════════
   ОБЛАСТЬ СООБЩЕНИЙ
═══════════════════════════════════════════════════ */
#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: #f5f7fa;
    scroll-behavior: smooth;
}
#chat-messages::-webkit-scrollbar {
    width: 4px;
}
#chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
#chat-messages::-webkit-scrollbar-thumb {
    background: #d0d0d0;
    border-radius: 2px;
}

/* ═══════════════════════════════════════════════════
   ОБЁРТКА СООБЩЕНИЯ
═══════════════════════════════════════════════════ */
.chat-msg-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 84%;
    gap: 2px;
    animation: msgFadeIn 0.2s ease;
}
@keyframes msgFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.chat-msg-wrapper--user {
    align-self: flex-end;
    align-items: flex-end;
}
.chat-msg-wrapper--bot,
.chat-msg-wrapper--typing {
    align-self: flex-start;
    align-items: flex-start;
}

/* ═══════════════════════════════════════════════════
   СООБЩЕНИЕ
═══════════════════════════════════════════════════ */
.chat-msg {
    padding: 9px 13px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.55;
    word-break: break-word;
    max-width: 100%;
}
.chat-msg--user {
    background: #2d7d46;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-msg--bot {
    background: #fff;
    color: #1a1a1a;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}
.chat-msg--bot a {
    color: #2d7d46;
    text-decoration: none;
}
.chat-msg--bot a:hover {
    text-decoration: underline;
}
.chat-msg--bot b {
    font-weight: 600;
}
.chat-msg--bot i {
    font-style: italic;
}

/* ═══════════════════════════════════════════════════
   ВРЕМЯ СООБЩЕНИЯ
═══════════════════════════════════════════════════ */
.chat-msg-time {
    font-size: 10px;
    color: #aaa;
    padding: 0 4px;
}

/* ═══════════════════════════════════════════════════
   ИНДИКАТОР ПЕЧАТАНИЯ
═══════════════════════════════════════════════════ */
.chat-msg--typing {
    background: #fff;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 16px;
    min-width: 52px;
}
.typing-dot {
    width: 7px;
    height: 7px;
    background: #aaa;
    border-radius: 50%;
    display: inline-block;
    animation: typingBounce 1.2s infinite ease-in-out;
}
.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); background: #ccc; }
    30%            { transform: translateY(-6px); background: #4caf6f; }
}

/* ═══════════════════════════════════════════════════
   ФОТО В СООБЩЕНИИ
═══════════════════════════════════════════════════ */
.chat-msg-photo {
    margin-top: 8px;
    border-radius: 10px;
    overflow: hidden;
    max-width: 240px;
}
.chat-msg-photo img {
    width: 100%;
    height: auto;
    display: block;
    max-height: 180px;
    object-fit: cover;
    border-radius: 10px;
}

/* ═══════════════════════════════════════════════════
   ПОЛЕ ВВОДА
═══════════════════════════════════════════════════ */
#chat-input-area {
    display: flex;
    align-items: flex-end;
    padding: 10px 12px;
    gap: 8px;
    border-top: 1px solid #eee;
    background: #fff;
    flex-shrink: 0;
}
#chat-input {
    flex: 1;
    border: 1.5px solid #e0e0e0;
    border-radius: 20px;
    padding: 9px 14px;
    font-size: 13.5px;
    outline: none;
    resize: none;
    font-family: inherit;
    line-height: 1.4;
    max-height: 120px;
    overflow-y: auto;
    background: #f9f9f9;
    transition: border-color 0.2s, background 0.2s;
    color: #1a1a1a;
}
#chat-input:focus {
    border-color: #4caf6f;
    background: #fff;
}
#chat-input::placeholder {
    color: #aaa;
}
#chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #2d7d46;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.15s, opacity 0.2s;
}
#chat-send:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}
#chat-send:not(:disabled):hover {
    background: #1b5e35;
    transform: scale(1.08);
}
#chat-send svg {
    width: 18px;
    height: 18px;
    fill: #fff;
    pointer-events: none;
}

/* ═══════════════════════════════════════════════════
   ФУТЕР
═══════════════════════════════════════════════════ */
#chat-footer {
    text-align: center;
    font-size: 10px;
    color: #bbb;
    padding: 5px 12px 7px;
    background: #fff;
    flex-shrink: 0;
}
#chat-footer a {
    color: #4caf6f;
    text-decoration: none;
}
#chat-footer a:hover {
    text-decoration: underline;
}



/* ═══════════════════════════════════════════════════
   КАРТОЧКА ОБЪЕКТА
═══════════════════════════════════════════════════ */
.chat-object-card {
    background: #fff;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.10);
    max-width: 310px;
    width: 100%;
    transition: box-shadow 0.2s;
}
.chat-object-card:hover {
    box-shadow: 0 4px 18px rgba(0,0,0,0.16);
}

/* Фото */
.chat-card-photo {
    width: 100%;
    height: 160px;
    overflow: hidden;
    background: #f0f0f0;
}
.chat-card-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}
.chat-object-card:hover .chat-card-photo img {
    transform: scale(1.04);
}

/* Тело карточки */
.chat-card-body {
    padding: 11px 13px 13px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.chat-card-title {
    font-weight: 700;
    font-size: 14px;
    color: #1a1a1a;
    line-height: 1.3;
}
.chat-card-type {
    font-size: 11px;
    color: #4caf6f;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.chat-card-address {
    font-size: 12px;
    color: #666;
}
.chat-card-preview {
    font-size: 12px;
    color: #555;
    line-height: 1.45;
    margin-top: 2px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.chat-card-link {
    display: inline-block;
    margin-top: 8px;
    padding: 6px 14px;
    background: #2d7d46;
    color: #fff !important;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none !important;
    text-align: center;
    transition: background 0.2s, transform 0.15s;
    align-self: flex-start;
}
.chat-card-link:hover {
    background: #1b5e35;
    transform: translateY(-1px);
}

/* ═══════════════════════════════════════════════════
   КНОПКА «ПОКАЗАТЬ ЕЩЁ»
═══════════════════════════════════════════════════ */
.chat-show-more-wrapper {
    display: flex;
    justify-content: center;
    padding: 6px 0 4px;
    width: 100%;
}
.chat-show-more-btn {
    background: #f0faf4;
    color: #2d7d46;
    border: 1.5px solid #4caf6f;
    border-radius: 20px;
    padding: 8px 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s, opacity 0.2s;
    font-family: inherit;
}
.chat-show-more-btn:hover:not(:disabled) {
    background: #2d7d46;
    color: #fff;
    transform: translateY(-1px);
}
.chat-show-more-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}
.chat-all-shown {
    font-size: 12px;
    color: #888;
    padding: 6px 0;
    text-align: center;
}

/* ═══════════════════════════════════════════════════
   ПАГИНАЦИЯ
═══════════════════════════════════════════════════ */
.chat-pagination-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 4px;
    width: 100%;
}
.chat-show-more-btn {
    background: #f0faf4;
    color: #2d7d46;
    border: 1.5px solid #4caf6f;
    border-radius: 20px;
    padding: 7px 18px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, transform 0.15s;
    font-family: inherit;
    white-space: nowrap;
}
.chat-show-more-btn:hover:not(:disabled) {
    background: #2d7d46;
    color: #fff;
    transform: translateY(-1px);
}
.chat-show-more-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}
.chat-pagination-counter {
    font-size: 11px;
    color: #aaa;
    white-space: nowrap;
    flex-shrink: 0;
}


#chat-input-area input::-webkit-outer-spin-button,#chat-input-area input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
#chat-input-area textarea {overflow:hidden;}

/* ═══════════════════════════════════════════════════
   МОБИЛЬНАЯ АДАПТАЦИЯ
═══════════════════════════════════════════════════ */
@media (max-width: 480px) {
    #chat-window {
        width: calc(100vw - 20px);
        max-height: calc(100dvh - 110px);
        right: 10px;
        bottom: 80px;
        top:80px;
        border-radius: 14px;
	z-index:9999;
    }

#chat-input-area input::-webkit-outer-spin-button,#chat-input-area input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

    #chat-fab {
/*        bottom: 16px;
        right: 16px;*/
	bottom: 80px;
        right: 20px;
        width: 54px;
        height: 54px;
    }
    #chat-fab svg {
        width: 24px;
        height: 24px;
    }
}
