/* 全站樣式 1/16：基本色票變數（:root）、手機防左右滑、登入頁（老師／管理員入口卡、Face ID） */
/* ============================================
   小太陽管理系統 — 清新自然風 UI
   ============================================ */

:root {
  --bg: #FBF8F3;
  --card: #ffffff;
  --text: #2D2A26;
  --text-secondary: #6F6A63;
  --accent: #E07B35;
  --accent-dark: #C9652A;
  --green: #3E8E57;
  --red: #CF4130;
  --orange: #E07B35;
  --purple: #7A5BC0;
  --separator: rgba(60,60,67,0.08);
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 24px rgba(0,0,0,0.08);
  --radius: 16px;
  --radius-sm: 12px;
  --transition: all 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html {
  overscroll-behavior-y: contain;
}

body {
  font-family: "Plus Jakarta Sans", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", -apple-system, BlinkMacSystemFont, sans-serif;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "lnum" 1, "ss01" 1;
  background:
    radial-gradient(ellipse 120% 50% at 50% -10%, rgba(244, 162, 97, 0.13), transparent 60%),
    radial-gradient(ellipse 80% 40% at 90% 30%, rgba(178, 151, 189, 0.06), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
  line-height: 1.5;
}

/* 手機版保險：整頁永遠不准左右滑（2026-09-02 立）
   有東西不小心撐寬時，只切掉多出來那一點，不要讓整個畫面歪掉變成可左右拖。
   用 overflow-x:clip 不用 hidden——hidden 會讓 body 變成捲動容器、害 sticky header 失效。
   真的很寬的表格（矩陣、總表）本來就各自包在自己的 overflow-x:auto 裡，滑動不受影響。 */
@media (max-width: 768px) {
  body { overflow-x: clip; }
}

/* ============================================
   登入頁面
   ============================================ */
#login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px 20px;
  background: linear-gradient(160deg, #FBF8F3 0%, #EDE7DD 40%, #EDE7DD 100%);
}

/* 登入頁淡入動畫 */
@keyframes loginFadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* logo 緩緩漂浮 */
@keyframes logoFloat {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-8px) rotate(-1deg); }
}

/* logo 初次彈跳登場 */
@keyframes logoBounceIn {
  0% { opacity: 0; transform: scale(0.6) rotate(-15deg); }
  60% { opacity: 1; transform: scale(1.08) rotate(2deg); }
  100% { opacity: 1; transform: scale(1) rotate(-3deg); }
}

.login-hero { animation: loginFadeUp 0.5s cubic-bezier(0.4,0,0.2,1) both 0.1s; }

.login-container {
  width: 100%;
  max-width: 460px;
  position: relative;
  z-index: 1;
}

.login-hero {
  text-align: center;
  margin-bottom: 24px;
}

/* 太陽 logo — 帶白底圓角卡片感（border-radius 切角）+ 漂浮動畫 */
.login-icon {
  display: block;
  width: 220px;
  max-width: 70%;
  height: auto;
  margin: 0 auto 18px;
  border-radius: 16px;
  box-shadow:
    0 1px 3px rgba(60,40,20,.08)
    0 14px 32px rgba(0,0,0,0.10);
  animation:
    logoBounceIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) both,
    logoFloat 5s ease-in-out infinite 0.8s;
  transform-origin: center center;
  cursor: pointer;
}

@media (max-width: 480px) {
  .login-icon {
    width: 180px;
    border-radius: 16px;
    margin-bottom: 14px;
  }
}

.login-title {
  font-family: "Fraunces", "Plus Jakarta Sans", -apple-system, serif;
  font-variation-settings: "SOFT" 100, "WONK" 1, "opsz" 144;
  font-size: 2.4rem;
  font-weight: 700;
  color: #1D4577;
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: 0;
}

@media (max-width: 480px) {
  .login-title {
    font-size: 2rem;
  }
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 0.8125rem;
  letter-spacing: 0.01em;
}

/* 雙入口卡片容器 */
.login-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-card {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 16px;
  box-shadow: 0 8px 28px rgba(60,40,20,.14);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.6);
}

/* 雙入口按鈕容器 — 交錯彈入 */
.login-entries {
  display: grid;
  /* 看得到幾顆就分幾欄（藏起來的那顆不佔位） */
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 14px;
}
.login-entries .login-entry:nth-child(1) { animation: loginFadeUp 0.5s cubic-bezier(0.4,0,0.2,1) both 0.30s; }
.login-entries .login-entry:nth-child(2) { animation: loginFadeUp 0.5s cubic-bezier(0.4,0,0.2,1) both 0.40s; }
.login-entries .login-entry:nth-child(3) { animation: loginFadeUp 0.5s cubic-bezier(0.4,0,0.2,1) both 0.50s; }
.login-entries .login-entry:nth-child(4) { animation: loginFadeUp 0.5s cubic-bezier(0.4,0,0.2,1) both 0.60s; }
/* 360 寬手機：四顆塞得下（原本第四顆「廚房」會被切掉，2026-10-28） */
.login-entries .login-entry { min-width: 0; }
@media (max-width: 380px) { .login-entries { gap: 8px; } .login-entries .login-entry { padding: 22px 4px; } }

.login-entry {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 26px 12px;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.6);
  box-shadow:
    0 1px 3px rgba(60,40,20,.08)
    0 8px 32px rgba(0,0,0,0.06);
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  transition:
    transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.login-entry:active {
  transform: scale(0.95);
}
.login-entry:active .login-entry-icon {
  transform: scale(0.9);
}

.login-entry-icon {
  width: 52px; height: 52px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.25),
    0 4px 12px rgba(0,0,0,0.08);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* 管理員表單展開動畫 */
#admin-login-form {
  animation: loginFadeUp 0.3s ease both;
}

/* 管理員卡片 */
.login-card-admin {
  padding: 16px 20px;
}

.login-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.login-card-icon {
  width: 36px; height: 36px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.admin-icon {
  background: linear-gradient(135deg, #E07B35, #C9652A);
  color: white;
}

.teacher-icon {
  background: linear-gradient(135deg, #3E8E57, #3E8E57);
  color: white;
}

.login-card-label {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--bg);
  border-radius: 12px;
  overflow: hidden;
}

.login-form input {
  width: 100%;
  padding: 13px 14px;
  border: none;
  border-bottom: 0.5px solid rgba(0,0,0,0.06);
  font-size: 0.9375rem;
  font-family: inherit;
  color: var(--text);
  background: transparent;
  transition: background 0.2s;
}

.login-form input:last-of-type {
  border-bottom: none;
}

.login-form input:focus {
  outline: none;
  background: rgba(244, 162, 97, 0.04);
}

.login-form input::placeholder {
  color: var(--text-secondary);
  opacity: 0.5;
}

.login-submit-btn {
  width: 100%;
  margin-top: 10px;
  padding: 12px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #E07B35, #C9652A);
  color: white;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
  box-shadow: 0 4px 16px rgba(244, 162, 97, 0.3);
}
.login-submit-btn:active {
  transform: scale(0.97);
  box-shadow: 0 2px 8px rgba(244, 162, 97, 0.2);
}

.login-error {
  color: var(--red);
  margin-top: 10px;
  font-size: 0.8125rem;
  min-height: 1em;
  text-align: center;
}

/* Face ID 按鈕 */
.btn-biometric {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 16px;
  background: linear-gradient(135deg, #3E8E57, #3E8E57);
  color: white;
  font-size: 0.9375rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 12px;
  transition: all 0.15s;
}
.btn-biometric:active { transform: scale(0.98); opacity: 0.85; }

/* 老師入口卡片 */
.login-card-teacher {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  text-decoration: none;
  color: var(--text);
  transition: all 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
  cursor: pointer;
}
.login-card-teacher:active {
  transform: scale(0.98);
  background: #FBF8F3;
}
.login-card-teacher svg:last-child {
  color: var(--text-secondary);
  opacity: 0.4;
  flex-shrink: 0;
}
.login-card-left {
  display: flex;
  align-items: center;
  gap: 14px;
}
.teacher-card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}
.teacher-card-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 1px;
}

/* 老師快速登入連結（保留給其他地方用） */
.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-family: inherit;
  font-size: 0.9375rem;
  cursor: pointer;
  padding: 8px 0;
  text-decoration: none;
}
.link-btn:active { opacity: 0.5; }

.pin-dots {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 24px;
}
.pin-dots span {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--separator);
  transition: background 0.15s;
}
.pin-dots span.filled {
  background: var(--accent);
}

.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-width: 280px;
  margin: 0 auto;
}
.pin-keypad button {
  padding: 16px;
  border: none;
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  font-family: inherit;
  font-size: 1.375rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(60,40,20,.08);
  transition: all 0.1s;
}
.pin-keypad button:active {
  transform: scale(0.93);
  background: var(--separator);
}

/* dark mode 補充 */
body.dark-mode .btn-biometric {
  background: linear-gradient(135deg, #3872B8, #3872B8);
}
body.dark-mode .teacher-grid button {
  background: var(--card);
}
body.dark-mode .pin-keypad button {
  background: var(--card);
}

/* 庫存登記選人卡片 */
.inv-student-pick {
  padding: 10px 4px;
  text-align: center;
  border-radius: 12px;
  border: 1.5px solid var(--separator);
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 600;
  transition: all 0.12s;
  background: var(--card);
  color: var(--text);
  user-select: none;
}
.inv-student-pick:active {
  transform: scale(0.95);
}
.inv-student-pick.picked {
  background: #3872B8;
  color: white;
  border-color: #3872B8;
  box-shadow: 0 2px 8px rgba(88, 86, 214, 0.35);
}
body.dark-mode .inv-student-pick {
  background: #2D2A26;
  border-color: #2D2A26;
}
body.dark-mode .inv-student-pick.picked {
  background: #3872B8;
  border-color: #3872B8;
}
.inv-order-row.selected {
  background: rgba(255,59,48,0.06) !important;
  border-left: 3px solid var(--red);
}
.inv-order-row.selected .inv-order-check {
  color: var(--red) !important;
}
.inv-order-row.selected .inv-order-check::after { content: '●'; }
.inv-order-row:not(.selected) .inv-order-check::after { content: '○'; }

