/* ============ CSS 设计变量 ============ */
:root {
    /* 品牌色 */
    --color-primary: #409EFF;
    --color-primary-hover: #337ECC;
    --color-primary-light: #ECF5FF;
    --color-success: #67C23A;
    --color-warning: #E6A23C;
    --color-danger: #F56C6C;
    --color-info: #909399;

    /* 背景色 */
    --bg-page: #F0F2F5;
    --bg-white: #FFFFFF;
    --bg-card: #FFFFFF;
    --bg-input: #F5F7FA;
    --bg-hover: #F5F7FA;

    /* 文字色 */
    --text-primary: #303133;
    --text-regular: #606266;
    --text-secondary: #909399;
    --text-placeholder: #C0C4CC;
    --text-white: #FFFFFF;

    /* 边框 */
    --border-color: #DCDFE6;
    --border-light: #E4E7ED;
    --border-lighter: #EBEEF5;

    /* 圆角 */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-round: 24px;

    /* 阴影 */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.10);

    /* 字体 */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    --font-size-base: 15px;
    --font-size-sm: 13px;
    --font-size-lg: 17px;

    /* 间距 */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
}

/* ============ 全局重置 ============ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    -webkit-text-size-adjust: 100%;
}

html {
    height: 100%;
    overflow: hidden;
    touch-action: manipulation;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-page);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    position: fixed;
    width: 100%;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    -webkit-overflow-scrolling: touch;
    font-size: var(--font-size-base);
    line-height: 1.5;
}

/* ============ 直播容器 ============ */
.live-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 100%;
}

/* ============ 视频播放区域 ============ */
.video-section {
    flex: 0 0 55%;
    position: relative;
    min-height: 0;
    max-height: 55vh;
}

.video-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #000;
}

.main-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    outline: none;
    background-color: #000;
}

.main-video::-webkit-media-controls {
    display: none !important;
}

/* 直播中标识 - Element Plus 风格 */
.live-indicator {
    position: absolute;
    top: 16px;
    left: 16px;
    background: var(--bg-white);
    padding: 5px 12px;
    border-radius: var(--radius-round);
    font-size: var(--font-size-sm);
    font-weight: 600;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: var(--shadow-sm);
    letter-spacing: 0.5px;
    color: var(--color-danger);
}

.live-indicator::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--color-danger);
    border-radius: 50%;
    animation: pulse-dot 1.5s infinite;
}

.live-indicator span {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.75); }
}

/* ============ 音量按钮 ============ */
.volume-btn {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 22px;
    transition: all 0.25s ease;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 25;
    box-shadow: var(--shadow-lg);
}

.volume-btn:hover {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
    transform: translate(-50%, -50%) scale(1.08);
}

.volume-btn.active {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

/* 按钮飞移动画 */
.volume-btn.teleporting {
    animation: teleportEffect 0.5s ease-out forwards;
}

@keyframes teleportEffect {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    50% {
        transform: translate(-50%, -50%) scale(0.1);
        opacity: 0;
    }
    100% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
}

.volume-btn.moved {
    position: relative;
    top: 0;
    left: 0;
    transform: none;
    margin: 0;
    width: 34px;
    height: 34px;
    font-size: 18px;
}

.volume-btn.moved:hover {
    transform: scale(1.08);
}

.volume-btn-container {
    display: inline-flex;
    align-items: center;
}

/* ============ 音量按钮（固定在头部） ============ */
.volume-btn-header {
    background: transparent;
    border: none;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 18px;
    transition: color 0.2s, background 0.2s;
    flex-shrink: 0;
}

.volume-btn-header:hover {
    color: var(--color-primary);
    background: var(--color-primary-light);
}

.volume-btn-header.active {
    color: var(--color-primary);
}

/* ============ 聊天区域 ============ */
.chat-section {
    flex: 1;
    background-color: var(--bg-white);
    display: flex;
    flex-direction: column;
    border-top: 1px solid var(--border-lighter);
    position: relative;
    z-index: 10;
    min-height: 0;
    overflow: hidden;
}

.chat-header {
    padding: 12px 16px;
    background-color: var(--bg-white);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-lighter);
}

.chat-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.online-count {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    background: var(--bg-input);
    padding: 3px 10px;
    border-radius: var(--radius-round);
    font-weight: 500;
}

/* ============ 消息列表 ============ */
.message-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 0;
    background: #FAFBFC;
}

.message-item {
    padding: 8px 12px;
    border-radius: var(--radius-md);
    max-width: 82%;
    word-wrap: break-word;
    font-size: 13px;
    line-height: 1.5;
    background: var(--bg-white);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-lighter);
    position: relative;
}

/* 用户消息 - 蓝色左边框 */
.user-message {
    align-self: flex-start;
    border-left: 3px solid var(--color-primary);
    background: var(--color-primary-light);
    border-color: transparent;
}

/* 机器人消息 - 绿色左边框 */
.bot-message {
    align-self: flex-end;
    border-right: 3px solid var(--color-success);
    background: #F0F9EB;
    border-color: transparent;
}

/* 系统消息 - 橙色居中 */
.system-message {
    align-self: center;
    text-align: center;
    max-width: 90%;
    background: var(--bg-input);
    border: none;
    box-shadow: none;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    padding: 6px 14px;
    border-radius: var(--radius-round);
}

.message-user {
    font-weight: 600;
    margin-right: 6px;
    color: var(--text-primary);
    font-size: 12px;
}

.message-content {
    word-break: break-word;
    color: var(--text-regular);
}

.bot-message .message-content {
    color: var(--text-primary);
}

.bot-message .message-user {
    color: var(--color-success);
}

.user-message .message-user {
    color: var(--color-primary);
}

.system-content {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

/* ============ 输入区域 ============ */
.chat-input-area {
    padding: 10px 14px;
    display: flex;
    gap: 8px;
    background-color: var(--bg-white);
    border-top: 1px solid var(--border-lighter);
    flex-shrink: 0;
    align-items: center;
}

#messageInput {
    flex: 1;
    padding: 9px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-round);
    background-color: var(--bg-input);
    color: var(--text-primary);
    font-size: var(--font-size-base);
    font-family: var(--font-family);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    height: 38px;
    min-width: 80px;
}

#messageInput:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(64, 158, 255, 0.2);
}

#messageInput::placeholder {
    color: var(--text-placeholder);
}

.send-btn {
    padding: 9px 18px;
    border: none;
    border-radius: var(--radius-round);
    background-color: var(--color-primary);
    color: #fff;
    cursor: pointer;
    font-size: var(--font-size-base);
    font-weight: 500;
    font-family: var(--font-family);
    transition: background-color 0.2s, transform 0.15s;
    white-space: nowrap;
    height: 38px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.send-btn:hover {
    background-color: var(--color-primary-hover);
}

.send-btn:active {
    transform: scale(0.96);
}

.like-btn {
    padding: 9px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-round);
    background-color: var(--bg-white);
    color: var(--text-regular);
    cursor: pointer;
    font-size: var(--font-size-base);
    font-family: var(--font-family);
    transition: all 0.2s;
    white-space: nowrap;
    height: 38px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.like-btn:hover {
    background-color: #FEF0F0;
    border-color: var(--color-danger);
    color: var(--color-danger);
}

.like-btn:active {
    transform: scale(0.96);
}

/* ============ 点击播放遮罩 ============ */
.video-tap-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 20;
    cursor: pointer;
}

.video-tap-overlay p {
    color: #fff;
    font-size: 20px;
    font-weight: 500;
    text-align: center;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ============ 滚动条 ============ */
.message-list::-webkit-scrollbar {
    width: 5px;
}

.message-list::-webkit-scrollbar-track {
    background: transparent;
}

.message-list::-webkit-scrollbar-thumb {
    background: #DCDFE6;
    border-radius: 3px;
}

.message-list::-webkit-scrollbar-thumb:hover {
    background: #C0C4CC;
}

/* ============ 横屏适配 ============ */
@media screen and (orientation: landscape) {
    body, html {
        height: 100%;
        width: 100%;
        overflow: hidden;
        margin: 0;
        padding: 0;
    }

    .live-container {
        flex-direction: column;
        height: 100vh;
        width: 100vw;
        position: fixed;
        top: 0;
        left: 0;
        z-index: 999;
    }

    .video-section {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100vh !important;
        z-index: 1000 !important;
        flex: none !important;
    }

    .chat-section {
        display: none !important;
    }

    .video-wrapper, .main-video {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100vh !important;
        z-index: 998 !important;
    }

    .volume-btn {
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        z-index: 1001 !important;
    }

    .volume-btn.moved {
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        z-index: 1001 !important;
    }

    .live-indicator {
        position: fixed !important;
        top: 20px !important;
        left: 20px !important;
        z-index: 1002 !important;
    }
}

/* ============ 平板/大屏适配 ============ */
@media (min-width: 768px) {
    .live-container {
        flex-direction: row;
    }

    .video-section {
        width: 70%;
        height: 100vh;
    }

    .chat-section {
        width: 30%;
        height: 100vh;
        position: fixed;
        right: 0;
        top: 0;
    }
}

/* ============ 小屏手机适配 ============ */
@media screen and (max-height: 700px) {
    .chat-section {
        flex: 1;
    }

    .message-list {
        flex: 1;
    }
}

@media screen and (max-height: 600px) {
    .chat-section {
        flex: 1;
    }

    .message-list {
        flex: 1;
    }

    .chat-input-area {
        padding: 6px 10px;
    }

    #messageInput {
        padding: 7px 12px;
        font-size: 14px;
        height: 34px;
    }

    .send-btn, .like-btn {
        padding: 7px 12px;
        font-size: 14px;
        height: 34px;
    }
}

/* ============ 键盘弹起适配 ============ */
body.keyboard-open .chat-section {
    height: 50vh !important;
}

body.keyboard-open .message-list {
    flex: 1;
}
