/* ==================== 메신저 스타일 (v2) ==================== */

.messenger-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 180px);
    max-height: 700px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    overflow: hidden;
}

/* 탭 헤더 */
.messenger-tabs {
    display: flex;
    border-bottom: 2px solid #e5e7eb;
    background: #f9fafb;
}
.messenger-tab-btn {
    flex: 1;
    padding: 12px;
    border: none;
    background: none;
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}
.messenger-tab-btn.active {
    color: #667eea;
    border-bottom: 2px solid #667eea;
    margin-bottom: -2px;
}
.messenger-tab-btn:hover { color: #667eea; }

.messenger-tab-content { display: none; flex: 1; overflow-y: auto; }
.messenger-tab-content.active { display: flex; flex-direction: column; }

/* ==================== 검색바 ==================== */
.messenger-search-bar {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
    gap: 8px;
}
.messenger-search-bar i { color: #9ca3af; font-size: 14px; }
.messenger-search-bar input {
    flex: 1;
    border: none;
    background: none;
    font-size: 14px;
    outline: none;
    color: #1f2937;
}
.messenger-search-bar input::placeholder { color: #9ca3af; }

/* ==================== 대화 목록 ==================== */
.conversation-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
    transition: background 0.15s;
    gap: 12px;
}
.conversation-item:hover { background: #f0f4ff; }
.conversation-item.active { background: #eef2ff; border-left: 3px solid #667eea; }

.conv-avatar { font-size: 36px; color: #9ca3af; flex-shrink: 0; }
.conv-info { flex: 1; min-width: 0; }
.conv-header { display: flex; justify-content: space-between; align-items: center; }
.conv-name { font-weight: 600; color: #1f2937; font-size: 15px; }
.conv-time { font-size: 11px; color: #9ca3af; }
.conv-preview { font-size: 14px; color: #6b7280; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-unread {
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    flex-shrink: 0;
}

/* ==================== 새 대화 직원 목록 ==================== */
.new-chat-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
    gap: 12px;
    transition: background 0.15s;
}
.new-chat-item:hover { background: #f0f4ff; }
.new-chat-item i { font-size: 32px; color: #9ca3af; }
.new-chat-item .emp-name { font-weight: 600; font-size: 14px; color: #1f2937; }
.new-chat-item .emp-dept { font-size: 12px; color: #9ca3af; }

/* ==================== 채팅 화면 ==================== */
#messengerChat {
    display: none;
    flex-direction: column;
    height: 100%;
}
.chat-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
    gap: 12px;
}
.chat-header .btn-back {
    border: none;
    background: none;
    font-size: 18px;
    color: #667eea;
    cursor: pointer;
    padding: 4px 8px;
}
.chat-partner-info .partner-name { font-weight: 600; font-size: 15px; color: #1f2937; }
.chat-partner-info .partner-dept { font-size: 12px; color: #9ca3af; }

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

.chat-message {
    display: flex;
    flex-direction: column;
    max-width: 75%;
    position: relative;
}
.chat-message.mine { align-self: flex-end; align-items: flex-end; }
.chat-message.theirs { align-self: flex-start; align-items: flex-start; }
.msg-sender { font-size: 11px; color: #6b7280; margin-bottom: 2px; font-weight: 500; }

/* 메시지 버블 + ⋮ 버튼 행 */
.msg-bubble-row {
    display: flex;
    align-items: flex-start;
    gap: 4px;
}
.msg-bubble-row.mine { flex-direction: row; }
.msg-bubble-row.theirs { flex-direction: row; }

/* ⋮ 액션 버튼 */
.msg-action-btn {
    background: none;
    border: none;
    color: #b0b8c4;
    font-size: 14px;
    cursor: pointer;
    padding: 4px 5px;
    border-radius: 50%;
    transition: all 0.15s;
    opacity: 0;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    min-height: 26px;
    margin-top: 2px;
}
.chat-message:hover .msg-action-btn {
    opacity: 1;
}
.msg-action-btn:hover {
    background: rgba(0,0,0,0.08);
    color: #667eea;
}
/* 모바일에서는 항상 보이게 */
@media (hover: none) {
    .msg-action-btn { opacity: 0.7; }
}

.msg-bubble {
    padding: 8px 12px;
    border-radius: 16px;
    font-size: 15px;
    line-height: 1.45;
    word-break: break-word;
    white-space: normal;
    cursor: default;
    user-select: text;
    font-family: -apple-system, BlinkMacSystemFont, 'Malgun Gothic', '맑은 고딕', 'Segoe UI', sans-serif;
    letter-spacing: -0.2px;
}
.msg-text {
    font-size: 15px;
    line-height: 1.45;
    white-space: pre-wrap;
}
.chat-message.mine .msg-bubble {
    background: #667eea;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-message.theirs .msg-bubble {
    background: #fff;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}
.msg-time { font-size: 11px; color: #9ca3af; margin-top: 3px; }
.msg-edited {
    font-size: 10px;
    opacity: 0.7;
    font-style: italic;
    margin-left: 4px;
}

/* ==================== 파일 첨부 ==================== */
.msg-file {
    margin-bottom: 6px;
}
.msg-file a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: rgba(255,255,255,0.2);
    border-radius: 8px;
    color: inherit;
    text-decoration: none;
    font-size: 13px;
    transition: background 0.15s;
}
.chat-message.theirs .msg-file a {
    background: #f3f4f6;
    color: #667eea;
}
.msg-file a:hover { opacity: 0.85; }
.msg-file-image img {
    max-width: 220px;
    max-height: 200px;
    border-radius: 8px;
    cursor: pointer;
    display: block;
    margin-bottom: 4px;
}
.msg-file-image .msg-file-name {
    font-size: 11px;
    opacity: 0.7;
}

/* 파일 프리뷰 */
#filePreview {
    display: none;
    padding: 6px 12px;
    background: #f0f4ff;
    border-top: 1px solid #e5e7eb;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}
.file-preview-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #374151;
}
.file-preview-item .file-size { color: #9ca3af; font-size: 11px; }
.file-preview-remove {
    border: none;
    background: none;
    color: #ef4444;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 4px;
}

/* ==================== 입력 영역 ==================== */
.chat-input-area {
    display: flex;
    padding: 10px 12px;
    border-top: 1px solid #e5e7eb;
    background: #fff;
    gap: 6px;
    align-items: center;
}
.chat-input-area .btn-attach {
    background: none;
    border: none;
    color: #9ca3af;
    font-size: 18px;
    cursor: pointer;
    padding: 6px;
    transition: color 0.2s;
    flex-shrink: 0;
}
.chat-input-area .btn-attach:hover { color: #667eea; }
.chat-input-area input[type="text"] {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    min-width: 0;
}
.chat-input-area input[type="text"]:focus { border-color: #667eea; }
.chat-input-area .btn-send {
    background: #667eea;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.chat-input-area .btn-send:hover { background: #5567d5; }
.chat-input-area .btn-send.editing { background: #10b981; }
.chat-input-area .btn-send.editing:hover { background: #059669; }

/* 수정 바 */
.edit-bar {
    display: none;
    padding: 6px 14px;
    background: #fef9c3;
    border-top: 1px solid #fde68a;
    font-size: 13px;
    color: #92400e;
    align-items: center;
    gap: 8px;
}
.edit-bar-cancel {
    margin-left: auto;
    border: none;
    background: none;
    color: #92400e;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 3px;
}
.edit-bar-cancel:hover { color: #dc2626; }

/* ==================== 컨텍스트 메뉴 ==================== */
.msg-context-menu {
    position: fixed;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    z-index: 10000;
    min-width: 140px;
    overflow: hidden;
    animation: ctxFadeIn 0.12s ease;
}
@keyframes ctxFadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}
.ctx-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-size: 13px;
    color: #374151;
    cursor: pointer;
    transition: background 0.1s;
}
.ctx-item:hover { background: #f0f4ff; }
.ctx-item i { width: 16px; text-align: center; color: #6b7280; }
.ctx-danger { color: #dc2626; }
.ctx-danger i { color: #dc2626; }
.ctx-danger:hover { background: #fef2f2; }

/* ==================== 공지 ==================== */
.notice-item {
    padding: 14px 16px;
    border-bottom: 1px solid #f3f4f6;
}
.notice-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
}
.notice-sender { font-size: 13px; font-weight: 600; color: #667eea; }
.notice-time { font-size: 11px; color: #9ca3af; }
.notice-body { font-size: 14px; color: #374151; line-height: 1.5; white-space: pre-wrap; }

.notice-input-area {
    display: flex;
    padding: 12px;
    border-top: 1px solid #e5e7eb;
    gap: 8px;
    margin-top: auto;
}
.notice-input-area input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
}
.notice-input-area input:focus { border-color: #667eea; }

/* ==================== 빈 상태 ==================== */
.messenger-empty {
    text-align: center;
    padding: 60px 20px;
    color: #9ca3af;
}
.messenger-empty i { font-size: 48px; margin-bottom: 12px; display: block; }
.messenger-empty p { margin: 4px 0; font-size: 15px; }
.messenger-empty .sub { font-size: 13px; }

/* ==================== 사이드바 배지 ==================== */
.menu-item .messenger-badge {
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    margin-left: auto;
}

/* ==================== 직원 입사/퇴사 관련 ==================== */
.employee-resigned {
    opacity: 0.55;
    background: #f9fafb !important;
}
.resigned-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #fee2e2;
    color: #dc2626;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
}
.hire-date-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #ecfdf5;
    color: #059669;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
}
.date-info-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

/* ==================== 모바일 대응 ==================== */
@media (max-width: 768px) {
    .messenger-container { height: calc(100vh - 140px); max-height: none; }
    .chat-message { max-width: 85%; }
    .msg-file-image img { max-width: 160px; max-height: 140px; }
    .msg-context-menu { min-width: 120px; }
    .ctx-item { padding: 9px 14px; font-size: 13px; }
    .msg-action-btn { opacity: 0.7; font-size: 13px; min-width: 24px; min-height: 24px; }
}
