/* 🔥 Chat Component CSS - 중복 제거 및 최적화 */

/* 🔥 공통 배경색 통합 */
.chat-input-form,
.chat-input-form input,
.message-text,
.message-input-wrapper {
}

/* 채팅 섹션 */
.chat-section {
    display: flex;
    flex-direction: column;
    min-width: 320px;
    background: var(--card-bg);
    overflow: hidden;
}

.chat-section-header h2 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-color);
}

.chat-header-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}



.chat-users-count {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--text-color-secondary);
}

/* 🔥 채팅 래퍼 */
.chat-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    background: var(--card-bg);
}

/* 🔥 채팅 메시지 영역 */
#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--card-bg);
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

/* 🔥 메시지 아이템 */
.message-item {
    display: flex;
    align-items: flex-start;
    gap: 3px;
    padding: 4px 0;
    max-width: 85%;
    word-break: break-word;
    margin-bottom: 4px;
}

.message-item.my-message {
    flex-direction: row-reverse;
    margin-left: auto;
    margin-right: 0;
}

.message-item:not(.my-message) {
    align-self: flex-start;
}

/* 🔥 프로필 사진 */
.chat-profile-pic-wrap {
    flex-shrink: 0;
    width: 36px;
    margin: 0 8px 0 0;
}

.chat-profile-pic {
    border-radius: 40%;
    object-fit: cover;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 13px;
    color: #fff;
    text-transform: uppercase;
}

.message-item.my-message .chat-profile-pic-wrap {
    margin: 0 0 0 8px;
}

/* 🔥 메시지 콘텐츠 */
.message-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    max-width: 90%;
}

.message-item.my-message .message-content {
    align-items: flex-end;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}

.message-sender {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-color-secondary);
    margin-bottom: 4px;
}

.message-sender .level-badge {
    color: var(--primary-color);
    font-weight: 700;
}

.message-sender .admin-badge {
    color: #ef5350;
    font-weight: 700;
}

.message-sender strong {
    color: var(--text-color);
    font-weight: 600;
}

.message-time {
    color: var(--text-color-secondary);
    font-size: 11px;
    white-space: nowrap;
    margin-left: 8px;
    min-width: 38px;
    text-align: right;
}

.message-item.my-message .message-time {
    margin-left: 0;
    margin-right: 8px;
    text-align: left;
}

/* 🔥 메시지 텍스트 */
.message-text {
    font-size: 14px;
    line-height: 1.4;
    word-break: break-word;
    color: var(--text-color);
    padding: 8px 12px;
    border-radius: 5px;
    margin: 0;
    max-width: 100%;
    box-sizing: border-box;
    overflow-wrap: break-word;
    background-color: #f1f1f1;
}

/* 🔥 채팅 입력 폼 */
.chat-input-form {
    display: flex;
    gap: 8px;
    padding: 10px 8px;
    flex-shrink: 0;
    box-sizing: border-box;
    height: 60px;
}

#message-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

#message-input:focus {
    border-color: var(--primary-color);
}

#message-input::placeholder {
    color: var(--text-color-secondary);
}

.chat-input-form button {
    padding: 0px 20px;
    border: none;
    border-radius: 12px;
    background-color: var(--primary-color);
    color: white;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    min-width: 60px;
}

.chat-input-form button:hover {
    background-color: #2563eb;
    transform: translateY(-1px);
}

.chat-input-form button:active {
    transform: translateY(0);
}

/* 🔥 채팅 스크롤바 */
#chat-messages::-webkit-scrollbar {
    width: 6px;
}

#chat-messages::-webkit-scrollbar-track {
    border-radius: 3px;
}

#chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

#chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-color-secondary);
}

/* 🔥 채팅 알림 */
.chat-notice {
    text-align: center;
    padding: 20px;
    color: var(--text-color-secondary);
    font-size: 14px;
    border-radius: 8px;
    margin: 10px;
}

/* 🔥 채팅 입력 비활성화 */
.chat-input-disabled {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.chat-input-disabled::after {
    content: '채팅이 일시적으로 제한되었습니다';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(239, 68, 68, 0.9);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    z-index: 10;
}

/* 🔥 검열된 메시지 */
.message-moderated {
    position: relative;
    opacity: 0.7;
}

.message-moderated::before {
    content: '⚠️ 부적절한 내용이 감지되어 필터링되었습니다';
    position: absolute;
    top: -25px;
    left: 0;
    font-size: 0.8rem;
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid rgba(239, 68, 68, 0.2);
}



/* 속보 뉴스 메시지 스타일 */
.message-item.breaking-news {
    background: linear-gradient(135deg, #ffa726, #ffcc02);
    border-left: 4px solid #ff9800;
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.3);
}

.message-item.breaking-news.clickable {
    cursor: pointer;
    transition: all 0.2s ease;
}

.message-item.breaking-news.clickable:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.4);
}

/* 다크모드에서 속보 뉴스 스타일 */
:root.dark-mode .message-item.breaking-news {
    background: linear-gradient(135deg, #ff9800, #ffa726);
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.4);
}


/* 🔥 모바일 반응형 */
@media (max-width: 768px) {
    .chat-section {
        flex: 1;
        width: 100% !important;
        min-width: 0;
        max-width: 100vw;
        border-left: none;
        border-top: 1px solid var(--border-color);
        position: relative;
    }
    
    .chat-section-header {
        height: 41px;
        border-bottom: 3px solid var(--border-color);
    }
    
    .chat-wrapper {
        position: relative;
        padding-bottom: 0;
    }
    
    #chat-messages {
        padding: 10px;
        padding-bottom: 60px;
    }
    
    .chat-input-form {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--card-bg);
        border-top: 1px solid var(--border-color);
        padding: 8px;
        z-index: 100;
        height: 52px;
    }
    
    #message-input {
        font-size: 16px;
        height: 36px;
        padding: 8px 12px;
    }
    
    .chat-input-form button {
        height: 36px;
        padding: 8px 16px;
        font-size: 14px;
    }
    
    .message-item {
        max-width: 85%;
        margin: 4px 0;
    }
    
    .chat-profile-pic,
    .chat-profile-pic-wrap {
        width: 32px;
        height: 32px;
    }
    
    .message-text {
        font-size: 14px;
        padding: 8px 12px;
    }
}

/* 🔥 다크 모드 지원 */
:root.dark-mode .chat-section,
:root.dark-mode .chat-wrapper,
:root.dark-mode #chat-messages,
:root.dark-mode .chat-input-form {
    background-color: var(--bg-primary);
}

:root.dark-mode #message-input {
    color: var(--text-color);
    border-color: var(--border-color);
    background-color: var(--card-bg);
}

/* 다크모드 메시지 텍스트 배경 */
:root.dark-mode .message-text {
    color: var(--text-color);
    background-color: rgba(255, 255, 255, 0.1);
}

/* 라이트모드 메시지 텍스트 */
:root:not(.dark-mode) #message-input {
    color: var(--text-color);
    border-color: var(--border-color);
    background-color: #ffffff;
}

:root:not(.dark-mode) .message-text {
    color: var(--text-color);
    background-color: #f2f3f5;
}


 