/* ✅ 채팅 전체 박스 */
.chat-box {
    display: flex;
    flex-direction: column;
    height: 320px;
    max-height: 320px;
    font-family: 'Noto Sans KR', sans-serif;
}

/* ✅ 상단 툴바 (새로고침, 청소 등) */
.chat-tools-top {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    background: #fff;
    border-radius: 6px 6px 0 0;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
    position: relative;
    z-index: 5;
}

.chat-tools-top img {
    width: 14px;
    height: 14px;
    opacity: 0.75;
    cursor: pointer;
    transition: 0.2s;
}

.chat-tools-top img:hover {
    transform: scale(1.1);
    opacity: 1;
}

/* ✅ 메시지 영역 */
.chat-content {
    flex: 1;
    min-height: 252px;
    max-height: 255px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
    background: #fff;
    border-radius: 0 0 8px 8px;
    box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.08);
    font-size: 14px;
    color: #111;
}

/* ✅ 기본 말풍선 */
.chat-msg {
    display: inline-block;
    background: #f1f1f1;
    color: #000;
    border-radius: 10px;
    padding: 2px 7px;
    margin: 4px 0;
    max-width: 80%;
    word-break: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    line-height: 1.5;
    transition: background 0.3s, color 0.3s;
}

/* ✅ 내 메시지 */
.chat-msg.user {
    align-self: flex-end;
    background: #cce5ff;
    text-align: left;
}

/* ✅ 시스템 메시지 */
.chat-msg.system {
    align-self: center;
    color: #666;
    font-size: 12px;
    background: none;
    padding: 2px 6px;
    border-radius: 0;
}

/* ✅ 닉네임 */
.chat-sender {
    font-weight: 700;
    margin-bottom: 4px;
    color: #333;
}

/* ✅ 채팅 내용 */
.chat-text {
    color: #111;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: break-word;
    line-height: 1.5;
}

/* ✅ 채팅 입력 영역 */
.chat-input-area {
    display: flex;
    align-items: center;
    margin-top: 6px;
    gap: 5px;
    height: 26px;
}

#chatInput {
    flex: 1;
    height: 100%;
    padding: 0 8px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 13px;
    outline: none;
    background: #fff;
    color: #111;
    transition: background 0.3s, color 0.3s, border 0.3s;
}

#chatInput:focus {
    border-color: #4a90e2;
}

.img-btn {
    background: none;
    border: none;
    padding: 0;
    height: 100%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.img-btn img {
    height: 90%;
    width: auto;
    max-height: 24px;
    transition: transform 0.2s;
}

.img-btn img:hover {
    transform: scale(1.1);
}

/* ✅ 🌙 다크모드 대응 */
body.dark-mode .chat-tools-top {
    background: #222;
    box-shadow: 0 1px 4px rgba(255, 255, 255, 0.05);
}

body.dark-mode .chat-content {
    background: #2a2a2a;
    color: #eee;
    box-shadow: inset 0 0 4px rgba(255, 255, 255, 0.05);
}

/* 기본 말풍선 */
body.dark-mode .chat-msg {
    background: #3a3a3a;
    color: #f5f5f5;
}

/* 내 말풍선 */
body.dark-mode .chat-msg.user {
    background: #4a6fa5;
    color: #e8f0ff;
}

/* 시스템 메시지 */
body.dark-mode .chat-msg.system {
    color: #aaa;
    background: none;
}

/* 입력창 */
body.dark-mode #chatInput {
    background: #1f1f1f;
    border-color: #555;
    color: #eee;
}

/* 버튼 */
body.dark-mode .img-btn img {
    filter: invert(1);
    opacity: 0.9;
}

/* 닉네임 */
body.dark-mode .chat-sender {
    color: #ddd;
}

/* 텍스트 */
body.dark-mode .chat-text {
    color: #f1f1f1;
}

/* ✅ 모바일에서 채팅 전체 박스 표시 강제 (header.css 덮어쓰기) */
@media screen and (max-width: 768px) {
    /* chat-box를 보이게 복구 */
    .chat-box {
        display: flex !important;
        flex-direction: column !important;
        height: auto !important;
        max-height: none !important;
        background: transparent !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin-top: 6px !important;
    }

    /* 메시지·입력창은 숨김 */
    .chat-content,
    .chat-input-area,
    .chat-tools-top {
        display: none !important;
    }

    /* 인기글/뉴스는 표시 */
    .chat-extra-section,
    .chat-stock-news-section {
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
        /*margin-top: 10px !important;*/
    }

    /* 내부 요소 여백 최소화 */
    .chat-extra-section ul li,
    .chat-stock-news-section ul li {
        font-size: 13px !important;
        padding: 4px 0 !important;
    }
}


