/* ---------------- 聊天容器 ---------------- */
.wp-ajax-chat-container {
    width: 100%;
    max-width: 400px;
    margin: 10px auto;
    display: flex;
    flex-direction: column;
    height: 80vh;
    max-height: 80vh;
    border-radius: 14px;
    background: #111;
    border: 2px solid #444;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

/* ---------------- 消息区及滚动条 ---------------- */
.wp-ajax-chat-box {
    padding: 14px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: linear-gradient(180deg,#0f0f0f 0%,#1a1a1a 100%);
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.18) rgba(255, 255, 255, 0.03);
}

/* 消息区永久显示的自定义滚动条 (适配 Webkit 与 Firefox) */
.wp-ajax-chat-box::-webkit-scrollbar {
    width: 6px;
    display: block !important;
}

.wp-ajax-chat-box::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
}

.wp-ajax-chat-box::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.18);
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, 0.2);
    transition: background 0.2s;
}

.wp-ajax-chat-box::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ---------------- 消息气泡 ---------------- */
.chat-bubble {
    max-width: 78%;
    padding: 12px 16px;
    border-radius: 20px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
    position: relative;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.chat-bubble:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.35);
}

.bubble-left {
    background: #2a2a2a;
    color: #f1f1f1;
    align-self: flex-start;
    border-radius: 18px 18px 18px 6px;
    border: 1px solid #3a3a3a;
}

.bubble-right {
    background: linear-gradient(135deg,#2b9cff,#00c6ff);
    color: #fff;
    align-self: flex-end;
    border-radius: 18px 18px 6px 18px;
}

/* ---------------- 用户名和时间 ---------------- */
.chat-name {
    font-size: 12px;
    color: rgba(255,255,255,0.6);
    margin-bottom: 4px;
}

.bubble-right .chat-name {
    color: rgba(255,255,255,0.9);
}

.chat-time {
    font-size: 11px;
    color: rgba(255,255,255,0.4);
    margin-top: 6px;
    text-align: right;
}

.bubble-right .chat-time {
    color: rgba(255,255,255,0.75);
}

/* ---------------- 消息内容与链接 ---------------- */
.chat-message-content {
    white-space: pre-wrap;
}

.chat-msg-link {
    color: #2b9cff;
    text-decoration: underline;
    word-break: break-all;
}

.bubble-right .chat-msg-link {
    color: #ffffff;
    font-weight: 500;
}

/* ---------------- 图片与视频消息 ---------------- */
.chat-img,
.chat-video-thumb-wrapper {
    max-width: 160px;
    max-height: 160px;
    width: auto;
    height: auto;
    border-radius: 12px;
    display: block;
    margin: 4px 0;
    background-color: #2a2a2a;
    cursor: pointer;
    overflow: hidden;
    position: relative;
}

.chat-img {
    object-fit: contain;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chat-img:hover {
    transform: scale(1.03);
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

/* 多图/多视频并排画廊样式 */
.chat-img-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 6px;
    margin-top: 6px;
    width: 100%;
}

.chat-img-gallery .chat-img,
.chat-img-gallery .chat-video-thumb-wrapper {
    width: 100%;
    height: 120px;
    max-width: 100%;
    margin: 0;
}

.chat-img-gallery .chat-img,
.chat-img-gallery .chat-video-thumb-wrapper video {
    object-fit: cover !important;
}

/* 单个媒体覆盖样式 */
.chat-img.single-media,
.chat-video-thumb-wrapper.single-media {
    max-width: 200px;
    max-height: 200px;
    margin-top: 5px;
    border-radius: 8px;
}

.chat-video-thumb-wrapper.single-media {
    background: #000;
}

/* 视频缩略图及播放按钮 */
.chat-video-thumb-wrapper video {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    pointer-events: none;
    display: block;
    opacity: 0.7;
}

.video-play-overlay {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 40px; height: 40px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background 0.2s;
    z-index: 2;
}

.chat-video-thumb-wrapper:hover .video-play-overlay {
    background: rgba(0, 0, 0, 0.6);
}

.video-play-overlay svg {
    width: 20px; height: 20px;
    fill: rgba(255, 255, 255, 0.95);
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.4));
}

/* ---------------- 输入区 ---------------- */
.wp-ajax-chat-input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid #333;
    background: #111;
}

.wp-ajax-chat-input {
    width: 100%;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid #333;
    background: #1a1a1a;
    color: #fff;
    font-size: 16px;
    outline: none;
}

.wp-ajax-chat-input:focus {
    border-color: #2b9cff;
}

.wp-ajax-chat-send,
.wp-ajax-chat-upload {
    width: 100%;
    padding: 12px;
    border-radius: 14px;
    font-size: 16px;
    border: none;
    cursor: pointer;
}

.wp-ajax-chat-send {
    background: #2b9cff;
    color: #fff;
}

.wp-ajax-chat-upload {
    background: #4CAF50;
    color: #fff;
}

.wp-ajax-chat-send:hover,
.wp-ajax-chat-upload:hover {
    filter: brightness(1.05);
}

.wp-ajax-chat-send:active {
    transform: translateY(1px);
}

.wp-ajax-chat-send[disabled] {
    opacity: 0.6;
    cursor: default;
}

/* ---------------- 手机端优化 ---------------- */
@media (max-width:600px) {
    .wp-ajax-chat-container {
        height: calc(100vh - 70px);
        border-radius: 0;
    }
    .chat-bubble { font-size: 15px; }
    
    /* 手机端智能双列 */
    .chat-img-gallery {
        grid-template-columns: repeat(2, 1fr);
    }

    /* 手机端增强滚动条可见度 */
    .wp-ajax-chat-box::-webkit-scrollbar {
        width: 8px !important;
    }
    .wp-ajax-chat-box::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.45) !important;
    }
}

@media (max-width:420px) {
    .wp-ajax-chat-container {
        height: calc(100vh - 56px);
    }
    .chat-bubble { font-size: 14px; }
}

/* ---------------- 全屏大图/视频弹出层 ---------------- */
.chat-custom-lightbox {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: #000000;
    z-index: 999999;
    justify-content: center;
    align-items: center;
    user-select: none;
}

.lightbox-close-btn {
    position: absolute;
    top: 24px; left: 24px;
    width: 44px; height: 44px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000001;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 50%;
    transition: background 0.2s;
}

.lightbox-close-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.lightbox-close-btn svg {
    width: 24px; height: 24px;
    fill: #ffffff;
}

.lightbox-content-wrapper {
    width: 100%; height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

.lightbox-content-wrapper img,
.lightbox-content-wrapper video {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    box-shadow: 0 0 40px rgba(0,0,0,0.8);
    animation: chatZoomIn 0.2s cubic-bezier(0.1, 0.8, 0.3, 1);
}

@keyframes chatZoomIn {
    from { transform: scale(0.85); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.lightbox-video-controls {
    display: none;
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    width: 85%;
    max-width: 550px;
    background: rgba(28, 28, 28, 0.8);
    backdrop-filter: blur(10px);
    padding: 12px 20px;
    border-radius: 30px;
    align-items: center;
    gap: 14px;
    z-index: 1000001;
    box-sizing: border-box;
}

.lightbox-video-controls span {
    color: #ffffff;
    font-size: 12px;
    font-family: Menlo, Monaco, Consolas, monospace;
}

.video-progress-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.video-progress-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    height: 14px; width: 14px;
    border-radius: 50%;
    background: #ffffff;
    cursor: pointer;
}

.video-progress-slider::-moz-range-thumb {
    height: 14px; width: 14px;
    border-radius: 50%;
    background: #ffffff;
    cursor: pointer;
    border: none;
}