/**
 * style.css - 學生系統共用樣式
 *
 * 深色主題，包含：登入表單、管理員面板、數學分析頁、上傳區、分析結果、LaTeX 公式樣式
 */
* {
  box-sizing: border-box;
}
body {
  font-family: "Segoe UI", "Microsoft JhengHei", sans-serif;
  margin: 0;
  padding: 1rem;
  background: #0e1117;
  color: #fafafa;
  min-height: 100vh;
}
a {
  color: #7dd3fc;
}
.container {
  max-width: 720px;
  margin: 0 auto;
}
.card {
  background: #1e293b;
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1rem;
}
h1, h2, h3 { margin-top: 0; }
input, button, select {
  font-size: 1rem;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  border: 1px solid #334155;
  background: #0f172a;
  color: #fafafa;
}
button {
  cursor: pointer;
  background: #3b82f6;
  border-color: #3b82f6;
  color: #fff;
}
button:hover { background: #2563eb; }
button.secondary {
  background: #475569;
  border-color: #475569;
}
button.secondary:hover { background: #64748b; }
.form-group {
  margin-bottom: 1rem;
}
.form-group label {
  display: block;
  margin-bottom: 0.25rem;
  color: #94a3b8;
}
.form-group input { width: 100%; max-width: 320px; }
.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.tabs button {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  background: #334155;
  border: 1px solid #475569;
}
.tabs button.active { background: #3b82f6; border-color: #3b82f6; }
table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid #334155;
}
th { color: #94a3b8; }
.upload-zone {
  border: 2px dashed #475569;
  border-radius: 8px;
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  margin-bottom: 1rem;
}
.upload-zone:hover { border-color: #7dd3fc; background: #1e293b; }
.upload-zone input[type="file"] { display: none; }
.preview-img {
  max-width: 100%;
  max-height: 400px;
  border-radius: 8px;
  margin: 1rem 0;
}
/* 分析結果／API 輸出：長字串與 JSON 自動換行、不溢出 */
.analysis-result {
  line-height: 1.8;
  padding: 1rem;
  background: #0f172a;
  border-radius: 8px;
  margin-top: 1rem;
  color: #fafafa;
  font-size: 1rem;
  max-width: 100%;
  white-space: pre-wrap;
  word-wrap: break-word;
  word-break: break-word;
  overflow-wrap: break-word;
  font-family: system-ui, -apple-system, "Segoe UI", "Microsoft JhengHei", "Helvetica Neue", Arial, sans-serif;
}
.analysis-result p {
  margin: 0.75em 0;
  line-height: 1.8;
  white-space: normal; /* 段落內正常換行 */
}
.analysis-result p:first-child {
  margin-top: 0;
}
.analysis-result p:last-child {
  margin-bottom: 0;
}
.analysis-result h3 {
  margin: 1.5em 0 1em 0;
  color: #7dd3fc;
  font-size: 1.2em;
  font-weight: 600;
  border-bottom: 1px solid #334155;
  padding-bottom: 0.5em;
  white-space: normal;
}
.analysis-result h3:first-child {
  margin-top: 0;
}
/* KaTeX 數學公式樣式 */
.analysis-result .katex {
  font-size: 1.05em;
  color: #fafafa;
  font-family: KaTeX_Main, "Times New Roman", serif;
  /* 確保公式不會被截斷 */
  white-space: normal;
  word-wrap: normal;
  overflow-wrap: normal;
}
.analysis-result .katex-display {
  margin: 1.2em 0;
  overflow-x: auto;
  overflow-y: hidden;
  text-align: center;
  white-space: normal;
  display: block;
}
.analysis-result .katex-display > .katex {
  display: inline-block;
  text-align: initial;
  width: 100%;
}
.analysis-result .katex-html {
  white-space: normal;
}
/* 確保數學公式在深色背景下清晰可見 */
.analysis-result .katex .base {
  color: #fafafa;
}
.analysis-result .katex .mord {
  color: #fafafa;
}
/* 向量符號樣式 */
.analysis-result .katex .accent {
  color: #fafafa;
}
.analysis-result .katex .accent > .vlist-t {
  color: #fafafa;
}
/* 確保公式內的文字正確顯示 */
.analysis-result .katex .text {
  color: #fafafa;
}
/* 訊息區：避免 JSON／長字串溢出，保留換行並自動斷行 */
.msg {
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  margin: 0.5rem 0;
  max-width: 100%;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: break-word;
}
.msg.error {
  background: #7f1d1d;
  color: #fecaca;
  font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, monospace;
  font-size: 0.9em;
}
.msg.success { background: #14532d; color: #bbf7d0; }
.msg.info { background: #1e3a5f; color: #bae6fd; }
.header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

/* PlanET Server 品牌標題：淡藍發光文字效果 */
.planet-brand {
  font-weight: 700;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: #a5f3fc;
  text-shadow:
    0 0 8px rgba(165, 243, 252, 0.9),
    0 0 16px rgba(165, 243, 252, 0.6),
    0 0 28px rgba(165, 243, 252, 0.4),
    0 0 40px rgba(125, 211, 252, 0.25);
  letter-spacing: 0.02em;
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0;
}
.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
}

/* 學生資料：班級內學生名單（可點選） */
.student-name-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.student-name-list button {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  background: #334155;
  border: 1px solid #475569;
}
.student-name-list button:hover {
  background: #475569;
  border-color: #64748b;
}

/* 建制課表：月曆 */
.schedule-calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  max-width: 360px;
  font-size: 0.9rem;
}
.schedule-calendar .cal-header {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  color: #94a3b8;
  font-weight: 600;
  text-align: center;
  padding: 0.25rem 0;
}
.schedule-calendar .cal-cell {
  min-height: 32px;
  padding: 0.25rem;
  text-align: center;
  border-radius: 4px;
  background: #334155;
  color: #cbd5e1;
}
.schedule-calendar .cal-cell.empty {
  background: transparent;
  visibility: hidden;
}
.schedule-calendar .cal-cell.has-class {
  background: #1e40af;
  color: #fff;
}
.schedule-editor .cal-cell:not(.empty) {
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.1s;
}
.schedule-editor .cal-cell.selected {
  background: #2563eb;
  color: #fff;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
  transform: scale(0.96);
}
.schedule-editor .cal-cell.selected:hover {
  background: #1d4ed8;
}
.schedule-editor .cal-cell:hover:not(.empty) {
  background: #475569;
}

/* 新增班級：現有班級列表 */
.existing-class-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.existing-class-list .existing-class-btn {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  background: #334155;
  border: 1px solid #475569;
  color: #e2e8f0;
  cursor: pointer;
}
.existing-class-list .existing-class-btn:hover {
  background: #475569;
}

/* 出席紀錄：班級按鈕、學生名單、五狀態按鈕 */
.attendance-class-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.attendance-class-list .attendance-class-btn {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  background: #334155;
  border: 1px solid #475569;
}
.attendance-class-list .attendance-class-btn:hover {
  background: #475569;
}
.attendance-table { margin-top: 0.5rem; }
.attendance-table th { color: #94a3b8; }
.attendance-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}
.attendance-status-btn {
  padding: 0.35rem 0.6rem;
  font-size: 0.85rem;
  border-radius: 4px;
  border: 1px solid #475569;
  background: #334155;
  color: #cbd5e1;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.1s;
}
.attendance-status-btn:hover {
  background: #475569;
}
.attendance-status-btn.pressed {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
  transform: scale(0.96);
}

/* 預約座位：月曆可點選 */
.reservation-calendar .cal-cell:not(.empty):not(.disabled) {
  cursor: pointer;
}
.reservation-calendar .cal-cell.selected {
  background: #2563eb;
  color: #fff;
}
.reservation-calendar .cal-cell:not(.empty):not(.disabled):hover {
  background: #475569;
}
#reservationCalendarContainer {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
}
#reservationCalendarContainer .schedule-calendar {
  margin-bottom: 0.5rem;
}
.form-group select {
  min-width: 120px;
}
button.primary {
  padding: 0.75rem 1.5rem;
  font-size: 1.1rem;
}

/* 時段與座位：左表單、右側已被預約列表 */
.reservation-form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: flex-start;
}
.reservation-form-left {
  flex: 0 1 280px;
}
.reservation-form-right {
  flex: 1 1 260px;
  min-width: 200px;
  padding: 0.75rem;
  background: #0f172a;
  border-radius: 8px;
  border: 1px solid #334155;
}
.reserved-slots-list {
  font-size: 0.9rem;
  color: #cbd5e1;
  max-height: 240px;
  overflow-y: auto;
}
.reserved-slots-list .slot-item {
  padding: 0.35rem 0;
  border-bottom: 1px solid #334155;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.reserved-slots-list .slot-item:last-child {
  border-bottom: none;
}
.reserved-slots-list .slot-time {
  color: #7dd3fc;
  min-width: 5.5em;
}
.reserved-slots-list .slot-seat {
  color: #94a3b8;
}
