/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 导航高亮样式 */
.active-nav {
    font-weight: bold;
    text-decoration: underline;
    color: #667eea;
}

body {
    font-family: 'Arial', sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 2rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

header h1 {
    display: inline-block;
    margin-right: 2rem;
    font-size: 1.8rem;
}

nav {
    display: inline-block;
}

nav a {
    color: white;
    text-decoration: none;
    margin: 0 1rem;
    font-weight: bold;
    transition: all 0.3s ease;
}

nav a:hover {
    text-decoration: underline;
    transform: translateY(-2px);
}

main {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 2rem;
}

footer {
    background-color: #333;
    color: white;
    text-align: center;
    padding: 1rem 0;
    margin-top: 2rem;
}

/* 首页样式 */
.rank-section {
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.rank-section h2 {
    margin-bottom: 1rem;
    color: #667eea;
}

.student-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

/* 特殊排名布局 - 金字塔形紧凑排列 */
.special-rank-layout {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: auto auto;
    gap: 1rem;
    max-width: 700px;
    margin: 0 auto;
}

/* 第一行：1个学生，居中在第三列 */
.rank-row.row-1 {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
}

/* 第二行：2个学生，分布在第二和第四列 */
.rank-row.row-2 {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.rank-row.row-2 .student-card:nth-child(1) {
    grid-column: 1;
}

.rank-row.row-2 .student-card:nth-child(2) {
    grid-column: 3;
}

/* 第三行：3个学生，分布在第一、三、五列 */
.rank-row.row-3 {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
}

.rank-row.row-3 .student-card:nth-child(1) {
    grid-column: 1;
}

.rank-row.row-3 .student-card:nth-child(2) {
    grid-column: 3;
}

.rank-row.row-3 .student-card:nth-child(3) {
    grid-column: 5;
}

/* 学生卡片统一大小，突出第一行 */
.rank-row .student-card {
    width: 100%;
    max-width: 180px;
    margin: 0 auto;
}

.rank-row.row-1 .student-card {
    transform: scale(1.1); /* 第一行学生卡片稍大 */
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.2); /* 添加阴影效果 */
}

/* 响应式调整 */
@media (max-width: 768px) {
    .special-rank-layout {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .rank-row {
        grid-column: 1;
    }
    
    .rank-row.row-2,
    .rank-row.row-3 {
        grid-template-columns: 1fr;
    }
    
    .rank-row .student-card {
        grid-column: 1 !important;
        max-width: 200px;
    }
    
    .rank-row.row-1 .student-card {
        transform: none;
    }
}

.student-card {
    background: #f9f9f9;
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
    transition: all 0.3s ease;
    border: 1px solid #e0e0e0;
}

.student-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.student-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto 0.5rem;
    border: 2px solid #667eea;
    display: block;
}

.student-name {
    font-weight: bold;
    margin-bottom: 0.25rem;
}

.student-rank {
    color: #667eea;
    font-weight: bold;
    margin-bottom: 0.25rem;
}

.student-score {
    color: #888;
    font-size: 0.9rem;
}

.all-students {
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* 积分规则样式 */
.score-rules {
    margin-top: 1rem;
}

.rules-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.rule-item {
    background: #f9f9f9;
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid #667eea;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.rule-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.rule-name {
    font-weight: bold;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
    color: #333;
}

.rule-score {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.rule-score.positive {
    color: #2ecc71;
}

.rule-score.negative {
    color: #e74c3c;
}

.rule-description {
    color: #666;
    font-size: 0.9rem;
    line-height: 1.4;
}

.no-rules {
    text-align: center;
    color: #999;
    padding: 2rem 0;
    font-style: italic;
}

.all-students h2 {
    margin-bottom: 1rem;
    color: #667eea;
}

.student-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

/* 登录页面样式 */
.login-section {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    max-width: 500px;
    margin: 2rem auto;
}

.login-section h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: #667eea;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
}

.form-group textarea {
    resize: vertical;
}

button {
    background: #667eea;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 5px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

button:hover {
    background: #5a6fd8;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

button:active {
    transform: translateY(0);
}

#loginMessage {
    text-align: center;
    margin-top: 1rem;
    font-weight: bold;
}

/* 个人中心样式 */
.profile-section {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.profile-header {
    display: flex;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid #f0f0f0;
}

.avatar-container {
    margin-right: 2rem;
    text-align: center;
}

#profileAvatar {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #667eea;
    margin-bottom: 1rem;
}

.rank-display {
    display: flex;
    align-items: center;
}

.rank-icon {
    width: 80px;
    height: 80px;
    background-size: cover;
    background-position: center;
    margin-right: 1rem;
}

.rank-info {
    display: flex;
    flex-direction: column;
}

.rank-title {
    font-size: 1.5rem;
    font-weight: bold;
    color: #667eea;
}

.rank-score {
    font-size: 1.2rem;
    color: #888;
}

.profile-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-item {
    background: #f9f9f9;
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
    border: 1px solid #e0e0e0;
}

.stat-label {
    display: block;
    color: #888;
    margin-bottom: 0.5rem;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: bold;
    color: #667eea;
}

.progress-bar {
    width: 100%;
    height: 20px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    margin-top: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    transition: width 0.5s ease;
}

.broadcast-section {
    margin-top: 2rem;
}

.broadcast-section h3 {
    margin-bottom: 1rem;
    color: #667eea;
}

.broadcast-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.broadcast-item {
    background: #f9f9f9;
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.broadcast-title {
    font-weight: bold;
    margin-bottom: 0.5rem;
    color: #333;
}

.broadcast-content {
    color: #666;
    margin-bottom: 0.5rem;
}

.broadcast-date {
    font-size: 0.8rem;
    color: #999;
    text-align: right;
}

/* 教师管理后台样式 */
.admin-section {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.admin-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 0.5rem;
}

.tab-btn {
    background: #f0f0f0;
    color: #666;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 5px 5px 0 0;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab-btn.active {
    background: #667eea;
    color: white;
}

.tab-btn:hover {
    background: #e0e0e0;
    color: #333;
}

.tab-btn.active:hover {
    background: #5a6fd8;
    color: white;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.tab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e0e0e0;
}

.tab-header h3 {
    color: #667eea;
}

.btn-group {
    display: flex;
    gap: 0.5rem;
}

.btn-group button {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

/* 表格样式 */
table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

th {
    background: #f5f5f5;
    font-weight: bold;
    color: #333;
}

tr:hover {
    background: #f9f9f9;
}

input[type="checkbox"] {
    transform: scale(1.2);
}

/* 积分管理样式 */
.score-input-section {
    background: #f9f9f9;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    border: 1px solid #e0e0e0;
}

.score-input-section h4 {
    margin-bottom: 1rem;
    color: #667eea;
}

.score-input-section select,
.score-input-section input {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
}

/* 广播管理样式 */
.broadcast-management form {
    background: #f9f9f9;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    border: 1px solid #e0e0e0;
}

/* 段位图标样式 */
.bronze { background-image: url('public/images/bronze.png'); }
.silver { background-image: url('public/images/silver.png'); }
.gold { background-image: url('public/images/gold.png'); }
.platinum { background-image: url('public/images/platinum.png'); }
.diamond { background-image: url('public/images/diamond.png'); }
.master { background-image: url('public/images/master.png'); }

/* 响应式设计 */
@media (max-width: 768px) {
    header {
        padding: 1rem;
        text-align: center;
    }
    
    header h1 {
        display: block;
        margin-right: 0;
        margin-bottom: 1rem;
    }
    
    nav {
        display: block;
    }
    
    nav a {
        margin: 0 0.5rem;
    }
    
    main {
        padding: 0 1rem;
    }
    
    .profile-header {
        flex-direction: column;
        text-align: center;
    }
    
    .avatar-container {
        margin-right: 0;
        margin-bottom: 1.5rem;
    }
    
    .admin-tabs {
        flex-wrap: wrap;
    }
    
    .btn-group {
        flex-wrap: wrap;
    }
    
    .student-grid,
    .student-list {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }
}

/* 按钮样式扩展 */
.edit-student-btn,
.delete-broadcast-btn,
.end-bounty-btn,
.delete-bounty-btn,
.approve-btn,
.reject-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-right: 0.5rem;
}

.edit-student-btn:hover,
.delete-broadcast-btn:hover,
.end-bounty-btn:hover,
.delete-bounty-btn:hover,
.approve-btn:hover,
.reject-btn:hover {
    transform: translateY(-1px);
}

.edit-student-btn:hover,
.end-bounty-btn:hover,
.approve-btn:hover {
    background: #5a6fd8;
}

.delete-broadcast-btn,
.delete-bounty-btn,
.reject-btn {
    background: #e74c3c;
}

.delete-broadcast-btn:hover,
.delete-bounty-btn:hover,
.reject-btn:hover {
    background: #c0392b;
}

.broadcast-actions,
.bounty-actions,
.application-actions {
    margin-top: 10px;
    text-align: right;
}

.broadcast-actions button,
.bounty-actions button,
.application-actions button {
    margin-right: 0.5rem;
}

/* 悬赏令样式 */
.bounty-management {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.bounty-item {
    background: #f9f9f9;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border-left: 4px solid #667eea;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.bounty-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.bounty-title {
    font-weight: bold;
    margin-bottom: 0.25rem;
}

.bounty-score {
    font-weight: bold;
    color: #2ecc71;
    font-size: 1.1rem;
}

.bounty-content {
    margin-bottom: 0.5rem;
    color: #333;
}

.bounty-image {
    margin: 0.5rem 0;
}

.bounty-image img {
    border-radius: 4px;
    border: 1px solid #e0e0e0;
}

.bounty-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 0.5rem;
}

.bounty-status {
    font-weight: bold;
}

/* 悬赏令接受记录样式 */
.bounty-applications {
    margin-top: 2rem;
    background: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.application-item {
    background: #f9f9f9;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border-left: 4px solid #667eea;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.application-item.pending {
    border-left-color: #f39c12;
}

.application-item.approved {
    border-left-color: #2ecc71;
}

.application-item.rejected {
    border-left-color: #e74c3c;
}

.application-info {
    margin-bottom: 1rem;
}

.student-name {
    font-weight: bold;
    margin-bottom: 0.25rem;
}

.bounty-title {
    color: #667eea;
    margin-bottom: 0.25rem;
}

.application-date {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 0.25rem;
}

.application-status {
    font-weight: bold;
    margin-bottom: 0.25rem;
}

.application-item.approved .application-status {
    color: #2ecc71;
}

.application-item.rejected .application-status {
    color: #e74c3c;
}

/* 首页悬赏令样式 */
.bounty-section {
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.bounty-section h2 {
    margin-bottom: 1rem;
    color: #667eea;
}

.bounty-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.bounty-card {
    background: #f9f9f9;
    padding: 1.5rem;
    border-radius: 8px;
    border-left: 4px solid #667eea;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.bounty-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.bounty-card h3 {
    margin: 0;
    color: #333;
    font-size: 1.2rem;
}

.bounty-image {
    max-width: 100%;
    height: auto;
    border-radius: 5px;
    border: 1px solid #e0e0e0;
    display: block;
    margin: 0.5rem 0;
}

.bounty-content {
    color: #666;
    line-height: 1.5;
    margin: 0;
}

.bounty-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    margin-top: auto;
}

.bounty-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 1rem;
}

.no-bounties {
    text-align: center;
    color: #999;
    padding: 2rem 0;
    font-style: italic;
    grid-column: 1 / -1;
}

/* 按钮样式扩展 */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5a6fd8;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #95a5a6;
    color: white;
    cursor: not-allowed;
    opacity: 0.8;
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}