﻿/* ============================================================
   Telegram Chat Widget — PsycheCenter
   ============================================================ */

/* Обёртка — правый нижний угол */
#pc-chat-wrapper {
    position: fixed !important;
    bottom: 28px !important;
    right: 28px !important;
    top: auto !important;
    left: auto !important;
    z-index: 2147483645 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-end !important;
    gap: 12px !important;
    font-family: inherit;
    transform: none !important;
    margin: 0 !important;
}

/* Кнопка открытия */
#pc-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #1a6fd4;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(26,111,212,.45);
    transition: background .2s, transform .2s, box-shadow .2s;
    outline: none;
    position: relative;
}

#pc-chat-toggle:hover {
    background: #1255b0;
    transform: scale(1.08);
    box-shadow: 0 8px 28px rgba(26,111,212,.55);
}

#pc-chat-toggle:active { transform: scale(.95); }

/* Пульсирующий индикатор непрочитанных */
#pc-chat-toggle::after {
    content: '';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 12px;
    height: 12px;
    background: #e74c3c;
    border-radius: 50%;
    border: 2px solid #fff;
    display: none;
    animation: pcPulse 1.8s infinite;
}

#pc-chat-toggle.has-unread::after { display: block; }

@keyframes pcPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50%       { transform: scale(1.3); opacity: .7; }
}

/* Окно чата */
#pc-chat-box {
    width: 340px;
    max-width: calc(100vw - 56px);
    height: 480px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 16px 50px rgba(0, 0, 0, .2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    animation: pcChatOpen .3s cubic-bezier(.22,.68,0,1.2);
}

@keyframes pcChatOpen {
    from { opacity: 0; transform: scale(.85) translateY(20px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Шапка */
#pc-chat-header {
    background: linear-gradient(135deg, #1a6fd4, #2e85e0);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.pc-chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pc-chat-avatar {
    font-size: 1.8rem;
    line-height: 1;
}

#pc-chat-header strong {
    display: block;
    font-size: .95rem;
    font-weight: 700;
}

.pc-chat-status {
    font-size: .75rem;
    opacity: .85;
}

.pc-chat-status::before {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    background: #52c8e8;
    border-radius: 50%;
    margin-right: 5px;
    vertical-align: middle;
}

#pc-chat-close-btn {
    background: rgba(255,255,255,.15);
    border: none;
    color: #fff;
    font-size: 1.3rem;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s;
    line-height: 1;
}

#pc-chat-close-btn:hover { background: rgba(255,255,255,.3); }

/* Область сообщений */
#pc-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

#pc-chat-messages::-webkit-scrollbar { width: 4px; }
#pc-chat-messages::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }

/* Сообщения */
.pc-msg {
    max-width: 82%;
    padding: 9px 13px;
    border-radius: 14px;
    font-size: .88rem;
    line-height: 1.45;
    word-break: break-word;
    position: relative;
}

.pc-msg--admin {
    background: #f0f4f8;
    color: #1a1a1a;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.pc-msg--user {
    background: #1a6fd4;
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.pc-msg-time {
    display: block;
    font-size: .7rem;
    opacity: .6;
    margin-top: 3px;
    text-align: right;
}

/* Индикатор «печатает…» */
.pc-typing {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    align-self: flex-start;
}

.pc-typing span {
    width: 7px;
    height: 7px;
    background: #aaa;
    border-radius: 50%;
    animation: pcTyping 1.2s infinite;
}

.pc-typing span:nth-child(2) { animation-delay: .2s; }
.pc-typing span:nth-child(3) { animation-delay: .4s; }

@keyframes pcTyping {
    0%, 80%, 100% { transform: translateY(0); opacity: .4; }
    40%            { transform: translateY(-6px); opacity: 1; }
}

/* Форма ввода */
#pc-chat-form {
    border-top: 1px solid #eee;
    padding: 10px 12px 8px;
    flex-shrink: 0;
}

#pc-chat-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

#pc-chat-input {
    flex: 1;
    border: 1.5px solid #ddd;
    border-radius: 10px;
    padding: 9px 12px;
    font-size: .88rem;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
    max-height: 100px;
    overflow-y: auto;
    line-height: 1.4;
}

#pc-chat-input:focus {
    border-color: #1a6fd4;
    box-shadow: 0 0 0 3px rgba(26,111,212,.12);
}

#pc-chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #1a6fd4;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .2s;
}

#pc-chat-send-btn:hover { background: #1255b0; }
#pc-chat-send-btn:disabled { background: #aaa; cursor: default; }

.pc-chat-disclaimer {
    font-size: .7rem;
    color: #aaa;
    margin: 6px 0 0;
    line-height: 1.4;
}

.pc-chat-disclaimer a { color: #1a6fd4; text-decoration: none; }

@media (max-width: 520px) {
    /* Обёртка ближе к краю экрана */
    #pc-chat-wrapper {
        right: 12px !important;
        bottom: 16px !important;
    }
    /* Кнопка-тогл чуть меньше */
    #pc-chat-toggle {
        width: 52px !important;
        height: 52px !important;
    }
    /* Окно чата — почти на весь экран по высоте */
    #pc-chat-box {
        width: calc(100vw - 32px) !important;
        max-width: none !important;
        /* 65vh = разумный компромисс с браузерными панелями */
        height: 65vh !important;
        max-height: 65vh !important;
    }
    /* Сообщения — чуть компактнее */
    .pc-msg { font-size: .85rem; }
    #pc-chat-input { font-size: .9rem; } /* iOS не зумит при >16px */
}
