/* 기존 messengerToggle CSS를 아래 코드로 교체하세요 */
#messengerToggle { 
    position: fixed;
    right: 20px; /* 여기서 우측 20px로 강제 고정합니다 */
    background: #b5c0c8 !important; 
    border: none !important; 
    color: #ffffff !important; 
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2002 !important; /* 다른 아이콘들과 동일한 우선순위 */
}
#messengerToggle:hover { transform: scale(1.1); }

/* 알림 뱃지 */
.msg-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: #ff6b6b;
    color: white;
    border-radius: 50%;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: bold;
    display: none; /* 읽지 않은 메시지가 있을 때만 보임 */
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* 호버 툴팁 */
#messengerHoverBox { background: #dce4eb; color: #76a2c4; }

/* 이 부분의 z-index를 수정하세요! */
#messengerWindow {
    position: fixed;
    right: 20px;
    width: 280px; 
    height: min(380px, 70vh);
    min-height: 260px;
    background: #ffffff;
    border: 1px solid #dce4eb;
    border-radius: 12px;
    overflow: hidden;
    padding: 0;
    display: flex !important; 
    flex-direction: column; 
    visibility: hidden; 
    transform: translateX(300px); 
    transition: transform 0.4s ease, visibility 0.4s; 
    z-index: 2000 !important; 
}

@media (max-width: 768px) {
    #messengerWindow {
        width: min(238px, 75vw);
        height: 323px;
    }
}

/* 콕 찌르면 나타나는 스타일 */
#messengerWindow.is-open {
    transform: translateX(0) !important;
    visibility: visible !important;
}

/* 3. 헤더: 색상을 빼고 텍스트와 하단 테두리로만 깔끔하게 */
.msg-header {
    background: #ffffff;
    color: #333333;
    padding: 12px 15px;
    font-weight: bold;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f0f0f0; /* 하단 얇은 선 */
}

.msg-fake-input {
    flex: 1;

    height: 36px;

    border: 1px solid #dce4eb;
    border-radius: 18px;

    padding: 0 12px;

    display: flex;
    align-items: center;

    background: #fbfbfb;

    color: #999;
    font-size: 12px;

    overflow: hidden;
}

.msg-fake-input span::after {
    content:"";
    display:inline-block;

    width:1.5px;
    height:13px;

    background:#76a2c4;

    margin-left:3px;
    vertical-align:middle;

    animation: blinkCursor 1s infinite;
}

@keyframes blinkCursor {
    0%,50% {
        opacity:1;
    }

    51%,100% {
        opacity:0;
    }
}

.msg-force-btn {
    flex-shrink: 0;

    width: 32px;
    height: 32px;

    border: none;
    border-radius: 50%;

    display: flex;
    align-items: center;
    justify-content: center;

    background: #eef2f5;
    color: #aab4bc;

    cursor: default;

    padding: 0;
}
.msg-force-btn:hover {
    opacity:0.9;
}
.msg-force-btn:active { transform: scale(0.98); }
.msg-force-btn:disabled {
    opacity: 1;
    pointer-events: none;
}

.msg-body {
    padding: 15px 0; /* 👈 변경: 위아래 여백 15px 추가, 좌우는 0 유지 */
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* 메시지 창 스크롤바 숨기기 */
.msg-body::-webkit-scrollbar {
    display: none; /* 크롬, 사파리, 엣지에서 스크롤바 영역을 완전히 숨김 */
}

.msg-body {
    -ms-overflow-style: none;  /* 인터넷 익스플로러, 엣지 구버전 */
    scrollbar-width: none;  /* 파이어폭스 */
}

/* 점 세 개 애니메이션 */
.loading-dots::after {
    content: '.';
    animation: dots 1.5s steps(5, end) infinite;
}
@keyframes dots { 0%, 20% { content: '.'; } 40% { content: '..'; } 60% { content: '...'; } 80%, 100% { content: ''; } }

/* 메시지 버블 기본 스타일 */
.msg-bubble {
    padding: 8px 12px;
    margin: 0 12px;
    border-radius: 15px;
    font-size: 12px;
    display: inline-block;
    max-width: 75%; /* 글이 너무 길어지면 줄바꿈 되도록 설정 */
    word-break: break-word;
    line-height: 1.4;
}

/* 💛 A: 로잔나 (상대 톡 - 왼쪽 / 노란색 계열) */
.msg-bubble.A { 
    align-self: flex-start; /* 왼쪽 정렬 */
    color: #555555; /* 부드러운 진회색 텍스트 */
    background-color: #fce9b1; /* 아주 연한 노란색 바탕 */
    border-bottom-left-radius: 2px; /* 말풍선 꼬리 방향 (왼쪽) */
    border-bottom-right-radius: 15px; /* 반대쪽은 둥글게 복원 */
}

/* 💙 B: 마야 (내 톡 - 오른쪽 / 파란색 계열) */
.msg-bubble.B { 
    align-self: flex-end; /* 오른쪽 정렬 */
    color: #333333; /* 또렷한 진회색 텍스트 */
    background-color: #bfddf5; /* 파란색 바탕 */
    border-bottom-right-radius: 2px; /* 말풍선 꼬리 방향 (오른쪽) */
    border-bottom-left-radius: 15px; /* 반대쪽은 둥글게 복원 */
}

/* 통신 상태(입력 중) 스타일 */
.msg-typing {
    background-color: #eef2f5 !important;
    border: 1px solid #dce4eb !important;
    color: #888888 !important;
    font-style: italic;
    font-size: 11px;
    align-self: flex-start; /* 상대방이 치는 것처럼 보이기 위해 왼쪽 고정 */
    border-bottom-left-radius: 2px;
}

/* messenger.css 맨 아래에 추가 */

/* 창이 열렸을 때 화면 안으로 이동 */
#messengerWindow.is-open {
    transform: translateX(0) !important;
    display: flex !important;
}

.msg-footer {
    display: flex;
    align-items: center;
    gap: 6px;

    padding: 10px;
    border-top: 1px solid #f0f0f0;
    background: #fff;
}

.msg-loading {
    position: absolute;
    top: 50%;
    left: 50%;

    transform: translate(-50%, -50%);

    color: #888;
    font-size: 13px;
    white-space: nowrap;
}

.loading-dots::after {
    content: '';
    display: inline-block;
    width: 1.5em;
    text-align: left;
    animation: dots 1.2s infinite;
}

@keyframes dots {
    0%   { content: ''; }
    25%  { content: '.'; }
    50%  { content: '..'; }
    75%  { content: '...'; }
    100% { content: ''; }
}

.msg-error {
    text-align: center;
    padding: 30px 20px;
    color: #c55;
}

.msg-history-limit {

    margin: 0 0 12px 0;

    text-align: center;

    font-size: 11px;
    letter-spacing: 0.2px;
    line-height: 1.6;

    color: #888;
}

.msg-history-limit .history-text {
    opacity: 0.75;
}

.history-fade {
    margin-top: -15px; /* 👈 추가: msg-body의 패딩(15px)만큼 위로 다시 당기기 */
    height: 42px;
    background: linear-gradient(
        to bottom,
        rgba(180,180,180,0.22) 0%,
        rgba(180,180,180,0.08) 50%,
        rgba(180,180,180,0) 100%
    );
    margin-bottom: 8px;
}
