/* ----------------------------------------------------
   學校行政處室與級任導師資訊網 - 粉藍色系主題 (Pastel Light Blue)
   嘉義縣大同國小 專屬微光與樹狀圖樣式
   ---------------------------------------------------- */

:root {
  /* Color Palette - Pastel Sky & Ice Blue */
  --bg-gradient-start: #eef7ff;
  --bg-gradient-mid: #e0f2fe;
  --bg-gradient-end: #f0f9ff;
  
  --primary-blue: #0284c7;
  --primary-dark: #0369a1;
  --primary-navy: #1e3a8a;
  --primary-light: #bae6fd;
  --primary-soft-bg: #f0f7ff;

  --accent-cyan: #06b6d4;
  --accent-indigo: #4338ca;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-light: #64748b;

  --card-bg: rgba(255, 255, 255, 0.95);
  --card-border: rgba(186, 230, 253, 0.8);
  --card-hover-border: #38bdf8;
  
  --shadow-sm: 0 2px 8px rgba(14, 165, 233, 0.06);
  --shadow-md: 0 8px 24px rgba(14, 165, 233, 0.1);
  --shadow-lg: 0 16px 36px rgba(14, 165, 233, 0.15);

  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 9999px;

  --font-family: 'Noto Sans TC', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Reset & Base Styles */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-mid) 50%, var(--bg-gradient-end) 100%);
  background-attachment: fixed;
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* Subtle Animated Background Elements */
body::before {
  content: '';
  position: fixed;
  top: -150px;
  right: -150px;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(186, 230, 253, 0.4) 0%, rgba(255, 255, 255, 0) 70%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  bottom: -200px;
  left: -200px;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(224, 242, 254, 0.6) 0%, rgba(255, 255, 255, 0) 70%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}

.app-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px 60px 24px;
  position: relative;
  z-index: 1;
}

/* Header & Navigation Bar */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px 0;
  border-bottom: 2px solid rgba(186, 230, 253, 0.6);
  margin-bottom: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
  text-decoration: none;
}

.brand-icon {
  width: 58px;
  height: 58px;
  background: linear-gradient(135deg, #ff9800 0%, #fbbf24 35%, #0284c7 100%);
  color: #ffffff;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  box-shadow: 0 8px 20px rgba(255, 152, 0, 0.3);
  transition: transform 0.3s ease;
}

.brand:hover .brand-icon {
  transform: scale(1.05) rotate(-3deg);
}

.brand-text h1 {
  font-size: 1.95rem;
  font-weight: 900;
  letter-spacing: -0.5px;
  line-height: 1.25;
  margin-bottom: 2px;
  background: linear-gradient(135deg, #0369a1 0%, #0284c7 50%, #ea580c 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-text .sun-sparkle {
  font-size: 1.6rem;
  -webkit-text-fill-color: initial;
  display: inline-block;
  animation: pulseSun 2.5s infinite ease-in-out;
}

@keyframes pulseSun {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.15) rotate(12deg); }
}

.brand-text span {
  font-size: 1.05rem;
  color: #0284c7;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.btn-home {
  background: var(--primary-navy);
  color: #ffffff;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-home:hover {
  background: var(--primary-blue);
  transform: translateY(-1px);
}

.btn-secondary-light {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--primary-light);
  color: var(--primary-dark);
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.25s ease;
  box-shadow: var(--shadow-sm);
}

.btn-secondary-light:hover {
  background: var(--primary-blue);
  color: #ffffff;
  border-color: var(--primary-blue);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.3);
}

.badge-tag {
  background: #e0f2fe;
  color: #0369a1;
  padding: 10px 24px;
  border-radius: var(--radius-full);
  font-size: 1.25rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1.5px solid #bae6fd;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.15);
}

/* Breadcrumb Navigation Bar */
.breadcrumb-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(186, 230, 253, 0.6);
  border-radius: var(--radius-md);
  padding: 10px 20px;
  margin-bottom: 24px;
}

.breadcrumb-left {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
}

.breadcrumb-left a { color: var(--primary-blue); text-decoration: none; font-weight: 600; }
.breadcrumb-left .separator { color: #94a3b8; }
.breadcrumb-left .current-page { color: var(--primary-navy); font-weight: 700; }

.btn-back {
  background: #ffffff;
  border: 1px solid var(--primary-light);
  color: var(--primary-dark);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-back:hover { background: var(--primary-blue); color: #ffffff; }

/* PORTAL SELECTION SCREEN (Only 2 Major Cards) */
.portal-selection-screen { margin: 20px 0 40px 0; }

.portal-welcome { text-align: center; margin-bottom: 36px; }
.portal-welcome h2 { font-size: 2.2rem; font-weight: 800; color: var(--primary-navy); margin-top: 10px; margin-bottom: 8px; }
.portal-welcome p { font-size: 1.05rem; color: var(--text-muted); }

.portal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 32px;
}

.portal-card {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(16px);
  border: 2px solid rgba(186, 230, 253, 0.8);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  box-shadow: var(--shadow-md);
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  cursor: default;
}

.portal-card.office-theme:hover { border-color: #38bdf8; }
.portal-card.teacher-theme:hover { border-color: #34d399; }

.portal-card-badge {
  position: absolute; top: 24px; right: 24px; font-size: 0.82rem; font-weight: 700; padding: 4px 12px; border-radius: var(--radius-full);
}

.office-theme .portal-card-badge { background: #e0f2fe; color: #0369a1; }
.teacher-theme .portal-card-badge { background: #dcfce7; color: #15803d; }

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

.portal-icon {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.95rem;
  margin-bottom: 0;
  flex-shrink: 0;
}

.office-theme .portal-icon { background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%); color: #0284c7; }
.teacher-theme .portal-icon { background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%); color: #16a34a; }

.portal-card-header h3 { font-size: 1.85rem; font-weight: 800; color: var(--primary-navy); margin: 0; line-height: 1.2; }

.portal-content { flex-grow: 1; margin-bottom: 28px; }
.portal-content p { color: var(--text-muted); font-size: 0.98rem; line-height: 1.6; margin-bottom: 20px; }

/* 行政處室門戶 樹狀按鈕結構 (上層校長室，下層四處室) */
.office-portal-tree {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  margin-top: 18px;
  margin-bottom: 20px;
  width: 100%;
}

.office-tree-top {
  display: flex;
  justify-content: center;
  width: 100%;
}

.office-tree-top .btn-office-block {
  width: 48%;
}

.office-tree-bottom {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  width: 100%;
}

.btn-office-block {
  background: linear-gradient(135deg, #33cbf8 0%, #00bce4 55%, #0096c7 100%);
  color: #ffffff;
  border: none;
  border-radius: 14px;
  padding: 14px 6px;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-align: center;
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 14px rgba(0, 188, 228, 0.35);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  white-space: nowrap;
}

.btn-office-block:hover {
  background: linear-gradient(135deg, #57d5f9 0%, #00d2ff 50%, #00a8e8 100%);
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 8px 18px rgba(0, 188, 228, 0.45);
}

.btn-office-block:active {
  transform: translateY(-1px);
}

@keyframes pulseHighlight {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(2, 132, 199, 0.7); }
  50% { transform: scale(1.05); box-shadow: 0 0 0 16px rgba(2, 132, 199, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(2, 132, 199, 0); }
}

.pulse-highlight {
  animation: pulseHighlight 1.5s cubic-bezier(0.25, 1, 0.5, 1);
  border-color: #0284c7 !important;
}

/* 3x2 Grade Portal Grid (六個獨立綠色區塊) */
.grade-portal-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px 16px;
  margin-top: 18px;
  margin-bottom: 20px;
}

.btn-grade-block {
  background: linear-gradient(135deg, #8ad866 0%, #5cb834 100%);
  color: #ffffff;
  border: none;
  border-radius: 14px;
  padding: 16px 12px;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-align: center;
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 12px rgba(92, 184, 52, 0.35);
  text-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.btn-grade-block:hover {
  background: linear-gradient(135deg, #9ae279 0%, #66c63b 100%);
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 8px 18px rgba(92, 184, 52, 0.45);
}

.btn-grade-block:active {
  transform: translateY(-1px);
}

.btn-portal-action {
  width: 100%;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  border: none;
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  transition: all 0.25s ease;
  background: linear-gradient(135deg, #38bdf8 0%, #0284c7 50%, #0369a1 100%);
  color: #ffffff;
  box-shadow: 0 6px 16px rgba(2, 132, 199, 0.3);
  text-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.btn-portal-action:hover {
  background: linear-gradient(135deg, #7dd3fc 0%, #38bdf8 50%, #0284c7 100%);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(2, 132, 199, 0.4);
}

.btn-portal-action.green {
  background: linear-gradient(135deg, #34d399 0%, #10b981 50%, #059669 100%);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.3);
}

.btn-portal-action.green:hover {
  background: linear-gradient(135deg, #6ee7b7 0%, #34d399 50%, #10b981 100%);
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.4);
}

/* 6 GRADE BLOCKS LAYOUT (簡化成 1~6 年級六個區塊 - 同一排文字設計) */
.grade-blocks-container {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.grade-block-card {
  background: #ffffff;
  border: 1px solid rgba(186, 230, 253, 0.6);
  border-radius: var(--radius-lg);
  padding: 24px 30px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.grade-block-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.10);
}

.grade-block-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 7px;
  height: 100%;
  border-radius: 0 3px 3px 0;
}

/* ── 一年級：玫瑰粉 ── */
.grade-block-card.grade-1::before { background: linear-gradient(to bottom, #fb7185, #f43f5e); }
.grade-block-card.grade-1 { border-color: rgba(251,113,133,0.35); background: linear-gradient(135deg, #fff1f2 0%, #ffffff 60%); }
.grade-block-card.grade-1 .grade-block-header h3 { color: #e11d48; }
.grade-block-card.grade-1 .class-count-tag { background: #ffe4e6; color: #be123c; }
.grade-block-card.grade-1 .class-label-hi { color: #f43f5e; }
.grade-block-card.grade-1 .teacher-inline-pill:hover { border-color: #fb7185; box-shadow: 0 4px 14px rgba(244,63,94,0.18); }

/* ── 二年級：暖橘 ── */
.grade-block-card.grade-2::before { background: linear-gradient(to bottom, #fb923c, #f97316); }
.grade-block-card.grade-2 { border-color: rgba(251,146,60,0.35); background: linear-gradient(135deg, #fff7ed 0%, #ffffff 60%); }
.grade-block-card.grade-2 .grade-block-header h3 { color: #ea580c; }
.grade-block-card.grade-2 .class-count-tag { background: #ffedd5; color: #c2410c; }
.grade-block-card.grade-2 .class-label-hi { color: #f97316; }
.grade-block-card.grade-2 .teacher-inline-pill:hover { border-color: #fb923c; box-shadow: 0 4px 14px rgba(249,115,22,0.18); }

/* ── 三年級：陽光黃 ── */
.grade-block-card.grade-3::before { background: linear-gradient(to bottom, #fbbf24, #f59e0b); }
.grade-block-card.grade-3 { border-color: rgba(251,191,36,0.35); background: linear-gradient(135deg, #fffbeb 0%, #ffffff 60%); }
.grade-block-card.grade-3 .grade-block-header h3 { color: #d97706; }
.grade-block-card.grade-3 .class-count-tag { background: #fef3c7; color: #b45309; }
.grade-block-card.grade-3 .class-label-hi { color: #f59e0b; }
.grade-block-card.grade-3 .teacher-inline-pill:hover { border-color: #fbbf24; box-shadow: 0 4px 14px rgba(245,158,11,0.18); }

/* ── 四年級：翠綠 ── */
.grade-block-card.grade-4::before { background: linear-gradient(to bottom, #34d399, #10b981); }
.grade-block-card.grade-4 { border-color: rgba(52,211,153,0.35); background: linear-gradient(135deg, #ecfdf5 0%, #ffffff 60%); }
.grade-block-card.grade-4 .grade-block-header h3 { color: #059669; }
.grade-block-card.grade-4 .class-count-tag { background: #d1fae5; color: #047857; }
.grade-block-card.grade-4 .class-label-hi { color: #10b981; }
.grade-block-card.grade-4 .teacher-inline-pill:hover { border-color: #34d399; box-shadow: 0 4px 14px rgba(16,185,129,0.18); }

/* ── 五年級：天藍 ── */
.grade-block-card.grade-5::before { background: linear-gradient(to bottom, #38bdf8, #0ea5e9); }
.grade-block-card.grade-5 { border-color: rgba(56,189,248,0.35); background: linear-gradient(135deg, #f0f9ff 0%, #ffffff 60%); }
.grade-block-card.grade-5 .grade-block-header h3 { color: #0284c7; }
.grade-block-card.grade-5 .class-count-tag { background: #e0f2fe; color: #0369a1; }
.grade-block-card.grade-5 .class-label-hi { color: #0ea5e9; }
.grade-block-card.grade-5 .teacher-inline-pill:hover { border-color: #38bdf8; box-shadow: 0 4px 14px rgba(14,165,233,0.18); }

/* ── 六年級：紫羅蘭 ── */
.grade-block-card.grade-6::before { background: linear-gradient(to bottom, #a78bfa, #7c3aed); }
.grade-block-card.grade-6 { border-color: rgba(167,139,250,0.35); background: linear-gradient(135deg, #f5f3ff 0%, #ffffff 60%); }
.grade-block-card.grade-6 .grade-block-header h3 { color: #7c3aed; }
.grade-block-card.grade-6 .class-count-tag { background: #ede9fe; color: #6d28d9; }
.grade-block-card.grade-6 .class-label-hi { color: #7c3aed; }
.grade-block-card.grade-6 .teacher-inline-pill:hover { border-color: #a78bfa; box-shadow: 0 4px 14px rgba(124,58,237,0.18); }

.grade-block-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid #f0f7ff;
}

.grade-block-header h3 {
  font-size: 1.5rem;
  font-weight: 800;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 10px;
}

.grade-block-header .class-count-tag {
  font-size: 0.85rem;
  font-weight: 600;
  background: #e0f2fe;
  color: #0369a1;
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

/* 一在同一排的三欄式相鄰網格 (3-Column Row Layout) */
.grade-teachers-row-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px 24px;
  align-items: center;
}

.teacher-inline-pill {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  font-size: 1.3rem;
  font-weight: 800;
  color: #0f172a;
  display: flex;
  align-items: center;
  white-space: nowrap;
  transition: all 0.22s ease;
  cursor: pointer;
}

.teacher-inline-pill:hover {
  background: #ffffff;
  border-color: #38bdf8;
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(14, 165, 233, 0.15);
}

/* 班級標籤色（各年段主色 / 深色交替） */
.teacher-inline-pill .class-label-hi {
  font-weight: 800;
  margin-right: 2px;
}

.teacher-inline-pill .class-label-dark {
  color: #1e293b;
  font-weight: 800;
  margin-right: 2px;
}

.teacher-inline-pill .slash-sep {
  color: #94a3b8;
  margin: 0 5px;
  font-weight: 500;
}

/* SECTION VIEWS (Header & Controls) */
.section-view { animation: fadeIn 0.3s ease forwards; }

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

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.section-header h2 { font-size: 1.8rem; font-weight: 800; color: var(--primary-navy); margin-bottom: 4px; }
.section-header p { color: var(--text-muted); font-size: 0.98rem; }

.view-switch-group {
  display: flex;
  background: rgba(255, 255, 255, 0.9);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(186, 230, 253, 0.8);
}

.btn-view-toggle {
  background: transparent;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-view-toggle.active { background: var(--primary-navy); color: #ffffff; }

/* TREE DIAGRAM CSS (行政處室 樹狀圖) */
.tree-container {
  padding: 30px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(186, 230, 253, 0.8);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow-x: auto;
  text-align: center;
}

.tree-wrapper { display: inline-flex; flex-direction: column; align-items: center; min-width: 700px; }
.tree-root-node { position: relative; margin-bottom: 50px; }
.tree-root-node::after {
  content: ''; position: absolute; bottom: -50px; left: 50%; width: 3px; height: 50px; background: #38bdf8; transform: translateX(-50%);
}

.tree-node-card {
  background: #ffffff;
  border: 2px solid var(--primary-light);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  width: 240px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  display: inline-block;
  text-align: left;
}

.tree-node-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--primary-blue); }
.tree-node-card.principal-card { border-color: #38bdf8; background: linear-gradient(135deg, #ffffff 0%, #f0f9ff 100%); width: 260px; }

.node-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.node-title { font-size: 1.15rem; font-weight: 800; color: var(--primary-navy); }
.node-ext { font-size: 0.78rem; font-weight: 700; background: #e0f2fe; color: #0369a1; padding: 2px 8px; border-radius: var(--radius-full); }
.node-leader { font-size: 0.95rem; font-weight: 600; color: var(--primary-blue); margin-bottom: 6px; }
.node-duty-preview { font-size: 0.82rem; color: var(--text-muted); display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.tree-branches { display: flex; justify-content: center; position: relative; gap: 20px; }
.tree-branches::before { content: ''; position: absolute; top: 0; left: 120px; right: 120px; height: 3px; background: #38bdf8; }
.tree-branch-item { position: relative; padding-top: 30px; }
.tree-branch-item::before { content: ''; position: absolute; top: 0; left: 50%; width: 3px; height: 30px; background: #38bdf8; transform: translateX(-50%); }

/* Search Bar */
.search-wrapper { position: relative; width: 100%; }
.search-input {
  width: 100%; padding: 14px 20px 14px 48px; font-size: 1rem; border-radius: var(--radius-md); border: 2px solid rgba(186, 230, 253, 0.9); background: #ffffff; color: var(--text-main); outline: none; transition: all 0.25s ease; font-family: inherit;
}
.search-input:focus { border-color: var(--primary-blue); box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.25); }
.search-icon { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--primary-blue); font-size: 18px; }

/* Sub Filter Chips with Grade-Specific Colors */
.sub-filters { display: flex; gap: 8px; overflow-x: auto; padding: 6px 0; }
.chip-btn {
  background: rgba(255, 255, 255, 0.9);
  border: 1.5px solid rgba(186, 230, 253, 0.8);
  padding: 8px 18px;
  border-radius: var(--radius-full);
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.22s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.chip-btn[data-grade="all"] {
  color: var(--primary-navy);
}
.chip-btn[data-grade="all"].active {
  background: var(--primary-navy);
  color: #ffffff;
  border-color: var(--primary-navy);
}

/* 一年級: 粉紅 */
.chip-btn[data-grade="一年級"] {
  color: #ec4899;
  border-color: rgba(236, 72, 153, 0.4);
}
.chip-btn[data-grade="一年級"]:hover {
  background: #fce7f3;
  color: #be185d;
  border-color: #ec4899;
}
.chip-btn[data-grade="一年級"].active {
  background: linear-gradient(135deg, #f472b6 0%, #ec4899 100%);
  color: #ffffff;
  border-color: #ec4899;
  box-shadow: 0 4px 12px rgba(236, 72, 153, 0.3);
}

/* 二年級: 陽光橘 */
.chip-btn[data-grade="二年級"] {
  color: #ea580c;
  border-color: rgba(234, 88, 12, 0.4);
}
.chip-btn[data-grade="二年級"]:hover {
  background: #ffedd5;
  color: #c2410c;
  border-color: #ea580c;
}
.chip-btn[data-grade="二年級"].active {
  background: linear-gradient(135deg, #fb923c 0%, #ea580c 100%);
  color: #ffffff;
  border-color: #ea580c;
  box-shadow: 0 4px 12px rgba(234, 88, 12, 0.3);
}

/* 三年級: 活力黃 */
.chip-btn[data-grade="三年級"] {
  color: #d97706;
  border-color: rgba(217, 119, 6, 0.4);
}
.chip-btn[data-grade="三年級"]:hover {
  background: #fef3c7;
  color: #b45309;
  border-color: #d97706;
}
.chip-btn[data-grade="三年級"].active {
  background: linear-gradient(135deg, #fbbf24 0%, #d97706 100%);
  color: #ffffff;
  border-color: #d97706;
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.3);
}

/* 四年級: 翡翠綠 */
.chip-btn[data-grade="四年級"] {
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.4);
}
.chip-btn[data-grade="四年級"]:hover {
  background: #d1fae5;
  color: #047857;
  border-color: #10b981;
}
.chip-btn[data-grade="四年級"].active {
  background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
  color: #ffffff;
  border-color: #10b981;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* 五年級: 湛藍色 */
.chip-btn[data-grade="五年級"] {
  color: #0284c7;
  border-color: rgba(2, 132, 199, 0.4);
}
.chip-btn[data-grade="五年級"]:hover {
  background: #e0f2fe;
  color: #0369a1;
  border-color: #0284c7;
}
.chip-btn[data-grade="五年級"].active {
  background: linear-gradient(135deg, #38bdf8 0%, #0284c7 100%);
  color: #ffffff;
  border-color: #0284c7;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
}

/* 六年級: 夢幻紫 */
.chip-btn[data-grade="六年級"] {
  color: #8b5cf6;
  border-color: rgba(139, 92, 246, 0.4);
}
.chip-btn[data-grade="六年級"]:hover {
  background: #f3e8ff;
  color: #6d28d9;
  border-color: #8b5cf6;
}
.chip-btn[data-grade="六年級"].active {
  background: linear-gradient(135deg, #a78bfa 0%, #8b5cf6 100%);
  color: #ffffff;
  border-color: #8b5cf6;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

/* Card Grid Layout */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 24px; }

/* Item Card Styles */
.card {
  background: var(--card-bg); backdrop-filter: blur(10px); border: 1px solid var(--card-border); border-radius: var(--radius-md); padding: 24px; box-shadow: var(--shadow-sm); transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1); display: flex; flex-direction: column;
}
.card:hover { transform: translateY(-6px); box-shadow: var(--shadow-md); border-color: var(--card-hover-border); }

/* Modal Overlay */
.modal-overlay {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(15, 23, 42, 0.45); backdrop-filter: blur(6px); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; opacity: 0; visibility: hidden; transition: all 0.25s ease;
}
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal-box { background: #ffffff; border-radius: var(--radius-lg); max-width: 760px; width: 100%; max-height: 94vh; overflow-y: auto; box-shadow: var(--shadow-lg); transform: scale(0.92); transition: all 0.25s ease; }
.modal-overlay.active .modal-box { transform: scale(1); }
.modal-header { background: linear-gradient(135deg, #e0f2fe 0%, #f0f9ff 100%); padding: 20px 24px; border-bottom: 1px solid rgba(186, 230, 253, 0.8); display: flex; justify-content: space-between; align-items: flex-start; }
.modal-title-group h2 { font-size: 1.3rem; color: var(--primary-navy); font-weight: 700; }
.modal-title-group p { color: var(--primary-blue); font-size: 0.92rem; font-weight: 600; }
.modal-close { background: #ffffff; border: 1px solid #cbd5e1; color: #64748b; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; transition: all 0.2s ease; }
.modal-close:hover { background: #f1f5f9; color: #0f172a; }
.modal-body { padding: 24px; }

/* 導師資料精簡專用小彈窗 (Compact Teacher Modal) */
.modal-box.compact-modal {
  max-width: 440px;
  height: auto;
}
.modal-box.compact-modal .modal-header {
  padding: 16px 20px;
  background: linear-gradient(135deg, #f0fdf4 0%, #ffffff 100%);
  border-bottom: 1px solid #dcfce7;
}
.modal-box.compact-modal .modal-title-group h2 {
  font-size: 1.2rem;
  color: #15803d;
}
.modal-box.compact-modal .modal-title-group p {
  color: #16a34a;
}
.modal-box.compact-modal .modal-body {
  padding: 18px 20px;
}

/* 第一圖示 專屬處室組織架構設計 (Header Strip -> Leader Box -> Staff Grid) */
.tree-design-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.tree-design-header-strip {
  width: 100%;
  background: linear-gradient(135deg, #f87171 0%, #f43f5e 100%);
  color: #ffffff;
  padding: 16px 24px;
  border-radius: 18px;
  margin-bottom: 24px;
  text-align: left;
  box-shadow: 0 4px 14px rgba(244, 63, 94, 0.25);
}

.tree-design-header-strip h3 {
  font-size: 1.85rem;
  font-weight: 800;
  color: #ffffff !important;
  margin: 0;
  letter-spacing: 2px;
}

.tree-design-header-strip .en-subtitle {
  font-size: 0.95rem;
  opacity: 0.9;
  font-style: italic;
}

.tree-design-leader-box {
  background: linear-gradient(135deg, #fca5a5 0%, #f43f5e 100%);
  color: #ffffff;
  border-radius: 14px;
  padding: 12px 36px;
  margin-bottom: 24px;
  text-align: center;
  box-shadow: 0 4px 14px rgba(244, 63, 94, 0.3);
}

.leader-pill-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 1px;
}

.leader-pill-name {
  font-size: 1rem;
  font-weight: 700;
  opacity: 0.95;
  margin-top: 2px;
}

.leader-pill-name .ext-tag {
  background: rgba(255, 255, 255, 0.25);
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.8rem;
  margin-left: 6px;
}

.tree-design-staff-grid {
  display: flex;
  flex-wrap: nowrap;
  gap: 16px;
  width: 100%;
  justify-content: center;
}

.tree-design-staff-grid .staff-card-node {
  flex: 0 1 240px;
  max-width: 240px;
  width: 100%;
}

.staff-card-node {
  background: #ffe4e6;
  border: 1px solid #fecdd3;
  border-radius: 14px;
  padding: 14px 8px;
  text-align: center;
  transition: transform 0.2s;
}

.staff-card-node:hover {
  transform: translateY(-3px);
  background: #fecdd3;
}

.staff-title-badge {
  font-size: 1.15rem;
  font-weight: 800;
  color: #9f1239;
  margin-bottom: 4px;
}

.staff-person-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: #881337;
}

.staff-ext {
  font-size: 0.78rem;
  color: #be123c;
  font-weight: 600;
}

.staff-duty-text {
  font-size: 0.78rem;
  color: #9f1239;
  opacity: 0.85;
  margin-top: 6px;
  line-height: 1.3;
}

/* 組別詳細 Modal (第二圖示格式) */
.staff-detail-modal-body {
  padding: 8px 0;
}

.staff-detail-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.staff-detail-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00bce4, #0096c7);
  flex-shrink: 0;
}

.staff-detail-heading {
  font-size: 1.35rem;
  font-weight: 800;
  color: #0f172a;
  margin: 0;
}

.staff-detail-list {
  list-style: disc;
  padding-left: 20px;
  color: #1e293b;
  font-size: 1rem;
  line-height: 2;
}

.staff-detail-list li {
  margin-bottom: 4px;
}

/* 行政處室組織樹狀圖 Modal 樣式 (藍色系列鮮艷漸層) */
.summary-tree-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 8px;
  width: 100%;
}

.summary-tree-root-row {
  display: flex;
  justify-content: center;
  position: relative;
  margin-bottom: 26px;
}

.summary-tree-root-row.no-children::after {
  display: none;
}

.summary-tree-root-row::after {
  content: '';
  position: absolute;
  bottom: -26px;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 26px;
  background-color: #0284c7;
}

.summary-tree-root {
  background: linear-gradient(135deg, #38bdf8 0%, #0284c7 100%);
  border: none;
  border-radius: 20px;
  padding: 16px 36px;
  min-width: 180px;
  cursor: pointer;
  text-align: center;
  box-shadow: 0 8px 22px rgba(2, 132, 199, 0.35);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.summary-tree-root:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 12px 28px rgba(2, 132, 199, 0.5);
  background: linear-gradient(135deg, #60a5fa 0%, #0369a1 100%);
}

.summary-tree-branches-wrapper {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.summary-tree-branches-wrapper.no-root .summary-tree-branch-item-container::before {
  display: none;
}

.summary-tree-line-horizontal {
  height: 2px;
  background-color: #0284c7;
  width: 76%;
  margin-bottom: 26px;
}

.summary-tree-branches {
  display: flex;
  justify-content: space-between;
  width: 100%;
  gap: 12px;
}

.summary-tree-branch-item-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  position: relative;
}

.summary-tree-branch-item-container::before {
  content: '';
  position: absolute;
  top: -26px;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 26px;
  background-color: #0284c7;
}

.summary-tree-branch-item {
  background: linear-gradient(135deg, #38bdf8 0%, #0284c7 100%);
  border: none;
  border-radius: 20px;
  padding: 16px 12px;
  width: 100%;
  cursor: pointer;
  text-align: center;
  box-shadow: 0 6px 18px rgba(2, 132, 199, 0.3);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.summary-tree-branch-item:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 12px 26px rgba(2, 132, 199, 0.48);
  background: linear-gradient(135deg, #60a5fa 0%, #0369a1 100%);
}

.summary-node-header {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 0;
}

.summary-node-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.en-title-span {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  font-style: italic;
  opacity: 0.92;
  margin-top: 2px;
  letter-spacing: 0;
}

/* 搜尋匹配之組別標籤 Pills */
.matched-section-pills {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  width: 100%;
}

.matched-section-pill {
  background: rgba(255, 255, 255, 0.95);
  color: #0369a1;
  border: 1.5px solid #38bdf8;
  border-radius: 12px;
  padding: 6px 14px;
  font-size: 0.9rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  transition: all 0.2s ease;
}

.matched-section-pill:hover {
  background: #ffffff;
  color: #0284c7;
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 6px 16px rgba(2, 132, 199, 0.3);
  border-color: #0284c7;
}

.matched-section-pill .staff-name-sub {
  font-size: 0.8rem;
  opacity: 0.85;
  font-weight: 600;
}

/* 圖示規格之業務職掌 Modal 樣式 */
.duty-modal-container {
  padding: 4px 6px;
  color: #1e293b;
}

.duty-badge-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: #fff1f2;
  border: 1px solid #fecdd3;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 700;
  color: #9f1239;
  margin-bottom: 12px;
}

.duty-header-row {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 14px;
  height: 42px;
}

.duty-circle-bg {
  position: absolute;
  left: -10px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  opacity: 0.85;
  z-index: 1;
}

.duty-title-text {
  position: relative;
  z-index: 2;
  font-size: 1.65rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
  padding-left: 12px;
}

.duty-content-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 1.08rem;
  line-height: 1.5;
  color: #334155;
  padding-left: 16px;
  margin-bottom: 14px;
}

.duty-list-item {
  display: flex;
  align-items: flex-start;
  gap: 4px;
}

.duty-num {
  font-weight: 700;
  color: #1e293b;
  flex-shrink: 0;
}

.duty-text {
  color: #334155;
}

.duty-phone-row {
  font-size: 1.08rem;
  font-weight: 600;
  color: #1e293b;
  padding-left: 16px;
}

.bullet-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  line-height: 1.5;
  font-size: 1.08rem;
  color: #1e293b;
}

.bullet-item.indent {
  padding-left: 20px;
}

.bullet-dot {
  font-weight: bold;
  color: #1e293b;
  flex-shrink: 0;
}

/* 文字較多時的緊湊模式 (Compact Dense Mode for 10+ Items) */
.duty-modal-container.compact-dense {
  padding: 2px 4px;
}

.duty-modal-container.compact-dense .duty-badge-tag {
  margin-bottom: 8px;
  padding: 2px 8px;
  font-size: 0.85rem;
}

.duty-modal-container.compact-dense .duty-header-row {
  margin-bottom: 8px;
  height: 36px;
}

.duty-modal-container.compact-dense .duty-circle-bg {
  width: 36px;
  height: 36px;
}

.duty-modal-container.compact-dense .duty-title-text {
  font-size: 1.5rem;
}

.duty-modal-container.compact-dense .duty-content-body {
  gap: 2px;
  font-size: 0.92rem;
  line-height: 1.36;
  margin-bottom: 6px;
}

.duty-modal-container.compact-dense .bullet-item {
  font-size: 0.92rem;
  line-height: 1.36;
}

.duty-modal-container.compact-dense .duty-phone-row {
  font-size: 0.92rem;
}

.summary-node-ext {
  font-size: 0.78rem;
  color: #0284c7;
  background: rgba(14,165,233,0.12);
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
}

.summary-node-leader {
  font-size: 0.88rem;
  font-weight: 700;
  color: #0284c7;
  margin-bottom: 4px;
}

.summary-node-duty {
  font-size: 0.78rem;
  color: #0369a1;
  opacity: 0.8;
  line-height: 1.4;
}

/* Toast */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 2000; display: flex; flex-direction: column; gap: 10px; }
.toast { background: #0f172a; color: #ffffff; padding: 12px 20px; border-radius: var(--radius-md); font-size: 0.9rem; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 10px; }

footer { margin-top: 60px; padding: 30px 0; border-top: 1px solid rgba(186, 230, 253, 0.6); text-align: center; color: var(--text-muted); font-size: 0.9rem; }

@media (max-width: 900px) {
  .grade-teachers-row-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .portal-grid { grid-template-columns: 1fr; }
  .tree-branches { flex-direction: column; align-items: center; gap: 30px; }
  .tree-branches::before { display: none; }
  .tree-branch-item::before { top: -30px; }
  .navbar { flex-direction: column; align-items: flex-start; gap: 16px; }
  .grade-teachers-row-grid { grid-template-columns: 1fr; }
}


/* ---- 首頁搜尋框 + 搜尋按鈕列 ---- */
.portal-search-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.portal-search-row .search-wrapper {
  flex: 1;
  margin-bottom: 0 !important;
}

.btn-portal-search {
  flex-shrink: 0;
  padding: 10px 20px;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(239,68,68,0.3);
  transition: transform 0.15s, box-shadow 0.15s;
  letter-spacing: 0.05em;
}

.btn-portal-search:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(239,68,68,0.45);
}

.btn-portal-search:active {
  transform: translateY(0);
}

.btn-portal-search.green {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  box-shadow: 0 2px 8px rgba(34,197,94,0.3);
}

.btn-portal-search.green:hover {
  box-shadow: 0 4px 14px rgba(34,197,94,0.45);
}

/* ── 樹狀圖節點：主任/校長姓名副標 ── */
.summary-node-leader {
  margin-top: 6px;
  font-size: 0.82rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.88);
  letter-spacing: 0.03em;
  text-align: center;
  line-height: 1.4;
}

.summary-node-leader strong {
  font-weight: 700;
  color: #ffffff;
}

