/* ============ 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%;
    height: 100dvh;
    overflow: hidden;
    touch-action: manipulation;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-page);
    color: var(--text-primary);
    height: 100%;
    height: 100dvh;
    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: 100%;
    height: 100dvh;
    max-width: 100%;
}

/* ============ 视频播放区域 ============ */
.video-section {
    flex-shrink: 0;
    position: relative;
    display: flex;
    flex-direction: column;
}

.video-wrapper {
    position: relative;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #000;
}

.main-video {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
    outline: none;
    background-color: #000;
}

.main-video::-webkit-media-controls {
    display: none !important;
}

/* 直播中标识 - Element Plus 风格 */
.live-indicator {
    display: none;
}

.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;
}

/* 在线人数角标 - 叠加在视频画面左上角 */
.online-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    pointer-events: none;
}

/* ============ 停播遮挡层 ============ */
.offline-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 15;
}

.offline-overlay p {
    font-size: 20px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.75);
    text-align: center;
}

/* 视频标题 */
.video-title {
    background: #fff;
    color: #333;
    font-size: 16px;
    font-weight: 700;
    padding: 12px 20px;
    line-height: 1.4;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
    min-height: 46px;
}

@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: #1a1a1a;
    display: flex;
    flex-direction: column;
    border-top: none;
    position: relative;
    z-index: 10;
    min-height: 0;
    overflow: hidden;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.chat-header {
    display: none;
}

/* ============ 消息列表 ============ */
.message-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 0;
    background: transparent;
}

.message-item {
    padding: 4px 0;
    max-width: 100%;
    word-wrap: break-word;
    font-size: 12px;
    line-height: 1.6;
    background: transparent;
    box-shadow: none;
    border: none;
    position: relative;
}

/* 用户消息 */
.user-message {
    align-self: flex-start;
}

/* 机器人消息 */
.bot-message {
    align-self: flex-start;
}

.message-user {
    font-weight: 600;
    margin-right: 4px;
    color: #F5C842;
    font-size: 12px;
}

.message-content {
    word-break: break-word;
    color: #fff;
    font-size: 12px;
}

.bot-message .message-content {
    color: #fff;
    font-size: 12px;
}

.bot-message .message-user {
    color: #F5C842;
    font-size: 12px;
}

.user-message .message-user {
    color: #F5C842;
    font-size: 12px;
}

.system-content {
    color: rgba(255,255,255,0.85);
    font-size: 12px;
}

.system-message {
    align-self: center;
    text-align: center;
    max-width: 90%;
    background: rgba(255,255,255,0.08);
    border: none;
    box-shadow: none;
    color: rgba(255,255,255,0.5);
    font-size: 12px;
    padding: 4px 12px;
    border-radius: var(--radius-round);
}

/* 系统通知消息 - 红色醒目显示 */
.notification-message {
    align-self: flex-start;
    padding: 6px 10px;
    background: rgba(245, 108, 108, 0.12);
    border-radius: var(--radius-sm);
    margin: 2px 0;
}

.notification-content {
    color: #F56C6C;
    font-size: 12px;
    word-break: break-word;
}

/* ============ 输入区域 ============ */
.chat-input-area {
    padding: 10px 14px;
    padding-bottom: max(10px, env(safe-area-inset-bottom, 10px));
    display: flex;
    gap: 8px;
    background-color: #1a1a1a;
    border-top: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
    align-items: center;
}

#messageInput {
    flex: 1;
    padding: 9px 14px;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: var(--radius-round);
    background-color: rgba(255,255,255,0.08);
    color: #fff;
    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.3);
}

#messageInput::placeholder {
    color: rgba(255,255,255,0.35);
}

.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 rgba(255,255,255,0.15);
    border-radius: var(--radius-round);
    background-color: transparent;
    color: rgba(255,255,255,0.7);
    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: rgba(245, 108, 108, 0.15);
    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: 4px;
}

.message-list::-webkit-scrollbar-track {
    background: transparent;
}

.message-list::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.12);
    border-radius: 2px;
}

.message-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.25);
}

/* ============ 横屏适配 ============ */
@media screen and (orientation: landscape) {
    body, html {
        height: 100%;
        height: 100dvh;
        width: 100%;
        overflow: hidden;
        margin: 0;
        padding: 0;
        padding-top: env(safe-area-inset-top, 0px);
    }

    .live-container {
        flex-direction: column;
        height: 100%;
        height: 100dvh;
        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: 100% !important;
        height: 100dvh !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: 100% !important;
        height: 100dvh !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: calc(20px + env(safe-area-inset-top, 0px)) !important;
        left: calc(20px + env(safe-area-inset-left, 0px)) !important;
        z-index: 1002 !important;
    }

.online-badge {
        position: fixed !important;
        top: calc(20px + env(safe-area-inset-top, 0px)) !important;
        right: calc(20px + env(safe-area-inset-right, 0px)) !important;
        left: auto !important;
        z-index: 1002 !important;
    }
}

/* ============ 平板/大屏适配 ============ */
@media (min-width: 768px) {
    .live-container {
        flex-direction: row;
    }

    .video-section {
        width: 70%;
        height: 100%;
        height: 100dvh;
    }

    .chat-section {
        width: 30%;
        height: 100%;
        height: 100dvh;
        position: fixed;
        right: 0;
        top: 0;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
}

/* ============ 小屏手机适配 ============ */
@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;
    }
}

/* ============ 键盘弹起适配（iOS visualViewport + Android resize） ============ */
body.keyboard-open .live-container {
    height: auto !important;
    min-height: 100%;
    min-height: 100dvh;
}

body.keyboard-open .chat-section {
    flex: 1 1 auto !important;
}

body.keyboard-open .video-section {
    flex-shrink: 0 !important;
}

body.keyboard-open .chat-input-area {
    position: sticky;
    bottom: 0;
    z-index: 100;
}

/* ============ 昵称输入弹窗 ============ */
.name-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.45);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.name-overlay.show {
    display: flex;
}

.name-card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 32px 24px 24px;
    text-align: center;
    max-width: 320px;
    width: 85%;
    box-shadow: var(--shadow-lg);
    animation: nameCardIn 0.3s ease-out;
}

@keyframes nameCardIn {
    from { opacity: 0; transform: translateY(20px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.name-card-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--color-primary-light);
    color: var(--color-primary);
    font-size: 28px;
    margin-bottom: 12px;
}

.name-card h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.name-card-desc {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.name-input-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
}

.name-input-row input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    font-size: var(--font-size-base);
    font-family: var(--font-family);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.name-input-row input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(64, 158, 255, 0.2);
}

.name-input-row input::placeholder {
    color: var(--text-placeholder);
}

.name-submit-btn {
    width: 100%;
    padding: 11px 0;
    border: none;
    border-radius: var(--radius-round);
    background: var(--color-primary);
    color: #fff;
    font-size: var(--font-size-base);
    font-weight: 500;
    font-family: var(--font-family);
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
}

.name-submit-btn:hover {
    background: var(--color-primary-hover);
}

.name-submit-btn:active {
    transform: scale(0.97);
}

.random-name-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-round);
    padding: 6px 16px;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    cursor: pointer;
    font-family: var(--font-family);
    transition: all 0.2s;
}

.random-name-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: var(--color-primary-light);
}

#liveTime { display: none; }
