/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* 科技蓝主题色 */
    --bg-primary: #0a1929;
    --bg-secondary: #1a2847;
    --color-primary: #00d4ff;
    --color-secondary: #0066ff;
    --color-highlight: #00ffff;
    --color-text: #ffffff;
    --color-text-secondary: #b0c4de;
    --card-bg: rgba(255, 255, 255, 0.05);
    --card-border: rgba(0, 212, 255, 0.3);
    --success: #00ff88;
    --danger: #ff4444;
    --warning: #ffaa00;
}

body {
    font-family: 'Microsoft YaHei', 'PingFang SC', Arial, sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    color: var(--color-text);
    min-height: 100vh;
    overflow-x: hidden;
}

.container {
    max-width: 1920px;
    margin: 0 auto;
    padding: 20px;
}

/* 头部样式 */
.header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: var(--card-bg);
    border-radius: 15px;
    border: 1px solid var(--card-border);
    box-shadow: 0 0 30px rgba(0, 212, 255, 0.2);
}

.title {
    font-size: 3rem;
    font-weight: bold;
    background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
    text-shadow: 0 0 20px rgba(0, 212, 255, 0.5);
}

.datetime {
    font-size: 1.2rem;
    color: var(--color-text-secondary);
    letter-spacing: 2px;
}

.header {
    position: relative;
    /* Ensure absolute positioning works inside */
}

/* 全局悬浮二维码 */
.header-qrcode {
    position: fixed !important;
    /* Fixed to viewport */
    right: 30px;
    top: 30px;
    z-index: 9999;
    /* Highest priority */
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(10, 25, 41, 0.6);
    /* Slightly transparent background */
    padding: 15px;
    border-radius: 15px;
    backdrop-filter: blur(5px);
    border: 1px solid var(--card-border);
    transition: all 0.3s ease;
}

.header-qrcode:hover {
    transform: scale(1.05);
    background: rgba(10, 25, 41, 0.9);
}

.header-qrcode img {
    width: 150px;
    /* Standard: Larger size */
    height: 150px;
    border-radius: 10px;
    border: 2px solid var(--color-primary);
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.3);
    margin-bottom: 8px;
    display: block;
}

.header-qrcode p {
    color: var(--color-highlight);
    font-size: 1.1rem;
    /* Larger text */
    font-weight: bold;
    margin: 0;
    line-height: 1.2;
    white-space: nowrap;
    text-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
}

/* 主内容区布局 */
.main-content {
    display: grid;
    grid-template-columns: 300px 1fr 350px;
    gap: 20px;
    min-height: calc(100vh - 200px);
}

/* 面板卡片通用样式 */
.panel-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 15px;
    padding: 25px;
    backdrop-filter: blur(10px);
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.15);
}

.panel-title {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: var(--color-primary);
    border-bottom: 2px solid var(--color-primary);
    padding-bottom: 10px;
}

/* 左侧控制面板 */
.control-panel {
    display: flex;
    flex-direction: column;
}

.control-group {
    margin-bottom: 20px;
}

/* 文件上传按钮 */
.file-label {
    display: block;
    cursor: pointer;
}

.file-hint {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    margin-top: 8px;
    text-align: center;
}

/* 统计信息 */
.stats-group {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.stat-item {
    background: rgba(0, 212, 255, 0.1);
    padding: 15px;
    border-radius: 10px;
    text-align: center;
    border: 1px solid var(--card-border);
}

.stat-label {
    display: block;
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    margin-bottom: 5px;
}

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: bold;
    color: var(--color-primary);
}

.stat-value.highlight {
    color: var(--color-highlight);
}

/* 输入框 */
.input-label {
    display: block;
    margin-bottom: 8px;
    color: var(--color-text-secondary);
    font-size: 0.95rem;
}

.input-number {
    width: 100%;
    padding: 12px;
    font-size: 1.1rem;
    background: rgba(0, 212, 255, 0.05);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    color: var(--color-text);
    text-align: center;
    transition: all 0.3s ease;
}

.input-number:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.3);
}

/* 按钮通用样式 */
.btn {
    padding: 12px 24px;
    font-size: 1rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    width: 100%;
    margin-bottom: 10px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    color: white;
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.6);
    transform: translateY(-2px);
}

.btn-success {
    background: linear-gradient(135deg, var(--success), #00cc66);
    color: white;
}

.btn-success:hover:not(:disabled) {
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.6);
    transform: translateY(-2px);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #cc0000);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    box-shadow: 0 0 20px rgba(255, 68, 68, 0.6);
    transform: translateY(-2px);
}

.btn-secondary {
    background: linear-gradient(135deg, #555, #777);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    box-shadow: 0 0 15px rgba(119, 119, 119, 0.4);
}

.btn-warning {
    background: linear-gradient(135deg, var(--warning), #ff8800);
    color: white;
}

.btn-warning:hover:not(:disabled) {
    box-shadow: 0 0 15px rgba(255, 170, 0, 0.4);
}

.btn-large {
    font-size: 1.2rem;
    padding: 15px 30px;
}

.toggle-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.btn-icon {
    font-size: 1.5rem;
    padding: 12px;
}

/* 提示框 */
.hint-box {
    background: rgba(0, 212, 255, 0.05);
    padding: 15px;
    border-radius: 8px;
    border: 1px dashed var(--card-border);
    margin-top: 20px;
}

.hint-box p {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    margin-bottom: 5px;
}

.hint-box p:last-child {
    margin-bottom: 0;
}

/* 中央抽奖区域 */
.lottery-area {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* 名片墙容器 */
.card-wall {
    position: relative;
    width: 100%;
    height: 70vh;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 15px;
    overflow: hidden;

    /* 保持 3D 透视效果 */
    perspective: 1000px;
    perspective-origin: center center;
}

/* 单个名片样式 - 绝对定位 */
.name-card {
    position: absolute;
    width: 100px;
    height: 80px;
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.15), rgba(0, 102, 255, 0.15));
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

.name-card .name {
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--color-text);
    margin-bottom: 3px;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.name-card .student-id {
    font-size: 0.75rem;
    color: var(--color-text-secondary);
    text-align: center;
}

/* 悬停效果 */
.name-card:hover {
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.6);
    z-index: 10;
}

/* 随机高亮效果（抽奖时） */
.card-wall .name-card.highlight {
    border-color: var(--color-primary);
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.8);
    transform: scale(1.2);
    z-index: 5;
}

/* 刷新切换动画类 */
.name-card.switching {
    transform: scale(0);
    opacity: 0;
}

/* 淡入淡出动画类 */
.name-card.fade-out {
    animation: fadeOut 0.5s ease-out forwards;
}

.name-card.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }

    to {
        opacity: 0;
        transform: scale(0.8);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* 弹窗遮罩层 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}

.modal-overlay.show {
    display: flex;
}

/* 弹窗内容 */
.modal-content {
    background: linear-gradient(135deg, var(--bg-primary), var(--bg-secondary));
    border: 2px solid var(--color-primary);
    border-radius: 20px;
    max-width: 90%;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: 0 0 50px rgba(0, 212, 255, 0.6);
    animation: modalSlideIn 0.4s ease;
}

@keyframes modalSlideIn {
    from {
        transform: scale(0.7) translateY(-50px);
        opacity: 0;
    }

    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

/* 弹窗头部 */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 30px 40px;
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.15), rgba(0, 102, 255, 0.15));
    border-bottom: 2px solid var(--color-primary);
}

.modal-title {
    font-size: 2.5rem;
    color: var(--color-primary);
    margin: 0;
    text-shadow: 0 0 20px rgba(0, 212, 255, 0.5);
}

.modal-close {
    background: none;
    border: 2px solid var(--color-primary);
    color: var(--color-primary);
    font-size: 2rem;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.modal-close:hover {
    background: var(--color-primary);
    color: var(--bg-primary);
    transform: rotate(90deg);
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.8);
}

/* 弹窗主体 */
.modal-body {
    padding: 40px;
    overflow-y: auto;
    max-height: calc(85vh - 150px);
}

.modal-body::-webkit-scrollbar {
    width: 10px;
}

.modal-body::-webkit-scrollbar-track {
    background: rgba(0, 212, 255, 0.05);
    border-radius: 5px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: var(--color-primary);
    border-radius: 5px;
}

/* 中奖名单 - Flex 居中布局，最多 5 个一行 */
.winner-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 30px;
    max-width: 1200px;
    margin: 0 auto;
}

/* 中奖者卡片 */
.winner-item {
    flex: 0 0 auto;
    max-width: calc(20% - 24px);
    min-width: 180px;
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.2), rgba(0, 102, 255, 0.2));
    border: 2px solid var(--color-primary);
    border-radius: 15px;
    padding: 30px 20px;
    text-align: center;
    box-shadow: 0 0 40px rgba(0, 212, 255, 0.5);
    animation: winnerPop 0.5s ease;
}

@keyframes winnerPop {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.winner-item .name {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--color-highlight);
    margin-bottom: 10px;
    text-shadow: 0 0 15px rgba(0, 255, 255, 0.5);
}

.winner-item .student-id {
    font-size: 1.2rem;
    color: var(--color-text-secondary);
}

/* 响应式：少于 5 个时自动居中并增大显示 */
.winner-list:has(.winner-item:nth-child(1):nth-last-child(1)) .winner-item,
.winner-list:has(.winner-item:nth-child(1):nth-last-child(2)) .winner-item,
.winner-list:has(.winner-item:nth-child(1):nth-last-child(3)) .winner-item,
.winner-list:has(.winner-item:nth-child(1):nth-last-child(4)) .winner-item {
    max-width: 220px;
    min-width: 200px;
}

/* 右侧历史记录 */
.history-panel {
    height: 100%;
    overflow: hidden;
}

.history-panel .panel-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    min-height: 200px;
    max-height: calc(100vh - 400px);
    /* Limit height to trigger scroll */
}

.history-list::-webkit-scrollbar {
    width: 8px;
}

.history-list::-webkit-scrollbar-track {
    background: rgba(0, 212, 255, 0.05);
    border-radius: 4px;
}

.history-list::-webkit-scrollbar-thumb {
    background: var(--color-primary);
    border-radius: 4px;
}

.empty-hint {
    text-align: center;
    color: var(--color-text-secondary);
    padding: 40px 20px;
    font-size: 1rem;
}

.history-item {
    background: rgba(0, 212, 255, 0.08);
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 12px;
    border-left: 3px solid var(--color-primary);
    transition: all 0.3s ease;
}

.history-item:hover {
    background: rgba(0, 212, 255, 0.15);
    transform: translateX(5px);
}

.history-item .name {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--color-text);
    margin-bottom: 5px;
}

.history-item .student-id {
    font-size: 0.95rem;
    color: var(--color-text-secondary);
}

.history-item .time {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    margin-top: 5px;
    opacity: 0.7;
}

/* 历史记录控制区 */
.history-controls {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px dashed var(--card-border);
}

.history-controls .control-group {
    margin-bottom: 20px;
}

.history-controls .control-group:last-child {
    margin-bottom: 0;
}

/* 响应式设计 */
@media (max-width: 1400px) {
    .main-content {
        grid-template-columns: 280px 1fr 300px;
    }

    .title {
        font-size: 2.5rem;
    }
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .control-panel,
    .history-panel {
        max-width: 100%;
    }

    .card-wall {
        max-width: 800px;
        margin: 0 auto;
    }
}