/* ===== 全局变量 ===== */
:root {
    --bg-dark: #0f0f1e;
    --bg-card: #1a1a2e;
    --bg-card-hover: #222240;
    --bg-panel: #16213e;
    --accent: #e94560;
    --accent-2: #0f3460;
    --accent-3: #533483;
    --text-primary: #ffffff;
    --text-secondary: #a0a0b8;
    --text-muted: #6c6c80;
    --border: rgba(255, 255, 255, 0.08);
    --success: #00d4aa;
    --warning: #ffa500;
    --danger: #ff4757;
    --radius: 12px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== 重置 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* ===== 16:9 舞台容器 ===== */
.stage {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ===== 顶部栏 ===== */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    height: 60px;
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-panel) 100%);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.4);
    z-index: 100;
    flex-shrink: 0;
}

.logo {
    font-size: 22px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent) 0%, #ff6b9d 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 1px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ===== 状态徽章 ===== */
.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    background: rgba(0, 212, 170, 0.1);
    border: 1px solid rgba(0, 212, 170, 0.3);
    border-radius: 20px;
    font-size: 14px;
    color: var(--success);
    font-weight: 600;
}

.status-badge .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ===== 按钮 ===== */
.btn {
    padding: 8px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.btn:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3); }
.btn:active { transform: translateY(0); }

.btn-primary { background: linear-gradient(135deg, var(--accent-2) 0%, var(--accent-3) 100%); }
.btn-warning { background: linear-gradient(135deg, #ff8c00 0%, #ffa500 100%); }
.btn-danger { background: linear-gradient(135deg, var(--danger) 0%, #ff6b6b 100%); }

/* ===== 主体区域 ===== */
.main-area {
    flex: 1;
    display: flex;
    overflow: hidden;
    gap: 0;
}

/* ===== 左侧二维码区 ===== */
.qr-section {
    width: 26%;
    min-width: 280px;
    max-width: 360px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.section-title {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 20px;
    text-align: center;
}

.qr-wrapper {
    position: relative;
    background: #fff;
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 280px;
}

.qr-wrapper img {
    width: 100%;
    max-width: 248px;
    border-radius: 8px;
    display: block;
    margin: 0 auto;
}

.qr-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #666;
    font-size: 14px;
}

.qr-url-box {
    width: 100%;
    max-width: 280px;
    margin-bottom: 20px;
}

.qr-url-box label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.url-display {
    padding: 10px 14px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    color: var(--accent);
    word-break: break-all;
    font-family: 'Courier New', monospace;
    text-align: center;
}

.qr-tips {
    width: 100%;
    max-width: 280px;
    padding: 16px;
    background: var(--bg-panel);
    border-radius: var(--radius);
    border-left: 3px solid var(--accent);
}

.qr-tips p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.8;
}

/* ===== 右侧学员卡位区 ===== */
.slots-section {
    flex: 1;
    padding: 20px 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.slots-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-shrink: 0;
}

.slots-header .section-title {
    margin-bottom: 0;
}

.slots-info {
    font-size: 14px;
    color: var(--text-secondary);
    padding: 4px 14px;
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border);
}

/* ===== 6个卡位网格 (3列x2行) ===== */
.slots-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 16px;
    min-height: 0;
}

/* ===== 单个卡位 ===== */
.slot-card {
    background: var(--bg-card);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: var(--transition);
    position: relative;
    min-height: 0;
}

/* 空卡位 */
.slot-card.empty {
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.slot-card.empty .empty-icon {
    font-size: 48px;
    margin-bottom: 8px;
    opacity: 0.3;
}

.slot-card.empty .empty-text {
    font-size: 14px;
}

.slot-card.empty .slot-number {
    position: absolute;
    top: 8px;
    left: 12px;
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 600;
}

/* 已占用卡位 */
.slot-card.occupied {
    border: 2px solid var(--accent);
    border-style: solid;
    box-shadow: 0 0 20px rgba(233, 69, 96, 0.15);
}

/* 仅新增卡位时播放进入动画 */
.slot-card.occupied.slot-new {
    animation: slotPulse 0.5s ease;
}

@keyframes slotPulse {
    0% { transform: scale(0.95); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.slot-card.occupied .slot-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: linear-gradient(135deg, var(--accent-2) 0%, var(--accent-3) 100%);
    flex-shrink: 0;
}

.slot-card.occupied .slot-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.slot-card.occupied .slot-num-badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 700;
}

.slot-card.occupied .slot-name {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 在线/离线标签 */
.slot-online-tag {
    padding: 1px 6px;
    background: rgba(0, 212, 170, 0.3);
    color: #6fffd0;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 600;
}

.slot-offline-tag {
    padding: 1px 6px;
    background: rgba(255, 165, 0, 0.3);
    color: #ffcc66;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 600;
}

/* 离线卡位头部变灰 */
.slot-header.offline {
    background: linear-gradient(135deg, #4a4a5a 0%, #5a5a6a 100%);
    opacity: 0.85;
}

/* 离线卡位整体半透明 */
.slot-card.occupied.offline-slot {
    opacity: 0.7;
}

.slot-card.occupied .slot-actions {
    display: flex;
    gap: 4px;
}

.slot-card.occupied .slot-action-btn {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.slot-card.occupied .slot-action-btn:hover { background: rgba(255, 255, 255, 0.3); }
.slot-card.occupied .slot-action-btn.danger:hover { background: var(--danger); }

/* 卡位内容区 */
.slot-card.occupied .slot-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 8px;
    gap: 6px;
    min-height: 0;
}

/* 文字内容 */
.slot-text {
    background: var(--bg-panel);
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-primary);
    overflow-y: auto;
    word-break: break-word;
    border-left: 3px solid var(--accent);
    flex: 1;
    min-height: 0;
}

.slot-text:empty { display: none; }

/* 图片内容 */
.slot-image {
    flex: 1;
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}

.slot-image:empty { display: none; }

.slot-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    max-height: 100%;
}

/* 无内容时 */
.slot-card.occupied .slot-no-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 13px;
}

/* ===== 全屏投影模式 ===== */
.projection-mode {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg-dark);
    display: none;
    z-index: 999;
    overflow-y: auto;
    padding: 20px;
}

.projection-mode.active { display: block; }

.exit-projection {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 10px 24px;
    background: var(--danger);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    cursor: pointer;
    z-index: 1001;
    box-shadow: var(--shadow);
}

.exit-projection:hover { opacity: 0.9; }

.projection-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 16px;
    width: 100%;
    height: calc(100vh - 40px);
}

.projection-grid .slot-card {
    min-height: 300px;
}

.projection-grid .slot-text {
    font-size: 18px;
    max-height: 100px;
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 12px 28px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--text-primary);
    box-shadow: var(--shadow);
    z-index: 2000;
    opacity: 0;
    transition: var(--transition);
    pointer-events: none;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }

/* ===== 双击放大查看模态框 ===== */
.viewer-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 5000;
    display: none;
    align-items: center;
    justify-content: center;
}

.viewer-modal.active { display: flex; }

.viewer-backdrop {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.viewer-content {
    position: relative;
    z-index: 1;
    max-width: 80vw;
    max-height: 85vh;
    background: var(--bg-card);
    border-radius: 16px;
    box-shadow: 0 20px 80px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: viewerIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes viewerIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

.viewer-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    z-index: 10;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.viewer-close:hover { background: var(--danger); transform: rotate(90deg); }

.viewer-header {
    padding: 16px 24px;
    background: linear-gradient(135deg, var(--accent-2) 0%, var(--accent-3) 100%);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.viewer-header:empty { display: none; }

.viewer-header .viewer-name {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
}

.viewer-header .viewer-slot-tag {
    padding: 4px 12px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    font-size: 14px;
    color: #fff;
    font-weight: 600;
}

.viewer-body {
    flex: 1;
    overflow: auto;
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

/* 放大后的文字样式 */
.viewer-body .viewer-text {
    font-size: 22px;
    line-height: 1.8;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-word;
    text-align: left;
    width: 100%;
    max-height: 70vh;
    overflow-y: auto;
    padding: 8px;
}

/* 放大后的图片样式 */
.viewer-body .viewer-image {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: 8px;
}

/* 卡位中的文字和图片可点击提示 */
.slot-text, .slot-image {
    cursor: pointer;
    transition: var(--transition);
}

.slot-text:hover, .slot-image:hover {
    opacity: 0.85;
    box-shadow: 0 0 0 2px var(--accent);
}

/* ===== 滚动条 ===== */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--bg-panel); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-2); }

/* ===== 响应式：小屏适配保持16:9比例 ===== */
@media (max-width: 1200px) {
    .qr-section { width: 24%; min-width: 260px; }
    .slots-grid { gap: 12px; }
    .slot-card.occupied .slot-name { max-width: 80px; }
    .slot-text { font-size: 14px; }
}

@media (max-width: 900px) {
    .qr-section { width: 22%; min-width: 220px; padding: 14px; }
    .section-title { font-size: 18px; }
    .slots-grid { gap: 10px; }
    .slot-card.occupied .slot-name { font-size: 12px; max-width: 60px; }
    .slot-text { font-size: 13px; padding: 8px 10px; }
    .slot-card.occupied .slot-content { padding: 6px; gap: 5px; }
}
