/* ==========================================================================
   会议室预约 —— 样式
   ========================================================================== */

:root {
  --slot: 64px;
  --room-w: 132px;
  --bg: #f2f4f7;
  --card: #ffffff;
  --text: #1b1f27;
  --muted: #7a8291;
  --line: #eaedf2;
  --line-strong: #dde2ea;
  --blue: #2563eb;
  --blue-soft: #eaf1fe;
  --blue-deep: #1d4ed8;
  --green: #0f8a5f;
  --green-soft: #e6f7ef;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 10px 30px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

button, input, select { font-family: inherit; font-size: inherit; }

.hidden { display: none !important; }

/* 原生日期选择器需要一个“存在但不可见”的输入框 */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------------- 顶栏 ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 64px;
  padding: 0 20px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  box-shadow: 0 0 0 4px var(--blue-soft);
  flex: none;
}

.brand h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.datenav {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 auto;
}

.iconbtn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 10px;
  font-size: 18px;
  line-height: 1;
  color: #48505e;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s, border-color 0.15s;
}

.iconbtn:hover { background: #f6f8fb; border-color: #cfd6e2; }

.datepill {
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 10px;
  padding: 5px 14px;
  min-width: 132px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  transition: background 0.15s;
}

.datepill:hover { background: #f6f8fb; }
.datepill b { font-size: 14px; font-weight: 650; }
.datepill span { font-size: 11px; color: var(--muted); }

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

.ghostbtn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: #48505e;
  text-decoration: none;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}

.ghostbtn:hover { background: #f6f8fb; }

/* ---------------- 主体 ---------------- */

.wrap {
  max-width: 1680px;
  margin: 0 auto;
  padding: 18px 20px 40px;
}

.board {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.scroller {
  overflow: auto;
  max-height: calc(100vh - 210px);
  overscroll-behavior: contain;
}

.sheet { position: relative; width: max-content; min-width: 100%; }

/* 表头 */

.thead {
  position: sticky;
  top: 0;
  z-index: 6;
  display: flex;
  background: #fff;
  border-bottom: 1px solid var(--line-strong);
}

.corner {
  position: sticky;
  left: 0;
  z-index: 8;
  flex: none;
  width: var(--room-w);
  display: flex;
  align-items: flex-end;
  padding: 0 12px 9px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: #fff;
  border-right: 1px solid var(--line-strong);
}

.timescale { display: flex; }

.timescale .t {
  flex: none;
  width: var(--slot);
  padding: 8px 0 9px;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  border-right: 1px solid transparent;
}

.timescale .t.hour { color: #3d4552; border-right-color: var(--line); font-weight: 600; }

/* 行 */

.row {
  display: flex;
  height: 58px;
  border-bottom: 1px solid var(--line);
}

.row:last-child { border-bottom: none; }

.room {
  position: sticky;
  left: 0;
  z-index: 4;
  flex: none;
  width: var(--room-w);
  display: flex;
  align-items: center;
  padding: 0 12px;
  background: #fcfcfd;
  border-right: 1px solid var(--line-strong);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  color: #2c333f;
}

.track {
  position: relative;
  display: flex;
  flex: none;
}

.cell {
  flex: none;
  width: var(--slot);
  height: 100%;
  border-right: 1px solid #f4f6f9;
  cursor: pointer;
  transition: background 0.12s;
}

.cell.hour { border-right-color: var(--line); }
.cell:hover { background: #f3f7ff; }
.cell.past { cursor: not-allowed; background: #eef1f6; }
.cell.past:hover { background: #eef1f6; }

/* 预约块 */

.bk {
  position: absolute;
  top: 5px;
  bottom: 5px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  padding: 4px 9px;
  border-radius: 9px;
  background: linear-gradient(180deg, #eef4ff, #e4eeff);
  border-left: 3px solid #4b83f0;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.08);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
}

.bk:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(37, 99, 235, 0.16); }

.bk .bk-name {
  font-size: 12px;
  font-weight: 650;
  color: #1c3f8f;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bk .bk-time {
  font-size: 10.5px;
  color: #5b76ab;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 只有一个时段宽的时候只放名字，避免时间被截成 “11:30–…” */
.bk.narrow .bk-time { display: none; }
.bk.narrow { padding: 4px 6px; }

.bk.ongoing {
  background: linear-gradient(180deg, #e9f8f1, #dcf3e8);
  border-left-color: #16a36a;
}

.bk.ongoing .bk-name { color: #0b6b47; }
.bk.ongoing .bk-time { color: #3d8a6c; }

/* 当前时间线 */

.nowline {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  border-left: 1.5px solid #f04438;
  z-index: 5;
  pointer-events: none;
  opacity: 0.85;
}

/* ---------------- 图例 / 提示 ---------------- */

.foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding: 14px 4px 0;
  font-size: 12px;
  color: var(--muted);
}

.legend { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

.swatch { width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--line-strong); }
.swatch.free { background: #fff; }
.swatch.booked { background: linear-gradient(180deg, #eef4ff, #e4eeff); border-color: #c7d9fb; }
.swatch.now { background: var(--green-soft); border-color: #b7e6d1; }
.swatch.past { background: #eef1f6; }

.foot .spacer { flex: 1; }
.foot .count { color: #3d4552; font-weight: 600; }

/* ---------------- 近期预约 ---------------- */

.upcoming {
  margin-top: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px 10px;
}

.up-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.up-head h2 { margin: 0; font-size: 14px; font-weight: 650; }
.up-count { font-size: 12px; color: var(--muted); }

.up-group { padding: 8px 0; border-top: 1px solid #f1f4f8; }
.up-group:first-child { border-top: none; }

.up-date { font-size: 12px; color: #5b6472; font-weight: 600; margin-bottom: 4px; }

.up-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.12s;
}

.up-row:hover { background: #f6f9ff; }

.up-time {
  width: 104px;
  flex: none;
  color: #5b76ab;
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
}

.up-room { flex: none; width: 118px; color: #3d4552; }

.up-name {
  font-weight: 600;
  color: #1b1f27;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.up-empty { color: var(--muted); font-size: 12.5px; padding: 10px 0; }

/* ---------------- 悬浮预约按钮 ---------------- */

.fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 60;
  height: 46px;
  padding: 0 20px;
  border: none;
  border-radius: 23px;
  background: var(--blue);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.3);
  transition: transform 0.12s, background 0.15s;
}

.fab:hover { background: var(--blue-deep); }
.fab:active { transform: scale(0.97); }

/* ---------------- 弹窗 ---------------- */

dialog {
  border: none;
  padding: 0;
  border-radius: 18px;
  width: min(92vw, 400px);
  background: #fff;
  box-shadow: 0 24px 64px rgba(16, 24, 40, 0.22);
  color: var(--text);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(3px);
}

.dlg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 6px;
}

.dlg-head h2 { margin: 0; font-size: 16px; font-weight: 650; }

.xbtn {
  border: none;
  background: #f3f5f8;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  color: #6b7280;
  cursor: pointer;
  font-size: 13px;
  display: grid;
  place-items: center;
}

.xbtn:hover { background: #e9edf3; }

.dlg-body { padding: 4px 20px 18px; }

.dlg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  margin-bottom: 14px;
  background: #f6f8fb;
  border-radius: 10px;
  font-size: 13px;
  color: #3d4552;
}

.dlg-meta b { font-weight: 650; }
.dlg-meta .sep { color: #c3c9d4; }

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }

.field input,
.field select {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus,
.field select:focus {
  border-color: #9dbcf7;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.row2 { display: flex; gap: 10px; }
.row2 .field { flex: 1; }

.dlg-err {
  min-height: 18px;
  margin: 2px 0 6px;
  font-size: 12.5px;
  color: #d92d20;
}

.dlg-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 20px;
}

.dlg-foot .grow { flex: 1; }

.primary {
  height: 42px;
  padding: 0 20px;
  border: none;
  border-radius: 10px;
  background: var(--blue);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.primary:hover { background: var(--blue-deep); }
.primary:active { transform: translateY(1px); }
.primary[disabled] { background: #a9bde8; cursor: default; }

.danger {
  height: 42px;
  padding: 0 16px;
  border: 1px solid #f3c6c2;
  border-radius: 10px;
  background: #fff;
  color: #d92d20;
  font-weight: 600;
  cursor: pointer;
}

.danger:hover { background: #fdf3f2; }

/* 轻提示 */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 12px);
  background: #1f2937;
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
  max-width: 86vw;
  text-align: center;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 笔记本屏幕：压缩一格宽度，让 08:30–20:00 一屏放下 */
@media (min-width: 761px) and (max-width: 1520px) {
  :root { --slot: 52px; --room-w: 118px; }
  .corner, .room { padding: 0 9px; }
  .room { font-size: 12.5px; }
  .timescale .t { font-size: 10.5px; }
  .bk .bk-name { font-size: 11.5px; }
  .bk .bk-time { font-size: 10px; }
}

/* ---------------- 小屏 ---------------- */

@media (max-width: 760px) {
  :root { --slot: 58px; --room-w: 98px; }

  .topbar { height: 56px; padding: 0 12px; gap: 8px; }
  .brand h1 { font-size: 14px; }
  .brand-dot { box-shadow: 0 0 0 3px var(--blue-soft); }
  .datepill { min-width: 104px; padding: 3px 8px; }
  .datepill b { font-size: 13px; }
  .iconbtn { width: 30px; height: 30px; font-size: 16px; }
  .actions { display: none; }
  .wrap { padding: 10px 10px 28px; }
  .scroller { max-height: calc(100vh - 175px); }
  .room { font-size: 11.5px; padding: 0 7px; }
  .row { height: 52px; }
  .bk { padding: 3px 6px; top: 4px; bottom: 4px; border-radius: 7px; }
  .bk .bk-name { font-size: 11px; }
  .bk .bk-time { font-size: 9.5px; }
  .corner { padding: 0 7px 8px; font-size: 11px; }

  .foot { gap: 8px; flex-direction: column; align-items: flex-start; }
  .foot .spacer { display: none; }
  #exportLink { display: none; }
  .foot .count { margin-left: 0; }

  .upcoming { padding: 12px 12px 8px; margin-top: 12px; }
  .up-time { width: 92px; }
  .up-room { width: 84px; font-size: 12px; }
  .up-row { gap: 8px; padding: 7px 4px; }
  .fab { right: 16px; bottom: 16px; height: 44px; padding: 0 18px; }
}
