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

/* 플로팅 버튼 */
#chat-widget-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: none center / contain no-repeat;
    color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: none;
    filter: drop-shadow(0 0 6px rgb(255 188 70 / 34%)) drop-shadow(0 4px 8px rgb(0 0 0 / 55%));
    z-index: 9990;
    transition: transform 0.2s, background 0.2s;
}
#chat-widget-btn:hover {
    transform: scale(1.1);
    background: none center / contain no-repeat;
    filter: brightness(1.08) drop-shadow(0 0 7px rgb(255 201 92 / 46%)) drop-shadow(0 4px 8px rgb(0 0 0 / 55%));
}
#chat-widget-btn.chat-active {
    background: none center / contain no-repeat;
    filter: brightness(.88) drop-shadow(0 0 5px rgb(255 168 50 / 28%)) drop-shadow(0 3px 6px rgb(0 0 0 / 55%));
}
#chat-widget-btn svg {
    display: none;
}

/* 안읽은 배지 */
#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: #dfb962;
    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: #f8f6f1;
}

/* 메시지 공통 */
.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: #9c9894;
    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: #dfb962;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-msg-other .chat-bubble {
    background: #fff;
    color: #292826;
    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 #f0ebe0;
    background: #fff;
}
.chat-input-area input[type="text"] {
    flex: 1;
    border: 1px solid #e4dcc8;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 14px;
    outline: none;
}
.chat-input-area input[type="text"]:focus {
    border-color: #dfb962;
}
#chat-send-btn {
    padding: 8px 16px;
    background: #dfb962;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}
#chat-send-btn:hover {
    background: #daae48;
}

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

/* 타이핑 표시 */
.chat-typing {
    font-size: 12px;
    color: #9c9894;
    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 #f0ebe0;
    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: #f8f6f1;
}

/* ========================================
   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: rgb(24 23 23 / 0.97);
    color: #f0ebe0;
    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, #d4a12b);
    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, #d4a12b); }
}
.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: #b6b3b0;
    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: #e4dcc8;
    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 {
        top: calc(var(--lion-mobile-header-height, 50px) + 12px);
        width: calc(100vw - 16px);
        height: auto;
        max-height: calc(100dvh - var(--lion-mobile-header-height, 50px) - 24px);
        right: 8px;
        bottom: 12px;
        border-radius: 12px;
        z-index: 10003;
    }
    #chat-widget-btn {
        bottom: 16px;
        right: 16px;
        width: 48px;
        height: 48px;
    }
}

/* 모바일: 실시간 채팅 버튼을 최상단 헤더(.top_wrap) 안, 배팅슬립 버튼(.m_menu_pc_btn) 왼쪽에 배치.
   데스크톱은 기존 우하단 플로팅 유지(위 기본 규칙). */
@media screen and (max-width: 980px) {
    body #chat-widget-btn {
        position: fixed;
        top: calc(var(--lion-mobile-header-height, 50px) / 2);
        right: calc(1.5vw + min(11.7vw, 46px) + 2.6vw);
        bottom: auto;
        left: auto;
        width: min(10.2vw, 40px);
        height: min(10.2vw, 40px);
        border: 0;
        border-radius: 0;
        background: none center / contain no-repeat;
        color: transparent;
        box-shadow: none;
        z-index: 10002;
        filter: drop-shadow(0 0 4px rgb(255 188 70 / 34%)) drop-shadow(0 3px 5px rgb(0 0 0 / 48%));
        transform: translateY(-50%);
        transition: filter 160ms ease, transform 160ms ease;
    }
    body #chat-widget-btn:hover {
        transform: translateY(-50%);
        background: none center / contain no-repeat;
        filter: brightness(1.08) drop-shadow(0 0 5px rgb(255 201 92 / 46%)) drop-shadow(0 3px 5px rgb(0 0 0 / 48%));
    }
    body #chat-widget-btn.chat-active {
        background: none center / contain no-repeat;
        filter: brightness(.88) drop-shadow(0 0 4px rgb(255 168 50 / 28%)) drop-shadow(0 2px 3px rgb(0 0 0 / 50%));
        transform: translateY(-50%) scale(.96);
    }
    body #chat-widget-btn svg {
        display: none;
    }
}
