/* =====================================================
   教師管理系統 - teacher.css（重寫版）
   ===================================================== */

:root {
    --primary: #4a6baf;
    --primary-dark: #2c3e50;
    --bg: #f5f7fb;
    --text: #2c3e50;
    --border: #eef1f6;
}

* { box-sizing: border-box; }

body {
    font-family: 'Microsoft JhengHei', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    min-height: 100vh;
    padding-top: 60px;
}


/* =====================================================
   登入頁
   ===================================================== */
.login-page {
    background: linear-gradient(135deg, #4a6baf 0%, #2c3e50 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    margin: 0;
    padding-top: 0;
}

.login-container {
    width: 100%;
    max-width: 420px;
}

.login-card {
    background: white;
    border-radius: 20px;
    padding: 50px 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.5s ease;
}

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

.login-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, #4a6baf, #2c3e50);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 36px;
    box-shadow: 0 8px 20px rgba(74, 107, 175, 0.4);
}

.login-card h1 {
    text-align: center;
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.login-card p.subtitle {
    text-align: center;
    color: #7f8c8d;
    font-size: 14px;
    margin-bottom: 30px;
}

.form-label {
    font-weight: 600;
    color: var(--text);
    font-size: 14px;
    margin-bottom: 8px;
}

.form-control {
    border: 2px solid #e1e8ed;
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 15px;
    transition: all 0.3s;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(74, 107, 175, 0.15);
}

.btn-login {
    background: linear-gradient(135deg, #4a6baf, #2c3e50);
    border: none;
    border-radius: 10px;
    padding: 14px;
    font-weight: 600;
    font-size: 16px;
    color: white;
    width: 100%;
    transition: all 0.3s;
}

.btn-login:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(74, 107, 175, 0.4);
    color: white;
}

.btn-login:disabled { opacity: 0.7; }

.error-message {
    background-color: #fde8e8;
    color: #e53e3e;
    border: 1px solid #f8c6c6;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 20px;
    display: none;
    font-size: 14px;
}


/* =====================================================
   導覽列
   ===================================================== */
.teacher-navbar {
    background: linear-gradient(135deg, #4a6baf, #2c3e50);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    height: 60px;
}

.teacher-navbar .navbar-brand {
    font-weight: 700;
    color: white !important;
    font-size: 18px;
}


/* =====================================================
   側邊欄
   ===================================================== */
.teacher-sidebar {
    position: fixed;
    top: 60px;
    left: 0;
    bottom: 0;
    width: 240px;
    background: white;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    z-index: 1020;
    transition: transform 0.3s ease;
}

.sidebar-nav { padding: 20px 0; }

/* 主項目 */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
    font-size: 1rem;
    transition: background-color 0.15s, color 0.15s, border-color 0.15s;
    border-left: 3px solid transparent;
    cursor: pointer;
}

.sidebar-link i {
    font-size: 18px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

/* hover：淡灰底、不加左側藍條 */
.sidebar-link:hover {
    background-color: #f8fafc;
    color: var(--primary);
    border-left-color: transparent;
}

/* active：藍底、左側藍條、加粗 */
.sidebar-link.active {
    background-color: #e0e8ff;
    color: var(--primary);
    border-left-color: var(--primary);
    font-weight: 700;
}

/* focus：移除殘留底色 */
.sidebar-link:focus {
    outline: none;
    background-color: transparent;
}
.sidebar-link:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
    background-color: transparent;
}


/* =====================================================
   側邊欄下拉群組
   ===================================================== */
.sidebar-group {
    margin-bottom: 2px;
}

.sidebar-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
}

.sidebar-group .sidebar-caret {
    margin-left: auto;
    transition: transform 0.2s;
    font-size: 0.75rem;
    opacity: 0.7;
}

.sidebar-group.open .sidebar-caret {
    transform: rotate(180deg);
}


/* =====================================================
   側邊欄子項目（白底風格，與主項目一致）
   ===================================================== */
.sidebar-submenu {
    padding-left: 24px;
    margin-top: 2px;
}

.sidebar-sublink {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px 9px 56px;
    color: var(--text);
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    transition: background-color 0.15s, color 0.15s, border-color 0.15s;
    position: relative;
    border-left: 3px solid transparent;
}

/* 圓點 */
.sidebar-sublink::before {
    content: '';
    position: absolute;
    left: 32px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #cbd5e1;
    transition: background 0.15s, box-shadow 0.15s;
}

/* hover：淡灰底、圓點變藍 */
.sidebar-sublink:hover {
    background-color: #f8fafc;
    color: var(--primary);
}
.sidebar-sublink:hover::before {
    background: var(--primary);
}

/* active：藍底、藍圓點、加粗 */
.sidebar-sublink.active {
    background-color: #e0e8ff;
    color: var(--primary);
    font-weight: 700;
    border-left-color: var(--primary);
}
.sidebar-sublink.active::before {
    background: var(--primary);
    box-shadow: 0 0 0 3px rgba(74, 107, 175, 0.2);
}

/* focus */
.sidebar-sublink:focus {
    outline: none;
    background-color: transparent;
}
.sidebar-sublink:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
    background-color: transparent;
}


/* =====================================================
   主內容區
   ===================================================== */
.teacher-main {
    margin-left: 240px;
    min-height: calc(100vh - 60px);
}

.teacher-content {
    padding: 30px;
    max-width: 1400px;
}

.page-title {
    font-size: 26px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 25px;
    padding-bottom: 15px;
    border-bottom: 3px solid var(--primary);
    display: inline-block;
}

/* 側邊欄遮罩（手機版） */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1015;
}

.sidebar-backdrop.show { display: block; }

@media (max-width: 991.98px) {
    .teacher-sidebar { transform: translateX(-100%); }
    .teacher-sidebar.show { transform: translateX(0); }
    .teacher-main { margin-left: 0; }
    .teacher-content { padding: 20px 15px; }
}


/* =====================================================
   統計卡片
   ===================================================== */
.stat-card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: all 0.2s;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(74,107,175,0.15);
}

.stat-icon {
    width: 65px;
    height: 65px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 28px;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.stat-info { flex: 1; }

.stat-label {
    color: #8892a0;
    font-size: .9rem;
    margin-bottom: 6px;
}

.stat-value {
    font-size: 2.2rem;
    font-weight: 700;
    color: #2c3e50;
    line-height: 1;
}


/* =====================================================
   卡片
   ===================================================== */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.card-header {
    background: #f8f9fa;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    padding: 15px 20px;
    border-radius: 12px 12px 0 0 !important;
}


/* =====================================================
   最近更新列表
   ===================================================== */
.recent-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.recent-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    border-radius: 10px;
    background: #f8fafc;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    flex-wrap: wrap;
    gap: 10px;
}

.recent-item:hover {
    background: #f0f4ff;
    border-left-color: var(--primary);
}

.recent-item-title {
    font-weight: 500;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .92rem;
    flex-wrap: wrap;
}

.recent-item-date {
    font-size: .8rem;
    color: #8892a0;
    font-family: 'SF Mono', Consolas, monospace;
    white-space: nowrap;
}


/* =====================================================
   狀態徽章
   ===================================================== */
.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: .78rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-done    { background: #e6f7ee; color: #0a9950; }
.badge-partial { background: #fff4e6; color: #c2691a; }
.badge-todo    { background: #f3f5f8; color: #64748b; }


/* =====================================================
   進度表格
   ===================================================== */
.progress-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}

.progress-table th,
.progress-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.progress-table th {
    background: #f8fafc;
    font-weight: 700;
    color: #475569;
    font-size: .82rem;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.progress-table th.cell-class { text-align: center; width: 120px; }
.progress-table td.cell-class { text-align: center; }

.progress-table tr.section-row td {
    background: #f0f4ff;
    font-weight: 700;
    color: var(--primary);
    border-bottom: 2px solid #cfd8ff;
}

.progress-table tr:hover:not(.section-row) td {
    background: #fafbfd;
}

.progress-cell {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    min-width: 80px;
}

.progress-cell:hover {
    transform: scale(1.05);
    box-shadow: 0 3px 8px rgba(0,0,0,0.15);
}

.progress-cell.status-0 { background: #f3f5f8; color: #64748b; border-color: #e2e8f0; }
.progress-cell.status-1 { background: #fff4e6; color: #c2691a; border-color: #fde68a; }
.progress-cell.status-2 { background: #e6f7ee; color: #0a9950; border-color: #b7e4c7; }

.progress-cell .note-icon {
    font-size: .75rem;
    margin-left: 4px;
    opacity: 0.7;
}


/* =====================================================
   篩選列
   ===================================================== */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 15px;
    background: white;
    padding: 15px 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-bar label {
    font-weight: 600;
    color: #475569;
    font-size: .9rem;
    margin: 0;
}

.filter-bar select { width: 300px; }

.filter-bar input[type="date"] { max-width: 160px; }


/* =====================================================
   空狀態
   ===================================================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #8892a0;
}

.empty-state i {
    font-size: 3rem;
    opacity: 0.4;
    margin-bottom: 15px;
    display: block;
}


/* =====================================================
   學生卡片
   ===================================================== */
.student-card {
    background: #f8fafc;
    border: 1px solid #eef1f6;
    border-radius: 10px;
    padding: 15px 20px;
    text-align: left;
    transition: all 0.2s;
    cursor: pointer;
    color: #2c3e50;
}
.student-card:hover {
    background: #f0f4ff;
    border-color: #4a6baf;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74,107,175,0.15);
}
.student-grid .col-md-6 { display: flex; }


/* =====================================================
   主題卡片
   ===================================================== */
.topic-card {
    background: #f8fafc;
    border: 1px solid #eef1f6;
    border-radius: 10px;
    overflow: hidden;
    transition: all 0.2s;
}
.topic-card:hover {
    border-color: #4a6baf;
    box-shadow: 0 4px 12px rgba(74,107,175,0.1);
}
.topic-card-header {
    padding: 14px 18px;
    cursor: pointer;
    font-size: 0.95rem;
    background: white;
    transition: background 0.2s;
    user-select: none;
}
.topic-card-header:hover { background: #f0f4ff; }
.topic-card-header .bi-chevron-down {
    transition: transform 0.2s;
    color: #8892a0;
}
.topic-card-header[aria-expanded="true"] .bi-chevron-down {
    transform: rotate(180deg);
}
.topic-card-body {
    padding: 8px 18px 14px;
    background: #fafbfd;
}
.topic-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px dashed #e2e8f0;
    font-size: 0.88rem;
}
.topic-item:last-child { border-bottom: none; }
.topic-item-name { font-weight: 500; color: #334155; }
.topic-item-badges { display: flex; gap: 6px; }


/* =====================================================
   課程統計
   ===================================================== */
.stats-card {
    background: white;
    border: 1px solid #eef1f6;
    border-radius: 12px;
    padding: 18px;
    height: 100%;
    transition: all 0.2s;
}
.stats-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.06); }
.stats-card-title {
    font-size: 1rem;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 8px;
}
.stats-card-total {
    font-size: 0.85rem;
    color: #8892a0;
    margin-bottom: 14px;
}
.stats-row { display: flex; gap: 10px; }
.stats-btn {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 10px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    font-size: 0.9rem;
}
.stats-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.stats-btn i { font-size: 1.5rem; }
.stats-num { font-size: 1.4rem; font-weight: 700; line-height: 1; }
.stats-label { font-size: 0.75rem; opacity: 0.8; }
.stats-done    { background: #e6f7ee; color: #0a9950; border-color: #b7e4c7; }
.stats-partial { background: #fff4e6; color: #c2691a; border-color: #fde68a; }
.stats-todo    { background: #f3f5f8; color: #64748b; border-color: #e2e8f0; }

.student-list-item {
    background: #f8fafc;
    border: 1px solid #eef1f6;
    border-radius: 10px;
    padding: 14px 18px;
    text-align: left;
    transition: all 0.2s;
    cursor: pointer;
    color: #2c3e50;
}
.student-list-item:hover {
    background: #f0f4ff;
    border-color: #4a6baf;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74,107,175,0.15);
}


/* =====================================================
   課程統計：文章 / 單字 分開
   ===================================================== */
.stats-type-row {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px dashed #e2e8f0;
}
.stats-type-row:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}
.stats-type-label {
    font-size: .88rem;
    font-weight: 700;
    color: #475569;
    margin-bottom: 8px;
}
.stats-type-label i { color: #4a6baf; margin-right: 4px; }
.stats-type-label small { font-weight: 500; color: #8892a0; }
.stats-type-empty {
    padding: 10px 14px;
    background: #f8fafc;
    border-radius: 8px;
    color: #94a3b8;
    font-size: .85rem;
    text-align: center;
    margin-bottom: 10px;
}
.stats-type-empty i { margin-right: 6px; }


/* =====================================================
   班級學習總覽
   ===================================================== */
.overview-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    padding: 15px 20px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.overview-label {
    font-weight: 700;
    color: #2c3e50;
    margin: 0;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.overview-label i { color: #4a6baf; }
.overview-class-select {
    width: auto;
    min-width: 180px;
    border: 2px solid #e1e8ed;
    border-radius: 10px;
}
.overview-class-select:focus {
    border-color: #4a6baf;
    box-shadow: 0 0 0 4px rgba(74,107,175,0.15);
}
.overview-meta {
    color: #8892a0;
    font-size: .9rem;
    margin-left: auto;
}

/* 主題按鈕 */
.topic-buttons-wrap {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    margin-bottom: 20px;
    align-items: start;
}
.topic-btn {
    padding: 16px 18px;
    background: #f0f4ff;
    border: 2px solid #cfd8ff;
    border-radius: 10px;
    color: #4a6baf;
    font-weight: 600;
    font-size: .95rem;
    cursor: pointer;
    transition: all .15s;
    font-family: inherit;
    text-align: center;
    white-space: normal;
    word-wrap: break-word;
    word-break: break-word;
    line-height: 1.4;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.topic-btn:hover {
    background: #e0e8ff;
    border-color: #4a6baf;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74,107,175,0.2);
}
.topic-btn.active {
    background: linear-gradient(135deg, #4a6baf, #2c3e50);
    border-color: #2c3e50;
    color: #fff;
}


/* =====================================================
   學生卡片 Modal（4 欄）
   ===================================================== */
.student-cards-grid-modal {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    align-items: start;
}

.student-card-box {
    background: #fff;
    border: 1px solid #eef1f6;
    border-radius: 12px;
    padding: 16px 12px 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    transition: all .15s;
    height: auto;
    align-self: start;
    width: 100%;
}
.student-card-box:hover {
    box-shadow: 0 6px 16px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.student-card-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: #2c3e50;
    text-align: center;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f1f5f9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.student-card-cells {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.student-cell {
    padding: 10px 6px;
    border-radius: 10px;
    border: 2px solid;
    cursor: pointer;
    transition: all .15s;
    text-align: center;
    min-width: 0;
    overflow: hidden;
}
.student-cell[data-action="none"] {
    cursor: default;
    opacity: 0.65;
}

.cell-label {
    font-size: .7rem;
    font-weight: 600;
    margin-bottom: 5px;
    white-space: nowrap;
}
.cell-value {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 2px;
}
.cell-num { font-weight: 800; font-size: 1.1rem; }
.cell-unit { font-size: .75rem; font-weight: 600; opacity: 0.9; }

.student-cell.cell-listening {
    background: #e6f7ee;
    border-color: #4cc9a4;
    color: #0a9950;
}
.student-cell.cell-listening[data-action="listening"]:hover {
    background: #4cc9a4;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76,201,164,0.35);
}
.student-cell.cell-listening[data-action="none"] {
    background: #f8fafc;
    border-color: #e2e8f0;
    color: #94a3b8;
}

.student-cell.cell-reading {
    background: #eef2ff;
    border-color: #cfd8ff;
    color: #4a6baf;
}
.student-cell.cell-reading[data-action="reading"]:hover {
    background: #4a6baf;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74,107,175,0.35);
}
.student-cell.cell-reading[data-action="none"] {
    background: #f8fafc;
    border-color: #e2e8f0;
    color: #94a3b8;
}


/* =====================================================
   Modal 分頁
   ===================================================== */
.modal-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    padding: 12px 16px;
    background: #f8fafc;
    border-radius: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}
.pagination-info {
    color: #64748b;
    font-size: .9rem;
}
.pagination-btns {
    display: flex;
    gap: 5px;
    align-items: center;
}
.page-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    background: #fff;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    color: #475569;
    font-family: inherit;
    font-size: .9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all .15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.page-btn:hover:not(:disabled):not(.active) {
    background: #f0f4ff;
    border-color: #4a6baf;
    color: #4a6baf;
}
.page-btn.active {
    background: linear-gradient(135deg, #4a6baf, #2c3e50);
    border-color: #2c3e50;
    color: #fff;
}
.page-btn:disabled {
    opacity: .4;
    cursor: not-allowed;
}
.page-ellipsis {
    color: #94a3b8;
    padding: 0 6px;
    font-weight: 700;
}


/* =====================================================
   排序表頭
   ===================================================== */
.sortable-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: all .15s;
    white-space: nowrap;
}
.sortable-table th.sortable:hover {
    background: #e8efff;
    color: #4a6baf;
}
.sort-icon {
    font-size: .75rem;
    opacity: 0.5;
    margin-left: 4px;
}
.sort-icon.active {
    opacity: 1;
    color: #4a6baf;
}


/* =====================================================
   統計區塊（Modal 上方）
   ===================================================== */
.stats-block {
    background: #f8fafc;
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 15px;
}
.stats-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    gap: 10px;
}
.stats-block-title {
    font-size: .92rem;
    font-weight: 700;
    color: #334155;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}
.stats-block-title i { color: #4a6baf; }

.sort-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    background: #fff;
    border: 1.5px solid #cbd5e1;
    border-radius: 16px;
    color: #475569;
    font-size: .78rem;
    font-weight: 700;
    cursor: pointer;
    transition: all .15s;
    font-family: inherit;
    white-space: nowrap;
}
.sort-toggle-btn:hover {
    border-color: #4a6baf;
    color: #4a6baf;
    background: #f0f4ff;
}
.sort-toggle-btn[data-dir="asc"] {
    border-color: #4a6baf;
    color: #4a6baf;
    background: #f0f4ff;
}

.stats-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.stat-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 78px;
    padding: 8px 12px;
    background: #fff;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
    transition: all .15s;
    font-family: inherit;
    color: #475569;
}
.stat-chip:hover {
    border-color: #4a6baf;
    background: #f0f4ff;
    transform: translateY(-1px);
}
.stat-chip.active {
    background: linear-gradient(135deg, #4a6baf, #2c3e50);
    border-color: #2c3e50;
    color: #fff;
    box-shadow: 0 4px 12px rgba(74,107,175,0.35);
}
.chip-label {
    font-size: .82rem;
    font-weight: 700;
    line-height: 1.2;
}
.chip-count {
    font-size: .72rem;
    opacity: 0.85;
    font-weight: 600;
}

.filter-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #eef2ff;
    border-radius: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    border-left: 4px solid #4a6baf;
}
.filter-status-label {
    font-size: .82rem;
    font-weight: 700;
    color: #4a6baf;
}
.filter-tag {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    background: #fff;
    border: 1.5px solid #cfd8ff;
    border-radius: 14px;
    font-size: .78rem;
    font-weight: 600;
    color: #4a6baf;
}
.filter-clear {
    margin-left: auto;
    padding: 4px 12px;
    background: transparent;
    border: 1.5px solid #fca5a5;
    border-radius: 14px;
    color: #dc2626;
    font-size: .78rem;
    font-weight: 700;
    cursor: pointer;
    transition: all .15s;
    font-family: inherit;
}
.filter-clear:hover { background: #fef2f2; }


/* =====================================================
   學習預警
   ===================================================== */
.warning-settings {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    margin-bottom: 20px;
    overflow: hidden;
    border-left: 4px solid #4a6baf;
}
.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}
.settings-header h6 {
    margin: 0;
    font-weight: 700;
    color: #334155;
    display: flex;
    align-items: center;
    gap: 8px;
}
.settings-header h6 i { color: #4a6baf; }
.settings-body {
    padding: 18px 20px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px 30px;
}
.setting-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.setting-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .9rem;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    min-width: 130px;
    margin: 0;
}
.setting-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}
.setting-input {
    max-width: 80px;
    text-align: center;
    font-weight: 700;
    color: #4a6baf;
}
.setting-unit {
    font-size: .85rem;
    color: #64748b;
    font-weight: 600;
}

.warning-summary {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}
.summary-item {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 18px 24px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    border-left: 4px solid;
}
.summary-item i { font-size: 2rem; }
.summary-item.high { border-color: #ef4444; }
.summary-item.high i { color: #ef4444; }
.summary-item.mid { border-color: #f59e0b; }
.summary-item.mid i { color: #f59e0b; }
.summary-num {
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1;
    color: #1e293b;
}
.summary-label {
    font-size: .85rem;
    color: #64748b;
    margin-top: 4px;
}

.warning-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 15px;
}

.warning-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    overflow: hidden;
    border-left: 5px solid;
    transition: all .15s;
}
.warning-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.1);
}
.warning-card.high { border-color: #ef4444; }
.warning-card.mid  { border-color: #f59e0b; }

.warning-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid #f1f5f9;
}
.warning-card-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}
.warning-card.high .warning-card-avatar { background: #fee2e2; color: #dc2626; }
.warning-card.mid .warning-card-avatar  { background: #fef3c7; color: #d97706; }
.warning-card-info { flex: 1; min-width: 0; }
.warning-card-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1e293b;
}
.warning-card-id {
    font-size: .78rem;
    color: #94a3b8;
    font-family: 'SF Mono', Consolas, monospace;
}
.warning-card-level {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: .78rem;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
}
.warning-card-level.high { background: #fee2e2; color: #b91c1c; }
.warning-card-level.mid  { background: #fef3c7; color: #92400e; }

.warning-card-reasons {
    padding: 12px 18px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.warning-reason {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: #f8fafc;
    border-radius: 8px;
    font-size: .85rem;
}
.warning-reason i {
    font-size: .5rem;
    color: #94a3b8;
    flex-shrink: 0;
}
.reason-label {
    font-weight: 600;
    color: #334155;
    flex: 1;
}
.reason-detail {
    font-size: .75rem;
    color: #94a3b8;
    white-space: nowrap;
}

.all-clear {
    text-align: center;
    padding: 80px 20px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.all-clear i {
    font-size: 4rem;
    color: #10b981;
    display: block;
    margin-bottom: 20px;
}
.all-clear h5 {
    color: #065f46;
    font-weight: 700;
    font-size: 1.4rem;
}
.all-clear p {
    color: #64748b;
    margin: 0;
}


/* =====================================================
   響應式
   ===================================================== */
@media (max-width: 1199.98px) {
    .topic-buttons-wrap { grid-template-columns: repeat(3, 1fr); }
    .student-cards-grid-modal { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 991.98px) {
    .teacher-sidebar { transform: translateX(-100%); }
    .teacher-sidebar.show { transform: translateX(0); }
    .teacher-main { margin-left: 0; }
    .teacher-content { padding: 20px 15px; }
}

@media (max-width: 767.98px) {
    .topic-buttons-wrap { grid-template-columns: repeat(2, 1fr); }
    .student-cards-grid-modal { grid-template-columns: repeat(2, 1fr); }
    .overview-meta { margin-left: 0; width: 100%; }
    .settings-body { grid-template-columns: 1fr; }
    .warning-cards-grid { grid-template-columns: 1fr; }
    .warning-summary { flex-direction: column; }
}