
:root {
  /* ===== โทนกรมท่า-ทอง (navy & gold) ===== */
  --navy-900: #0A1F38;   /* sidebar พื้นหลังเข้มสุด */
  --navy-800: #123A5E;   /* หัวการ์ด / แถบเน้น */
  --navy-700: #1D4E7A;   /* sidebar hover / active */
  --navy-600: #2A6694;   /* ปุ่มรอง */
  --primary: #123A5E;
  --primary-light: #E7EEF5;
  --primary-mid: #1D4E7A;
  --primary-dark: #0A1F38;
  --gold: #C49A45;
  --gold-dark: #9C7A33;
  --accent: #C49A45;
  --accent-light: #F6EFDE;
  --danger: #A32D2D;
  --danger-light: #FCEBEB;
  --info: #185FA5;
  --info-light: #E6F1FB;
  --success: #1F8A53;
  --success-light: #E6F6EC;
  --text: #1C2733;
  --text-muted: #7D8A9A;
  --text-on-dark: #E9EEF4;
  --text-on-dark-muted: #90A3BA;
  --border: #E6E8EC;
  --bg: #F4F6F9;
}
* { font-family: 'Sarabun', sans-serif; }
body { background: var(--bg); color: var(--text); }

/* ===== Buttons ===== */
.btn-primary { background: var(--navy-800) !important; border-color: var(--navy-800) !important; }
.btn-primary:hover { background: var(--navy-900) !important; border-color: var(--navy-900) !important; }
.btn-outline-primary { color: var(--navy-800) !important; border-color: var(--navy-800) !important; }
.btn-outline-primary:hover { background: var(--navy-800) !important; color: #fff !important; }
.btn-gold, .btn-accent {
  background: var(--gold) !important; border-color: var(--gold) !important; color: #fff !important;
}
.btn-gold:hover, .btn-accent:hover { background: var(--gold-dark) !important; border-color: var(--gold-dark) !important; }

/* ===== Cards ===== */
.card { border-radius: 14px; border: 1px solid var(--border); box-shadow: 0 1px 3px rgba(10,31,56,0.04); }

/* ===== Status badges ===== */
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.status-waiting  { background: var(--accent-light); color: #7A5A1F; border: 1px solid var(--gold); }
.status-done     { background: var(--success-light); color: #1C5B38; border: 1px solid #6FB98C; }
.status-revision { background: var(--info-light); color: #0C447C; border: 1px solid #85B7EB; }
.status-nosend   { background: var(--danger-light); color: var(--danger); border: 1px solid #F09595; }
.status-closed   { background: #EEF0F3; color: #52606D; border: 1px solid #C7CDD6; }
.status-resubmit { background: var(--info-light); color: #042C53; border: 1px solid #B5D4F4; }

/* ===== Sidebar ===== */
#appSidebar {
  background: var(--navy-900);
  min-height: 100vh;
  position: sticky;
  top: 0;
  align-self: flex-start;
  max-height: 100vh;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 10px;
}
.sidebar-brand-badge {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--gold), var(--gold-dark));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(196,154,69,0.35);
}
.sidebar-brand-text { line-height: 1.25; }
.sidebar-brand-text .b-title { color: #fff; font-weight: 700; font-size: 15px; }
.sidebar-brand-text .b-sub { color: var(--text-on-dark-muted); font-size: 12px; }
.sidebar-group-label {
  color: var(--text-on-dark-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 14px 16px 6px;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin: 2px 10px;
  border-radius: 9px;
  color: var(--text-on-dark-muted);
  text-decoration: none;
  font-size: 14px;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}
.sidebar-link:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
}
.sidebar-link.active {
  background: var(--navy-700);
  color: #fff;
  border-left: 3px solid var(--gold);
  font-weight: 600;
}
.sidebar-link i { font-size: 18px; width: 22px; text-align: center; }
.sidebar-link.active i { color: var(--gold); }

/* ===== Top bar ===== */
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.topbar-breadcrumb { color: var(--text-muted); font-size: 14px; }
.topbar-breadcrumb a { color: var(--navy-800); text-decoration: none; font-weight: 600; }

/* ปีการศึกษา / ภาคเรียน selector ที่ใช้ร่วมกันทุกหน้า */
.period-selector {
  display: flex; align-items: center; gap: 8px;
  background: var(--primary-light);
  border: 1px solid #D7E2EE;
  border-radius: 10px;
  padding: 6px 10px;
}
.period-selector i { color: var(--navy-800); font-size: 16px; }
.period-selector select {
  border: none; background: transparent; color: var(--navy-900);
  font-family: 'Sarabun', sans-serif; font-size: 13px; font-weight: 600;
  outline: none; cursor: pointer;
}

/* ===== Bottom Nav (มือถือ) ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--navy-900);
  border-top: 1px solid rgba(255,255,255,0.08);
  z-index: 1000;
  height: 58px;
  padding: 0;
}
.bottom-nav > div {
  display: flex;
  height: 100%;
}
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--text-on-dark-muted);
  font-size: 10px;
  gap: 2px;
  border: none;
  background: none;
  cursor: pointer;
  transition: color 0.15s;
}
.bottom-nav-item.active, .bottom-nav-item:hover { color: var(--gold); }
.bottom-nav-item i { font-size: 22px; }

/* ===== Stat cards (สไตล์ไอคอนวงกลมพาสเทล) ===== */
.stat-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.stat-icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.stat-icon.i-blue   { background: #E6F0FB; color: #2F6FB0; }
.stat-icon.i-gold   { background: var(--accent-light); color: var(--gold-dark); }
.stat-icon.i-green  { background: var(--success-light); color: #2E9E5B; }
.stat-icon.i-red    { background: var(--danger-light); color: var(--danger); }
.stat-icon.i-purple { background: #EFE7FB; color: #7A57C9; }
.stat-icon.i-navy   { background: var(--primary-light); color: var(--navy-800); }
.stat-number { font-size: 24px; font-weight: 700; line-height: 1.1; color: var(--navy-900); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ===== Assignment Card ===== */
.assign-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 10px;
  transition: box-shadow 0.15s;
}
.assign-card:hover { box-shadow: 0 2px 12px rgba(10,31,56,0.08); }
.assign-card.overdue { border-left: 3px solid var(--danger); }
.assign-card.pending { border-left: 3px solid var(--gold); }
.assign-card.done { border-left: 3px solid var(--success); }

/* ===== Comment Chat ===== */
.comment-bubble {
  max-width: 85%;
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 8px;
  position: relative;
}
.comment-teacher {
  background: var(--primary-light);
  border-bottom-left-radius: 2px;
  align-self: flex-start;
  margin-right: auto;
}
.comment-student {
  background: var(--accent-light);
  border-bottom-right-radius: 2px;
  align-self: flex-end;
  margin-left: auto;
}
.comment-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.comment-text { font-size: 14px; }

/* Mobile adjustments — เดิมมี #mainContent{display:none} ที่ทำให้ต้อง render เนื้อหาซ้ำ 2 ชุด
   (ต้นเหตุที่ฟอร์ม/คอมเมนท์บนมือถือกดส่งไม่ได้ เพราะ id ซ้ำกันทำให้ JS อ่านค่าจากชุดที่มองไม่เห็น)
   ตอนนี้ #mainContent เป็นคอนเทนเนอร์เดียวที่ใช้ทั้งมือถือและเดสก์ท็อป จึงไม่ต้องซ่อน/ซ้ำอีกต่อไป */
@media (max-width: 991px) {
  /* กันไม่ให้ปุ่ม/ฟอร์มท้ายเนื้อหาถูก bottom-nav แบบ fixed (สูง 58px) บังจนกดไม่โดน */
  #mainContent { padding-bottom: 86px !important; }
}
@media (min-width: 992px) {
  .bottom-nav { display: none !important; }
}
/* Loading overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,31,56,0.88);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  color: #fff;
  gap: 16px;
}
.spinner-grow { width: 3rem; height: 3rem; color: var(--gold) !important; }
/* Table */
.table-hover tbody tr:hover { background: var(--primary-light); }
.table thead th {
  background: var(--primary-light);
  color: var(--navy-900);
  font-size: 13px;
  font-weight: 600;
  border-bottom: none;
}

/* ============================================================
   เพิ่มเติมสำหรับตารางสรุปการตรวจงาน (ข้อ 2.1) — คอลัมน์ชื่อนักศึกษาแบบ sticky
   ============================================================ */
.table-responsive table td[style*="sticky"],
.table-responsive table th[style*="sticky"] {
  box-shadow: 2px 0 4px rgba(0,0,0,0.06);
}

/* ===== Roster cards (รายชื่อนักศึกษาแบบคลิกเข้าไปดูรายบุคคล) ===== */
.roster-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 12px;
}
.roster-card:hover {
  border-color: var(--navy-700);
  box-shadow: 0 2px 10px rgba(10,31,56,0.08);
  transform: translateY(-1px);
}
.roster-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--navy-800);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
  flex-shrink: 0;
}

/* ===== Period tabs (แท็บเลือกปี/ภาคเรียนในหน้ารายการ) ===== */
.period-tabs {
  display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px;
}
.period-tab {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
}
.period-tab:hover { border-color: var(--navy-700); color: var(--navy-800); }
.period-tab.active {
  background: var(--navy-800);
  border-color: var(--navy-800);
  color: #fff;
  font-weight: 600;
}

/* ปรับปรุงความ responsive บนมือถือ (คำขอข้อ "responsive มากขึ้น") */
@media (max-width: 575px) {
  .card { border-radius: 10px; }
  .stat-number { font-size: 20px; }
  .stat-icon { width: 40px; height: 40px; font-size: 18px; }
  h4.fw-bold { font-size: 1.15rem; }
  h5.fw-bold { font-size: 1.05rem; }
  .modal-dialog { margin: 0.5rem; }
  .table-responsive table { font-size: 12px; }
  .assign-card { padding: 12px; }
  .topbar { padding: 10px 14px; }
}
