/* ============================================================
   荣师星盟 · 教师端基础样式
   版本：v3.0（已清理家庭端残留）
   兼容：手机 / 平板 / 桌面
   ============================================================ */

/* ---------- 0. 重置 ---------- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
                 "Microsoft YaHei", "Comic Neue", "Segoe UI Emoji", sans-serif;
    background: #F5F7FB;
    color: #1F2937;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 1em;
    padding-left: max(1em, env(safe-area-inset-left, 0px));
    padding-right: max(1em, env(safe-area-inset-right, 0px));
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

img, video, canvas, svg {
    max-width: 100%;
    height: auto;
    display: block;
}

button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
}

a {
    color: #4D96FF;
    text-decoration: none;
    transition: color 0.18s ease;
}
a:hover { color: #2563EB; }

/* ---------- 1. 容器 ---------- */
.container {
    max-width: 75em;
    margin: 0 auto;
    position: relative;
    width: 100%;
}

/* ---------- 2. 卡片 ---------- */
.card {
    background: rgba(255, 255, 255, 0.98);
    border-radius: 1.8em;
    padding: 1.5em;
    margin-bottom: 1.5em;
    box-shadow: 0 0.35em 1em rgba(15, 23, 42, 0.06);
    border: 1px solid rgba(191, 219, 254, 0.5);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.6em 1.6em rgba(15, 23, 42, 0.1);
}

.card h1, .card h2, .card h3, .card h4 {
    color: #1E40AF;
    line-height: 1.3;
}

.card h1 { font-size: 1.5em; margin-bottom: 0.6em; }
.card h2 { font-size: 1.25em; margin-bottom: 0.5em; }
.card h3 { font-size: 1.1em; margin-bottom: 0.4em; }

/* ---------- 3. 按钮 ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35em;
    background: linear-gradient(135deg, #4D96FF 0%, #2563EB 100%);
    color: #fff;
    padding: 0.6em 1.5em;
    border-radius: 2em;
    border: none;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 700;
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    box-shadow: 0 0.25em 0.6em rgba(77, 150, 255, 0.3);
    min-height: 42px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    line-height: 1.2;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.45em 1em rgba(77, 150, 255, 0.45);
}

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

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-primary {
    background: linear-gradient(135deg, #1E40AF 0%, #4D96FF 100%);
    box-shadow: 0 0.25em 0.6em rgba(30, 64, 175, 0.35);
}
.btn-primary:hover {
    box-shadow: 0 0.45em 1em rgba(30, 64, 175, 0.5);
}

.btn-success {
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    box-shadow: 0 0.25em 0.6em rgba(16, 185, 129, 0.3);
}
.btn-success:hover {
    box-shadow: 0 0.45em 1em rgba(16, 185, 129, 0.45);
}

.btn-warning {
    background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
    box-shadow: 0 0.25em 0.6em rgba(245, 158, 11, 0.3);
}
.btn-warning:hover {
    box-shadow: 0 0.45em 1em rgba(245, 158, 11, 0.45);
}

.btn-outline {
    background: transparent;
    border: 2px solid #B3D9FF;
    color: #1E40AF;
    box-shadow: none;
}
.btn-outline:hover {
    background: #F0F7FF;
    border-color: #4D96FF;
    transform: translateY(-2px);
    box-shadow: 0 0.35em 0.9em rgba(77, 150, 255, 0.2);
}

.btn-remove {
    background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%);
    color: #fff;
    box-shadow: 0 0.25em 0.6em rgba(239, 68, 68, 0.3);
}
.btn-remove:hover {
    box-shadow: 0 0.45em 1em rgba(239, 68, 68, 0.45);
}

.btn-icon {
    padding: 0.3em 0.8em;
    font-size: 0.78em;
    border-radius: 1.5em;
    min-height: 30px;
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.25em;
    border: none;
    cursor: pointer;
}

.btn-edit {
    background: linear-gradient(135deg, #4D96FF, #2563EB);
}
.btn-edit:hover {
    box-shadow: 0 0.3em 0.7em rgba(77, 150, 255, 0.4);
}

.btn-disable {
    background: linear-gradient(135deg, #EF4444, #DC2626);
}
.btn-disable:hover {
    box-shadow: 0 0.3em 0.7em rgba(239, 68, 68, 0.4);
}

.btn-enable {
    background: linear-gradient(135deg, #10B981, #059669);
}
.btn-enable:hover {
    box-shadow: 0 0.3em 0.7em rgba(16, 185, 129, 0.4);
}

.btn-disabled {
    background: #E5E7EB;
    color: #9CA3AF;
    padding: 0.5em 1em;
    border-radius: 2em;
    border: none;
    cursor: not-allowed;
    box-shadow: none;
}

/* ---------- 4. 表单 ---------- */
.form-group {
    margin-bottom: 1.2em;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 0.4em;
    color: #374151;
    font-weight: 700;
    font-size: 0.9em;
    letter-spacing: 0.01em;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75em 1em;
    border: 2px solid #DBEAFE;
    border-radius: 1em;
    font-size: 1em;
    font-family: inherit;
    background: #F8FCFF;
    color: #1F2937;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
    min-height: 46px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #4D96FF;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(77, 150, 255, 0.12);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: #9CA3AF;
}

.form-group input:disabled,
.form-group select:disabled,
.form-group textarea:disabled {
    background: #F3F4F6;
    color: #9CA3AF;
    cursor: not-allowed;
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
    line-height: 1.6;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1em;
}

.form-actions {
    display: flex;
    gap: 0.8em;
    margin-top: 1.5em;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.code-group {
    display: flex;
    gap: 0.75em;
    align-items: stretch;
}

.btn-code {
    background: linear-gradient(135deg, #4D96FF, #2563EB);
    white-space: nowrap;
    padding: 0 1.2em;
    border: none;
    border-radius: 1em;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    min-height: 46px;
    transition: opacity 0.2s ease;
}
.btn-code:disabled { opacity: 0.6; cursor: not-allowed; }

/* ---------- 5. 表格 ---------- */
.task-table,
.member-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92em;
}

.task-table th,
.task-table td,
.member-table th,
.member-table td {
    padding: 0.75em;
    text-align: left;
    border-bottom: 1px solid #E5E7EB;
    vertical-align: middle;
}

.task-table th,
.member-table th {
    background: #F0F7FF;
    color: #1E40AF;
    font-weight: 700;
    font-size: 0.88em;
    letter-spacing: 0.02em;
}

.task-table tr:hover td,
.member-table tr:hover td {
    background: #F8FCFF;
}

/* ---------- 6. 徽章 ---------- */
.badge {
    display: inline-block;
    padding: 0.25em 0.65em;
    border-radius: 1em;
    font-size: 0.75em;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.badge-basic        { background: #DBEAFE; color: #1E40AF; }
.badge-growth       { background: #FEF3C7; color: #92400E; }
.badge-contribution { background: #E0E7FF; color: #3730A3; }
.badge-daily        { background: #D1FAE5; color: #166534; }
.badge-weekly       { background: #FEF3C7; color: #92400E; }
.badge-once         { background: #F3E8FF; color: #6B21A8; }

.task-status {
    display: inline-block;
    padding: 0.25em 0.75em;
    border-radius: 1em;
    font-size: 0.75em;
    font-weight: 700;
}
.task-status.active   { background: #D1FAE5; color: #065F46; }
.task-status.disabled { background: #FEE2E2; color: #991B1B; }

/* ---------- 7. 提示框 ---------- */
.alert {
    padding: 1em 1.2em;
    border-radius: 1em;
    margin-bottom: 1em;
    font-size: 0.92em;
    line-height: 1.6;
    border-left: 4px solid;
    animation: alertSlideIn 0.3s ease;
}

@keyframes alertSlideIn {
    from { opacity: 0; transform: translateX(-10px); }
    to   { opacity: 1; transform: translateX(0); }
}

.alert-success {
    background: #ECFDF5;
    color: #065F46;
    border-left-color: #10B981;
}

.alert-error {
    background: #FEF2F2;
    color: #991B1B;
    border-left-color: #EF4444;
}

.alert-info {
    background: #EFF6FF;
    color: #1E40AF;
    border-left-color: #4D96FF;
}

.alert-warning {
    background: #FFFBEB;
    color: #92400E;
    border-left-color: #F59E0B;
}

/* ---------- 8. 空状态 ---------- */
.empty-tip,
.empty-state {
    text-align: center;
    padding: 2.5em 1.5em;
    color: #6B7280;
    font-size: 1em;
    background: #F8FCFF;
    border-radius: 1.5em;
    border: 2px dashed #DBEAFE;
    line-height: 1.7;
}

.empty-tip .icon,
.empty-state .icon {
    font-size: 3em;
    display: block;
    margin-bottom: 0.4em;
    opacity: 0.7;
}

.empty-tip .empty-title,
.empty-state .empty-title {
    font-size: 1.15em;
    font-weight: 700;
    color: #1E40AF;
    margin-bottom: 0.4em;
}

/* ---------- 9. 进度条 ---------- */
.progress-wrapper {
    margin: 1.2em 0;
    border-radius: 2em;
}

.progress-bar {
    background: #E5E7EB;
    border-radius: 2em;
    height: 2em;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.06);
    position: relative;
}

.progress-fill {
    background: linear-gradient(90deg, #4D96FF 0%, #6BCB77 100%);
    height: 100%;
    border-radius: 2em;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 0.82em;
    transition: width 0.5s ease;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    white-space: nowrap;
    min-width: 3em;
}

/* ---------- 10. 头像 ---------- */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5em;
    line-height: 1;
    flex-shrink: 0;
}

/* ---------- 11. 分数徽标 ---------- */
.points-badge {
    background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
    color: #fff;
    padding: 0.5em 1.2em;
    border-radius: 2em;
    display: inline-flex;
    align-items: center;
    gap: 0.3em;
    margin-bottom: 1.5em;
    font-weight: 700;
    font-size: 1.15em;
    box-shadow: 0 0.3em 0.8em rgba(245, 158, 11, 0.3);
}

.points-cost {
    color: #F59E0B;
    font-weight: 700;
    margin: 0.5em 0;
    font-size: 1.1em;
}

/* ---------- 12. 筛选栏（通用） ---------- */
.filter-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1em;
    margin-bottom: 1.5em;
    padding: 1em;
    background: #F8FCFF;
    border-radius: 1em;
    border: 1px solid #DBEAFE;
}

.member-filter {
    display: flex;
    align-items: center;
    gap: 0.75em;
    flex-wrap: wrap;
}

.member-filter label {
    font-weight: 700;
    color: #374151;
    font-size: 0.9em;
}

.member-filter select {
    padding: 0.5em 1em;
    border: 2px solid #DBEAFE;
    border-radius: 0.7em;
    font-size: 0.9em;
    min-width: 8em;
    background: #fff;
    font-family: inherit;
    min-height: 40px;
}

.member-filter select:focus {
    outline: none;
    border-color: #4D96FF;
    box-shadow: 0 0 0 3px rgba(77, 150, 255, 0.15);
}

.status-filter {
    display: flex;
    gap: 0.5em;
    flex-wrap: wrap;
}

.status-btn {
    padding: 0.5em 1em;
    border: 2px solid #DBEAFE;
    background: #fff;
    border-radius: 2em;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    font-weight: 700;
    font-size: 0.85em;
    color: #4B5563;
    min-height: 38px;
}

.status-btn:hover {
    border-color: #93C5FD;
    background: #F0F7FF;
}

.status-btn.active {
    background: linear-gradient(135deg, #4D96FF, #2563EB);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 0.25em 0.6em rgba(77, 150, 255, 0.35);
}

.task-stats {
    display: flex;
    gap: 1em;
    margin-bottom: 1em;
    padding: 0.75em 1em;
    background: #ECFDF5;
    border-radius: 0.75em;
    font-size: 0.88em;
    flex-wrap: wrap;
    color: #065F46;
    font-weight: 600;
}

/* ---------- 13. 操作按钮组 ---------- */
.action-buttons {
    display: flex;
    gap: 0.5em;
    flex-wrap: wrap;
}

/* ---------- 14. 滚动条 ---------- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(77, 150, 255, 0.35);
    border-radius: 8px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(77, 150, 255, 0.6);
}

/* ---------- 15. 选中文字 ---------- */
::selection {
    background: rgba(77, 150, 255, 0.35);
    color: #fff;
}

/* ---------- 16. 触摸优化 ---------- */
@media (hover: none) and (pointer: coarse) {
    button, .btn, .nav-item, .menu-item, .card {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
    button:active, .btn:active {
        transform: scale(0.97);
        transition: transform 0.1s ease;
    }
}

/* ---------- 17. 动画 ---------- */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25%      { transform: translateX(-5px); }
    75%      { transform: translateX(5px); }
}

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

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-20px); }
    to   { opacity: 1; transform: translateX(0); }
}

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

.animate-shake { animation: shake 0.3s ease; }
.animate-pulse { animation: pulse 0.5s ease; }

/* ============================================================
   夜间模式（教师端选择器）
   ============================================================ */
html.night-mode,
body.night-mode {
    background: #0F172A !important;
    color: #E2E8F0;
}

/* 卡片 */
body.night-mode .card {
    background: rgba(30, 41, 59, 0.95);
    border-color: #334155;
    box-shadow: 0 0.35em 1em rgba(0, 0, 0, 0.4);
}

body.night-mode .card:hover {
    box-shadow: 0 0.6em 1.6em rgba(0, 0, 0, 0.5);
}

/* 标题 */
body.night-mode .card h1,
body.night-mode .card h2,
body.night-mode .card h3,
body.night-mode .card h4 {
    color: #F1F5F9;
}

/* 输入框 */
body.night-mode .form-group input,
body.night-mode .form-group select,
body.night-mode .form-group textarea,
body.night-mode .member-filter select {
    background: #1E293B;
    color: #E2E8F0;
    border-color: #334155;
}

body.night-mode .form-group input:focus,
body.night-mode .form-group select:focus,
body.night-mode .form-group textarea:focus,
body.night-mode .member-filter select:focus {
    border-color: #4D96FF;
    background: #1E293B;
    box-shadow: 0 0 0 4px rgba(77, 150, 255, 0.15);
}

body.night-mode .form-group input::placeholder,
body.night-mode .form-group textarea::placeholder {
    color: #64748B;
}

/* 表格 */
body.night-mode .task-table th,
body.night-mode .member-table th {
    background: #1E293B;
    color: #93C5FD;
    border-bottom-color: #334155;
}

body.night-mode .task-table td,
body.night-mode .member-table td {
    border-bottom-color: #1E293B;
    color: #CBD5E1;
}

body.night-mode .task-table tr:hover td,
body.night-mode .member-table tr:hover td {
    background: #1E293B;
}

/* 按钮（outline 变体） */
body.night-mode .btn-outline {
    border-color: #475569;
    color: #93C5FD;
}
body.night-mode .btn-outline:hover {
    background: #1E293B;
    border-color: #4D96FF;
}

/* 提示框 */
body.night-mode .alert-success {
    background: rgba(16, 185, 129, 0.15);
    color: #6EE7B7;
    border-left-color: #10B981;
}
body.night-mode .alert-error {
    background: rgba(239, 68, 68, 0.15);
    color: #FCA5A5;
    border-left-color: #EF4444;
}
body.night-mode .alert-info {
    background: rgba(77, 150, 255, 0.15);
    color: #93C5FD;
    border-left-color: #4D96FF;
}
body.night-mode .alert-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #FCD34D;
    border-left-color: #F59E0B;
}

/* 空状态 */
body.night-mode .empty-tip,
body.night-mode .empty-state {
    background: #1E293B;
    border-color: #334155;
    color: #94A3B8;
}
body.night-mode .empty-tip .empty-title,
body.night-mode .empty-state .empty-title {
    color: #93C5FD;
}

/* 筛选栏 */
body.night-mode .filter-bar {
    background: #1E293B;
    border-color: #334155;
}
body.night-mode .member-filter label {
    color: #CBD5E1;
}
body.night-mode .status-btn {
    background: #1E293B;
    border-color: #334155;
    color: #CBD5E1;
}
body.night-mode .status-btn:hover {
    background: #334155;
    border-color: #4D96FF;
}
body.night-mode .status-btn.active {
    background: linear-gradient(135deg, #4D96FF, #2563EB);
    color: #fff;
}

body.night-mode .task-stats {
    background: rgba(16, 185, 129, 0.12);
    color: #6EE7B7;
}

/* 进度条 */
body.night-mode .progress-bar {
    background: #1E293B;
}

/* 徽章（保留） */
body.night-mode .badge-basic        { background: #1E3A8A; color: #BFDBFE; }
body.night-mode .badge-growth       { background: #78350F; color: #FDE68A; }
body.night-mode .badge-contribution { background: #3730A3; color: #C7D2FE; }
body.night-mode .badge-daily        { background: #064E3B; color: #A7F3D0; }
body.night-mode .badge-weekly       { background: #78350F; color: #FDE68A; }
body.night-mode .badge-once         { background: #581C87; color: #E9D5FF; }

body.night-mode .task-status.active   { background: #064E3B; color: #A7F3D0; }
body.night-mode .task-status.disabled { background: #7F1D1D; color: #FECACA; }

/* 滚动条 */
body.night-mode::-webkit-scrollbar-thumb {
    background: rgba(77, 150, 255, 0.4);
}
body.night-mode::-webkit-scrollbar-thumb:hover {
    background: rgba(77, 150, 255, 0.7);
}

/* ============================================================
   响应式：平板（≤ 1024px）
   ============================================================ */
@media (max-width: 1024px) {
    body { padding: 0.75em; }
    .container { max-width: 100%; }
}

/* ============================================================
   响应式：手机（≤ 768px）
   ============================================================ */
@media (max-width: 768px) {
    body { padding: 0.5em; }
    .card {
        padding: 1.2em;
        border-radius: 1.5em;
    }
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
    .task-table th,
    .task-table td,
    .member-table th,
    .member-table td {
        padding: 0.5em 0.4em;
        font-size: 0.85em;
    }
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .status-filter {
        justify-content: center;
    }
    .form-actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }
    .form-actions .btn,
    .form-actions .btn-outline {
        width: 100%;
    }
}

/* ============================================================
   响应式：超小屏（≤ 480px）
   ============================================================ */
@media (max-width: 480px) {
    body { padding: 0.4em; }
    .card {
        padding: 1em;
        border-radius: 1.2em;
        margin-bottom: 1em;
    }
    .card h1 { font-size: 1.25em; }
    .card h2 { font-size: 1.1em; }
    .card h3 { font-size: 1em; }
    .btn {
        padding: 0.55em 1.1em;
        font-size: 0.85em;
        min-height: 40px;
    }
    .btn-icon {
        padding: 0.25em 0.6em;
        font-size: 0.72em;
    }
    .empty-tip,
    .empty-state {
        padding: 2em 1em;
    }
    .empty-tip .icon,
    .empty-state .icon {
        font-size: 2.5em;
    }
}

/* ============================================================
   打印
   ============================================================ */
@media print {
    body {
        background: #fff !important;
        color: #000 !important;
        padding: 0;
    }
    .card {
        box-shadow: none;
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }
    .btn, .btn-outline, .nav-item, .bottom-nav,
    .filter-bar, .form-actions {
        display: none !important;
    }
    body.night-mode,
    html.night-mode {
        background: #fff !important;
        color: #000 !important;
    }
    body.night-mode .card {
        background: #fff !important;
        color: #000 !important;
    }
}