/* ===== 全站變數（主題色） ===== */
:root {
  --bg: #f5f5f5;
  --accent-hero: #e3f2fd;
  --accent-tools: #fff3e0;
  --accent-about: #ede7f6;
}

/* ===== 基本設定 ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  height: 100%;
  display: flex;
  flex-direction: column;   /* 上：nav，中：內容，下：footer */
  overflow: hidden;         /* 禁止整個視窗捲動，只讓中間內容捲 */
  font-family: -apple-system, BlinkMacSystemFont, "Noto Sans TC", sans-serif;
  background: var(--bg);
  color: #333;
}

/* 打開漢堡選單時，鎖住中間內容捲動 */
body.menu-open .content-scroll {
  overflow: hidden;
}

/* ===== 置頂導覽列（玻璃質感） ===== */
.top-nav {
  height: 56px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  position: relative;
  z-index: 300;
}

/* 導覽列左側：Logo + 標題 */
.nav-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
  color: inherit;
}

.nav-logo-img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.nav-logo-text {
  white-space: nowrap;
}

/* 中間：依身份顯示的選單（桌機置中） */
.nav-links {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* 導覽列右側：角色資訊 + 登入按鈕 */
.nav-auth {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 登入前 / 後的角色文字 */
.nav-mode-message {
  font-size: 0.75rem;
  color: #666;
  max-width: 260px;
  text-align: right;
  white-space: nowrap;    /* 🔥 不換行 */
}

/* 角色選擇（開發階段用） */
.role-selector {
  font-size: 0.75rem;
  padding: 2px 4px;
  border-radius: 6px;
  border: 1px solid #ddd;
  background: #fff;
}

.auth-button {
  border: none;
  background: transparent;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.8rem;
  color: #1976d2;
  white-space: nowrap;    /* 🔥 不換行 */
}

.auth-button:hover {
  background: rgba(25, 118, 210, 0.08);
}

/* 角色專用選單（桌機：橫排） */
.nav-role-links {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 0.9rem;
}


.nav-role-links a {
  text-decoration: none;
  color: #555;
  padding: 4px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.nav-role-links a:hover {
  background: rgba(0, 0, 0, 0.04);
}

/* ===== 手機版遮罩用容器（長在 page 上） ===== */
.nav-overlay {
  display: none;   /* 預設隱藏，手機版才會啟用 */
}

/* 可重複使用的狀態顯示元件 */
.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ccc;
}

.status-dot--connected {
  background: #4caf50;
}

.status-dot--disconnected {
  background: #f44336;
}

.status-text {
  color: #555;
}

/* ===== 頁面主體 / 捲動區 ===== */
.content-scroll {
  flex: 1;
  overflow-y: auto;   /* 捲軸在這裡 */
  width: 100%;
  position: relative; /* 給 nav-overlay 定位用 */
}

.page {
  max-width: 1000px;
  width: 100%;
  margin: 0 auto;
  padding: 16px 16px 24px;
}

/* 區塊共用樣式 */
.section,
.hero {
  border-radius: 16px;
  padding: 24px 20px;
  margin-bottom: 24px;
}

/* Hero 區塊（首頁主標） */
.hero {
  background: var(--accent-hero);
}

.hero h1 {
  margin: 0;
  white-space: nowrap; /* 避免 h1 自己換行 */
  font-size: 2.4rem;
}

.hero p {
  margin: 4px 0;
}

.hero-sub {
  font-size: 0.9rem;
  color: #555;
}

.hero-header {
  display: flex;
  align-items: center;
  gap: 16px; /* logo 與文字距離 */
  justify-content: left; /* 居左 */
  flex-wrap: nowrap; /* 禁止換行，避免縮小後變成兩列 */
}

.hero-logo-inline {
  width: 64px;
  height: auto;
}


/* 功能區塊 */
.tools-section {
  background: var(--accent-tools);
}

.tools-section h2,
.about-section h2 {
  margin-top: 0;
  margin-bottom: 12px;
}

/* 工具卡片排版 */
.tool-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.tool-card {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 12px;
  padding: 14px 12px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.tool-card h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.tool-card p {
  margin: 0;
  font-size: 0.85rem;
  color: #555;
}

/* ===== 課堂點名列表（示範） ===== */
.attendance-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.attendance-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.attendance-name {
  font-size: 0.95rem;
}

.status-pill {
  min-width: 64px;
  padding: 4px 10px;
  border-radius: 999px;
  border: none;
  font-size: 0.8rem;
  cursor: pointer;
}

.status-pill--absent {
  background: #ffebee;
  color: #c62828;
}

.status-pill--present {
  background: #e8f5e9;
  color: #2e7d32;
}

/* ===== 頁腳 ===== */
.site-footer {
  flex-shrink: 0;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.9);
  position: relative;
  z-index: 300;
}

.footer-inner {
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.8rem;
}

.footer-left,
.footer-center,
.footer-right {
  display: flex;
  align-items: center;
}

.footer-center {
  flex: 1;
  justify-content: center;
  text-align: center;
}

/* 桌機：只顯示完整版 copy，隱藏簡短版 */
.footer-copy-full {
  display: inline;
}

.footer-copy-compact {
  display: none;
}

.footer-right {
  justify-content: flex-end;
}

.footer-widget {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.03);
}

.widget-title {
  color: #666;
}

@media (max-width: 600px) {
  .footer-inner {
    flex-direction: row;          /* 🔥 保持一列 */
    align-items: center;
    justify-content: space-between;
    width: 100%;
  }

  /* 左邊：只顯示紅綠燈，不顯示文字 */
  .status-text {
    display: none;
  }

  /* 中間：顯示精簡版，隱藏完整版 */
  .footer-copy-full {
    display: none;
  }

  .footer-copy-compact {
    display: inline;
  }

  /* 右邊：小工具區保持在右側 */
  .footer-right {
    justify-content: flex-end;
  }
}


/* 關於區塊 */
.about-section {
  background: var(--accent-about);
  font-size: 0.9rem;
}

/* 平板以上：工具卡片變兩欄 */
@media (min-width: 768px) {
  .tool-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ===== 導覽列：目前所在的標籤（Active 狀態） ===== */
.nav-role-links a.active-nav {
  background: rgba(25, 118, 210, 0.12);
  color: #0d47a1;
  font-weight: 600;
}

.nav-role-links a.active-nav:hover {
  background: rgba(25, 118, 210, 0.18);
}

/* ===== 漢堡按鈕（桌機預設隱藏） ===== */
.nav-menu-toggle {
  display: none;
  border: none;
  background: transparent;
  padding: 4px;
  margin-right: 8px;
  cursor: pointer;
  border-radius: 999px;
}

.nav-menu-toggle span {
  display: block;
  width: 20px;
  height: 3px;
  border-radius: 999px;
  background: #33333360;
  margin: 3px 0;
}

.nav-menu-toggle.is-open {
  background: rgba(0, 0, 0, 0.06);
}

/* ===== 手機版：漢堡 + page 遮罩選單（不蓋 nav/footer） ===== */
@media (max-width: 1000px) {
  /* 中間 nav：漢堡置中 */
  .nav-links {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* 顯示漢堡 */
  .nav-menu-toggle {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }

  /* 手機時隱藏 nav 中的橫向選單，改用 overlay */
  .nav-role-links {
    display: none;
  }

  /* 手機版：覆蓋在 page（content-scroll）上的遮罩 */
    .nav-overlay {
    position: fixed;                  /* ✅ 固定在視窗，不受捲動影響 */
    top: 0;                           /* 先暫時設 0，會由 JS 動態調整 */
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 200;                     /* 小於 nav/footer 的 300 */

    display: none;
    justify-content: center;
    align-items: center;
    padding: 16px;
    box-sizing: border-box;
  }


  .nav-overlay.nav-overlay-open {
    display: flex;
  }

  /* 遮罩中的白色面板 */
  .nav-overlay-panel {
    width: 100%;
    max-width: 360px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;

    /* ✅ 最大高度交給 JS 算好塞進「頁頭 + 頁尾」之間 */
    max-height: 100%;
    overflow-y: auto;
  }


  .nav-overlay-links a {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    text-align: center;
    text-decoration: none;
    color: #333;
    font-size: 0.95rem;
  }

  .nav-overlay-links a:hover {
    background: #e0e0e0;
  }

  .nav-overlay-links a.active-nav {
    background: #1976d2;
    color: #fff;
    font-weight: 600;
  }
  
}
