/* ========================================
   Live Chat Widget — 유저 플로팅 채팅
   ======================================== */

/* 플로팅 버튼 */
#chat-widget-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #4a6cf7;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(74, 108, 247, 0.4);
    z-index: 9990;
    transition: transform 0.2s, background 0.2s;
}
#chat-widget-btn:hover {
    transform: scale(1.1);
    background: #3b5de7;
}
#chat-widget-btn.chat-active {
    background: #6b7280;
}

/* 안읽은 배지 */
#chat-unread-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

/* 채팅 패널 */
#chat-widget-panel {
    position: fixed;
    bottom: 90px;
    right: 24px;
    width: 380px;
    height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    z-index: 9991;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 헤더 */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: #4a6cf7;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
}
.chat-header-brand {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 10px;
}
.chat-header-logo {
    display: block;
    width: auto;
    max-width: 132px;
    height: 28px;
    object-fit: contain;
    object-position: left center;
}
.chat-header-logo[hidden] {
    display: none;
}
.chat-header button {
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

/* 메시지 영역 */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #f3f4f6;
}

/* 메시지 공통 */
.chat-msg {
    display: flex;
    max-width: 80%;
}
.chat-msg-me {
    align-self: flex-end;
}
.chat-msg-other {
    align-self: flex-start;
}
.chat-msg-system {
    align-self: center;
    max-width: 100%;
}
.chat-msg-system .chat-bubble {
    background: transparent;
    color: #9ca3af;
    font-size: 12px;
    text-align: center;
    padding: 4px 0;
    box-shadow: none;
}

/* 말풍선 */
.chat-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}
.chat-msg-me .chat-bubble {
    background: #4a6cf7;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-msg-other .chat-bubble {
    background: #fff;
    color: #1f2937;
    border-bottom-left-radius: 4px;
}

/* 보낸사람 */
.chat-sender {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 2px;
    font-weight: 500;
}

/* 메타 (시간 + 읽음) */
.chat-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}
.chat-time {
    font-size: 11px;
    opacity: 0.6;
}
.chat-msg-me .chat-time {
    color: rgba(255, 255, 255, 0.7);
}
.chat-read-status {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.8);
}

/* 이미지 메시지 */
.chat-img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    cursor: pointer;
    display: block;
}
.chat-img:hover {
    opacity: 0.9;
}

/* 입력 영역 */
.chat-input-area {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-top: 1px solid #e5e7eb;
    background: #fff;
}
.chat-input-area input[type="text"] {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 14px;
    outline: none;
}
.chat-input-area input[type="text"]:focus {
    border-color: #4a6cf7;
}
#chat-send-btn {
    padding: 8px 16px;
    background: #4a6cf7;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}
#chat-send-btn:hover {
    background: #3b5de7;
}

/* 이미지 업로드 버튼 */
#chat-img-label {
    cursor: pointer;
    display: flex;
    align-items: center;
    color: #6b7280;
}
#chat-img-label:hover {
    color: #4a6cf7;
}

/* 타이핑 표시 */
.chat-typing {
    font-size: 12px;
    color: #9ca3af;
    padding: 4px 0;
    font-style: italic;
}

/* 이모티콘 버튼 */
.chat-emoji-btn {
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    user-select: none;
    opacity: 0.7;
    transition: opacity 0.15s;
}
.chat-emoji-btn:hover {
    opacity: 1;
}

/* 이모티콘 피커 */
.chat-emoji-picker {
    position: absolute;
    bottom: 50px;
    right: 14px;
    display: grid;
    grid-template-columns: repeat(6, auto);
    gap: 3px;
    padding: 8px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    z-index: 10;
}
.chat-emoji-item {
    font-size: 22px;
    text-align: center;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: background 0.1s;
}
.chat-emoji-item:hover {
    background: #f3f4f6;
}

/* ========================================
   Admin Toast 알림 (사이트 다크 테마)
   ======================================== */
.admin-toast-popup {
    position: fixed;
    top: 28px;
    left: 50%;
    z-index: 99999;
    opacity: 0;
    transform: translate(-50%, -28px) scale(0.92);
    transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1), transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
}
.admin-toast-popup.show {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
    pointer-events: auto;
}
.admin-toast-popup.hide {
    opacity: 0;
    transform: translate(-50%, -28px) scale(0.92);
}
.admin-toast-inner {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 24px;
    border-radius: 12px;
    background: rgba(17, 22, 34, 0.97);
    color: #e5e7eb;
    min-width: 340px;
    max-width: 480px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-left: 6px solid var(--admin-toast-accent, #0090ff);
    overflow: hidden;
    animation: adminToastGlow 1.3s ease-in-out 0.45s 2;
}
@keyframes adminToastGlow {
    0%, 100% { box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55); }
    50% { box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55), 0 0 22px 4px var(--admin-toast-accent, #0090ff); }
}
.admin-toast-icon {
    font-size: 30px;
    flex-shrink: 0;
}
.admin-toast-content {
    flex: 1;
    min-width: 0;
}
.admin-toast-label {
    font-size: 12px;
    font-weight: 700;
    color: #b9c0cc;
    margin-bottom: 3px;
    letter-spacing: 0.02em;
}
.admin-toast-message {
    font-size: 15px;
    line-height: 1.55;
    font-weight: 600;
    word-break: break-word;
    color: #ffffff;
}
.admin-toast-close {
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #d1d5db;
    border-radius: 6px;
    padding: 5px 14px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}
.admin-toast-close:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}
.admin-toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: rgba(255, 255, 255, 0.05);
    overflow: hidden;
}
.admin-toast-progress-bar {
    height: 100%;
    width: 100%;
    opacity: 0.6;
    animation: toastProgress linear forwards;
}
@keyframes toastProgress {
    from { width: 100%; }
    to { width: 0%; }
}

/* 모바일 대응 */
@media (max-width: 480px) {
    #chat-widget-panel {
        width: calc(100vw - 16px);
        height: calc(100vh - 120px);
        right: 8px;
        bottom: 80px;
        border-radius: 12px;
    }
    #chat-widget-btn {
        bottom: 16px;
        right: 16px;
        width: 48px;
        height: 48px;
    }
}
