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

body {
    font-family: 'Microsoft YaHei', 'PingFang SC', 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-attachment: fixed;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 24px;
    box-shadow: 0 30px 80px rgba(0,0,0,0.25);
    overflow: hidden;
    animation: slideIn 0.5s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 头部 */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 40px 30px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 300px;
    height: 300px;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
}

header::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: -5%;
    width: 200px;
    height: 200px;
    background: rgba(255,255,255,0.08);
    border-radius: 50%;
}

header h1 {
    font-size: 2.8em;
    font-weight: bold;
    position: relative;
    z-index: 1;
    text-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

/* 标签页导航 */
.tabs {
    display: flex;
    background: linear-gradient(to bottom, #f8f9fa, #e9ecef);
    border-bottom: 1px solid #dee2e6;
    padding: 0 10px;
}

.tab-btn {
    flex: 1;
    padding: 18px 20px;
    background: none;
    border: none;
    font-size: 1.15em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: #6c757d;
    position: relative;
    border-radius: 8px 8px 0 0;
    margin: 5px 2px 0;
}

.tab-btn:hover {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    transform: translateY(-2px);
}

.tab-btn.active {
    background: white;
    color: #667eea;
    font-weight: bold;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 3px 3px 0 0;
}

/* 标签页内容 */
.tab-content {
    display: none;
    padding: 40px;
    min-height: 500px;
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tab-content.active {
    display: block;
}

/* 点名页面 */
.roll-call-section {
    text-align: center;
}

.result-display {
    margin: 60px auto;
    min-height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05), rgba(118, 75, 162, 0.05));
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
}

.selected-student {
    font-size: 4.5em;
    font-weight: bold;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: scaleIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.selected-student .hint {
    font-size: 0.35em;
    color: #999;
    display: block;
    margin-top: 10px;
    background: none;
    -webkit-text-fill-color: #999;
}

.selected-student .name {
    margin: 20px 0;
}

.selected-student .seat {
    font-size: 0.5em;
    color: #764ba2;
}

.roll-btn {
    padding: 28px 70px;
    font-size: 2em;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    border: none;
    border-radius: 60px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: 0 15px 40px rgba(102, 126, 234, 0.5);
    position: relative;
    overflow: hidden;
    /* 确保按钮不会因为任何原因变暗 */
    opacity: 1 !important;
    -webkit-tap-highlight-color: transparent;
    /* iOS Safari特殊处理 */
    -webkit-appearance: none;
    -webkit-user-select: none;
    user-select: none;
}

/* 按钮禁用状态 */
.roll-btn.btn-disabled,
.roll-btn:disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
    -webkit-filter: grayscale(0);
    filter: grayscale(0);
}

/* 确保按钮正常状态在所有浏览器中一致 */
.roll-btn:not(.btn-disabled):not(:disabled) {
    opacity: 1 !important;
    cursor: pointer !important;
    pointer-events: auto !important;
    -webkit-filter: none;
    filter: none;
}

.roll-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255,255,255,0.4);
    transform: translate(-50%, -50%);
    transition: width 0.8s, height 0.8s;
}

.roll-btn:hover::before {
    width: 500px;
    height: 500px;
}

.roll-btn:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 25px 60px rgba(102, 126, 234, 0.7);
    opacity: 1 !important;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
}

.roll-btn:active {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 15px 40px rgba(102, 126, 234, 0.5);
    opacity: 1 !important;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
}

.roll-btn:focus {
    outline: none;
    opacity: 1 !important;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
}

.roll-btn:focus-visible {
    outline: 3px solid rgba(102, 126, 234, 0.5);
    outline-offset: 3px;
    opacity: 1 !important;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
}

/* 确保按钮在失去焦点后也能保持正常状态 */
.roll-btn:not(:active):not(:hover):not(:focus) {
    opacity: 1 !important;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
}

.student-info {
    margin-top: 30px;
    font-size: 1.2em;
    color: #666;
}

/* 学生管理页面 */
.students-section {
    max-width: 1200px;
    margin: 0 auto;
}

.student-list {
    width: 100%;
}

.action-buttons {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
}

.action-buttons .btn {
    min-width: 200px;
}

.btn {
    padding: 14px 28px;
    font-size: 1.05em;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    position: relative;
    overflow: hidden;
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.25);
}

.btn:active {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #5568d3 0%, #66408f 100%);
}

.btn-secondary {
    background: linear-gradient(135deg, #868e96 0%, #6c757d 100%);
    color: white;
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
}

.btn-success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
}

.btn-success:hover {
    background: linear-gradient(135deg, #218838 0%, #1aa179 100%);
}

.btn-danger {
    background: linear-gradient(135deg, #dc3545 0%, #bd2130 100%);
    color: white;
}

.btn-danger:hover {
    background: linear-gradient(135deg, #c82333 0%, #a71d2a 100%);
}

.btn-warning {
    background: linear-gradient(135deg, #ffc107 0%, #ff9800 100%);
    color: white;
}

.btn-warning:hover {
    background: linear-gradient(135deg, #e0a800 0%, #e68900 100%);
}

.student-list h3 {
    margin-bottom: 20px;
    color: #333;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
}

thead {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
}

th, td {
    padding: 18px;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}

/* 学生管理表格列宽 */
#students-table th:nth-child(1),
#students-table td:nth-child(1) {
    width: 20%;
    text-align: center;
}

#students-table th:nth-child(2),
#students-table td:nth-child(2) {
    width: 50%;
}

#students-table th:nth-child(3),
#students-table td:nth-child(3) {
    width: 30%;
    text-align: center;
}

th {
    font-weight: 700;
    color: #667eea;
    font-size: 1.05em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

tbody tr {
    transition: all 0.2s ease;
}

tbody tr:hover {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05), rgba(118, 75, 162, 0.05));
    transform: scale(1.01);
}

tbody tr:last-child td {
    border-bottom: none;
}

.empty-message {
    text-align: center;
    color: #999;
    padding: 50px !important;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.95em;
    margin-right: 8px;
    border-radius: 8px;
    font-weight: 600;
}

/* 历史记录页面 */
.history-section {
    max-width: 100%;
}

.date-filter {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
    flex-wrap: wrap;
    align-items: center;
}

.date-filter label {
    display: flex;
    align-items: center;
    gap: 10px;
}

.date-filter input[type="date"] {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1em;
}

.history-list h3 {
    margin-bottom: 20px;
    color: #333;
}

.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
}

.history-item {
    padding: 24px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    border-left: 5px solid transparent;
    background-image: linear-gradient(white, white),
                      linear-gradient(135deg, #667eea, #764ba2);
    background-origin: padding-box, border-box;
    background-clip: padding-box, border-box;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.history-item:hover {
    transform: translateY(-4px) scale(1.01);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.2);
}

.history-item .date {
    font-weight: bold;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
    font-size: 1.15em;
}

.history-item .info {
    color: #495057;
    font-size: 1.1em;
    font-weight: 500;
}

/* 统计分析页面 */
.statistics-section {
    max-width: 100%;
}

.stats-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 30px;
    gap: 15px;
    flex-wrap: wrap;
}

.stats-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 35px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.35);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200px;
    height: 200px;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
}

.stat-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 15px 35px rgba(102, 126, 234, 0.45);
}

.stat-card h4 {
    margin-bottom: 18px;
    font-size: 1.15em;
    opacity: 0.95;
    font-weight: 600;
    position: relative;
    z-index: 1;
}

.stat-card p {
    font-size: 3em;
    font-weight: bold;
    position: relative;
    z-index: 1;
    text-shadow: 0 2px 10px rgba(0,0,0,0.15);
}

.stats-detail h4 {
    margin-bottom: 20px;
    color: #333;
}

.stats-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.stat-item-card {
    background: white;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    border: 1px solid transparent;
    background-image: linear-gradient(white, white),
                      linear-gradient(135deg, rgba(102, 126, 234, 0.3), rgba(118, 75, 162, 0.3));
    background-origin: padding-box, border-box;
    background-clip: padding-box, border-box;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stat-item-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.2);
}

.stat-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.stat-rank {
    font-weight: bold;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 1.15em;
    min-width: 80px;
}

.stat-call-count {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.95em;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    min-width: 80px;
    text-align: center;
}

.stat-item-body {
    flex: 1;
}

.stat-seat {
    color: #666;
    margin-bottom: 5px;
    font-size: 0.9em;
}

.stat-name {
    font-size: 1.2em;
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
}

.stat-item-footer {
    text-align: left;
}

.stat-last-call {
    font-size: 0.9em;
    color: #999;
    word-break: break-word;
}

/* 弹窗 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-content h3 {
    margin-bottom: 25px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 1.8em;
}

.modal-content label {
    display: block;
    margin-bottom: 20px;
    font-weight: 600;
    color: #495057;
}

.modal-content input {
    width: 100%;
    padding: 14px;
    margin-top: 8px;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-size: 1.05em;
    transition: all 0.3s;
}

.modal-content input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.modal-buttons {
    display: flex;
    gap: 15px;
    margin-top: 30px;
}

.modal-buttons button {
    flex: 1;
}

.confirm-modal .modal-content {
    border-top: 4px solid #667eea;
    animation: fadeIn 0.25s ease-out;
}

.confirm-modal[data-type="danger"] .modal-content {
    border-top-color: #dc3545;
}

.confirm-modal[data-type="warning"] .modal-content {
    border-top-color: #ffc107;
}

.confirm-message {
    color: #495057;
    line-height: 1.6;
}

.confirm-message ul {
    margin: 15px 0 0;
    padding-left: 20px;
    max-height: 240px;
    overflow-y: auto;
}

.confirm-issues {
    list-style: disc;
}

.confirm-message li {
    margin-bottom: 6px;
}

.confirm-alert {
    margin-top: 18px;
    color: #dc3545;
    font-weight: 600;
}

.confirm-modal .modal-buttons {
    margin-top: 25px;
}

.confirm-student p {
    margin: 6px 0;
}

.confirm-student strong {
    color: #343a40;
}

/* 动画 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes rollAnimation {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.rolling {
    animation: rollAnimation 0.5s ease-in-out;
}

/* 快速滚动动画 */
.rolling-fast {
    animation: rollingFast 0.1s ease-in-out infinite;
}

@keyframes rollingFast {
    0%, 100% {
        transform: translateY(0) scale(1);
        opacity: 0.8;
    }
    50% {
        transform: translateY(-10px) scale(1.05);
        opacity: 1;
    }
}

.rolling-text {
    filter: blur(1px);
    animation: textBlur 0.1s ease-in-out;
}

@keyframes textBlur {
    0%, 100% { filter: blur(1px); }
    50% { filter: blur(2px); }
}

/* 3D翻转动画 */
.flip-in {
    animation: flipIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes flipIn {
    0% {
        transform: perspective(800px) rotateY(180deg) scale(0.5);
        opacity: 0;
    }
    50% {
        transform: perspective(800px) rotateY(90deg) scale(0.8);
        opacity: 0.5;
    }
    100% {
        transform: perspective(800px) rotateY(0deg) scale(1);
        opacity: 1;
    }
}

/* 发光文字效果 */
.glow-text {
    animation: glowPulse 1.5s ease-in-out infinite;
    text-shadow:
        0 0 10px rgba(102, 126, 234, 0.8),
        0 0 20px rgba(102, 126, 234, 0.6),
        0 0 30px rgba(102, 126, 234, 0.4),
        0 0 40px rgba(118, 75, 162, 0.4);
}

@keyframes glowPulse {
    0%, 100% {
        text-shadow:
            0 0 10px rgba(102, 126, 234, 0.8),
            0 0 20px rgba(102, 126, 234, 0.6),
            0 0 30px rgba(102, 126, 234, 0.4),
            0 0 40px rgba(118, 75, 162, 0.4);
    }
    50% {
        text-shadow:
            0 0 20px rgba(102, 126, 234, 1),
            0 0 30px rgba(102, 126, 234, 0.8),
            0 0 40px rgba(102, 126, 234, 0.6),
            0 0 50px rgba(118, 75, 162, 0.6),
            0 0 60px rgba(118, 75, 162, 0.4);
    }
}

/* 粒子效果 */
.particle {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 100;
    animation: particleExplosion 1s ease-out forwards;
    box-shadow: 0 0 10px currentColor;
}

@keyframes particleExplosion {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(var(--tx), var(--ty)) scale(0);
        opacity: 0;
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.8em;
    }

    .tab-btn {
        padding: 15px 10px;
        font-size: 0.9em;
    }

    .selected-student {
        font-size: 2.5em;
    }

    .roll-btn {
        padding: 20px 40px;
        font-size: 1.4em;
    }

    .action-buttons {
        flex-direction: column;
        justify-content: stretch;
    }

    .action-buttons .btn {
        width: 100%;
        min-width: 0;
    }

    .stats-header {
        flex-direction: column;
        align-items: stretch;
    }

    .stats-summary {
        grid-template-columns: 1fr;
    }

    .history-grid,
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .modal-content {
        width: 95%;
        padding: 30px 20px;
    }

    table {
        font-size: 0.9em;
    }

    th, td {
        padding: 12px 8px;
    }

    body {
        padding: 10px;
    }

    .container {
        border-radius: 16px;
    }

    header {
        padding: 30px 20px;
    }

    header h1 {
        font-size: 2em;
    }

    .tab-content {
        padding: 25px 20px;
    }
}
