/* ── Виджет чата ── */

/* Кнопка открытия (fixed,右下) */
#chat-toggle-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1050;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, #FF6B35, #FFA500);
    border: none;
    color: #fff;
    font-size: 1.3rem;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(255,107,53,.35);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .2s, box-shadow .2s;
}
#chat-toggle-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(255,107,53,.5);
}

/* Бейдж непрочитанных */
#chat-toggle-btn .chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #dc3545;
    color: #fff;
    font-size: .65rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    line-height: 1;
}

/* Панель чата */
#chat-panel {
    position: fixed;
    bottom: 82px;
    right: 20px;
    z-index: 1049;
    width: 340px;
    height: 440px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 8px 36px rgba(0,0,0,.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
}

/* Заголовок панели */
#chat-panel .chat-header {
    background: linear-gradient(135deg, #FF6B35, #2C3E50);
    color: #fff;
    padding: .7rem 1rem;
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-shrink: 0;
}
#chat-panel .chat-header .chat-back {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0;
    display: none;
}
#chat-panel .chat-header .chat-title {
    font-weight: 700;
    font-size: .9rem;
    flex: 1;
}
#chat-panel .chat-header .chat-close {
    background: none;
    border: none;
    color: rgba(255,255,255,.7);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
}

/* Поиск контактов */
.chat-search {
    padding: .5rem .75rem;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}
.chat-search input {
    width: 100%;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: .4rem .6rem;
    font-size: .82rem;
    outline: none;
}
.chat-search input:focus {
    border-color: #FF6B35;
}

/* Список контактов */
#chat-contacts {
    flex: 1;
    overflow-y: auto;
    padding: .3rem 0;
}
.chat-contact {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .55rem 1rem;
    cursor: pointer;
    transition: background .12s;
}
.chat-contact:hover {
    background: #f8f9fa;
}
.chat-contact .contact-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.chat-contact .contact-dot.online { background: #4CAF50; }
.chat-contact .contact-dot.offline { background: #ccc; }
.chat-contact .contact-name {
    font-size: .84rem;
    font-weight: 500;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chat-contact .contact-badge {
    background: #dc3545;
    color: #fff;
    font-size: .6rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* Окно чата */
#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: .75rem;
    display: none;
    flex-direction: column;
    gap: .4rem;
}
.chat-msg {
    max-width: 80%;
    padding: .45rem .7rem;
    border-radius: 12px;
    font-size: .82rem;
    line-height: 1.35;
    word-break: break-word;
}
.chat-msg.mine {
    align-self: flex-end;
    background: #FF6B35;
    color: #fff;
    border-bottom-right-radius: 4px;
}
/* Разделитель дат в ленте сообщений */
.chat-date-sep {
    text-align: center;
    font-size: .7rem;
    color: #999;
    padding: .3rem 0;
    margin: .2rem 0;
}
.chat-msg.theirs {
    align-self: flex-start;
    background: #f0f0f0;
    color: #333;
    border-bottom-left-radius: 4px;
}
.chat-msg .msg-time {
    font-size: .62rem;
    opacity: .7;
    margin-top: 2px;
    text-align: right;
}
.chat-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #aaa;
    font-size: .82rem;
    text-align: center;
    padding: 1rem;
}

/* Поле ввода */
#chat-input-area {
    padding: .5rem .75rem;
    border-top: 1px solid #eee;
    display: none;
    gap: .4rem;
    flex-shrink: 0;
}
#chat-input-area input {
    flex: 1;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    padding: .4rem .8rem;
    font-size: .82rem;
    outline: none;
}
#chat-input-area input:focus {
    border-color: #FF6B35;
}
#chat-input-area button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #FF6B35;
    border: none;
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    flex-shrink: 0;
}
