/* ========== 全局变量 ========== */
:root {
    --primary-color: #667eea;
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --success-color: #4CAF50;
    --danger-color: #f44336;
    --warning-color: #ff9800;
    --text-color: #2c3e50;
    --text-muted: #6c757d;
    --border-color: #e0e0e0;
    --white-bg: #ffffff;
    --light-bg: #f8f9fa;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.2);
}

/* ========== 全局样式 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Body style is handled in header-unified.css, but we keep basic reset just in case or empty it */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    color: var(--text-color);
    line-height: 1.6;
}

/* ========== 页面头部 ========== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.page-header .header-title {
    font-size: 18px;
    font-weight: bold;
    color: white !important;
}

.page-header .btn-parent-login {
    background: rgba(255, 255, 255, 0.2) !important;
    color: white !important;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 6px 14px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.3s;
}

.page-header .btn-parent-login:hover {
    background: rgba(255, 255, 255, 0.3) !important;
    transform: translateY(-1px);
}

/* ========== 容器 ========== */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 10px;
}

/* ========== 状态面板 ========== */
.status-panel {
    background: var(--white-bg);
    border-radius: 16px;
    padding: 20px;
    box-shadow: var(--shadow-md);
    margin-bottom: 10px;
}

/* ========== 学生信息 ========== */
.student-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.student-info h3 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-color);
    margin: 0;
}

.student-level-grade {
    font-size: 1rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ========== 经验条 ========== */
.exp-bar-container {
    position: relative;
    width: 100%;
    height: 35px;
    background: #e0e0e0;
    border-radius: 20px;
    overflow: hidden;
    margin-top: 12px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.exp-bar {
    height: 100%;
    background: var(--primary-gradient);
    transition: width 0.5s ease;
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.exp-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: bold;
    color: var(--text-color);
    font-size: 14px;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

/* ========== 资产栏 ========== */
.assets-bar {
    display: flex;
    justify-content: space-around;
    align-items: center;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
    gap: 8px;
}

.asset-item,
.reward-icon-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 12px;
    transition: all 0.3s;
    position: relative;
    text-decoration: none;
}

.asset-item:hover,
.reward-icon-item:hover {
    background-color: var(--light-bg);
    transform: translateY(-2px);
}

.asset-item .icon,
.reward-icon-item .icon {
    font-size: 2.5rem;
}

.asset-item .value {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-color);
    line-height: 1;
}

.badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--danger-color);
    color: white;
    border-radius: 50%;
    min-width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ========== 任务容器 ========== */
#task-container {
    min-height: 200px;
}

.no-tasks {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    font-size: 16px;
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
}

.subject-group {
    margin-bottom: 10px;
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    border: 1px solid var(--border-color);
    padding: 12px 12px;
    font-weight: 700 !important;
    font-size: 18px !important;
    margin-top: 2px;
    margin-right: 0px;
    margin-bottom: 2px;
    margin-left: 0px;
}

.subject-group summary::-webkit-details-marker {
    display: none;
}

.subject-group[open] summary {
    border-bottom-color: var(--primary-color);
}

/* ========== 任务列表 ========== */
.task-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* ========== 已完成任务折叠区域 ========== */
.completed-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 12px 20px;
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.95rem;
    border-top: 1px dashed var(--border-color);
    user-select: none;
    background-color: #fafbfc;
    transition: all 0.3s;
}

.completed-summary:hover {
    background-color: #f1f3f5;
}

.toggle-arrow {
    font-style: normal;
    font-size: 0.8em;
    transition: transform 0.3s ease;
    display: inline-block;
}

.completed-summary.expanded .toggle-arrow {
    transform: rotate(90deg);
}

.completed-tasks-container {
    transition: max-height 0.4s ease-out, opacity 0.3s ease-out;
    overflow: hidden;
    max-height: 1000px;
    opacity: 1;
}

.completed-tasks-container.collapsed {
    max-height: 0;
    opacity: 0;
}

/* ========== 按钮统一风格 ========== */
.btn-switch-student {
    padding: 6px 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    border-radius: 6px;
    color: white;
    background: var(--primary-gradient);
    transition: all 0.3s;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.btn-switch-student:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

/* ========== 模态框通用样式 ========== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 2000;
}

.modal-overlay.show {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--white-bg);
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content h3 {
    margin: 0 0 20px;
    color: var(--text-color);
    font-size: 1.5rem;
}

.modal-content input[type="number"] {
    width: 100px;
    font-size: 1.5rem;
    text-align: center;
    padding: 10px;
    margin: 1rem 0;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    transition: border-color 0.3s;
}

.modal-content input[type="number"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.modal-buttons {
    display: flex !important;
    gap: 12px;
    justify-content: space-between;
    align-items: center;
    margin-top: 25px;
    width: 100%;
    flex-flow: row nowrap !important;
    /* 强制不换行 */
}

.modal-btn {
    flex: 1 1 0;
    /* 允许收缩和扩展，基准为0 */
    padding: 10px 8px;
    /* 进一步减小内边距 */
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    /* 稍微减小字体 */
    font-weight: 600;
    transition: all 0.3s;
    min-width: 60px;
    /* 设置更小的最小宽度 */
    white-space: nowrap;
    text-overflow: ellipsis;
    /* 防止极小屏幕文字溢出 */
    overflow: hidden;
}

.confirm-btn {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.confirm-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.cancel-btn {
    background: #e9ecef;
    color: var(--text-color);
}

.cancel-btn:hover {
    background: #dee2e6;
}

/* ========== 切换学生弹窗 ========== */
.switch-student-modal {
    background: white;
    padding: 25px;
    border-radius: 12px;
    width: 90%;
    max-width: 360px;
    max-height: 70vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.switch-student-modal h3 {
    margin: 0 0 20px;
    text-align: center;
    color: var(--text-color);
}

.student-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.student-item {
    padding: 12px 15px;
    font-size: 1rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s;
    border-radius: 6px;
    margin-bottom: 5px;
}

.student-item:hover {
    background-color: #f1f5f9;
    transform: translateX(5px);
}

.student-item:last-child {
    border-bottom: none;
}

.green-dot {
    width: 10px;
    height: 10px;
    background-color: var(--success-color);
    border-radius: 50%;
    display: inline-block;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.current-tip {
    color: var(--success-color);
    font-size: 0.85rem;
    font-weight: 600;
    margin-left: auto;
}

/* ========== Toast 提示 ========== */
.toast-notification {
    position: fixed;
    top: 50%;
    /* 垂直居中 */
    left: 50%;
    /* 水平居中 */
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #28a745, #20c997);
    /* 渐变绿 */
    color: white;
    padding: 16px 32px;
    /* 稍微增加内边距，使其更醒目 */
    border-radius: 30px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    font-size: 1.1rem;
    /* 稍微增大字体，突出显示 */
    font-weight: 500;
    z-index: 9999;
    max-width: 80%;
    text-align: center;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
    /* 增强阴影 */
    bottom: auto;
    /* 覆盖之前的 bottom */
}



.toast-notification.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    /* 保持居中并缩放 */
}

.toast-notification.error {
    background: rgba(220, 53, 69, 0.9);
}

/* ========== 响应式设计 ========== */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    header {
        padding: 10px 15px;
    }

    .header-title {
        font-size: 16px;
    }

    .student-info h3 {
        font-size: 1.5rem;
    }

    .btn-switch-student,
    .btn-parent-login {
        font-size: 12px;
        padding: 5px 10px;
    }

    .modal-content {
        padding: 20px;
        width: 95%;
    }

    .assets-bar {
        gap: 6px;
    }
}

@media (max-width: 480px) {
    .student-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .student-info h3 {
        font-size: 1.3rem;
    }

    .student-level-grade {
        font-size: 0.9rem;
    }

    .exp-bar-container {
        height: 28px;
    }

    .exp-text {
        font-size: 12px;
    }

    .modal-buttons {
        flex-direction: column;
    }

    .modal-btn {
        width: 100%;
    }
}

/* ========== 超小屏幕优化 ========== */
@media (max-width: 360px) {
    .header-title {
        font-size: 14px;
    }

    .student-info h3 {
        font-size: 1.2rem;
    }
}

/* ========== 学生信息头部优化 ========== */
.student-info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.student-name-grade {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex: 1;
}

.student-name-grade h3 {
    margin: 0;
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-color);
}

.student-grade-inline {
    font-size: 1.2rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ========== 等级+经验条同行 ========== */
.level-exp-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
}

.student-level-badge {
    background: var(--primary-gradient);
    color: white;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
}

.level-exp-row .exp-bar-container {
    flex: 1;
    margin-top: 0;
}

/* ========== 资产栏缩小 ========== */
.assets-bar {
    margin-top: 10px;
    padding-top: 10px;
    gap: 8px;
}

.asset-item,
.reward-icon-item {
    padding: 4px 8px;
}

.asset-item .icon,
.reward-icon-item .icon {
    font-size: clamp(2rem, 5vw, 2.5rem);
}

.asset-item .value {
    font-size: clamp(1rem, 3.5vw, 1.2rem);
}

.badge {
    min-width: 22px;
    height: 22px;
    font-size: 0.85rem;
    top: -4px;
    right: -4px;
}

/* ========== 今日打卡进度区域 ========== */
.daily-progress-section {
    margin: 8px 0 12px 0;
    padding: 12px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.daily-progress-section h3 {
    margin: 0 0 10px 0;
    font-size: 15px;
    color: #495057;
    font-weight: 600;
}

.daily-progress-bar-container {
    position: relative;
    width: 100%;
    height: 32px;
    background: #e0e0e0;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.daily-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    transition: width 0.4s ease;
    border-radius: 16px;
    box-shadow: 0 2px 6px rgba(76, 175, 80, 0.3);
}

.daily-progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: bold;
    color: #2c3e50;
    font-size: 14px;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

/* ========== 科目进度数字 - 徽章风格 ========== */
.subject-progress {
    display: inline-block;
    margin-left: 12px;
    padding: 2px 10px;
    font-size: 18px;
    color: #fff;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
    vertical-align: middle;
    line-height: 1.4;
    margin: 5px;
}

/* ========== 任务标题突出显示 ========== */
.task-title-highlight {
    font-weight: 700 !important;
    font-size: 20px !important;
    color: #2c3e50 !important;
    flex: 1;
    line-height: 1.5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 10px;
}

/* ========== 任务按钮样式 ========== */
.task-button-small {
    padding: 6px 16px;
    font-size: 13px;
    border: none;
    border-radius: 6px;
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
    cursor: pointer;
    margin-left: auto;
    min-width: 60px;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(0, 123, 255, 0.3);
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.task-button-small.completed {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
    box-shadow: 0 2px 6px rgba(108, 117, 125, 0.3);
}

.task-button-small:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 123, 255, 0.4);
}

.task-button-small.completed:hover {
    box-shadow: 0 4px 8px rgba(108, 117, 125, 0.4);
}

.task-button-small:active {
    transform: translateY(0);
}

.task-button-small:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ========== 任务项布局 ========== */
.task-item {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 14px 16px !important;
    margin-bottom: 6px;
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    transition: all 0.2s ease;
    min-height: 52px;
    gap: 12px;
}

.task-item:last-child {
    border-bottom: none;
}

.task-item:hover {
    border-color: #007bff;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.15);
    transform: translateX(2px);
    background-color: #f8f9fa;
}


/* ========== 烟花效果 ========== */
.fireworks-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

.firework {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    box-shadow: 0 0 10px #fff;
    animation: explode 1s ease-out forwards;
}

@keyframes explode {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }

    100% {
        transform: translate(var(--dx), var(--dy)) scale(0);
        opacity: 0;
    }
}

/* ========== +1 动画 ========== */
.plus-one-anim {
    position: absolute;
    top: -20px;
    right: 0;
    color: #ff4757;
    font-weight: bold;
    font-size: 24px;
    animation: floatUpFade 1.5s ease-out forwards;
    z-index: 100;
    pointer-events: none;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

@keyframes floatUpFade {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }

    100% {
        transform: translateY(-40px) scale(1.5);
        opacity: 0;
    }
}