/* =====================================================
   太平新光分校 司機回報 v2 (批次版)
   ===================================================== */

:root {
  --c-bg: #f4f6f8;
  --c-card: #ffffff;
  --c-text: #1f2937;
  --c-muted: #6b7280;
  --c-line: #e5e7eb;
  --c-primary: #1e90ff;
  --c-primary-dk: #1976d2;
  --c-ok: #2e8b57;
  --c-ok-bg: #e8f5ee;
  --c-fail: #dc143c;
  --c-fail-bg: #fdebef;
  --c-hold: #ff8c00;
  --c-hold-bg: #fff4e5;
  --c-leave: #6b7280;
  --c-leave-bg: #eef0f3;
  --c-walk: #1e90ff;
  --c-walk-bg: #e6f2ff;
  --c-official: #8a2be2;
  --c-official-bg: #f1e6fa;
  --c-bus: #d97706;
  --c-bus-bg: #fff4e0;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--c-bg);
  color: var(--c-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Microsoft JhengHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.5;
  padding-bottom: 90px;
}
.hidden { display: none !important; }

.container { max-width: 480px; margin: 0 auto; padding: 0; }

/* Header */
.header {
  background: linear-gradient(135deg, #1e90ff 0%, #1976d2 100%);
  color: #fff;
  padding: 18px 16px 20px;
}
.logo-row { display: flex; align-items: center; gap: 12px; }
.logo { color: #fff; flex-shrink: 0; }
.brand { flex: 1; }
.brand-zh { font-size: 18px; font-weight: 700; margin: 0; }
.brand-en { font-size: 12px; opacity: .9; margin: 2px 0 0; }
.lang-toggle {
  background: rgba(255,255,255,.2); color: #fff; border: 1px solid rgba(255,255,255,.4);
  border-radius: 14px; padding: 4px 10px; font-size: 12px; font-weight: 600;
  cursor: pointer; min-width: 44px;
}
.lang-toggle:active { background: rgba(255,255,255,.3); }

/* Cards */
.card {
  background: var(--c-card); border-radius: 12px; box-shadow: var(--shadow);
  padding: 14px; margin: 12px;
}

.loading-card, .error-card { text-align: center; padding: 32px 20px; }
.spinner {
  width: 28px; height: 28px; border: 3px solid var(--c-line); border-top-color: var(--c-primary);
  border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: var(--c-muted); margin: 0; }

.error-icon {
  width: 44px; height: 44px; border-radius: 50%; background: var(--c-fail-bg);
  color: var(--c-fail); font-size: 24px; font-weight: 700; line-height: 44px;
  margin: 0 auto 10px;
}
.error-title { font-size: 16px; margin: 0 0 6px; }
.error-msg { color: var(--c-muted); font-size: 13px; margin: 0 0 14px; }

/* Stats bar */
.stats-bar {
  display: flex; align-items: stretch; padding: 10px 6px; gap: 0;
  margin: 12px 12px 6px;
}
.stat-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 4px 2px;
}
.stat-icon { font-size: 14px; }
.stat-value { font-size: 18px; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: 10px; color: var(--c-muted); white-space: nowrap; }
.stat-ok .stat-value { color: var(--c-ok); }
.stat-fail .stat-value { color: var(--c-fail); }
.stat-hold .stat-value { color: var(--c-hold); }
.stat-leave .stat-value { color: var(--c-leave); }
.stat-divider { width: 1px; background: var(--c-line); margin: 4px 0; }

/* Date heading */
.date-heading { padding: 4px 18px 8px; }
.date-label { font-size: 13px; color: var(--c-muted); }

/* Route group header */
.student-cards { padding: 0 12px; }
.route-header {
  display: flex; align-items: center; gap: 10px;
  background: #fff; border-radius: 12px; padding: 12px 14px;
  margin: 14px 0 6px; box-shadow: var(--shadow);
  border-left: 4px solid var(--c-primary);
}
.route-icon { font-size: 22px; }
.route-text { display: flex; flex-direction: column; flex: 1; }
.route-zh { font-weight: 700; font-size: 15px; }
.route-en { font-size: 11px; color: var(--c-muted); margin-top: 1px; }
.route-count {
  background: var(--c-primary); color: #fff; font-size: 12px; font-weight: 700;
  padding: 2px 10px; border-radius: 10px;
}

/* Student card */
.stu-card {
  background: #fff; border-radius: 12px; padding: 12px; margin: 0 0 10px;
  box-shadow: var(--shadow);
}
.stu-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 10px; gap: 10px;
}
.stu-name { display: flex; flex-direction: column; gap: 1px; }
.stu-zh { font-size: 16px; font-weight: 700; }
.stu-en { font-size: 12px; color: var(--c-muted); }
.stu-meta { display: flex; flex-direction: column; gap: 2px; align-items: flex-end; font-size: 11px; color: var(--c-muted); }
.stu-class { font-weight: 600; color: var(--c-text); }

/* Status grid (4 buttons) */
.st-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
  margin-bottom: 8px;
}
.st-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; padding: 8px 4px; border: 1.5px solid var(--c-line); border-radius: 10px;
  background: #fff; color: var(--c-muted); cursor: pointer;
  font-size: 11px; font-weight: 600; line-height: 1.2; text-align: center;
  transition: all .15s;
}
.st-btn .st-icon { font-size: 18px; }
.st-btn:active { transform: scale(.96); }
.st-btn.active.st-ok { background: var(--c-ok-bg); border-color: var(--c-ok); color: var(--c-ok); }
.st-btn.active.st-fail { background: var(--c-fail-bg); border-color: var(--c-fail); color: var(--c-fail); }
.st-btn.active.st-hold { background: var(--c-hold-bg); border-color: var(--c-hold); color: var(--c-hold); }
.st-btn.active.st-leave { background: var(--c-leave-bg); border-color: var(--c-leave); color: var(--c-leave); }

/* Note row */
.note-row { border-top: 1px dashed var(--c-line); padding-top: 8px; }
.note-toggle {
  display: flex; align-items: center; gap: 6px; background: none; border: 0;
  color: var(--c-primary); font-size: 13px; cursor: pointer; padding: 4px 0;
}
.note-icon { font-size: 14px; }
.note-input-wrap { margin-top: 6px; }
.note-input {
  width: 100%; border: 1px solid var(--c-line); border-radius: 8px;
  padding: 8px 10px; font-size: 13px; outline: none;
  font-family: inherit;
}
.note-input:focus { border-color: var(--c-primary); }

/* Empty state */
.empty-state { text-align: center; color: var(--c-muted); padding: 32px 20px; }

/* Sticky submit */
.sticky-submit {
  position: fixed; bottom: 0; left: 0; right: 0; max-width: 480px; margin: 0 auto;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(244,246,248,0) 0%, rgba(244,246,248,1) 30%);
  z-index: 50;
}
.btn-submit {
  width: 100%; padding: 14px; font-size: 15px; font-weight: 700;
  border-radius: 12px; border: 0; cursor: pointer;
  background: linear-gradient(135deg, #1e90ff 0%, #1976d2 100%);
  color: #fff; box-shadow: 0 4px 12px rgba(30,144,255,.3);
}
.btn-submit:disabled { opacity: .6; }

/* Buttons (modals) */
.btn-primary {
  background: var(--c-primary); color: #fff; border: 0; border-radius: 10px;
  padding: 11px 18px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn-primary:active { background: var(--c-primary-dk); }
.btn-secondary {
  background: #fff; color: var(--c-text); border: 1px solid var(--c-line);
  border-radius: 10px; padding: 11px 18px; font-size: 14px; font-weight: 600; cursor: pointer;
}

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 24px;
}
.modal-box {
  background: #fff; border-radius: 14px; padding: 22px; width: 100%; max-width: 360px;
  text-align: center;
}
.success-icon { font-size: 44px; margin-bottom: 6px; }
.modal-title { font-size: 17px; margin: 0 0 8px; font-weight: 700; }
.modal-body-text { color: var(--c-muted); font-size: 13px; margin: 0 0 16px; line-height: 1.55; }
.modal-actions { display: flex; gap: 8px; justify-content: center; }
.modal-actions .btn-primary, .modal-actions .btn-secondary { flex: 1; max-width: 140px; }

/* Footer */
.footer { text-align: center; padding: 20px 16px 12px; }
.footer-text { font-size: 11px; color: var(--c-muted); margin: 0; }

/* =====================================================
   Transfer Request button (on student card)
   ===================================================== */
.transfer-row {
  border-top: 1px dashed var(--c-line);
  padding-top: 8px;
  margin-top: 2px;
}
.btn-transfer {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: 1.5px solid #5B7FE6;
  border-radius: 8px;
  color: #5B7FE6;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  cursor: pointer;
  transition: all .15s;
}
.btn-transfer:active {
  background: #eef2fd;
}

/* =====================================================
   Transfer Modal (slide-up sheet)
   ===================================================== */

/* Animate the modal overlay */
.modal-overlay {
  transition: opacity .2s cubic-bezier(0.16, 1, 0.3, 1);
  opacity: 1;
  pointer-events: auto;
}
.modal-overlay.hidden {
  display: none !important;
}

/* Sheet style for transfer modal */
.modal-sheet {
  background: #fff;
  border-radius: 20px 20px 0 0;
  max-width: 520px;
  width: 100%;
  padding: 24px 18px calc(24px + env(safe-area-inset-bottom));
  max-height: 88dvh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform .28s cubic-bezier(0.16, 1, 0.3, 1);
}
#transferModal {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  opacity: 0;
  pointer-events: none;
  background: rgba(0,0,0,0);
  transition: opacity .22s, background .22s;
}
#transferModal.open {
  opacity: 1;
  pointer-events: auto;
  background: rgba(0,0,0,.5);
}
#transferModal.open .modal-sheet {
  transform: translateY(0);
}

.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--c-line);
  border-radius: 9999px;
  margin: 0 auto 18px;
}
.modal-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}
.transfer-applicant {
  font-size: 13px;
  color: var(--c-muted);
  margin-bottom: 16px;
}

/* Reason options */
.transfer-section {
  margin-bottom: 16px;
}
.transfer-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--c-text, #1f2937);
  margin-bottom: 8px;
}
.transfer-reasons {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.reason-option {
  display: flex;
  cursor: pointer;
}
.reason-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.reason-box {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--c-line);
  border-radius: 10px;
  background: #fff;
  transition: all .15s;
}
.reason-option:has(input:checked) .reason-box {
  border-color: #5B7FE6;
  background: #eef2fd;
  color: #5B7FE6;
}
.reason-icon { font-size: 18px; }
.reason-text { font-size: 13px; font-weight: 600; }

/* Textarea */
.transfer-detail {
  width: 100%;
  border: 1.5px solid var(--c-line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  min-height: 72px;
  outline: none;
  transition: border-color .15s;
}
.transfer-detail:focus {
  border-color: #5B7FE6;
}

/* Success toast */
.transfer-success {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #e8f5ee;
  color: #2e8b57;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 14px;
  animation: fadeSlideIn .3s cubic-bezier(0.16,1,0.3,1);
}
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.transfer-success-icon { font-size: 18px; }

/* Actions row */
.transfer-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}
.transfer-actions .btn-secondary {
  flex: 1;
}
.btn-transfer-submit {
  flex: 2;
  padding: 12px;
  background: linear-gradient(135deg, #5B7FE6 0%, #4163cc 100%);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(91,127,230,.3);
  transition: all .15s;
}
.btn-transfer-submit:disabled {
  opacity: .6;
  cursor: not-allowed;
}
.btn-transfer-submit:active:not(:disabled) {
  transform: scale(.97);
}
