/* ============================================
   ЧАТ: СПИСОК КОМНАТ
   ============================================ */
.chat-page {
    max-width: 800px;
    margin: 0 auto;
}

.chat-page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 12px;
}

.chat-rooms-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-room-card {
    display: block;
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    text-decoration: none;
    color: var(--text-primary);
    transition: background 0.2s;
    border: 1px solid var(--border);
}

.chat-room-card:hover {
    background: var(--bg-secondary);
}

.chat-room-name {
    font-size: 18px;
    margin-bottom: 8px;
}

.chat-room-desc {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 8px;
}

.chat-room-type {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.chat-room-type--public {
    background: rgba(46, 204, 113, 0.2);
    color: var(--success);
}

.chat-room-type--officer {
    background: rgba(255, 215, 0, 0.2);
    color: var(--gold);
}

.chat-room-type--private {
    background: rgba(136, 146, 164, 0.2);
    color: var(--text-secondary);
}

/* Анимация появления формы создания комнаты */
.create-room-form {
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   ЧАТ: КОМНАТА
   ============================================ */
.chat-room-page {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 120px);
    max-width: 1200px;
    margin: 0 auto;
}

.chat-room-header {
    padding: 16px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}

.chat-back-btn {
    display: inline-block;
    margin-bottom: 8px;
    color: var(--accent);
    text-decoration: none;
}

.chat-room-title {
    font-size: 20px;
    margin: 0;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-loading {
    text-align: center;
    color: var(--text-secondary);
    padding: 20px;
}

.chat-empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px 20px;
    font-style: italic;
    font-size: 15px;
}

.chat-message {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 12px;
    border: 1px solid var(--border);
    transition: background 0.3s ease;
}

/* ============================================
   ЧАТ: ПОДСВЕТКА УПОМИНАНИЙ
   ============================================ */
.chat-message--mentioned {
    border-left: 4px solid var(--accent);
    background: linear-gradient(135deg, rgba(233, 69, 96, 0.1) 0%, rgba(233, 69, 96, 0.03) 100%);
    position: relative;
    box-shadow: 0 0 0 1px rgba(233, 69, 96, 0.1);
}

.chat-message--mentioned.new-mention {
    animation: highlightMention 2.5s ease-out;
}

@keyframes highlightMention {
    0% { 
        background: rgba(233, 69, 96, 0.4); 
        transform: translateX(-10px);
        box-shadow: 0 0 20px rgba(233, 69, 96, 0.3);
    }
    50% {
        background: rgba(233, 69, 96, 0.2);
    }
    100% { 
        background: linear-gradient(135deg, rgba(233, 69, 96, 0.1) 0%, rgba(233, 69, 96, 0.03) 100%); 
        transform: translateX(0);
        box-shadow: 0 0 0 1px rgba(233, 69, 96, 0.1);
    }
}

.chat-message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 13px;
    flex-wrap: wrap;
    gap: 8px;
}

.chat-message-author-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-message-author {
    font-weight: 600;
    color: var(--accent);
}

.chat-message-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ============================================
   ЧАТ: КНОПКА ОТВЕТА (УВЕЛИЧЕННАЯ)
   ============================================ */
.chat-reply-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 20px;
    padding: 8px 10px;
    border-radius: 6px;
    transition: all 0.2s;
    opacity: 1;
    line-height: 1;
    min-width: 36px;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.chat-reply-btn:hover {
    background: var(--bg-secondary);
    transform: scale(1.1);
}

.chat-reply-btn:active {
    transform: scale(0.95);
}

.chat-message-time {
    color: var(--text-secondary);
    font-size: 12px;
}

/* ============================================
   ЧАТ: КНОПКА КОПИРОВАНИЯ НИКА
   ============================================ */
.chat-copy-nick-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 4px 6px;
    border-radius: 4px;
    transition: all 0.2s;
    opacity: 0.6;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.chat-copy-nick-btn:hover {
    background: var(--bg-secondary);
    opacity: 1;
    transform: scale(1.1);
}

.chat-copy-nick-btn:active {
    transform: scale(0.95);
}

/* На мобильных кнопка копирования всегда видна и больше */
@media (max-width: 768px) {
    .chat-copy-nick-btn {
        font-size: 16px;
        padding: 6px 8px;
        opacity: 1;
    }
}

.chat-mention-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    margin-left: 4px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { 
        opacity: 1; 
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(233, 69, 96, 0.7);
    }
    50% { 
        opacity: 0.8; 
        transform: scale(1.1);
        box-shadow: 0 0 0 4px rgba(233, 69, 96, 0);
    }
}

/* ============================================
   ЧАТ: ЦИТАТА (ОТВЕТ)
   ============================================ */
.chat-message-reply {
    background: var(--bg-secondary);
    border-left: 3px solid var(--accent);
    padding: 8px 12px;
    border-radius: 4px;
    margin-bottom: 8px;
    font-size: 13px;
}

.chat-message-reply-author {
    color: var(--accent);
    font-weight: 600;
    display: block;
    margin-bottom: 2px;
}

.chat-message-reply-text {
    color: var(--text-secondary);
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.chat-message-text {
    font-size: 15px;
    line-height: 1.5;
    word-wrap: break-word;
}

/* ============================================
   ЧАТ: ОБЛАСТЬ ВВОДА
   ============================================ */
.chat-input-area {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 16px;
}

.chat-profile-selector {
    margin-bottom: 12px;
}

.chat-profile-selector label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.chat-profile-selector select {
    width: 100%;
}

/* ============================================
   ЧАТ: ПРЕДПРОСМОТР ОТВЕТА
   ============================================ */
.chat-reply-preview {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    padding: 10px 16px;
    margin-bottom: -1px;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-reply-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.chat-reply-cancel {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.chat-reply-cancel:hover {
    color: var(--danger);
}

.chat-reply-preview-text {
    font-size: 14px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-form {
    display: flex;
    gap: 8px;
}

.chat-input {
    flex: 1;
    padding: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    color: var(--text-primary);
    font-size: 15px;
    resize: none;
    font-family: inherit;
    max-height: 120px;
    overflow-y: auto;
}

.chat-input:focus {
    outline: none;
    border-color: var(--accent);
}

.chat-send-btn {
    padding: 12px 24px;
    white-space: nowrap;
}

/* ============================================
   АДАПТИВНОСТЬ: МОБИЛЬНЫЕ
   ============================================ */
@media (max-width: 768px) {
    .chat-room-page {
        height: calc(100vh - 100px);
    }
    
    .chat-form {
        flex-direction: column;
    }
    
    .chat-send-btn {
        width: 100%;
    }
    
    /* Кнопка ответа ещё больше на мобильных */
    .chat-reply-btn {
        font-size: 22px;
        padding: 10px 12px;
        min-width: 40px;
        min-height: 40px;
    }
    
    .chat-message--mentioned {
        border-left-width: 5px;
    }
    
    .chat-message-actions {
        gap: 4px;
    }
    
    .chat-mention-icon {
        width: 20px;
        height: 20px;
        font-size: 12px;
    }
}

/* ============================================
   АДАПТИВНОСТЬ: ДЕСКТОП
   ============================================ */
@media (min-width: 769px) {
    .chat-message:hover .chat-reply-btn {
        background: var(--bg-secondary);
    }
}