/* 智能会议门牌 · 员工预约端 · 时间轴日历视图（24h 自适应铺满，无水平滚动） */
:root {
  --primary: #185FA5;
  --primary-dark: #0C447C;
  --primary-bg: #E6F1FB;
  --bg: #f2f4f7;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e9f0;
  --past: rgba(220, 226, 235, 0.55);
  --past-edge: #c5ccd6;
  --now: #ef4444;
  --danger: #c0392b;
  --success: #0F6E56;
  --rowH: 64px;     /* 每行会议室高度 */
  --sideW: 200px;   /* 左侧会议室列宽度 */
  --headH: 38px;    /* 时间轴头部高度 */
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5;
}

/* 顶部栏 */
.topbar {
  height: 52px; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; padding: 0 16px;
}
.topbar .title { font-size: 16px; font-weight: 600; color: var(--primary-dark); margin-right: 4px; }
.topbar select, .topbar input[type=date] {
  height: 32px; border: 1px solid var(--border); border-radius: 7px;
  padding: 0 10px; font-size: 13px; background: #fff; color: var(--text); outline: none;
}
.topbar select { padding-right: 22px; }
.topbar .spacer { flex: 1; }
.topbar a { color: var(--primary); text-decoration: none; font-size: 13px; }
.topbar .legend { display: flex; gap: 8px; font-size: 11.5px; color: var(--muted); margin-right: 6px; align-items: center; }
.topbar .legend span { display: inline-flex; align-items: center; gap: 3px; }
.topbar .legend i { width: 11px; height: 11px; border-radius: 2px; display: inline-block; }

/* 主区 */
.main { height: calc(100vh - 52px); }
.grid-wrap { height: 100%; overflow: auto; background: #fff; position: relative; }
.grid-inner { width: 100%; position: relative; min-width: 620px; } /* 窄屏兜底 */

/* 时间轴头部：左 corner + 右时间刻度轨道 */
.time-header {
  display: grid; grid-template-columns: var(--sideW) 1fr;
  height: var(--headH); background: #fafbfd; border-bottom: 1px solid var(--border);
  font-size: 11px; color: var(--muted);
  position: sticky; top: 0; z-index: 7;
}
.time-header .corner {
  position: sticky; left: 0; z-index: 9;
  background: #fafbfd; border-right: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 12px;
  font-size: 12px; font-weight: 600; color: var(--primary-dark);
}
.head-track { display: grid; grid-template-columns: repeat(24, 1fr); }
.head-track .hcell {
  display: flex; align-items: center; justify-content: center;
  border-right: 1px solid var(--border); overflow: hidden;
}
.head-track .hcell.now-hour { color: var(--now); font-weight: 600; }

/* 会议室行：左 sticky 名称列 + 右时间轨道 */
.grid-row {
  display: grid; grid-template-columns: var(--sideW) 1fr;
  min-height: var(--rowH); border-bottom: 1px solid var(--border);
}
.grid-row .row-head {
  position: sticky; left: 0; z-index: 5;
  background: #fff; border-right: 1px solid var(--border);
  padding: 8px 12px; display: flex; flex-direction: column; justify-content: center;
}
.grid-row .row-head .name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid-row .row-head .meta { font-size: 11px; color: var(--muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-track { position: relative; display: grid; grid-template-columns: repeat(24, 1fr); min-height: var(--rowH); }
.row-track .hcell { border-right: 1px solid #f0f2f5; }
.row-track .hcell:nth-child(even) { background: #fbfcfd; }

/* 过去时间覆盖（相对 row-track，JS 按百分比设宽） */
.past-cover {
  position: absolute; top: 0; bottom: 0; left: 0;
  background-image: repeating-linear-gradient(
    135deg, var(--past) 0 8px, transparent 8px 16px
  );
  border-right: 2px solid var(--past-edge);
  pointer-events: none; z-index: 1;
}

/* 当前时间线（JS 计算 left） */
.now-line {
  position: absolute; top: var(--headH); bottom: 0;
  width: 2px; background: var(--now); z-index: 6; pointer-events: none;
}
.now-line::before {
  content: ''; position: absolute; top: -4px; left: -4px;
  width: 10px; height: 10px; background: var(--now); border-radius: 50%;
}

/* 预约块（相对 row-track 百分比定位） */
.booking-block {
  position: absolute; top: 4px; bottom: 4px;
  border-radius: 4px; color: #fff; font-size: 11px; padding: 2px 5px;
  overflow: hidden; cursor: pointer; z-index: 2;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
  display: flex; flex-direction: column; justify-content: center;
  min-width: 6px;
}
.booking-block:hover { z-index: 3; box-shadow: 0 2px 6px rgba(0,0,0,0.25); }
.booking-block .b-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.3; }
.booking-block .b-meta { font-size: 10px; opacity: 0.92; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.3; }
.booking-block .b-repeat { display: inline-block; margin-left: 3px; font-size: 10px; opacity: 0.95; }

/* 全天预约：整行铺满 + 斜纹底纹区分 */
.booking-block.all-day {
  background-image: repeating-linear-gradient(
    135deg, rgba(255,255,255,0.22) 0 6px, rgba(255,255,255,0) 6px 12px
  );
  border: 1px solid rgba(255,255,255,0.55);
}

/* 拖动选区（相对 row-track） */
.drag-select {
  position: absolute; top: 2px; bottom: 2px;
  background: rgba(24, 95, 165, 0.18);
  border: 1.5px solid var(--primary); border-radius: 3px;
  z-index: 4; pointer-events: none;
  display: flex; align-items: flex-end; justify-content: flex-end;
}
.drag-select .hint {
  background: var(--primary); color: #fff; font-size: 10px;
  padding: 1px 5px; border-radius: 2px; margin: 2px; white-space: nowrap;
}

/* 模态框 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45);
  display: none; align-items: center; justify-content: center; z-index: 100;
}
.modal-mask.show { display: flex; }
.modal-box {
  background: #fff; border-radius: 14px; padding: 22px 24px;
  width: min(420px, 92vw); box-shadow: 0 12px 40px rgba(0,0,0,0.2);
}
.modal-box h3 { font-size: 17px; color: var(--primary-dark); margin-bottom: 10px; }
.modal-box .info {
  background: var(--primary-bg); color: var(--primary-dark);
  border-radius: 8px; padding: 8px 12px; font-size: 13px; margin-bottom: 14px;
}
.modal-box label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
.modal-box input[type=text] {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; outline: none;
}
.modal-box input[type=text]:focus { border-color: var(--primary); }
.modal-btns { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.btn {
  display: inline-block; border: none; border-radius: 8px; padding: 9px 18px;
  font-size: 14px; cursor: pointer; background: var(--primary); color: #fff;
}
.btn.ghost { background: #f0f2f5; color: var(--text); }
.btn.danger { background: #fdecea; color: var(--danger); }

/* 详情 modal 字段 */
.detail-row { font-size: 14px; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.detail-row:last-child { border-bottom: none; }
.detail-row .lbl { color: var(--muted); display: inline-block; width: 70px; }

/* 轻提示 */
.toast {
  position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%);
  background: rgba(0,0,0,0.82); color: #fff; padding: 10px 18px;
  border-radius: 8px; font-size: 14px; z-index: 999;
  opacity: 0; transition: opacity 0.25s; pointer-events: none; max-width: 80vw;
}
.toast.show { opacity: 1; }

/* 创建会议弹窗扩展样式（按企业微信风格） */
.modal-create { width: min(580px, 95vw); max-height: 90vh; overflow-y: auto; }
.modal-create h3 { font-size: 18px; margin-bottom: 14px; }
.title-input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 16px; font-weight: 500; outline: none;
  background: #f7f9fc;
}
.title-input:focus { border-color: var(--primary); background: #fff; }

.field-row { margin-bottom: 16px; }
.field-row > label,
.field-row > .field-label {
  display: block; font-size: 13px; color: var(--muted); margin-bottom: 8px;
}
.time-edit { display: flex; align-items: center; gap: 8px; }
.time-edit input { flex: 1; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; outline: none; }
.time-edit input:focus { border-color: var(--primary); }
.time-edit .arrow { color: var(--muted); font-size: 16px; }
.time-tz { font-size: 12px; color: var(--muted); margin-top: 4px; }
.attendee-list {
  display: flex; flex-wrap: wrap; gap: 6px; min-height: 38px; padding: 6px;
  border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px;
  align-items: center;
}
.attendee-list:empty::before { content: '暂无参与人，点击下方按钮添加'; color: var(--muted); font-size: 13px; }
.attendee-chip {
  background: var(--primary-bg); color: var(--primary-dark);
  padding: 4px 6px 4px 12px; border-radius: 14px;
  font-size: 13px; display: inline-flex; align-items: center; gap: 6px;
}
.attendee-chip .x {
  cursor: pointer; opacity: .6; font-size: 14px; line-height: 1;
  padding: 2px 6px; border-radius: 50%;
}
.attendee-chip .x:hover { background: rgba(0,0,0,.08); opacity: 1; }
.btn-add-attendee {
  font-size: 13px; color: var(--primary); background: #fff;
  border: 1px dashed var(--primary); padding: 7px 14px;
  border-radius: 6px; cursor: pointer;
}
.btn-add-attendee:hover { background: var(--primary-bg); }

/* 双栏选人面板（类企微通讯录） */
.picker-modal { width: min(720px, 96vw); }
.picker-body { display: flex; gap: 12px; min-height: 380px; }
.picker-left {
  width: 190px; flex-shrink: 0; border: 1px solid var(--border); border-radius: 8px;
  background: #fafbfd; overflow-y: auto; padding: 4px 0;
}
.picker-left .company-item {
  display: flex; align-items: center; gap: 6px; padding: 10px 12px;
  font-size: 13px; cursor: pointer; border-bottom: 1px solid var(--border);
}
.picker-left .company-item:hover { background: var(--primary-bg); }
.picker-left .company-item.active { background: var(--primary-bg); color: var(--primary-dark); font-weight: 600; }
.picker-left .company-item .count { margin-left: auto; font-size: 11px; color: var(--muted); }
.picker-left .company-item.active .count { color: var(--primary); }
.picker-right { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.picker-list { flex: 1; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; min-height: 0; background: #fff; }
.picker-list details summary {
  padding: 8px 10px; cursor: pointer; background: #fafbfd;
  font-size: 12px; color: var(--primary-dark); font-weight: 600;
  list-style: none; display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--border);
}
.picker-list details summary::-webkit-details-marker { display: none; }
.picker-list details .b-row {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; cursor: pointer; border-bottom: 1px solid var(--border);
}
.picker-list details .b-row:hover { background: #f6f9fc; }
.picker-list .empty {
  padding: 40px; color: var(--muted); text-align: center; font-size: 13px;
}
.room-edit {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; background: #fafbfd;
}
.room-edit { display: flex; align-items: center; justify-content: space-between; }
.link-btn { font-size: 13px; color: var(--primary); background: none; border: none; cursor: pointer; padding: 4px 8px; }
.link-btn:hover { text-decoration: underline; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.icon { display: inline-block; width: 18px; text-align: center; margin-right: 4px; color: var(--primary); }

/* ================= 响应式：≤820px 顶部栏折行 ================= */
@media (max-width: 820px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 6px; }
  .topbar .legend { display: none; }
  .main { height: calc(100vh - 96px); }
}

/* ================= 移动端（≤768px）：卡片列表取代横向时间轴 ================= */
.m-wrap { display: none; }
.m-only { display: none; }

@media (max-width: 768px) {
  body { font-size: 15px; }

  /* 顶部栏精简 */
  .topbar { padding: 10px 12px; gap: 8px; align-items: center; }
  .topbar .title { font-size: 17px; margin-right: auto; }
  .topbar #versionBadge, .topbar #roomCountBadge { display: none; }
  .topbar #dateInput { display: none; }            /* 日期改用下方移动端日期栏 */
  .topbar select { font-size: 14px; padding: 7px 9px; height: 36px; }
  .topbar #buildingSelect { flex: 0 1 auto; min-width: 0; }
  .topbar a.m-only { display: inline-block; flex: none; font-size: 14px; color: var(--primary); text-decoration: none; padding: 6px 0; }

  .main { height: auto; overflow: visible; }
  .grid-wrap { display: none !important; }         /* 隐藏桌面的 24 小时时间轴 */

  /* ---- 日期栏 ---- */
  .m-wrap { display: block; padding: 10px 12px 30px; }
  .m-datebar {
    display: flex; align-items: center; gap: 8px;
    background: #fff; border: 1px solid var(--border); border-radius: 12px;
    padding: 8px 10px; margin-bottom: 10px;
    position: sticky; top: 0; z-index: 20;
  }
  .m-nav {
    width: 34px; height: 34px; flex: none; border: 1px solid var(--border); background: #f7f9fc;
    border-radius: 9px; font-size: 20px; line-height: 1; color: var(--primary-dark); cursor: pointer;
  }
  .m-nav:active { background: var(--primary-bg); }
  .m-date { flex: 1; text-align: center; font-size: 15px; font-weight: 600; color: var(--primary-dark); }
  .m-today {
    flex: none; border: 1px solid var(--primary); background: var(--primary-bg); color: var(--primary-dark);
    border-radius: 9px; padding: 8px 12px; font-size: 13px; cursor: pointer;
  }
  .m-today:disabled { opacity: .4; }

  /* ---- 会议室卡片 ---- */
  .m-list { display: flex; flex-direction: column; gap: 10px; }
  .m-card { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 12px 13px; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
  .m-card-head { display: flex; align-items: flex-start; gap: 10px; }
  .m-room-name { font-size: 16px; font-weight: 600; line-height: 1.35; }
  .m-room-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
  .m-book-btn {
    margin-left: auto; flex: none; background: var(--primary); color: #fff; border: none;
    border-radius: 9px; padding: 10px 16px; font-size: 14px; font-weight: 500; cursor: pointer;
  }
  .m-book-btn:active { background: var(--primary-dark); }

  .m-status { display: inline-flex; align-items: center; gap: 5px; margin-top: 9px; font-size: 12.5px; padding: 3px 9px; border-radius: 20px; }
  .m-status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
  .m-status.free { background: #E7F6EF; color: #0F6E56; }
  .m-status.busy { background: #FDECEA; color: #B42318; }
  .m-status.soon { background: #FFF4E5; color: #B54708; }

  .m-events { margin-top: 10px; border-top: 1px dashed var(--border); padding-top: 2px; }
  .m-event { display: flex; align-items: center; gap: 8px; padding: 10px 2px; border-bottom: 1px solid #f4f6f9; font-size: 13px; }
  .m-event:last-child { border-bottom: none; }
  .m-et { flex: none; font-variant-numeric: tabular-nums; color: var(--primary-dark); font-weight: 600; font-size: 12.5px; }
  .m-en { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .m-eo { flex: none; color: var(--muted); font-size: 12px; }
  .m-event.cur { background: var(--primary-bg); margin: 0 -13px; padding-left: 13px; padding-right: 13px; }
  .m-event.past { opacity: .42; }
  .m-event.past .m-et { color: var(--muted); font-weight: 500; }
  .m-more { padding: 8px 2px 2px; color: var(--primary); font-size: 13px; }
  .m-empty { text-align: center; padding: 44px 0; color: var(--muted); }

  /* ---- 弹窗：时间竖排 + 快捷时段 ---- */
  .modal-create { width: 94vw; max-height: 88vh; padding: 18px 16px; }
  .time-edit { flex-direction: column; align-items: stretch; gap: 8px; }
  .time-edit .arrow { transform: rotate(90deg); align-self: center; }
  .time-edit input { width: 100%; }
  .quick-slots { flex-wrap: wrap; gap: 7px; margin-bottom: 10px; }
  .quick-slot {
    border: 1px solid var(--border); background: #fff; border-radius: 8px;
    padding: 8px 11px; font-size: 13px; color: var(--text); cursor: pointer; font-variant-numeric: tabular-nums;
  }
  .quick-slot.on { border-color: var(--primary); background: var(--primary-bg); color: var(--primary-dark); font-weight: 600; }
  .modal-btns .btn { flex: 1; padding: 12px 0; font-size: 15px; }

  /* 会议室：手机上改用原生下拉，比输入 ID 友好 */
  .room-edit #roomLabel, .room-edit #changeRoomBtn { display: none; }
  .room-edit #roomSelectMobile {
    display: block !important; width: 100%; padding: 10px 11px; font-size: 15px;
    border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text);
  }
}