/* ============================================
   每日作业签到打卡系统 - 样式表
   ============================================ */

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #e0e7ff;
    --purple: #8b5cf6;
    --success: #10b981;
    --success-light: #d1fae5;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --bg: #f1f5f9;
    --card: #ffffff;
    --text: #1e293b;
    --muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0,0,0,.06), 0 2px 4px -2px rgba(0,0,0,.04);
    --shadow-lg: 0 10px 25px -5px rgba(0,0,0,.1), 0 8px 10px -6px rgba(0,0,0,.05);
    --radius: 16px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-attachment: fixed;
    min-height: 100vh;
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
}
main.container { flex: 1; }

.hidden { display: none !important; }

/* ============ 顶部导航 ============ */
.header {
    background: rgba(255,255,255,.95);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon {
    width: 46px; height: 46px;
    background: linear-gradient(135deg, var(--primary), var(--purple));
    border-radius: 13px;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px;
    box-shadow: 0 4px 12px rgba(99,102,241,.35);
}
.brand-text h1 { font-size: 19px; font-weight: 700; letter-spacing: .5px; }
.brand-text p { font-size: 12px; color: var(--muted); }

.tabs {
    display: flex;
    background: var(--bg);
    border-radius: 12px;
    padding: 4px;
    gap: 4px;
}
.tab {
    border: none;
    background: transparent;
    padding: 9px 16px;
    border-radius: 9px;
    font-size: 14px;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    transition: all .2s;
    white-space: nowrap;
    font-family: inherit;
}
.tab:hover { color: var(--primary); }
.tab.active {
    background: var(--card);
    color: var(--primary);
    box-shadow: var(--shadow);
}
.tab-icon { margin-right: 4px; }

/* ============ 容器 ============ */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 26px 20px 50px;
}
.view { display: none; animation: fadeIn .3s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ============ 卡片 ============ */
.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-lg);
}
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}
.card-head h2 { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.emoji { font-size: 20px; }
.card-sub { font-size: 13px; color: var(--muted); }

/* ============ 表单元素 ============ */
.field { margin-bottom: 16px; flex: 1; min-width: 0; }
.field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 7px;
}
.optional { font-weight: 400; color: var(--muted); font-size: 12px; }
input, select, textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 15px;
    font-family: inherit;
    color: var(--text);
    background: #fff;
    transition: border-color .2s, box-shadow .2s;
    outline: none;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
select { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
textarea { resize: vertical; min-height: 80px; }
select:disabled { background-color: var(--bg); cursor: not-allowed; }

.identity-row { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.identity-row .btn { margin-bottom: 0; }

/* ============ 按钮 ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: none;
    border-radius: 10px;
    padding: 11px 22px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all .2s;
    white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--purple));
    color: #fff;
    box-shadow: 0 4px 12px rgba(99,102,241,.3);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(99,102,241,.4); }
.btn-block { width: 100%; }
.btn-lg { padding: 14px; font-size: 16px; }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-outline { background: #fff; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--bg); }
.icon-btn {
    width: 30px; height: 30px;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 8px;
    font-size: 18px;
    color: var(--muted);
    cursor: pointer;
    line-height: 1;
    transition: all .2s;
}
.icon-btn:hover { border-color: var(--primary); color: var(--primary); }

/* ============ 打卡 ============ */
.date-badge {
    background: var(--primary-light);
    color: var(--primary-dark);
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}
.greeting { color: var(--muted); margin-bottom: 20px; font-size: 15px; }
.greeting strong { color: var(--primary); }

.status-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 22px; }
.status-btn {
    border: 2px solid var(--border);
    background: #fff;
    border-radius: 14px;
    padding: 20px 10px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    transition: all .2s;
    font-family: inherit;
}
.status-btn:hover { border-color: var(--primary); transform: translateY(-2px); }
.status-btn.selected { border-color: var(--primary); background: var(--primary-light); box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
.status-btn[data-status="done"].selected { border-color: var(--success); background: var(--success-light); box-shadow: 0 0 0 3px rgba(16,185,129,.15); }
.status-btn[data-status="incomplete"].selected { border-color: var(--danger); background: var(--danger-light); box-shadow: 0 0 0 3px rgba(239,68,68,.15); }
.status-btn[data-status="leave"].selected { border-color: var(--warning); background: var(--warning-light); box-shadow: 0 0 0 3px rgba(245,158,11,.15); }
.status-icon {
    width: 42px; height: 42px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; font-weight: 700; color: #fff;
}
.status-icon.done { background: var(--success); }
.status-icon.incomplete { background: var(--danger); }
.status-icon.leave { background: var(--warning); }
.status-label { font-size: 14px; font-weight: 600; }
.char-count { text-align: right; font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ============ 统计盒 ============ */
.stat-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-box {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
}
.stat-icon {
    width: 52px; height: 52px;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 26px;
    flex-shrink: 0;
}
.stat-icon.purple { background: #f3e8ff; }
.stat-icon.green { background: var(--success-light); }
.stat-info { display: flex; flex-direction: column; }
.stat-info span { font-size: 13px; color: var(--muted); }
.stat-info strong { font-size: 30px; font-weight: 800; line-height: 1.2; color: var(--text); }
.stat-info small { font-size: 12px; color: var(--muted); display: inline; margin-left: 4px; }

/* ============ 日历 ============ */
.month-nav { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; }
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-weekday { text-align: center; font-size: 12px; color: var(--muted); font-weight: 600; padding: 4px 0; }
.cal-cell {
    aspect-ratio: 1;
    border-radius: 9px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    background: var(--bg);
    color: var(--text);
    position: relative;
    transition: transform .15s;
}
.cal-cell:hover { transform: scale(1.05); }
.cal-cell.empty { background: transparent; }
.cal-cell.done { background: var(--success); color: #fff; }
.cal-cell.incomplete { background: var(--danger); color: #fff; }
.cal-cell.leave { background: var(--warning); color: #fff; }
.cal-cell.today { box-shadow: 0 0 0 2px var(--primary); }
.cal-cell .cal-count { font-size: 10px; opacity: .9; }
.cal-cell.level-1 { background: #d1fae5; }
.cal-cell.level-2 { background: #6ee7b7; }
.cal-cell.level-3 { background: #10b981; color: #fff; }
.cal-cell.level-4 { background: #059669; color: #fff; }
.calendar-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 16px; font-size: 12px; color: var(--muted); }
.calendar-legend span { display: flex; align-items: center; gap: 5px; }
.legend-dot { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend-dot.done { background: var(--success); }
.legend-dot.incomplete { background: var(--danger); }
.legend-dot.leave { background: var(--warning); }
.legend-dot.none { background: var(--bg); border: 1px solid var(--border); }

/* ============ 后台 ============ */
.login-card { max-width: 420px; margin: 40px auto; text-align: center; padding: 40px 32px; }
.login-icon { font-size: 48px; margin-bottom: 12px; }
.login-card h2 { font-size: 22px; margin-bottom: 6px; }
.login-sub { color: var(--muted); font-size: 14px; margin-bottom: 28px; }
.login-card .field { text-align: left; }
.login-hint { margin-top: 20px; font-size: 12px; color: var(--muted); }
.login-hint code { background: var(--bg); padding: 2px 7px; border-radius: 5px; color: var(--primary); font-weight: 600; }

.dashboard-bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.dashboard-bar h2 { font-size: 20px; }
.dashboard-bar > div { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.small-select { width: auto; padding: 8px 32px 8px 12px; font-size: 13px; }

.overview-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.overview-card {
    background: var(--card);
    border-radius: 14px;
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow);
}
.ov-icon { width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.ov-icon.blue { background: #dbeafe; }
.ov-icon.green { background: var(--success-light); }
.ov-icon.purple { background: #f3e8ff; }
.ov-icon.orange { background: var(--warning-light); }
.ov-info { display: flex; flex-direction: column; }
.ov-info span { font-size: 12px; color: var(--muted); }
.ov-info strong { font-size: 24px; font-weight: 800; line-height: 1.2; }
.ov-info small { font-size: 11px; color: var(--muted); }

/* 小组进度条 */
.group-bars { display: flex; flex-direction: column; gap: 14px; }
.group-bar-row { display: flex; align-items: center; gap: 14px; }
.group-bar-name { width: 100px; font-size: 14px; font-weight: 600; flex-shrink: 0; }
.group-bar-track { flex: 1; height: 22px; background: var(--bg); border-radius: 11px; overflow: hidden; position: relative; }
.group-bar-fill { height: 100%; border-radius: 11px; transition: width .6s ease; display: flex; align-items: center; justify-content: flex-end; padding-right: 10px; }
.group-bar-fill.high { background: linear-gradient(90deg, #34d399, #10b981); }
.group-bar-fill.mid { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.group-bar-fill.low { background: linear-gradient(90deg, #f87171, #ef4444); }
.group-bar-fill span { font-size: 11px; color: #fff; font-weight: 700; }
.group-bar-stat { width: 80px; text-align: right; font-size: 13px; color: var(--muted); flex-shrink: 0; }

/* 表格 */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th { text-align: left; padding: 12px 14px; background: var(--bg); color: var(--muted); font-weight: 600; font-size: 13px; white-space: nowrap; }
.data-table th:first-child { border-radius: 8px 0 0 8px; }
.data-table th:last-child { border-radius: 0 8px 8px 0; }
.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f8fafc; }
.student-name { font-weight: 600; }
.badge { display: inline-block; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.done { background: var(--success-light); color: #047857; }
.badge.incomplete { background: var(--danger-light); color: #b91c1c; }
.badge.leave { background: var(--warning-light); color: #b45309; }
.badge.none { background: var(--bg); color: var(--muted); }
.note-cell { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 13px; }

/* ============ 提示 ============ */
.msg { min-height: 20px; margin-top: 12px; font-size: 13px; text-align: center; }
.msg.success { color: var(--success); }
.msg.error { color: var(--danger); }
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text);
    color: #fff;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: all .3s;
    z-index: 1000;
    pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

.footer { text-align: center; padding: 20px; color: rgba(255,255,255,.7); font-size: 12px; }

/* ============ 响应式 ============ */
@media (max-width: 768px) {
    .header-inner { flex-direction: column; align-items: stretch; gap: 12px; }
    .tabs { width: 100%; }
    .tab { flex: 1; padding: 10px 8px; font-size: 13px; }
    .container { padding: 16px 12px 40px; }
    .card { padding: 18px; border-radius: 14px; }
    .identity-row { flex-direction: column; align-items: stretch; }
    .identity-row .btn { width: 100%; }
    .status-grid { gap: 8px; }
    .status-btn { padding: 16px 6px; }
    .stat-row { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-box { padding: 14px; gap: 10px; }
    .stat-icon { width: 42px; height: 42px; font-size: 20px; }
    .stat-info strong { font-size: 24px; }
    .overview-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .overview-card { padding: 14px; }
    .ov-icon { width: 38px; height: 38px; font-size: 18px; }
    .ov-info strong { font-size: 20px; }
    .dashboard-bar { flex-direction: column; align-items: stretch; }
    .dashboard-bar > div { justify-content: space-between; }
    .group-bar-name { width: 74px; font-size: 12px; }
    .group-bar-stat { width: 60px; font-size: 11px; }
    .calendar { gap: 4px; }
    .cal-cell { font-size: 11px; border-radius: 6px; }
    .cal-cell .cal-count { font-size: 8px; }
    .calendar-legend { gap: 10px; font-size: 11px; }
}
@media (max-width: 400px) {
    .stat-row { grid-template-columns: 1fr; }
    .overview-grid { grid-template-columns: 1fr 1fr; }
    .tab-icon { display: none; }
}
