/* ─── 載入開源 芫荽體 (Iansui) ─── */
@font-face {
  font-family: 'Iansui';
  src: url('https://cdn.jsdelivr.net/gh/ButTaiwan/iansui@main/dist/Iansui-Regular.woff2') format('woff2'),
       url('https://cdn.jsdelivr.net/npm/font-iansui@0.9.3/Iansui-Regular.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@400;700;900&display=swap');

:root {
  --app-bg: #f8fafc;
  --panel-bg: rgba(255, 255, 255, 0.85);
  --panel-border: rgba(255, 255, 255, 0.95);
  --bb-green: #1a3c23;
  --chalk: #fff8dc;
  --chalk-yellow: #fef08a;
  --chalk-blue: #93c5fd;
  --accent: #0284c7;
  --accent-dark: #0369a1;
  --text: #1e293b;
  --text-dim: #64748b;
  --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Iansui', '芫荽', 'Noto Sans TC', sans-serif;
  background: var(--app-bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  position: relative;
}

/* 柔和液態背景 */
body::before, body::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  z-index: -1;
  pointer-events: none;
}
body::before {
  top: -10%; left: -10%; width: 50vw; height: 50vw;
  background: radial-gradient(circle, rgba(14, 165, 233, 0.16) 0%, rgba(139, 92, 246, 0.06) 100%);
}
body::after {
  bottom: -10%; right: -10%; width: 55vw; height: 55vw;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.1) 0%, rgba(236, 72, 153, 0.06) 100%);
}

/* ── 主佈局（桌面版） ── */
.app-layout {
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: 22px;
  max-width: 1800px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
  align-items: start;
}

.sidebar-scroll {
  display: flex; flex-direction: column; gap: 14px;
  position: sticky; top: 20px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  padding-right: 4px;
}
.sidebar-scroll::-webkit-scrollbar { width: 5px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); border-radius: 999px; }

.board-wrap {
  display: flex; flex-direction: column; gap: 10px;
  position: sticky; top: 20px;
  width: 100%;
}

/* ── 手機平板自適應優化 (Mobile RWD) ── */
.mobile-tabs { display: none; }

@media (max-width: 960px) {
  .app-layout {
    display: flex;
    flex-direction: column;
    padding: 12px;
    gap: 14px;
    min-height: auto;
  }
  
  .sidebar-scroll {
    position: static;
    max-height: none;
    overflow: visible;
    padding-right: 0;
    width: 100%;
  }

  .board-wrap {
    position: static;
    width: 100%;
  }

  /* 手機版分頁切換按鈕 */
  .mobile-tabs {
    display: flex;
    gap: 8px;
    background: rgba(0, 0, 0, 0.06);
    padding: 4px;
    border-radius: 12px;
    margin-bottom: 6px;
    width: 100%;
  }
  .mobile-tab-btn {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px;
    font-size: 14px;
    font-weight: 800;
    color: var(--text-dim);
    border-radius: 9px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
  }
  .mobile-tab-btn.active {
    background: #fff;
    color: var(--accent-dark);
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  }
}

/* ── 標題卡片 Banner ── */
.banner-card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  padding: 16px 20px;
  background: linear-gradient(135deg, #1e3a8a 0%, #0284c7 100%);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 10px 25px rgba(2, 132, 199, 0.15);
  color: #fff;
}
.banner-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 20px; font-weight: 900; letter-spacing: 0.5px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.banner-sub {
  font-size: 13px; color: rgba(255,255,255,0.88);
  margin-top: 4px; font-weight: 500;
}

/* ── 玻璃面版 ── */
.panel {
  background: var(--panel-bg);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.03), inset 0 1px 1px rgba(255, 255, 255, 0.8);
}

.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  background: rgba(255,255,255,0.5);
}
.panel-header-left { display: flex; align-items: center; gap: 8px; }
.panel-title { font-size: 14px; font-weight: 800; color: var(--text); }
.panel-body { padding: 14px 16px; }

/* ── 簡潔日期導覽條 ── */
.date-bar-wrap {
  display: flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid rgba(0,0,0,0.1);
  border-radius: 10px; padding: 6px 10px;
}
.date-bar-input {
  border: none; outline: none; background: transparent;
  font-family: inherit; font-size: 15px; font-weight: 800;
  color: var(--accent-dark); flex: 1; min-width: 0;
}
.date-nav-btn {
  background: #f1f5f9; border: none;
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; cursor: pointer; color: var(--text-dim);
  transition: all 0.15s;
}
.date-nav-btn:hover { background: #e2e8f0; color: var(--text); }

/* ── 留言輸入區 (非常顯眼) ── */
.msg-form-box {
  background: #f0f9ff;
  border: 1.5px solid #bae6fd;
  border-radius: 12px;
  padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
  margin-bottom: 14px;
}
.msg-form-title {
  font-size: 12px; font-weight: 800; color: var(--accent-dark);
  display: flex; align-items: center; gap: 5px;
}
.msg-form-row {
  display: flex; gap: 8px; align-items: center;
}
.msg-select-role {
  border: 1px solid #94a3b8; border-radius: 8px;
  padding: 6px 8px; font-family: inherit; font-size: 13px;
  background: #fff; font-weight: 700; color: var(--text);
  outline: none;
}
.msg-input-name {
  flex: 1; border: 1px solid #94a3b8; border-radius: 8px;
  padding: 6px 10px; font-family: inherit; font-size: 13px;
  background: #fff; outline: none;
}
.msg-textarea {
  width: 100%; border: 1px solid #94a3b8; border-radius: 8px;
  padding: 10px; font-family: inherit; font-size: 14px;
  resize: vertical; min-height: 60px; outline: none;
  background: #fff;
}
.msg-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(2,132,199,0.2); }

.btn-send-msg {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: #fff; border: none; border-radius: 8px;
  padding: 8px 14px; font-size: 13px; font-weight: 800;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  gap: 6px; font-family: inherit; transition: opacity 0.2s;
}
.btn-send-msg:hover { opacity: 0.92; }

/* ── 留言列表 ── */
.msg-list-wrap {
  display: flex; flex-direction: column; gap: 10px;
  max-height: 320px; overflow-y: auto; padding-right: 4px;
  margin-bottom: 12px;
}
.msg-item {
  background: #fffbeb;
  border: 1px solid #fef3c7;
  border-left: 4px solid #f59e0b;
  border-radius: 10px;
  padding: 10px 12px;
}
.msg-item.role-teacher {
  background: #eff6ff; border-color: #dbeafe; border-left-color: #3b82f6;
}
.msg-item.role-parent {
  background: #f0fdf4; border-color: #dcfce7; border-left-color: #10b981;
}

.msg-item-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px; font-size: 11px; color: var(--text-dim);
}
.msg-author { font-weight: 900; color: var(--text); }
.msg-time { font-size: 10px; opacity: 0.8; }
.msg-body-text {
  font-size: 13px; line-height: 1.5; color: #334155;
  white-space: pre-wrap; word-break: break-word; font-weight: 600;
}

.msg-empty-hint {
  text-align: center; color: #94a3b8; font-size: 13px;
  padding: 20px 10px; font-style: italic; background: #fff;
  border-radius: 10px; border: 1px dashed #cbd5e1;
}

.btn-archive {
  background: #fff; border: 1px solid #cbd5e1;
  color: #475569; border-radius: 8px; padding: 5px 10px;
  font-size: 11px; font-weight: 700; cursor: pointer;
}
.btn-archive:hover { background: #f1f5f9; }

/* ── 按鈕類 ── */
.btn-admin {
  background: #fff; color: #334155;
  border: 1.5px solid #cbd5e1; border-radius: 12px;
  padding: 12px 14px; font-size: 14px; font-weight: 800;
  cursor: pointer; width: 100%; font-family: inherit;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; transition: all 0.2s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.03);
}
.btn-admin:hover { background: #f1f5f9; border-color: #94a3b8; }

.btn-copy {
  background: linear-gradient(135deg, #059669, #047857);
  color: #fff; border: none; border-radius: 10px;
  padding: 11px 14px; font-size: 13px; font-weight: 800;
  cursor: pointer; width: 100%; font-family: inherit;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; transition: opacity 0.2s;
}
.btn-copy:hover { opacity: 0.92; }

.btn-primary {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: #fff; border: none; border-radius: 8px;
  padding: 8px 16px; font-size: 13px; font-weight: 800;
  cursor: pointer; font-family: inherit;
}
.btn-secondary {
  background: #f1f5f9; color: var(--text);
  border: 1px solid #cbd5e1; border-radius: 8px;
  padding: 6px 12px; font-size: 12px; font-weight: 700;
  cursor: pointer; font-family: inherit;
}

.input-field {
  width: 100%; border: 1px solid #cbd5e1; background: #fff;
  border-radius: 10px; padding: 10px; font-size: 13px;
  font-family: inherit; line-height: 1.5; color: var(--text);
  resize: vertical; outline: none;
}

/* ── 黑板畫布（芫荽體標準直式注音） ── */
.blackboard-bg {
  background-color: var(--bb-green);
  background-image: 
    radial-gradient(ellipse at 50% 50%, rgba(35, 78, 48, 0.9) 0%, rgba(20, 48, 28, 0.98) 100%),
    radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.03) 0%, transparent 40%);
  border: 12px solid #5c3a21;
  border-radius: 14px;
  box-shadow: 
    inset 0 0 25px rgba(0,0,0,0.7),
    0 10px 25px rgba(0,0,0,0.2);
  color: var(--chalk);
  user-select: none;
  position: relative;
  overflow: hidden;
  font-family: 'Iansui', '芫荽', serif;
}

@media (max-width: 600px) {
  .blackboard-bg {
    border-width: 8px;
  }
}

.btn-fullscreen {
  position: absolute; top: 10px; right: 10px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff; border: 1px solid rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(8px);
  padding: 6px 10px; border-radius: 8px;
  font-size: 12px; font-weight: 700;
  cursor: pointer; z-index: 10;
}

.bb-sticky-note {
  position: absolute; left: 16px; bottom: 16px;
  max-width: 300px;
  background: rgba(254, 240, 138, 0.16);
  border: 1.5px dashed rgba(254, 240, 138, 0.6);
  border-radius: 8px; padding: 8px 12px;
  backdrop-filter: blur(4px);
  color: var(--chalk-yellow);
  z-index: 5;
}
.bb-sticky-title {
  font-size: 12px; font-weight: 900; margin-bottom: 3px;
  border-bottom: 1px dashed rgba(254, 240, 138, 0.3);
  padding-bottom: 2px; color: #fef9c3;
}
.bb-sticky-content {
  font-size: 11px; line-height: 1.4; font-weight: 600;
  white-space: pre-wrap;
}

.bb-zhuyin-track {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  line-height: 1; flex-shrink: 0;
  font-family: 'Iansui', '芫荽', serif;
}
.bb-zy-char { position: relative; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.bb-zy-tone { position: absolute; right: -0.6em; top: 50%; transform: translateY(-50%); font-size: 0.85em; }
.bb-zy-light { display: flex; align-items: center; justify-content: center; font-size: 0.85em; font-weight: 900; }

/* ── 彈窗 ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  z-index: 999;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.admin-modal-card {
  background: #fff;
  width: 100%; max-width: 740px;
  max-height: 90vh;
  border-radius: var(--radius);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.admin-modal-header {
  padding: 14px 18px; border-bottom: 1px solid #e2e8f0;
  display: flex; align-items: center; justify-content: space-between;
  background: #f8fafc;
}
.admin-modal-title { font-size: 16px; font-weight: 900; color: #0f172a; }
.admin-modal-body {
  padding: 16px 18px; overflow-y: auto; flex: 1;
  display: flex; flex-direction: column; gap: 16px;
}
.admin-modal-footer {
  padding: 12px 18px; border-top: 1px solid #e2e8f0;
  background: #f8fafc; display: flex; justify-content: flex-end; gap: 10px;
}

.admin-section {
  background: #f8fafc; border: 1px solid #e2e8f0;
  border-radius: 12px; padding: 14px;
}
.admin-section-title {
  font-size: 13px; font-weight: 900; color: #334155;
  margin-bottom: 8px; display: flex; align-items: center; gap: 6px;
}

.overrides-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px; max-height: 220px; overflow-y: auto; padding-right: 4px;
}
.override-item {
  display: flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid #cbd5e1;
  border-radius: 8px; padding: 6px 8px;
}
.override-char { font-size: 18px; font-weight: 900; min-width: 22px; text-align: center; }
.override-input {
  width: 100%; border: 1px solid #cbd5e1; border-radius: 4px;
  padding: 4px 6px; font-size: 12px; font-weight: 700; outline: none;
}
