/* ==========================================================================
   元件與微互動樣式 (Components & Micro-interactions) - 無斷行優化版
   ========================================================================== */

/* 全域文字防斷行核心規則 (人名、週次、標籤嚴禁換行) */
.student-name,
.student-card,
.student-card-info,
.student-clickable,
.duty-hero-chip,
.projector-student-tag,
.seat-badge,
.badge,
.timeline-week,
.week-title,
.pill-btn,
.nav-tab,
.tab-button,
.master-table th,
.master-table td,
.master-table td strong,
.inspection-table th,
.inspection-table td,
.poster-box-header,
.duty-hero-title {
  white-space: nowrap !important;
  word-break: keep-all !important;
}

/* 按鈕系統 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.5rem 0.95rem;
  font-size: 0.875rem;
  font-weight: 700;
  font-family: inherit;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  min-height: 38px;
  user-select: none;
  white-space: nowrap;
}

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

.btn-primary {
  background-color: var(--color-primary);
  color: var(--color-on-primary);
  box-shadow: 0 1px 2px rgba(27, 77, 62, 0.2);
}
.btn-primary:hover {
  background-color: var(--color-primary-hover);
  box-shadow: 0 4px 10px rgba(27, 77, 62, 0.25);
}

.btn-outline {
  background-color: var(--color-bg-surface);
  border-color: var(--border-color);
  color: var(--text-secondary);
}
.btn-outline:hover {
  background-color: var(--color-bg-surface-elevated);
  color: var(--text-primary);
  border-color: var(--border-color-dark);
}

.btn-success {
  background-color: var(--color-success);
  color: white;
}

.btn-danger {
  background-color: var(--color-danger);
  color: white;
}

.btn-sm {
  padding: 0.3rem 0.65rem;
  font-size: 0.8125rem;
  min-height: 32px;
}

.btn-lg {
  padding: 0.65rem 1.35rem;
  font-size: 0.95rem;
  border-radius: var(--radius-lg);
  min-height: 44px;
}

.btn-icon {
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: var(--radius-md);
}

/* 狀態卡片與面板 */
.card {
  background: var(--color-bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-5);
  transition: border-color var(--transition-fast);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-color);
}

.card-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  white-space: nowrap;
}

/* 徽章標籤 (Badges) */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  letter-spacing: 0.2px;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-group-a {
  background: var(--color-group-a-light);
  color: var(--color-group-a);
  border: 1px solid var(--color-group-a-border);
}

.badge-group-b {
  background: var(--color-group-b-light);
  color: var(--color-group-b);
  border: 1px solid var(--color-group-b-border);
}

.badge-duty {
  background: var(--color-duty-light);
  color: var(--color-duty);
  border: 1px solid var(--color-duty-border);
}

.badge-officer {
  background: var(--color-officer-light);
  color: var(--color-officer);
  border: 1px solid var(--color-officer-border);
}

.badge-override {
  background: #fef08a;
  color: #854d0e;
  border: 1px solid #facc15;
}

.badge-count {
  background: var(--color-bg-surface-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

/* 搜尋列 */
.search-container {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.35rem 0.75rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-container:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(27, 77, 62, 0.2);
}

.search-input {
  border: none;
  outline: none;
  font-size: 0.875rem;
  width: 170px;
  font-family: inherit;
  color: var(--text-primary);
}

/* 學生卡片 (Draggable Student Card) - 嚴禁斷行 */
.student-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.45rem 0.65rem;
  margin-bottom: var(--space-2);
  box-shadow: var(--shadow-sm);
  cursor: grab;
  user-select: none;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
  white-space: nowrap;
}

.student-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-primary-border);
}

.student-card:active {
  cursor: grabbing;
}

.student-card.dragging {
  opacity: 0.4;
  transform: scale(0.95);
}

.student-card-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
}

.seat-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  font-size: 0.75rem;
  font-weight: 800;
  background: var(--color-bg-surface-elevated);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  white-space: nowrap;
  flex-shrink: 0;
}

.student-name {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text-primary);
  cursor: pointer;
  transition: color var(--transition-fast);
  white-space: nowrap;
}

.student-name:hover {
  color: var(--color-primary);
  text-decoration: underline;
}

/* 待指派學生池 (Pool) */
.student-pool-container {
  position: sticky;
  top: 1rem;
  background: var(--color-bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-card);
  max-height: calc(100vh - 2rem);
  display: flex;
  flex-direction: column;
}

.student-pool-list {
  flex: 1;
  overflow-y: auto;
  min-height: 240px;
  padding: var(--space-2);
  border-radius: var(--radius-md);
  background: var(--color-bg-surface-elevated);
  border: 2px dashed var(--border-color);
  transition: all var(--transition-fast);
}

.student-pool-list.drag-over {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
}

/* 打掃工作卡片與投放區 (Job Board) */
.job-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: var(--space-4);
}

.job-card {
  background: var(--color-bg-surface);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all var(--transition-fast);
}

.job-card.is-full {
  border-color: #86efac;
}

.job-card-header {
  padding: var(--space-3) var(--space-4);
  background: var(--color-bg-surface-elevated);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.job-name {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-primary);
  white-space: nowrap;
}

.job-capacity {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
}

.job-dropzone {
  padding: var(--space-3);
  min-height: 120px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  background: var(--color-bg-surface);
  transition: background var(--transition-fast);
}

.job-dropzone.drag-over {
  background: var(--color-primary-light);
  outline: 2px dashed var(--color-primary);
  outline-offset: -4px;
}

.dropzone-empty-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 80px;
  font-size: 0.8125rem;
  color: var(--text-muted);
  border: 1px dashed var(--border-color-dark);
  border-radius: var(--radius-sm);
  text-align: center;
  padding: var(--space-2);
  white-space: nowrap;
}

/* ==========================================================================
   本週投影看板專用樣式 (Projector View)
   ========================================================================== */

.projector-container {
  background: var(--color-bg-surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-color);
  padding: var(--space-6);
  box-shadow: var(--shadow-card);
}

.projector-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-4);
  border-bottom: 2px solid var(--border-color);
}

.week-display {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  white-space: nowrap;
}

.week-title {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  white-space: nowrap;
}

.duty-hero-card {
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  border: 2px solid #fde68a;
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-6);
  margin-bottom: var(--space-5);
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
}

.duty-hero-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #92400e;
  margin-bottom: 0.25rem;
  white-space: nowrap;
}

.duty-hero-list {
  display: flex;
  gap: var(--space-3);
  flex-wrap: nowrap;
}

.duty-hero-chip {
  background: white;
  border: 1.5px solid #f59e0b;
  padding: 0.45rem 1rem;
  border-radius: var(--radius-full);
  font-size: 1.1rem;
  font-weight: 800;
  color: #b45309;
  box-shadow: var(--shadow-sm);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  white-space: nowrap;
  flex-shrink: 0;
}

.duty-hero-chip:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.projector-job-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-4);
}

.projector-job-card {
  background: var(--color-bg-surface-elevated);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
}

.projector-job-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
  white-space: nowrap;
}

.projector-job-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-3);
}

.projector-job-students {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: auto;
}

.projector-student-tag {
  background: white;
  border: 1px solid var(--border-color-dark);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.projector-student-tag:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  transform: translateY(-1px);
}

/* ==========================================================================
   全學期總表樣式 (Master Table) - 嚴禁斷行規範
   ========================================================================== */

.table-container {
  background: var(--color-bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  box-shadow: var(--shadow-card);
}

.master-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

.master-table th {
  background: var(--color-bg-surface-elevated);
  padding: var(--space-3) var(--space-4);
  font-weight: 800;
  color: var(--text-primary);
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap !important;
}

.master-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
  white-space: nowrap !important;
}

.master-table tbody tr:hover {
  background: var(--color-bg-surface-elevated);
}

.master-table tr.segment-start-row td {
  border-top: 2px solid var(--color-primary-border);
}

.highlight-match {
  background: #fef08a !important;
  color: #854d0e !important;
  font-weight: 800 !important;
  padding: 0 3px;
  border-radius: 3px;
}

/* ==========================================================================
   公佈欄張貼海報 (Poster View)
   ========================================================================== */

.poster-container {
  background: white;
  border: 2px solid var(--text-primary);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  box-shadow: var(--shadow-card);
}

.poster-header {
  text-align: center;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 2px solid var(--text-primary);
}

.poster-title {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--text-primary);
  white-space: nowrap;
}

.poster-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 600;
  white-space: nowrap;
}

.poster-grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
  margin-bottom: var(--space-5);
}

.poster-box {
  border: 1.5px solid #64748b;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.poster-box-header {
  background: #f1f5f9;
  padding: var(--space-2) var(--space-3);
  font-weight: 800;
  font-size: 0.95rem;
  border-bottom: 1.5px solid #64748b;
  white-space: nowrap;
}

.poster-box-body {
  padding: var(--space-2);
}

/* ==========================================================================
   衛生股長檢核表 (Inspection Table)
   ========================================================================== */

.inspection-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.inspection-table th, .inspection-table td {
  border: 1px solid #cbd5e1;
  padding: var(--space-2);
  text-align: center;
  white-space: nowrap;
}

.inspection-table th {
  background: #f1f5f9;
  font-weight: 700;
}

.inspection-checkbox-cell {
  width: 55px;
  height: 36px;
}

/* ==========================================================================
   個人任務時間軸 (Student Timeline Modal)
   ========================================================================== */

.timeline-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-height: 480px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.timeline-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--color-bg-surface-elevated);
  border-radius: var(--radius-md);
  border-left: 4px solid var(--border-color);
}

.timeline-row.cleaning {
  border-left-color: var(--color-primary);
  background: var(--color-primary-light);
}

.timeline-row.duty {
  border-left-color: var(--color-duty);
  background: var(--color-duty-light);
}

.timeline-row.rest {
  border-left-color: var(--text-muted);
}

.timeline-week {
  font-weight: 800;
  font-size: 0.95rem;
  min-width: 90px;
  width: 90px;
  flex-shrink: 0;
  white-space: nowrap;
}

.timeline-task {
  font-weight: 700;
  font-size: 0.95rem;
  flex: 1;
}

.timeline-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

/* 表單與輸入框 */
.form-group {
  margin-bottom: var(--space-4);
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
  white-space: nowrap;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-family: inherit;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--color-bg-surface);
  color: var(--text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(27, 77, 62, 0.2);
}

/* 對話框模態視窗 (Modal) */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(6px);
  z-index: 900;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
}

.modal-backdrop.active {
  display: flex;
}

.modal-box {
  background: var(--color-bg-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 650px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border-color);
  animation: modalIn 0.22s var(--ease-spring);
}

@keyframes modalIn {
  from { transform: scale(0.95) translateY(12px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 800;
  white-space: nowrap;
}

.modal-body {
  padding: var(--space-5);
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border-color);
  background: var(--color-bg-surface-elevated);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
}

/* 浮動提示 Toast */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: #0f172a;
  color: white;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.1);
  animation: slideIn 0.22s var(--ease-spring);
  white-space: nowrap;
}

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

/* ==========================================================================
   全學期日曆圈選矩陣 (Interactive Calendar Matrix)
   ========================================================================== */

.calendar-matrix-card {
  background: var(--color-bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-5);
  box-shadow: var(--shadow-card);
}

.brush-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-color);
  margin-bottom: var(--space-4);
}

.brush-tools {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.brush-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.85rem;
  font-size: 0.8125rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--border-color);
  background: var(--color-bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.brush-btn:hover {
  transform: translateY(-1px);
}

.brush-btn.active.brush-exam {
  background: #fef2f2;
  border-color: #ef4444;
  color: #b91c1c;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

.brush-btn.active.brush-activity {
  background: #f0fdf4;
  border-color: #22c55e;
  color: #15803d;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}

.brush-btn.active.brush-normal {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
  color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(27, 77, 62, 0.2);
}

.calendar-matrix-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 4px;
}

.calendar-matrix-table th {
  text-align: center;
  font-size: 0.8125rem;
  font-weight: 800;
  color: var(--text-secondary);
  padding: 0.35rem;
  white-space: nowrap;
}

.calendar-matrix-table td {
  padding: 0;
  vertical-align: middle;
}

.day-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--color-bg-surface-elevated);
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
  min-height: 48px;
}

.day-chip:hover {
  transform: scale(1.04);
  box-shadow: var(--shadow-md);
  z-index: 2;
}

.day-chip .day-date {
  font-size: 0.8125rem;
  font-weight: 800;
  color: var(--text-primary);
}

.day-chip .day-status {
  font-size: 0.65rem;
  font-weight: 700;
  margin-top: 2px;
}

/* 各日狀態主題 */
.day-chip.day-normal {
  background: white;
  border-color: #cbd5e1;
}
.day-chip.day-normal .day-status {
  color: var(--color-primary);
}

.day-chip.day-holiday {
  background: #f1f5f9;
  border-color: #94a3b8;
  cursor: not-allowed;
  opacity: 0.8;
}
.day-chip.day-holiday .day-status {
  color: #64748b;
}

.day-chip.day-exam {
  background: #fff1f2;
  border-color: #f87171;
}
.day-chip.day-exam .day-date {
  color: #991b1b;
}
.day-chip.day-exam .day-status {
  color: #dc2626;
  font-weight: 800;
}

.day-chip.day-activity {
  background: #f0fdf4;
  border-color: #86efac;
}
.day-chip.day-activity .day-date {
  color: #166534;
}
.day-chip.day-activity .day-status {
  color: #15803d;
  font-weight: 800;
}

/* 值日生支援與拖拉投放區 */
.duty-dropzone {
  transition: all var(--transition-fast);
  border-radius: var(--radius-sm);
  position: relative;
}

.duty-dropzone.drag-over {
  outline: 2px dashed var(--color-primary) !important;
  background: rgba(37, 99, 235, 0.12) !important;
  box-shadow: inset 0 0 8px rgba(37, 99, 235, 0.2);
}

.student-chip.student-draggable {
  cursor: grab;
}

.student-chip.student-draggable:active {
  cursor: grabbing;
}

