:root {
    --bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    --card-bg: rgba(255, 255, 255, 0.9);
    --primary-color: #4facfe;
    --accent-color: #ff9a9e;
    --text-main: #2c3e50;
    --shadow-soft: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    --font-main: "PingFang SC", "Microsoft YaHei", sans-serif;
    --success-color: #52c41a;
    --error-color: #ff4d4f;
}

body {
    margin: 0;
    padding: 0;
    height: 100vh;
    background: var(--bg-gradient);
    font-family: var(--font-main);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 顶部状态栏 */
.top-bar {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    z-index: 10;
}

.school-info {
    display: flex;
    align-items: center;
    font-size: 18px;
    font-weight: bold;
    color: var(--text-main);
}

.school-icon {
    font-size: 24px;
    margin-right: 10px;
}

.status-indicator {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    background: #fff1f0; /* Default Disconnected */
    border: 1px solid #ffa39e;
    border-radius: 20px;
    color: var(--error-color);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s;
}

.status-indicator.connected {
    background: #e6fffa;
    border-color: #b7eb8f;
    color: #389e0d;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--error-color);
    border-radius: 50%;
    margin-right: 6px;
    position: relative;
}

.status-indicator.connected .status-dot {
    background: #52c41a;
    box-shadow: 0 0 0 2px rgba(82, 196, 26, 0.2);
}

.status-indicator.waiting {
    background: #fffbe6;
    border-color: #ffe58f;
    color: #faad14;
}

.status-indicator.waiting .status-dot {
    background: #faad14;
    box-shadow: 0 0 0 2px rgba(250, 173, 20, 0.2);
    animation: status-pulse 2s infinite;
}

@keyframes status-pulse {
    0% { opacity: 0.6; transform: scale(0.9); }
    50% { opacity: 1; transform: scale(1.1); }
    100% { opacity: 0.6; transform: scale(0.9); }
}

/* 核心内容区 */
.main-container {
    width: 90%;
    height: 80%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: minmax(0, 1fr); /* 限制高度，防止撑开 */
    gap: 30px;
    max-width: 1200px;
    animation: fadeIn 0.5s ease;
}

/* 左侧：时钟卡片 */
.clock-card {
    background: var(--card-bg);
    border-radius: 24px;
    padding: 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    position: relative;
    overflow: hidden;
}

.clock-time {
    font-size: 100px;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1;
    margin-bottom: 20px;
    font-variant-numeric: tabular-nums;
    text-shadow: 2px 4px 0px rgba(0,0,0,0.05);
}

.clock-date {
    font-size: 24px;
    color: #666;
    margin-bottom: 40px;
}

.class-badge {
    background: linear-gradient(to right, #4facfe 0%, #00f2fe 100%);
    color: white;
    padding: 15px 40px;
    border-radius: 50px;
    font-size: 28px;
    font-weight: bold;
    box-shadow: 0 10px 20px rgba(79, 172, 254, 0.3);
}

/* 右侧：通知与控制 */
.side-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: 100%; /* 充满父容器 */
    min-height: 0; /* 允许收缩 */
}

.info-card {
    flex: 1;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    min-height: 0; /* 关键：允许内部滚动 */
}

.card-title {
    font-size: 16px;
    color: #888;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.log-list {
    flex: 1;
    overflow-y: auto;
    font-size: 14px;
}

.log-item {
    padding: 12px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: flex-start;
    animation: slideLeft 0.3s ease;
}

.log-item:last-child {
    border-bottom: none;
}

.log-time {
    color: #999;
    margin-right: 12px;
    font-size: 12px;
    margin-top: 2px;
    min-width: 45px;
}

.log-content-wrapper {
    flex: 1;
}

.log-text {
    color: #333;
    margin-bottom: 6px;
}

.log-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.log-btn {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    color: white;
}
.log-btn.confirm { background: var(--success-color); }
.log-btn.reject { background: var(--error-color); }
.log-btn.replay { background: var(--primary-color); }
.log-btn:disabled { background: #ccc; cursor: not-allowed; }

.control-card {
    background: white;
    border-radius: 20px;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 16px rgba(0,0,0,0.05);
}

.dnd-label {
    font-size: 18px;
    font-weight: bold;
    color: var(--text-main);
    display: flex;
    align-items: center;
}

/* 开关样式 */
.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}
input:checked + .slider { background-color: var(--accent-color); }
input:checked + .slider:before { transform: translateX(26px); }

/* Setup Panel (New Style) */
#setupPanel {
    background: rgba(255, 255, 255, 0.95);
    padding: 40px;
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.1);
    width: 90%;
    max-width: 480px;
    text-align: center;
    position: relative;
    z-index: 100;
    backdrop-filter: blur(20px);
}

#setupPanel select, #setupPanel input {
    width: 100%;
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    font-size: 16px;
    outline: none;
    background: #f9f9f9;
    transition: all 0.3s;
    box-sizing: border-box;
}

#setupPanel select:focus, #setupPanel input:focus {
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 4px rgba(79, 172, 254, 0.1);
}

#setupPanel label {
    display: block;
    text-align: left;
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
    font-size: 14px;
}

.btn-primary {
    width: 100%;
    padding: 15px;
    background: linear-gradient(to right, #4facfe 0%, #00f2fe 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 10px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(79, 172, 254, 0.3);
}

.btn-sm {
    padding: 6px 15px;
    background: white;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
}

.btn-sm:hover {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 10px rgba(79, 172, 254, 0.3);
}

/* 全屏呼叫弹窗 */
.overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: none; 
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.call-card {
    background: white;
    width: 80%;
    max-width: 800px;
    border-radius: 30px;
    padding: 50px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: popIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    border: 5px solid var(--primary-color);
}

.call-icon {
    font-size: 80px;
    margin-bottom: 20px;
    display: inline-block;
    animation: shake 1s infinite;
}

.call-title {
    font-size: 28px;
    color: #666;
    margin-bottom: 20px;
}

/* 优化后的名字显示样式 */
#overlayName {
    font-size: 100px;
    font-weight: 900;
    /* 渐变色文字 */
    background: linear-gradient(135deg, #2af598 0%, #009efd 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    
    margin: 20px 0 40px;
    /* 文字阴影/发光效果 */
    filter: drop-shadow(0 10px 20px rgba(0, 158, 253, 0.3));
    
    /* 动画 */
    animation: namePulse 2s infinite ease-in-out;
    letter-spacing: 4px;
}

@keyframes namePulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); filter: drop-shadow(0 15px 30px rgba(0, 158, 253, 0.5)); }
    100% { transform: scale(1); }
}

/* 保留原类名用于其他地方，但这里我们用 ID 覆盖 */
.student-name-legacy {}

.action-text {
    font-size: 40px;
    color: #333;
    margin-bottom: 50px;
    font-weight: 500;
}

.btn-large {
    padding: 20px 60px;
    font-size: 24px;
    background: #52c41a;
    color: white;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    box-shadow: 0 8px 0 #389e0d;
    transition: all 0.1s;
}

.btn-large:active {
    transform: translateY(4px);
    box-shadow: 0 4px 0 #389e0d;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideLeft { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes popIn { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes shake {
    0% { transform: rotate(0deg); }
    25% { transform: rotate(10deg); }
    75% { transform: rotate(-10deg); }
    100% { transform: rotate(0deg); }
}

/* Scrollbar */
::-webkit-scrollbar { width: 12px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,0.05); border-radius: 6px; }
::-webkit-scrollbar-thumb { 
    background: #bbb; 
    border-radius: 6px; 
    border: 3px solid transparent; 
    background-clip: content-box; 
}
::-webkit-scrollbar-thumb:hover { background-color: #999; }

/* Custom Confirm Modal */
.custom-confirm-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    z-index: 2000;
    display: none;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.custom-confirm-box {
    background: white;
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    text-align: center;
    width: 300px;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.confirm-icon {
    font-size: 40px;
    margin-bottom: 15px;
}

.confirm-title {
    font-size: 20px;
    font-weight: bold;
    color: #333;
    margin-bottom: 10px;
}

.confirm-message {
    font-size: 16px;
    color: #666;
    margin-bottom: 25px;
    line-height: 1.5;
}

.confirm-actions {
    display: flex;
    justify-content: space-between;
    gap: 15px;
}

.btn-cancel, .btn-confirm {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
}

.btn-cancel {
    background: #f0f0f0;
    color: #666;
}

.btn-cancel:hover {
    background: #e0e0e0;
}

.btn-confirm {
    background: var(--primary-color);
    color: white;
}

.btn-confirm:hover {
    box-shadow: 0 4px 12px rgba(79, 172, 254, 0.4);
}

/* --- 学生卡片视图样式 (移植自教师端) --- */
:root {
    /* Glassmorphism Variables */
    --glass-bg: rgba(255, 255, 255, 0.65);
    --glass-border: 1px solid rgba(255, 255, 255, 0.4);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
    --glass-blur: blur(12px);
}

#studentViewPanel {
    width: 90%;
    height: 80%;
    max-width: 1200px;
    animation: fadeIn 0.5s ease;
    display: none;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 24px;
    padding: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    overflow: hidden; /* Changed from overflow-y: auto to fix header */
}

.student-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 20px;
    align-content: start;
    padding: 10px;
    /* Allow scrolling only within the grid */
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    width: 100%;
}

.student-card {
    background: var(--glass-bg);
    border-radius: 20px;
    padding: 20px 10px;
    text-align: center;
    cursor: default;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
    border: 1px solid rgba(255,255,255,0.6);
    position: relative;
}

.student-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.08);
    background: white;
    z-index: 10;
}

.student-avatar {
    width: 60px;
    height: 60px;
    border-radius: 22px;
    margin: 0 auto 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
    font-weight: 600;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.3s;
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}

.student-card:hover .student-avatar {
    transform: scale(1.1) rotate(3deg);
}

.student-name {
    font-size: 16px; /* Adjusted for card */
    font-weight: bold;
    color: #333;
    margin-bottom: 0; /* Reset */
}

/* 呼叫中动画 */
.student-card.calling { 
    animation: breathe 2s infinite ease-in-out;
    background: white;
    box-shadow: 0 0 0 2px var(--primary-color);
}
@keyframes breathe {
    0% { box-shadow: 0 4px 15px rgba(24, 144, 255, 0.2); border-color: transparent; }
    50% { box-shadow: 0 4px 25px rgba(24, 144, 255, 0.6); transform: scale(1.02); }
    100% { box-shadow: 0 4px 15px rgba(24, 144, 255, 0.2); border-color: transparent; }
}

/* 状态标记 */
.status-dot {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 8px;
    height: 8px;
    background-color: #d9d9d9;
    border-radius: 50%;
    display: none;
}
.student-card.has-called .status-dot {
    display: block;
    background-color: #1890ff;
    box-shadow: 0 0 0 2px white;
}

/* 随机点名相关样式 */
.random-btn-container {
    width: 100%;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 20px;
    padding: 0 10px;
    gap: 15px; /* Add gap between buttons */
}

.btn-icon-round {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s;
    color: #666;
}

.btn-icon-round:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    color: #1890ff;
}

.btn-icon-round.muted {
    color: #ccc;
    background: #f5f5f5;
    box-shadow: none;
}

.btn-random {
    background: linear-gradient(135deg, #b06ab3, #4568dc);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 25px;
    font-size: 15px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(176, 106, 179, 0.4);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-random:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(176, 106, 179, 0.6);
}

/* 随机点名高亮样式 - 增强版 (Slot Machine Effect) */
.student-card.highlight {
    transform: scale(1.18) !important; /* 明显放大 */
    background: linear-gradient(135deg, #fff 0%, #e6f7ff 100%) !important;
    box-shadow: 0 0 30px rgba(24, 144, 255, 0.6), 0 0 10px rgba(24, 144, 255, 0.4) inset !important;
    z-index: 100 !important;
    border: 2px solid #1890ff !important;
    transition: transform 0.05s ease-out; /* 极速响应 */
}

.student-card.highlight .student-name {
    color: #1890ff !important;
    font-weight: 900 !important;
    font-size: 1.2em;
}

.student-card.highlight .student-avatar {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 4px 15px rgba(24, 144, 255, 0.3);
}

/* 结果展示弹窗 */
.result-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(8px);
    z-index: 3000;
    display: none;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.result-card {
    background: white;
    padding: 40px 60px;
    border-radius: 30px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
    animation: popIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    border: 4px solid #b06ab3;
}

.result-avatar {
    width: 100px;
    height: 100px;
    border-radius: 30px;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 50px;
    color: white;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    border: 4px solid white;
}

.result-name {
    font-size: 28px;
    font-weight: bold;
    color: #333;
    margin-bottom: 10px;
}

.result-title {
    color: #b06ab3;
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 30px;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.confetti-piece {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #ffd300;
    top: 0;
    opacity: 0;
}
