/* ============================================================
   Стили кнопки и окна чата ИПЭ
   Файл: assets/styles/chat.css
   ============================================================ */

/* Круглая кнопка чата в правом нижнем углу — жёлтый кружок,
   чёрная иконка (серединка) */
.custom-chat-btn {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 9999;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;              /* чёрная иконка */
    background: #FFD400;      /* жёлтый кружок */
    box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.custom-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, .3);
    background: #FFC400;      /* чуть темнее жёлтый при наведении */
}
.custom-chat-btn:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}
.custom-chat-btn__icon { display: block; }

@media (max-width: 639px) {
    .custom-chat-btn {
        right: 14px;
        bottom: 14px;
        width: 50px;
        height: 50px;
    }
}

/* ---- Модальное окно чата ---- */
.chat-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, .5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.chat-window {
    width: 420px;
    max-width: 100%;
    height: 560px;
    max-height: 100%;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .3);
    display: flex;
    flex-direction: column;
    font-family: "Open Sans", Arial, sans-serif;
    color: #222;
}

/* Шапка окна — логотип + адрес сайта */
.chat-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: #333;
    color: #fff;
    font-size: 14px;
    letter-spacing: .3px;
}
.chat-header__left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.chat-header__logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
    flex: 0 0 auto;
}
.chat-header__title {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chat-header__close {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .15);
    color: #fff;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}
.chat-header__close:hover { background: rgba(255, 255, 255, .3); }

/* Рабочая зона */
.chat-body {
    flex: 1 1 auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.chat-textarea {
    flex: 1 1 auto;
    width: 100%;
    resize: none;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    line-height: 1.4;
    font-family: inherit;
    color: #222;
    background: #fafafa;
    min-height: 0;
    box-sizing: border-box;
}
.chat-textarea::placeholder {
    color: #999;
    opacity: 1;
}
.chat-textarea:focus {
    outline: none;
    border-color: #999;
    background: #fff;
}

/* Список прикреплённых файлов */
.chat-files {
    flex: 0 0 auto;
    margin-top: 8px;
    font-size: 12px;
    color: #555;
    max-height: 80px;
    overflow-y: auto;
}
.chat-files__item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0;
}
.chat-files__remove {
    color: #c00;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
}

/* Панель кнопок */
.chat-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #eee;
    background: #fff;
}
.chat-actions__left,
.chat-actions__right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    padding: 8px 14px;
    transition: background .15s ease, opacity .15s ease;
    box-sizing: border-box;
}
.chat-btn_icon {
    width: 40px;
    height: 40px;
    padding: 0;
    background: #f0f0f0;
    color: #333;
}
.chat-btn_icon:hover { background: #e4e4e4; }
.chat-btn_send {
    background: #333;
    color: #fff;
    font-weight: 600;
}
.chat-btn_send:hover { background: #1f1f1f; }
.chat-btn_send:disabled { opacity: .5; cursor: default; }

.chat-btn__icon { display: block; }
.chat-hidden-input { display: none; }

/* ============================================================
   Плавный переход: по умолчанию ничего не прозрачно.
   Класс .is-fading добавляется к <body> ТОЛЬКО в момент
   старта анимации, поэтому начальная страница видна всегда.
   ============================================================ */
.page-fade-overlay {
    position: fixed;
    inset: 0;
    z-index: 100000;
    background: #fff;
    opacity: 0;
    transition: opacity var(--fade-duration, 800ms) ease;
    pointer-events: none;
}
.page-fade-overlay.is-active {
    opacity: 1;
    pointer-events: auto;
}

body.is-fading .site-wrapper,
body.is-fading .custom-chat-btn {
    transition: opacity var(--fade-duration, 800ms) ease;
    opacity: 0;
}