/* ============================================================
   💬 СТИЛИ ЧАТА
   ============================================================ */

/* Плавающая кнопка чата */
#chatToggleBtn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(145deg, #2980b9, #1a5276);
    color: white;
    font-size: 1.8rem;
    cursor: pointer;
    box-shadow: 0 4px 0 #0d3a5c, 0 0 25px rgba(41, 128, 185, 0.5);
    z-index: 10000;
    transition: 0.2s;
}

#chatToggleBtn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #0d3a5c;
}

/* Окно чата */
#chatWindow {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 320px;
    max-width: 90vw;
    height: 420px;
    max-height: 70vh;
    background: rgba(15, 20, 35, 0.95);
    border: 2px solid #2980b9;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 10000;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
}

/* Шапка чата */
.chat-header {
    background: linear-gradient(90deg, #2980b9, #1a5276);
    padding: 12px 15px;
    font-weight: bold;
    font-size: 1rem;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chat-user-label {
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.15);
    padding: 3px 10px;
    border-radius: 15px;
}

/* Область сообщений */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}
.chat-messages::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}
.chat-messages::-webkit-scrollbar-thumb {
    background: #2980b9;
    border-radius: 3px;
}

/* Сообщение */
.chat-msg {
    padding: 8px 12px;
    border-radius: 14px;
    max-width: 85%;
    display: flex;
    flex-direction: column;
    gap: 2px;
    word-wrap: break-word;
    animation: chatFadeIn 0.3s ease;
}

@keyframes chatFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.chat-msg-mine {
    align-self: flex-end;
    background: linear-gradient(145deg, #2980b9, #1a5276);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-msg-other {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.1);
    color: #ddd;
    border-bottom-left-radius: 4px;
}

.chat-msg-name {
    font-size: 0.7rem;
    font-weight: bold;
    opacity: 0.8;
}

.chat-msg-text {
    font-size: 0.9rem;
    line-height: 1.3;
}

.chat-msg-time {
    font-size: 0.6rem;
    opacity: 0.6;
    align-self: flex-end;
}

/* Пустой чат и ошибки */
.chat-empty {
    text-align: center;
    color: #888;
    font-style: italic;
    margin-top: 20px;
}

.chat-error {
    text-align: center;
    color: #ff6b6b;
    font-size: 0.8rem;
    padding: 10px;
}

/* Поле ввода */
.chat-input-row {
    display: flex;
    gap: 8px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
}

#chatInput {
    flex: 1;
    padding: 10px 14px;
    border: none;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 0.9rem;
    outline: none;
}

#chatInput:focus {
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 0 2px #2980b9;
}

#chatInput::placeholder {
    color: #888;
}

#chatSendBtn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: #2980b9;
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    transition: 0.1s;
    flex-shrink: 0;
}

#chatSendBtn:active {
    transform: scale(0.9);
    background: #1a5276;
}

/* ============================================================
   МОДАЛЬНОЕ ОКНО ВВОДА ИМЕНИ
   ============================================================ */
#chatNameModal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10001;
    backdrop-filter: blur(5px);
}

.chat-name-box {
    background: #1a2a3a;
    padding: 30px 40px;
    border-radius: 25px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 0 50px rgba(41, 128, 185, 0.5);
    border: 2px solid #2980b9;
}

.chat-name-box h2 {
    color: white;
    margin-bottom: 10px;
    font-size: 1.4rem;
}

.chat-name-box p {
    color: #aaa;
    margin-bottom: 20px;
    font-size: 0.95rem;
}

#chatNameInput {
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-radius: 30px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 1rem;
    text-align: center;
    outline: none;
    margin-bottom: 15px;
}

#chatNameInput:focus {
    box-shadow: 0 0 0 2px #2980b9;
}

#chatNameSaveBtn {
    background: linear-gradient(145deg, #2980b9, #1a5276);
    border: none;
    border-radius: 30px;
    padding: 12px 30px;
    color: white;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: 0.1s;
    box-shadow: 0 3px 0 #0d3a5c;
}

#chatNameSaveBtn:active {
    transform: translateY(3px);
    box-shadow: 0 0 0 #0d3a5c;
}

/* ============================================================
   АДАПТАЦИЯ ДЛЯ ТЕЛЕФОНА
   ============================================================ */
@media (max-width: 500px) {
    #chatToggleBtn {
        width: 50px;
        height: 50px;
        font-size: 1.4rem;
        bottom: 15px;
        right: 15px;
    }

    #chatWindow {
        width: calc(100vw - 30px);
        right: 15px;
        bottom: 75px;
        height: 350px;
    }

    .chat-name-box {
        padding: 20px;
    }
}