/* ============================================
   班级宠物园积分管理系统 - 样式文件
   ============================================ */

:root {
    --primary: #4A90D9;
    --primary-light: #6BA5E7;
    --primary-dark: #3A7BC8;
    --success: #52C41A;
    --warning: #FAAD14;
    --danger: #FF4D4F;
    --bg: #F0F5FF;
    --card-bg: #FFFFFF;
    --text: #333333;
    --text-secondary: #888888;
    --border: #E8E8E8;
    --shadow: 0 2px 12px rgba(74, 144, 217, 0.15);
    --radius: 12px;
    --radius-sm: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* 页面容器 */
.page {
    display: none;
    min-height: 100vh;
    padding-bottom: 70px;
    animation: fadeIn 0.3s ease;
}
.page.active { display: block; }

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

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

@keyframes bounceIn {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.05); }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); opacity: 1; }
}

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

@keyframes shine {
    0% { background-position: -200% center; }
    100% { background-position: 200% center; }
}

/* ========== 登录页 ========== */
.login-page {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    padding-bottom: 20px;
}

.login-logo {
    font-size: 72px;
    margin-bottom: 10px;
    animation: bounceIn 0.8s ease;
}

.login-title {
    color: #fff;
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 6px;
    text-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.login-subtitle {
    color: rgba(255,255,255,0.8);
    font-size: 14px;
    margin-bottom: 30px;
}

.login-box {
    background: rgba(255,255,255,0.95);
    border-radius: 20px;
    padding: 30px 24px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.input-group {
    margin-bottom: 18px;
}

.input-group label {
    display: block;
    font-size: 13px;
    color: #666;
    margin-bottom: 6px;
    font-weight: 500;
}

.input-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.3s;
}

.input-group input:focus {
    border-color: var(--primary);
}

.btn-login {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 8px;
}

.btn-login:active {
    transform: scale(0.97);
    opacity: 0.9;
}

.login-hint {
    text-align: center;
    color: rgba(255,255,255,0.7);
    font-size: 12px;
    margin-top: 20px;
}

/* ========== 顶部导航栏 ========== */
.navbar {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(74,144,217,0.3);
}

.navbar-back {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    cursor: pointer;
    font-size: 18px;
    transition: background 0.3s;
}

.navbar-back:active { background: rgba(255,255,255,0.3); }

.navbar-title {
    font-size: 17px;
    font-weight: 600;
}

.navbar-action {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    cursor: pointer;
    font-size: 16px;
}

/* ========== 主界面 ========== */
.home-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px 16px 30px;
    color: #fff;
    border-radius: 0 0 24px 24px;
}

.home-welcome {
    font-size: 14px;
    opacity: 0.9;
}

.home-classname {
    font-size: 22px;
    font-weight: 700;
    margin: 4px 0 16px;
}

.home-stats {
    display: flex;
    gap: 10px;
}

.home-stat-item {
    flex: 1;
    background: rgba(255,255,255,0.2);
    border-radius: 12px;
    padding: 12px;
    text-align: center;
    backdrop-filter: blur(10px);
}

.home-stat-num {
    font-size: 24px;
    font-weight: 700;
}

.home-stat-label {
    font-size: 11px;
    opacity: 0.9;
    margin-top: 2px;
}

/* 功能网格 */
.func-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 16px;
    margin-top: -14px;
}

.func-item {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px 8px;
    text-align: center;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.3s;
}

.func-item:active {
    transform: scale(0.95);
}

.func-icon {
    font-size: 32px;
    margin-bottom: 8px;
    display: block;
}

.func-name {
    font-size: 12px;
    color: var(--text);
    font-weight: 500;
}

/* ========== 通用卡片 ========== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    margin: 12px 16px;
    padding: 16px;
    box-shadow: var(--shadow);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ========== 学生列表 ========== */
.student-list {
    padding: 8px 16px;
}

.student-item {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    cursor: pointer;
    transition: all 0.2s;
}

.student-item:active {
    transform: scale(0.98);
    background: #f8faff;
}

.student-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 18px;
    font-weight: 600;
    flex-shrink: 0;
}

.student-avatar.female {
    background: linear-gradient(135deg, #ff9a9e, #fad0c4);
}

.student-info {
    flex: 1;
    min-width: 0;
}

.student-name {
    font-size: 15px;
    font-weight: 600;
}

.student-meta {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.student-points {
    text-align: right;
    flex-shrink: 0;
}

.student-points-num {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
}

.student-points-label {
    font-size: 11px;
    color: var(--text-secondary);
}

.student-pet-badge {
    font-size: 20px;
    margin-left: 4px;
}

/* ========== 搜索栏 ========== */
.search-bar {
    padding: 12px 16px;
}

.search-input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    border: 2px solid var(--border);
    border-radius: 25px;
    font-size: 14px;
    outline: none;
    background: var(--card-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") no-repeat 14px center;
    transition: border-color 0.3s;
}

.search-input:focus {
    border-color: var(--primary);
}

/* 分组标签 */
.group-tabs {
    display: flex;
    gap: 8px;
    padding: 0 16px 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.group-tab {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    white-space: nowrap;
    cursor: pointer;
    background: var(--card-bg);
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.group-tab.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ========== 积分规则选择 ========== */
.rule-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 12px 16px;
}

.rule-item {
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    padding: 14px 12px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.rule-item.reward { border-left: 3px solid var(--success); }
.rule-item.punish { border-left: 3px solid var(--danger); }

.rule-item:active, .rule-item.selected {
    border-color: var(--primary);
    background: #f0f5ff;
}

.rule-icon {
    font-size: 24px;
    margin-bottom: 4px;
}

.rule-name {
    font-size: 13px;
    font-weight: 500;
}

.rule-points {
    font-size: 16px;
    font-weight: 700;
    margin-top: 4px;
}

.rule-points.positive { color: var(--success); }
.rule-points.negative { color: var(--danger); }

/* ========== 宠物相关 ========== */
.pet-select-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 12px 16px;
}

.pet-select-item {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px 12px;
    text-align: center;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.3s;
    border: 3px solid transparent;
}

.pet-select-item:active, .pet-select-item.selected {
    border-color: var(--primary);
    transform: scale(0.96);
}

.pet-select-icon {
    font-size: 48px;
    margin-bottom: 8px;
    display: block;
}

.pet-select-name {
    font-size: 15px;
    font-weight: 600;
}

.pet-select-desc {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* 宠物详情 */
.pet-detail-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    margin: 12px 16px;
    border-radius: 20px;
    padding: 24px;
    color: #fff;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.pet-detail-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 60%);
    animation: pulse 3s ease infinite;
}

.pet-big-icon {
    font-size: 80px;
    display: block;
    margin-bottom: 10px;
    position: relative;
    z-index: 1;
    animation: pulse 2s ease infinite;
}

.pet-detail-name {
    font-size: 22px;
    font-weight: 700;
    position: relative;
    z-index: 1;
}

.pet-level-badge {
    display: inline-block;
    background: rgba(255,255,255,0.25);
    padding: 4px 16px;
    border-radius: 20px;
    font-size: 14px;
    margin-top: 8px;
    position: relative;
    z-index: 1;
}

/* 成长进度条 */
.growth-bar-wrap {
    margin: 16px 16px;
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.growth-label {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    margin-bottom: 8px;
}

.growth-bar {
    height: 12px;
    background: #e8e8e8;
    border-radius: 6px;
    overflow: hidden;
}

.growth-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #52c41a, #73d13d);
    border-radius: 6px;
    transition: width 0.8s ease;
    position: relative;
}

.growth-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    background-size: 200% 100%;
    animation: shine 2s ease infinite;
}

/* 喂养按钮区 */
.feed-section {
    padding: 0 16px;
}

.feed-amount-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.feed-amount-btn {
    flex: 1;
    padding: 10px;
    border: 2px solid var(--border);
    border-radius: 10px;
    background: var(--card-bg);
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.feed-amount-btn.active {
    border-color: var(--primary);
    background: #f0f5ff;
    color: var(--primary);
}

.btn-feed {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #52c41a, #73d13d);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-feed:active {
    transform: scale(0.97);
}

/* ========== 商城 ========== */
.shop-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 12px 16px;
}

.shop-item {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px 12px;
    text-align: center;
    box-shadow: var(--shadow);
    transition: all 0.2s;
}

.shop-item:active {
    transform: scale(0.96);
}

.shop-icon {
    font-size: 36px;
    margin-bottom: 8px;
}

.shop-name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

.shop-desc {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    min-height: 30px;
}

.shop-price {
    display: inline-block;
    background: linear-gradient(135deg, #ffd700, #ffb347);
    color: #8B4513;
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 13px;
    font-weight: 700;
}

.shop-stock {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 6px;
}

/* ========== 排行榜 ========== */
.rank-tabs {
    display: flex;
    padding: 12px 16px;
    gap: 8px;
}

.rank-tab {
    flex: 1;
    padding: 10px;
    border-radius: 10px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    background: var(--card-bg);
    border: 2px solid var(--border);
    transition: all 0.2s;
}

.rank-tab.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.rank-list {
    padding: 0 16px;
}

.rank-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-bottom: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.rank-item.top-1 { background: linear-gradient(135deg, #fff9e6, #fff3cc); border: 1px solid #ffd700; }
.rank-item.top-2 { background: linear-gradient(135deg, #f5f5f5, #e8e8e8); border: 1px solid #c0c0c0; }
.rank-item.top-3 { background: linear-gradient(135deg, #fff5ee, #ffe4cc); border: 1px solid #cd7f32; }

.rank-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    background: var(--border);
    color: var(--text-secondary);
    flex-shrink: 0;
}

.top-1 .rank-num { background: #ffd700; color: #8B4513; font-size: 15px; }
.top-2 .rank-num { background: #c0c0c0; color: #555; }
.top-3 .rank-num { background: #cd7f32; color: #fff; }

.rank-info { flex: 1; }
.rank-name { font-size: 14px; font-weight: 600; }
.rank-pet { font-size: 12px; color: var(--text-secondary); }
.rank-score {
    font-size: 18px;
    font-weight: 700;
    color: var(--warning);
}

/* ========== 记录列表 ========== */
.record-list {
    padding: 8px 16px;
}

.record-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
}

.record-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.record-icon.reward { background: #e6f7e6; }
.record-icon.punish { background: #fff1f0; }
.record-icon.exchange { background: #fff7e6; }
.record-icon.feed { background: #e6f7ff; }

.record-info { flex: 1; }
.record-reason { font-size: 13px; font-weight: 500; }
.record-time { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
.record-points {
    font-size: 16px;
    font-weight: 700;
    flex-shrink: 0;
}
.record-points.positive { color: var(--success); }
.record-points.negative { color: var(--danger); }

/* ========== 弹窗 ========== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

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

.modal-content {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 24px;
    width: 100%;
    max-width: 360px;
    max-height: 80vh;
    overflow-y: auto;
    animation: bounceIn 0.3s ease;
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 16px;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    font-size: 24px;
    cursor: pointer;
    color: #999;
}

/* 升级弹窗 */
.level-up-modal {
    text-align: center;
}

.level-up-icon {
    font-size: 80px;
    animation: bounceIn 0.5s ease;
}

.level-up-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--warning);
    margin: 10px 0;
}

.level-up-text {
    font-size: 14px;
    color: var(--text-secondary);
}

/* ========== 通用按钮 ========== */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn:active { transform: scale(0.95); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-block { display: block; width: 100%; }

.btn-group {
    display: flex;
    gap: 10px;
    padding: 12px 16px;
}

/* ========== 选择学生 ========== */
.select-student-list .student-item {
    position: relative;
}

.student-checkbox {
    width: 22px;
    height: 22px;
    border: 2px solid var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}

.student-item.selected .student-checkbox {
    background: var(--primary);
    border-color: var(--primary);
}

.student-item.selected .student-checkbox::after {
    content: '✓';
    color: #fff;
    font-size: 14px;
    font-weight: 700;
}

/* ========== Toast 提示 ========== */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.8);
    color: #fff;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 14px;
    z-index: 2000;
    animation: fadeIn 0.3s ease;
    pointer-events: none;
    text-align: center;
    max-width: 80%;
}

/* ========== 加载动画 ========== */
.loading {
    text-align: center;
    padding: 30px;
    color: var(--text-secondary);
}

.loading::before {
    content: '';
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 8px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========== 空状态 ========== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* ========== 底部操作栏 ========== */
.bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card-bg);
    padding: 10px 16px;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    z-index: 99;
    display: flex;
    gap: 10px;
}

.bottom-bar .btn {
    flex: 1;
}

/* 学生多选操作栏 */
.select-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: #f0f5ff;
    border-bottom: 1px solid var(--border);
}

.select-bar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.select-all-btn {
    padding: 6px 12px;
    border: 1px solid var(--primary);
    border-radius: 6px;
    color: var(--primary);
    background: transparent;
    font-size: 12px;
    cursor: pointer;
}

.select-count {
    font-size: 13px;
    color: var(--primary);
    font-weight: 500;
}

/* ========== 自定义输入框 ========== */
.custom-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin: 8px 0;
}

.custom-input-row input {
    flex: 1;
    padding: 8px 12px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
}

.custom-input-row input:focus {
    border-color: var(--primary);
}

.custom-input-row .btn {
    padding: 8px 16px;
    font-size: 13px;
}

/* ========== 响应式 ========== */
@media (min-width: 500px) {
    .func-grid { grid-template-columns: repeat(5, 1fr); }
    .rule-grid { grid-template-columns: repeat(3, 1fr); }
    .pet-select-grid { grid-template-columns: repeat(4, 1fr); }
    .shop-grid { grid-template-columns: repeat(3, 1fr); }
}
