/* 메신저 — 완전 독립 스타일 */

/* ──────────────── 팝업 안내 다이얼로그 ──────────────── */
.messenger-info-dialog-dim {
    position: fixed;
    inset: 0;
    bottom: var(--ad-reserved, 40px);
    z-index: 10200;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: messengerFadeIn 0.15s ease-out;
    padding: 20px;
}
.messenger-info-dialog {
    background: #fff;
    border-radius: 14px;
    width: 460px;
    max-width: 100%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
    color: #1e293b;
    overflow: hidden;
}
.messenger-info-head {
    display: flex;
    align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid #e5e7eb;
    background: #f8fafc;
    font-weight: 700;
    font-size: 1rem;
}
.messenger-info-head > span { flex: 1; }
.messenger-info-head-warn {
    background: #fef3c7;
    color: #92400e;
    border-bottom-color: #fcd34d;
}
.messenger-info-close {
    background: none; border: none; font-size: 1.1rem; cursor: pointer;
    padding: 2px 6px; color: #6b7280;
}
.messenger-info-close:hover { color: #1e293b; }
.messenger-info-body {
    padding: 16px 18px;
    overflow-y: auto;
    font-size: 0.88rem;
    line-height: 1.6;
    color: #374151;
}
.messenger-info-body p { margin: 6px 0; }
.messenger-info-note {
    margin: 12px 0;
    padding: 10px 12px;
    background: #eff6ff;
    border-left: 3px solid #2563eb;
    border-radius: 6px;
    font-size: 0.85rem;
    color: #1e40af;
}
.messenger-info-details {
    margin-top: 10px;
    padding: 8px 12px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}
.messenger-info-details > summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    color: #1e293b;
    list-style: disclosure-closed;
    outline: none;
}
.messenger-info-details[open] > summary { list-style: disclosure-open; }
.messenger-info-details ol, .messenger-info-details ul { font-size: 0.85rem; color: #374151; }
.messenger-info-skip {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 14px;
    font-size: 0.82rem;
    color: #6b7280;
    cursor: pointer;
    user-select: none;
}
.messenger-info-skip input { margin: 0; }
.messenger-info-foot {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 18px;
    border-top: 1px solid #e5e7eb;
    background: #f8fafc;
}
.messenger-info-btn {
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
}
.messenger-info-btn-cancel {
    background: #fff;
    border-color: #d1d5db;
    color: #374151;
}
.messenger-info-btn-cancel:hover { background: #f3f4f6; }
.messenger-info-btn-primary {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}
.messenger-info-btn-primary:hover { background: #1d4ed8; border-color: #1d4ed8; }

/* 좁은 화면: 다이얼로그 세로 확장 */
@media (max-width: 520px) {
    .messenger-info-dialog { width: 100%; max-height: 90vh; border-radius: 12px; }
}

/* ──────────────── 드래그앤드롭 파일 업로드 오버레이 ──────────────── */
.msg-drop-overlay {
    position: absolute;
    inset: 0;
    z-index: 1000;
    background: rgba(37, 99, 235, 0.08);
    border: 3px dashed #2563eb;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;   /* 리스너는 view 에 이미 붙음; 오버레이는 hit-target X */
    opacity: 0;
    transition: opacity 0.12s ease-out;
}
.msg-drop-overlay.active {
    opacity: 1;
}
.msg-drop-inner {
    background: #fff;
    padding: 24px 32px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(37, 99, 235, 0.2);
    text-align: center;
    color: #1e40af;
}
.msg-drop-icon {
    font-size: 2.4rem;
    margin-bottom: 8px;
}
.msg-drop-text {
    font-size: 1rem;
    font-weight: 700;
    color: #1e40af;
}
.msg-drop-sub {
    font-size: 0.78rem;
    color: #6b7280;
    margin-top: 4px;
}

/* 스탠들언 모드 (/messenger 페이지) — 팝업 창 전체를 채움.
   position:fixed 대신 flex 컬럼으로 뷰포트 가득. body가 이미 height:100vh. */
.messenger-standalone-root {
    display: flex;
    flex-direction: column;
    width: 100vw;
    height: 100vh;
    background: #fff;
    overflow: hidden;
}
.messenger-standalone-root .messenger-body {
    flex: 1;
    min-height: 0;
}
/* 스탠들언에서는 뒤로 버튼을 모바일처럼 항상 노출 (친구추가/채팅방 진입 시 유용) */
.messenger-standalone-root .messenger-header-back { display: inline-block; }

/* 모바일: 전체 화면 (하단 광고 영역 보호) */
.messenger-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: var(--ad-reserved, 40px);
    z-index: 10000;
    background: #fff;
    display: flex;
    flex-direction: column;
    animation: messengerSlideUp 0.25s ease-out;
}
/* 데스크탑: 우측 사이드 패널 (페이지 분할 — 메인 콘텐츠 옆에 배치) */
@media (min-width: 768px) {
    .messenger-overlay {
        position: fixed;
        top: 0;
        right: 0;
        bottom: var(--ad-reserved, 0px);
        left: auto;
        width: 420px;
        max-width: 40vw;
        box-shadow: -4px 0 24px rgba(0,0,0,0.1);
        border-left: 1px solid #e5e7eb;
        animation: messengerSlideIn 0.25s ease-out;
    }
    /* 메인 콘텐츠 영역을 줄여서 메신저와 공존 */
    body.messenger-open {
        padding-right: 420px;
        transition: padding-right 0.25s ease-out;
    }
}
@keyframes messengerSlideUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
@keyframes messengerSlideIn {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

/* 배경 딤 — 모바일만 (데스크탑은 페이지 분할) */
.messenger-dim {
    display: none;
}
@media (max-width: 767px) {
    .messenger-dim {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: var(--ad-reserved, 40px);
        z-index: 9999;
        background: rgba(0,0,0,0.3);
    }
}

/* 헤더 */
.messenger-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
    background: #f8fafc;
    flex-shrink: 0;
}
.messenger-header-back {
    background: none; border: none; font-size: 1.3rem; cursor: pointer;
    padding: 4px 8px; margin-right: 8px; color: #374151;
}
@media (min-width: 768px) {
    .messenger-header-back { display: none; }
}
.messenger-header-title {
    font-size: 1.1rem; font-weight: 700; color: #1e293b; flex: 1;
}
.messenger-header-close {
    background: none; border: none; font-size: 1.2rem; cursor: pointer;
    padding: 4px 8px; color: #6b7280;
}

/* 탭 */
.messenger-tabs {
    display: flex;
    border-bottom: 2px solid #e5e7eb;
    background: #fff;
    flex-shrink: 0;
}
.messenger-tab {
    flex: 1;
    padding: 12px 0;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
    color: #6b7280;
    background: none;
    border: none;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}
.messenger-tab:hover { color: #374151; }
.messenger-tab.active {
    color: #2563eb;
    border-bottom-color: #2563eb;
}
.messenger-tab .tab-badge {
    display: inline-block;
    background: #ef4444;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: 10px;
    padding: 1px 5px;
    margin-left: 4px;
    vertical-align: top;
}

/* 탭 콘텐츠 */
.messenger-body {
    flex: 1;
    overflow-y: auto;
    background: #f9fafb;
}
.messenger-tab-content {
    display: none;
    padding: 0;
    height: 100%;
}
.messenger-tab-content.active {
    display: flex;
    flex-direction: column;
}

/* 친구 탭 */
.msg-friend-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 8px;
}
.msg-friend-search {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.85rem;
    outline: none;
}
.msg-friend-search:focus { border-color: #2563eb; }
.msg-friend-search-btn {
    padding: 8px 14px;
    background: #e2e8f0;
    color: #374151;
    border: none;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.msg-friend-search-btn:hover { background: #cbd5e1; }
.msg-friend-header-divider {
    width: 1px;
    height: 28px;
    background: #d1d5db;
    flex-shrink: 0;
    margin: 0 4px;
}
.msg-friend-add-btn {
    padding: 8px 14px;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.msg-friend-add-btn:hover { background: #1d4ed8; }

/* 섹션 제목 */
.msg-section-title {
    padding: 8px 16px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: #f1f5f9;
    border-bottom: 1px solid #e5e7eb;
}

/* 친구/요청 카드 */
.msg-friend-card {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.1s;
}
.msg-friend-card:hover { background: #f0f7ff; }
.msg-friend-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: #e0e7ff;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
    margin-right: 12px;
}
.msg-friend-info {
    flex: 1;
    min-width: 0;
}
.msg-friend-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: #1e293b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.msg-friend-meta {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 2px;
}
.msg-friend-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}
.msg-btn-accept {
    padding: 5px 12px;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
}
.msg-btn-reject {
    padding: 5px 12px;
    background: #f3f4f6;
    color: #6b7280;
    border: none;
    border-radius: 6px;
    font-size: 0.78rem;
    cursor: pointer;
}
.msg-btn-accept:hover { background: #1d4ed8; }
.msg-btn-reject:hover { background: #e5e7eb; }

/* 친구 추가 다이얼로그 */
.msg-add-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: var(--ad-reserved, 40px);
    z-index: 10100;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: messengerFadeIn 0.15s ease-out;
}
@keyframes messengerFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.msg-add-dialog {
    background: #fff;
    border-radius: 16px;
    width: 400px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 40px rgba(0,0,0,0.2);
}
.msg-add-dialog-header {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
}
.msg-add-dialog-title {
    font-size: 1rem;
    font-weight: 700;
    color: #1e293b;
    flex: 1;
}
.msg-add-dialog-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: #6b7280;
    padding: 4px 8px;
}
.msg-add-dialog-body {
    padding: 20px;
}
.msg-add-mobile-tip {
    margin-top: 16px;
    padding: 10px 14px;
    background: #f0f7ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    font-size: 0.8rem;
    color: #1e40af;
    line-height: 1.4;
}
.msg-add-input-row {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}
.msg-add-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.9rem;
}
.msg-add-search-btn {
    padding: 10px 18px;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}
.msg-search-result {
    padding: 16px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #fff;
}
.msg-search-result .msg-btn-request {
    padding: 8px 16px;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
}
.msg-search-result .msg-btn-sms {
    padding: 8px 16px;
    background: #10b981;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
}
.msg-empty {
    text-align: center;
    padding: 40px 16px;
    color: #9ca3af;
    font-size: 0.9rem;
}

/* 채팅 탭 (Phase 3 준비) */
.msg-chat-list { }
.msg-chat-card {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
}
.msg-chat-card:hover { background: #f0f7ff; }
.msg-chat-preview {
    flex: 1;
    min-width: 0;
}
.msg-chat-name {
    font-weight: 600;
    font-size: 0.88rem;
    color: #1e293b;
}
.msg-chat-last-msg {
    font-size: 0.78rem;
    color: #6b7280;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.msg-chat-time {
    font-size: 0.7rem;
    color: #9ca3af;
    flex-shrink: 0;
    margin-left: 8px;
}
.msg-chat-unread {
    background: #ef4444;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: 10px;
    padding: 2px 6px;
    margin-left: 6px;
    flex-shrink: 0;
}
