/* 积分管家 - 主样式表 */
:root {
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    
    /* Light mode */
    --bg: #f8fafc;
    --bg-card: #ffffff;
    --bg-sidebar: #1e1b4b;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-sidebar: #e2e8f0;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
    --radius: 12px;
    --radius-sm: 8px;
}

[data-theme="dark"] {
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-sidebar: #0f172a;
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-sidebar: #e2e8f0;
    --border: #334155;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.3);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    transition: background 0.3s, color 0.3s;
}

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

.login-container {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
}

.login-logo {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo h1 {
    font-size: 28px;
    color: var(--primary);
    margin-bottom: 8px;
}

.login-logo p {
    color: var(--text-secondary);
    font-size: 14px;
}

.role-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
}

.role-tab {
    flex: 1;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.2s;
    text-align: center;
}

.role-tab.active {
    border-color: var(--primary);
    background: var(--primary);
    color: white;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    background: var(--bg);
    color: var(--text);
    transition: border-color 0.2s;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
    width: 100%;
    padding: 14px;
    font-size: 16px;
}

.btn-primary:hover { background: var(--primary-dark); }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-success { background: var(--success); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-info { background: var(--info); color: white; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

.login-switch {
    text-align: center;
    margin-top: 20px;
    color: var(--text-secondary);
    font-size: 14px;
}

.login-switch a {
    color: var(--primary);
    cursor: pointer;
    text-decoration: none;
}

/* === 主布局 === */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: var(--bg-sidebar);
    color: var(--text-sidebar);
    padding: 20px 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.3s;
}

.sidebar-header {
    padding: 0 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 10px;
}

.sidebar-header h2 {
    font-size: 20px;
    color: white;
}

.sidebar-nav {
    list-style: none;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--text-sidebar);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-nav li a:hover,
.sidebar-nav li a.active {
    background: rgba(255,255,255,0.1);
    border-left-color: var(--primary-light);
    color: white;
}

.sidebar-nav li a .icon {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

.main-content {
    flex: 1;
    margin-left: 240px;
    padding: 24px;
    min-height: 100vh;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.top-bar h1 {
    font-size: 24px;
    font-weight: 600;
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* === 主题切换 === */
.theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s;
}

.theme-toggle:hover {
    border-color: var(--primary);
    color: var(--primary);
}

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

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
}

/* === 积分卡片轮播 === */
.points-carousel {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius);
    margin-bottom: 24px;
}

.points-cards {
    display: flex;
    transition: transform 0.3s ease;
    gap: 16px;
    padding: 4px;
}

.points-card {
    min-width: calc(100% - 8px);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: var(--radius);
    padding: 24px;
    color: white;
    position: relative;
    overflow: hidden;
}

.points-card::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    border-radius: 50%;
}

.points-card .child-name {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 4px;
}

.points-card .child-label {
    font-size: 12px;
    opacity: 0.7;
    margin-bottom: 12px;
}

.points-card .points-value {
    font-size: 42px;
    font-weight: 700;
    margin-bottom: 4px;
}

.points-card .points-label {
    font-size: 13px;
    opacity: 0.8;
}

.carousel-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
}

.carousel-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
    cursor: pointer;
    transition: all 0.2s;
}

.carousel-dot.active {
    background: var(--primary);
    width: 24px;
    border-radius: 4px;
}

.carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    z-index: 2;
}

.carousel-nav.prev { left: 8px; }
.carousel-nav.next { right: 8px; }

/* === 表格 === */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th, table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

table tr:hover {
    background: rgba(99, 102, 241, 0.05);
}

/* === 标签/徽章 === */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.badge-warning { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.badge-danger { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.badge-info { background: rgba(59, 130, 246, 0.1); color: var(--info); }
.badge-primary { background: rgba(99, 102, 241, 0.1); color: var(--primary); }

/* === 模态框 === */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius);
    width: 100%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 24px;
    transform: scale(0.95);
    transition: transform 0.2s;
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* === 扭蛋机动画 === */
.gacha-machine {
    text-align: center;
    padding: 40px 20px;
}

.gacha-ball {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    margin: 0 auto 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    box-shadow: 0 10px 30px rgba(245, 158, 11, 0.3);
    cursor: pointer;
    transition: transform 0.2s;
    position: relative;
}

.gacha-ball:hover { transform: scale(1.05); }

.gacha-ball.shaking {
    animation: shake 0.5s ease-in-out;
}

.gacha-ball.opening {
    animation: openBall 0.8s ease-in-out forwards;
}

@keyframes shake {
    0%, 100% { transform: rotate(0deg); }
    20% { transform: rotate(-15deg); }
    40% { transform: rotate(15deg); }
    60% { transform: rotate(-10deg); }
    80% { transform: rotate(10deg); }
}

@keyframes openBall {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.8; }
    100% { transform: scale(0); opacity: 0; }
}

.gacha-result {
    display: none;
    animation: fadeInUp 0.5s ease;
}

.gacha-result.show { display: block; }

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

.gacha-result-item {
    background: var(--bg-card);
    border: 2px solid var(--primary);
    border-radius: var(--radius);
    padding: 20px;
    margin: 10px auto;
    max-width: 300px;
}

.gacha-result-item.hit {
    border-color: var(--warning);
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.05), rgba(251, 191, 36, 0.05));
}

/* 扭蛋机多结果 */
.gacha-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 20px;
}

.gacha-result-mini {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 12px;
    text-align: center;
    border: 1px solid var(--border);
    animation: fadeInUp 0.3s ease;
}

.gacha-result-mini.hit {
    border-color: var(--warning);
    background: rgba(245, 158, 11, 0.05);
}

.gacha-result-mini .item-icon {
    font-size: 28px;
    margin-bottom: 6px;
}

.gacha-result-mini .item-name {
    font-size: 12px;
    font-weight: 500;
}

/* === 日历 === */
.calendar {
    width: 100%;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.calendar-day-header {
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 8px 0;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
    position: relative;
}

.calendar-day:hover { background: rgba(99, 102, 241, 0.1); }

.calendar-day.today {
    background: var(--primary);
    color: white;
}

.calendar-day.has-activity::after {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
    position: absolute;
    bottom: 4px;
}

.calendar-day.other-month {
    color: var(--text-secondary);
    opacity: 0.5;
}

/* === 勋章网格 === */
.badge-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 16px;
}

.badge-item {
    text-align: center;
    padding: 16px;
    border-radius: var(--radius);
    background: var(--bg);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
}

.badge-item:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.badge-item.locked {
    filter: grayscale(1);
    opacity: 0.5;
}

.badge-item .badge-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--warning), #fbbf24);
    margin: 0 auto 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

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

/* === 宠物卡片 === */
.pet-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    box-shadow: var(--shadow);
}

.pet-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, #a78bfa, #7c3aed);
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
}

.pet-avatar.dead {
    filter: grayscale(1);
    opacity: 0.6;
}

.pet-avatar.burned {
    filter: grayscale(1);
    opacity: 0.3;
}

.pet-level {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.pet-exp-bar {
    width: 100%;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.pet-exp-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), #34d399);
    border-radius: 4px;
    transition: width 0.3s;
}

/* === 审核列表 === */
.audit-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

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

.audit-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    flex-shrink: 0;
}

.audit-info { flex: 1; }
.audit-info .name { font-weight: 500; font-size: 14px; }
.audit-info .desc { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

.audit-actions {
    display: flex;
    gap: 8px;
}

/* === 响应式 === */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
        padding: 16px;
    }
    .points-card .points-value {
        font-size: 32px;
    }
    .modal {
        max-width: 100%;
        margin: 10px;
    }
    .gacha-results-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
    table {
        font-size: 13px;
    }
    table th, table td {
        padding: 8px 10px;
    }
}

/* === 菜单按钮(移动端) === */
.menu-toggle {
    display: none;
    width: 40px;
    height: 40px;
    border: none;
    background: var(--bg-card);
    color: var(--text);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 20px;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
}

@media (max-width: 768px) {
    .menu-toggle { display: flex; }
}

/* === 工具栏 === */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
    align-items: center;
}

.toolbar .search-input {
    flex: 1;
    min-width: 200px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

/* === 通知/提示 === */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
}

.toast {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 12px 20px;
    margin-bottom: 8px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    animation: slideIn 0.3s ease;
    border-left: 4px solid var(--primary);
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

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

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

.empty-state p {
    font-size: 14px;
}

/* === 统计卡片 === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* === 复选框 === */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

/* === 背包网格 === */
.backpack-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.backpack-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.backpack-item:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.backpack-item .item-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.backpack-item .item-name {
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 4px;
}

.backpack-item .item-qty {
    font-size: 12px;
    color: var(--text-secondary);
}

.backpack-item .item-type {
    font-size: 11px;
    margin-top: 4px;
}

/* === 战报 === */
.report-card {
    background: linear-gradient(135deg, #1e1b4b, #312e81);
    border-radius: var(--radius);
    padding: 30px;
    color: white;
    margin-bottom: 20px;
}

.report-card h2 {
    font-size: 20px;
    margin-bottom: 20px;
    text-align: center;
}

.report-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.report-stat {
    text-align: center;
}

.report-stat .value {
    font-size: 32px;
    font-weight: 700;
}

.report-stat .label {
    font-size: 12px;
    opacity: 0.8;
    margin-top: 4px;
}

/* === 选择孩子下拉(家长端) === */
.child-selector {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 0;
}

.child-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
    transition: all 0.2s;
}

.child-chip.active {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}

.child-chip .avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: white;
}

/* 隐藏页面 */
.page { display: none; }
.page.active { display: block; }
