/* ============================================================
   dm.css  –  1:1 다이렉트 메시지 플로팅 창
   ============================================================ */

/* ── DM 패널 공통 ─────────────────────────────────── */
.dm-panel {
    position: fixed;
    display: flex;
    flex-direction: column;
    width: 320px;
    height: 480px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,.22);
    border: 1px solid #e2e8f0;
    overflow: hidden;
    transition: box-shadow .2s, height .25s ease;
    font-family: inherit;
}
.dm-panel:hover {
    box-shadow: 0 12px 50px rgba(0,0,0,.28);
}

/* 최소화 */
.dm-panel.dm-minimized {
    height: 44px !important;
    overflow: hidden;
}
.dm-panel.dm-minimized .dm-body {
    display: none;
}

/* ── 헤더 ─────────────────────────────────────────── */
.dm-header {
    flex-shrink: 0;
    height: 44px;
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px 0 12px;
    cursor: grab;
    user-select: none;
    border-radius: 16px 16px 0 0;
}
.dm-panel.dm-minimized .dm-header {
    border-radius: 16px;
}
.dm-header:active { cursor: grabbing; }

.dm-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
}
.dm-header-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(255,255,255,.3);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.dm-header-nick {
    font-size: 13.5px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dm-unread-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 4px;
    border: 1.5px solid #fff;
    flex-shrink: 0;
}

.dm-header-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}
.dm-minimize-btn,
.dm-close-btn {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: rgba(255,255,255,.2);
    color: #fff;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background .15s;
    line-height: 1;
}
.dm-minimize-btn:hover { background: rgba(255,255,255,.35); }
.dm-close-btn:hover    { background: rgba(239,68,68,.7); }

/* ── 바디 ─────────────────────────────────────────── */
.dm-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: #fff;
}

/* ── 메시지 목록 ───────────────────────────────────── */
.dm-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #f8f9fb;
    min-height: 0;
}
.dm-messages::-webkit-scrollbar       { width: 4px; }
.dm-messages::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }

.dm-empty {
    text-align: center;
    color: #cbd5e1;
    font-size: 13px;
    padding: 40px 0;
    line-height: 1.8;
}

/* 날짜 구분선 */
.dm-date-sep {
    align-self: center;
    background: #ececec;
    color: #999;
    font-size: 11px;
    padding: 3px 12px;
    border-radius: 20px;
    margin: 4px 0;
    flex-shrink: 0;
}

/* 메시지 말풍선 */
.dm-msg {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    animation: dmMsgIn .15s ease;
}
@keyframes dmMsgIn {
    from { opacity: 0; transform: translateY(5px); }
    to   { opacity: 1; transform: translateY(0); }
}
.dm-msg.other { align-self: flex-start; }
.dm-msg.mine  { align-self: flex-end; }

.dm-msg-nick {
    font-size: 10.5px;
    font-weight: 700;
    color: #94a3b8;
    margin-bottom: 3px;
}
.dm-msg.mine .dm-msg-nick {
    text-align: right;
    color: #fb923c;
}

.dm-msg-bubble {
    padding: 7px 11px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.5;
    word-break: break-word;
}
.dm-msg.other .dm-msg-bubble {
    background: #fff;
    border: 1.5px solid #e2e8f0;
    color: #1e293b;
    border-radius: 4px 14px 14px 14px;
}
.dm-msg.mine .dm-msg-bubble {
    background: linear-gradient(135deg, #f97316, #ea580c);
    color: #fff;
    border-radius: 14px 4px 14px 14px;
}

/* 이미지 버블 */
.dm-msg-bubble--img {
    padding: 3px !important;
    background: transparent !important;
    border: none !important;
}
.dm-img-wrap  { position: relative; display: inline-block; }
.dm-img-thumb {
    display: block;
    max-width: 180px;
    max-height: 180px;
    border-radius: 10px;
    cursor: zoom-in;
    object-fit: cover;
    border: 2px solid #e2e8f0;
    transition: opacity .2s;
}
.dm-msg.mine .dm-img-thumb { border-color: #fed7aa; }
.dm-img-thumb:hover { opacity: .85; }
.dm-img-size {
    position: absolute; bottom: 4px; right: 4px;
    background: rgba(0,0,0,.48);
    color: #fff; font-size: 9px;
    padding: 1px 4px; border-radius: 3px;
    pointer-events: none;
}

/* 시간 & 읽음 */
.dm-msg-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 3px;
}
.dm-msg.mine .dm-msg-meta { justify-content: flex-end; }
.dm-msg-time {
    font-size: 10px;
    color: #94a3b8;
}
.dm-read-mark {
    font-size: 10px;
    color: #fb923c;
    font-weight: 700;
}

/* ── 이미지 미리보기 줄 ────────────────────────────── */
.dm-img-preview {
    flex-shrink: 0;
    display: none;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    background: #fff7ed;
    border-top: 1.5px solid #fed7aa;
}
.dm-preview-thumb {
    width: 44px; height: 44px;
    object-fit: cover;
    border-radius: 7px;
    border: 1.5px solid #fdba74;
    flex-shrink: 0;
}
.dm-preview-meta {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.dm-preview-name {
    font-size: 11.5px;
    font-weight: 600;
    color: #ea580c;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dm-preview-size {
    font-size: 10.5px;
    color: #94a3b8;
}
.dm-preview-cancel {
    flex-shrink: 0;
    width: 20px; height: 20px;
    background: #ef4444;
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 10px;
    display: flex; align-items: center; justify-content: center;
    padding: 0;
    transition: background .15s;
}
.dm-preview-cancel:hover { background: #dc2626; }

/* ── 업로드 진행 ────────────────────────────────────── */
.dm-upload-progress {
    flex-shrink: 0;
    display: none;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    background: #fff7ed;
    border-top: 1px solid #fed7aa;
}
.dm-upload-bar-wrap {
    flex: 1;
    height: 5px;
    background: #fed7aa;
    border-radius: 3px;
    overflow: hidden;
}
.dm-upload-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #f97316, #ea580c);
    border-radius: 3px;
}
.dm-upload-label {
    font-size: 11px;
    color: #ea580c;
    white-space: nowrap;
    font-weight: 600;
}

/* ── 입력 영역 ─────────────────────────────────────── */
.dm-input-area {
    flex-shrink: 0;
    display: flex;
    align-items: flex-end;
    gap: 5px;
    padding: 7px 8px;
    background: #fff;
    border-top: 1px solid #f1f5f9;
}
.dm-img-btn {
    flex-shrink: 0;
    width: 32px; height: 32px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    font-size: 15px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    padding: 0;
    transition: border-color .2s, background .2s;
}
.dm-img-btn:hover { border-color: #f97316; background: #fff7ed; }
.dm-img-btn:disabled { opacity: .45; cursor: not-allowed; }

.dm-input {
    flex: 1;
    border: 1.5px solid #e2e8f0;
    border-radius: 9px;
    padding: 6px 10px;
    font-size: 13px;
    line-height: 1.4;
    resize: none;
    min-height: 32px;
    max-height: 80px;
    outline: none;
    transition: border-color .2s;
    font-family: inherit;
    overflow-y: auto;
}
.dm-input:focus { border-color: #f97316; }

.dm-send-btn {
    flex-shrink: 0;
    width: 32px; height: 32px;
    border-radius: 8px;
    border: none;
    background: linear-gradient(135deg, #f97316, #ea580c);
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    padding: 0;
    transition: transform .15s, opacity .15s;
}
.dm-send-btn:hover    { transform: scale(1.08); }
.dm-send-btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

/* ── 라이트박스 ────────────────────────────────────── */
#dm-lightbox {
    position: fixed; inset: 0;
    z-index: 9998;
    display: none;
    align-items: center;
    justify-content: center;
}
#dm-lb-bg {
    position: absolute; inset: 0;
    background: rgba(0,0,0,.82);
    backdrop-filter: blur(4px);
}
#dm-lb-box {
    position: relative; z-index: 1;
    max-width: 92vw; max-height: 90vh;
    display: flex;
    align-items: center; justify-content: center;
    padding-bottom: 50px;
}
#dm-lb-img {
    max-width: 88vw; max-height: 82vh;
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0,0,0,.6);
    object-fit: contain;
    display: block;
}
#dm-lb-close {
    position: absolute; top: -14px; right: -14px;
    width: 30px; height: 30px;
    border-radius: 50%; border: none;
    background: #ef4444; color: #fff;
    font-size: 13px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    padding: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,.3);
    transition: background .2s;
}
#dm-lb-close:hover { background: #dc2626; }
#dm-lb-dl {
    position: absolute;
    bottom: -40px; left: 50%; transform: translateX(-50%);
    background: rgba(255,255,255,.15);
    color: #fff; text-decoration: none;
    border: 1.5px solid rgba(255,255,255,.4);
    border-radius: 20px;
    padding: 5px 16px;
    font-size: 13px; font-weight: 600;
    white-space: nowrap;
    transition: background .2s;
    backdrop-filter: blur(4px);
}
#dm-lb-dl:hover { background: rgba(255,255,255,.28); }

/* ── 단체채팅 닉네임 클릭 버튼 ───────────────────── */
.dm-nick-btn {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    padding: 1px 5px;
    border-radius: 5px;
    transition: background .15s;
    font-weight: 700;
    font-size: 11px;
}
.chat-msg.other .dm-nick-btn {
    color: #94a3b8;
}
.chat-msg.other .dm-nick-btn:hover {
    background: #f0f4ff;
    color: #667eea;
}
.chat-msg.mine .dm-nick-btn {
    color: rgba(255,255,255,.75);
}
.chat-msg.mine .dm-nick-btn:hover {
    background: rgba(255,255,255,.2);
    color: #fff;
}
.dm-nick-btn .dm-nick-icon {
    font-size: 10px;
    opacity: .7;
}

/* ── 반응형 ────────────────────────────────────────── */
@media (max-width: 480px) {
    .dm-panel {
        width: calc(100vw - 16px) !important;
        right: 8px !important;
        left: 8px !important;
        height: 60vh !important;
    }
    .dm-img-thumb { max-width: 140px; max-height: 140px; }
}
