/* ==================== 抢座助手 · 青春校园（浅蓝浅粉） ==================== */
:root {
  --primary: #5b9cf5;          /* 浅蓝主色 */
  --primary-deep: #3d7fe0;
  --primary-light: #e8f4ff;
  --pink: #ff9ec3;             /* 浅粉辅色 */
  --pink-light: #ffeef7;
  --pink-deep: #f77fb0;
  --bg: #f4f9ff;
  --card: #ffffff;
  --text: #33415c;
  --text-sub: #8b98b5;
  --border: #e3ecf9;
  --green: #5ad48b;
  --green-light: #e6f9ef;
  --gray: #c3cdde;
  --gray-light: #f0f4fa;
  --red: #ff6b81;
  --shadow: 0 4px 18px rgba(122, 165, 235, 0.14);
  --radius: 14px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: 'Segoe UI', 'Microsoft YaHei', 'PingFang SC', sans-serif;
  background: linear-gradient(160deg, #eef6ff 0%, #fdf1f7 100%);
  color: var(--text);
  font-size: 14px;
  user-select: none;
}

.app {
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-rows: 44px 1fr 190px;
  grid-template-areas: "titlebar titlebar" "sidebar content" "sidebar log";
  height: 100vh;
}

/* ==================== 无边框窗口标题栏 ==================== */
.titlebar {
  grid-area: titlebar;
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(90deg, #ffffff, #f4f9ff);
  border-bottom: 1px solid var(--border);
  -webkit-app-region: drag;
  user-select: none;
  position: relative; z-index: 20;
}
.titlebar-drag { flex: 1; display: flex; align-items: center; padding: 0 14px; height: 100%; overflow: hidden; }
.titlebar-title { font-size: 13px; color: var(--text-sub); font-weight: 600; letter-spacing: .5px; white-space: nowrap; }
.titlebar-title i { color: var(--primary); margin-right: 6px; }
.titlebar-controls { display: flex; height: 100%; -webkit-app-region: no-drag; }
.win-btn {
  width: 46px; height: 100%; border: none; background: transparent;
  color: var(--text-sub); font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s ease;
}
.win-btn:hover { background: rgba(122,165,235,.18); color: var(--primary-deep); }
.win-btn-close:hover { background: #e5484d; color: #fff; }
/* macOS：红绿灯由系统绘制，隐藏自绘按钮并给左侧留位 */
body.platform-darwin .titlebar-controls { display: none; }
body.platform-darwin .titlebar-drag { padding-left: 78px; }
body.platform-linux .win-btn:hover { border-radius: 0; }
/* PWA：无窗口概念，隐藏自绘窗口按钮，标题栏不可拖拽 */
body.platform-pwa .win-btn,
body.platform-ios .win-btn,
body.platform-android .win-btn { display: none; }
body.platform-pwa .titlebar,
body.platform-pwa .titlebar-drag { -webkit-app-region: no-drag; }

/* ==================== PWA 额度徽章（标题栏右侧） ==================== */
.quota-badge { display: flex; align-items: center; gap: 6px; padding: 0 14px; font-size: 12px; color: var(--text-sub); white-space: nowrap; }
.quota-badge i { color: var(--primary); }
.quota-badge.high { color: #d99000; }
.quota-badge.exhausted { color: var(--red); font-weight: 700; }
.quota-badge-bar {
  display: inline-block; width: 46px; height: 6px;
  background: var(--gray-light);
  box-shadow: inset 0 0 0 1px var(--border);
  border-radius: 999px; overflow: hidden;
}
.quota-badge-fill {
  display: block; height: 100%; width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), #7cb8ff);
  transition: width .3s ease;
}
.quota-badge-fill.warned { background: linear-gradient(90deg, #f5a623, #ffc14d); }
.quota-badge-fill.exhausted { background: linear-gradient(90deg, #ff6b81, #ffb0b0); }

/* ==================== 侧边栏 ==================== */
.sidebar {
  grid-area: sidebar;
  background: linear-gradient(180deg, #ffffff 0%, #f6fbff 100%);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.logo { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
.logo-icon {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--pink));
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; box-shadow: 0 4px 12px rgba(91, 156, 245, .35);
}
.logo-title { font-size: 17px; font-weight: 700; color: var(--primary-deep); letter-spacing: 1px; }
.logo-sub { font-size: 11px; color: var(--pink-deep); margin-top: 2px; }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border: none; border-radius: 12px;
  background: transparent; color: var(--text-sub);
  font-size: 14px; cursor: pointer; text-align: left;
  transition: all .18s ease;
}
.nav-btn:hover { background: var(--primary-light); color: var(--primary-deep); }
.nav-btn.active {
  background: linear-gradient(135deg, var(--primary-light), var(--pink-light));
  color: var(--primary-deep); font-weight: 600;
  box-shadow: inset 0 0 0 1.5px rgba(91,156,245,.25);
}
.nav-ico { font-size: 16px; width: 20px; text-align: center; }

.login-card {
  background: linear-gradient(135deg, var(--primary-light), var(--pink-light));
  border-radius: var(--radius);
  padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.login-status { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--gray); flex-shrink: 0; }
.dot.on { background: var(--green); box-shadow: 0 0 8px rgba(90,212,139,.6); }
.dot.warn { background: #ffb020; }

.sidebar-footer { font-size: 11px; color: var(--text-sub); text-align: center; }

/* ==================== 主内容 ==================== */
.content {
  grid-area: content;
  padding: 24px 28px;
  overflow-y: auto;
}

.tab { display: none; }
.tab.active { display: block; animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.tab-header { margin-bottom: 16px; }
.tab-header h2 { font-size: 21px; color: var(--primary-deep); font-weight: 700; }
.tab-desc { color: var(--text-sub); font-size: 13px; margin-top: 4px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.card.center-card { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 32px 20px; }

/* 表单 */
.form-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-sm { min-width: 90px; }
.field label { font-size: 12px; color: var(--text-sub); }
.field input, .field select {
  border: 1.5px solid var(--border); border-radius: 10px;
  padding: 8px 12px; font-size: 13px; color: var(--text);
  background: #fbfdff; outline: none; transition: border .15s;
}
.field input:focus, .field select:focus { border-color: var(--primary); }
.field input[type="time"] { width: 140px; }
.range-input { display: flex; align-items: center; gap: 6px; }
.range-input span { color: var(--text-sub); }

.form-actions { display: flex; align-items: center; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.task-state { font-size: 12px; color: var(--text-sub); margin-left: 4px; }
.task-state.running { color: var(--green); font-weight: 600; }
.task-state.error { color: var(--red); font-weight: 600; }

/* 按钮 */
.btn {
  border: none; border-radius: 10px; padding: 9px 20px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all .18s ease; color: #fff;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--primary), #7cb8ff); box-shadow: 0 3px 10px rgba(91,156,245,.35); }
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 5px 14px rgba(91,156,245,.45); }
.btn-danger { background: linear-gradient(135deg, #ff8f8f, #ffb0b0); box-shadow: 0 3px 10px rgba(255,143,143,.3); }
.btn-danger:hover:not(:disabled) { transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--primary-deep); box-shadow: inset 0 0 0 1.5px var(--primary); }
.btn-ghost:hover { background: var(--primary-light); }
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-xs { padding: 3px 10px; font-size: 11px; border-radius: 8px; }

.hidden { display: none !important; }

/* 座位网格 */
.seat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 8px;
  margin-top: 14px;
  max-height: 300px;
  overflow-y: auto;
  padding: 4px;
}
.seat {
  border-radius: 10px; padding: 10px 6px;
  text-align: center; cursor: pointer;
  border: 1.5px solid var(--border);
  background: var(--gray-light); color: var(--text-sub);
  font-size: 12px; font-weight: 600;
  transition: all .15s ease; position: relative;
}
.seat:hover { transform: translateY(-2px); box-shadow: 0 3px 8px rgba(122,165,235,.25); }
.seat.free { background: var(--green-light); border-color: #b9ecd0; color: #2f9e63; }
.seat.used { opacity: .55; }
.seat.selected {
  background: linear-gradient(135deg, var(--primary), #7cb8ff);
  border-color: var(--primary-deep); color: #fff;
  box-shadow: 0 4px 12px rgba(91,156,245,.4);
}
.seat.used.selected { opacity: 1; }
.seat.fav::after {
  content: ''; position: absolute; top: 4px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: #e5484d;
  font-size: 10px; color: var(--pink-deep);
}
.seat .seat-num { display: block; font-size: 13px; }
.seat .seat-stat { display: block; font-size: 9px; font-weight: 400; opacity: .8; }

.card-title { font-size: 14px; font-weight: 700; color: var(--text-sub); margin-bottom: 12px; }
.card-title i { color: var(--primary); margin-right: 6px; }
.card-head-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.card-head-row .card-title { margin-bottom: 0; }
.card-head-actions { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--text-sub); }
.card-head-actions b { color: var(--primary-deep); }

/* 已选座位列表（跨场馆） */
.seat-item-list { display: flex; flex-direction: column; gap: 8px; max-height: 190px; overflow-y: auto; }
.seat-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--gray-light); border: 1.5px solid var(--border); border-radius: 10px;
  padding: 8px 12px; font-size: 13px;
}
.seat-item-lib {
  color: var(--text-sub); font-size: 12px; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.seat-item-num { font-weight: 700; color: var(--primary-deep); white-space: nowrap; }
.seat-status {
  margin-left: auto; font-size: 11px; font-weight: 700; white-space: nowrap;
  color: var(--text-sub); background: var(--gray); border-radius: 999px; padding: 2px 10px;
}
.seat-status.actively {
  color: #fff; background: linear-gradient(135deg, var(--primary), #7cb8ff);
  animation: mono-pulse 1.6s ease-in-out infinite;
}
@keyframes mono-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(91,156,245,.45); }
  50% { box-shadow: 0 0 0 6px rgba(91,156,245,0); }
}
.seat-item-remove {
  width: 24px; height: 24px; border: none; border-radius: 6px;
  background: transparent; color: var(--text-sub); cursor: pointer; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.seat-item-remove:hover { background: #ffe3e8; color: var(--red); }
.seat-item .empty-hint { grid-column: 1 / -1; }

.empty-hint { color: var(--text-sub); font-size: 13px; text-align: center; padding: 30px 0; grid-column: 1 / -1; }

/* 场馆多选 */
.lib-check-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; margin-top: 10px; }
.lib-check {
  border: 1.5px solid var(--border); border-radius: 10px;
  padding: 10px 12px; cursor: pointer; transition: all .15s;
  display: flex; flex-direction: column; gap: 2px;
}
.lib-check:hover { border-color: var(--primary); }
.lib-check.checked { background: var(--primary-light); border-color: var(--primary); }
.lib-check .lib-name { font-size: 13px; font-weight: 600; }
.lib-check .lib-meta { font-size: 11px; color: var(--text-sub); }

/* 远程控制 */
.remote-status { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; }
.remote-status.running { color: var(--green); }
.url-display {
  background: var(--primary-light); border: 1.5px dashed var(--primary);
  border-radius: 10px; padding: 10px 16px; font-size: 15px;
  color: var(--primary-deep); font-weight: 600; letter-spacing: .5px;
  margin-bottom: 10px;
}

/* 复选框 */
.checkbox { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); cursor: pointer; }
.checkbox input { accent-color: var(--primary); }

.hint { font-size: 12px; color: var(--text-sub); margin-top: 12px; line-height: 1.7; }

/* 节约额度提示条（主内容顶部） */
.tip-save {
  display: flex; gap: 12px; align-items: flex-start;
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--pink-light) 100%);
  border: 1.5px solid rgba(91, 156, 245, .35);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 12.5px; color: var(--text-sub); line-height: 1.8;
  margin-bottom: 16px;
}
.tip-save i { color: var(--primary-deep); margin-top: 3px; flex-shrink: 0; }
.tip-save b { color: var(--primary-deep); }

/* 注意事项（额度/停机等警示） */
.warn-hint {
  background: #fff8e6;
  border: 1.5px solid #ffe3a8;
  border-radius: 10px;
  padding: 10px 12px;
  color: #9a7b2e;
}
.warn-hint i { color: #d99000; }

/* 设置页额度面板 */
.settings-quota {
  width: 100%; max-width: 520px;
  display: flex; flex-direction: column; align-items: stretch; gap: 6px;
}
.quota-detail { font-size: 15px; font-weight: 600; color: var(--text-sub); margin: 2px 0 8px; }
.quota-detail.warned { color: #d99000; }
.quota-detail.exhausted { color: var(--red); }
.quota-bar {
  height: 12px; border-radius: 999px;
  background: var(--gray-light);
  box-shadow: inset 0 0 0 1px var(--border);
  overflow: hidden;
}
.quota-bar-fill {
  height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), #7cb8ff);
  transition: width .3s ease;
}
.quota-bar-fill.warned { background: linear-gradient(90deg, #f5a623, #ffc14d); }
.quota-bar-fill.exhausted { background: linear-gradient(90deg, #ff6b81, #ffb0b0); }

/* 输入/日志允许选中复制 */
input, textarea { user-select: text; }
.log-line, .seat-item-num, .qr-url { user-select: text; }

/* ==================== 日志栏 ==================== */
.log-bar {
  grid-area: log;
  background: #ffffff;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column;
  min-height: 0;
}
.log-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 16px; border-bottom: 1px solid var(--border);
  font-size: 12px; font-weight: 600; color: var(--text-sub);
}
.log-body {
  flex: 1; overflow-y: auto; padding: 8px 16px;
  font-family: Consolas, 'Cascadia Mono', monospace;
  font-size: 12px; line-height: 1.8;
}
.log-line { display: flex; gap: 8px; color: #5a6b85; }
.log-line .log-time { color: #b3bfd4; flex-shrink: 0; }
.log-line .log-task { color: var(--pink-deep); flex-shrink: 0; min-width: 52px; }
.log-line.info { color: #5a6b85; }
.log-line.success { color: #2f9e63; }
.log-line.warn { color: #d99000; }
.log-line.error { color: #e5484d; }

/* ==================== 弹窗 ==================== */
.modal-mask {
  position: fixed; inset: 0; background: rgba(45, 62, 90, .45);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal {
  background: #fff; border-radius: 18px; padding: 26px 30px;
  width: 520px; max-width: 92vw;
  box-shadow: 0 20px 60px rgba(30, 60, 110, .3);
  animation: popIn .2s ease;
}
@keyframes popIn { from { transform: scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }
.modal h3 { font-size: 18px; color: var(--primary-deep); margin-bottom: 10px; }
.modal-desc { font-size: 12.5px; color: var(--text-sub); line-height: 1.9; margin-bottom: 12px; }
.modal textarea {
  width: 100%; border: 1.5px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font-size: 12px; resize: vertical;
  outline: none; font-family: Consolas, monospace;
}
.modal textarea:focus { border-color: var(--primary); }
.login-result { margin-top: 12px; font-size: 13px; min-height: 20px; }
.login-result.ok { color: var(--green); }
.login-result.err { color: var(--red); }

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #c9d7ec; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #aec3e0; }
::-webkit-scrollbar-track { background: transparent; }

/* Toast */
.toast {
  position: fixed; bottom: 220px; left: 50%;
  transform: translateX(-50%);
  background: rgba(52, 74, 110, .92); color: #fff;
  padding: 10px 22px; border-radius: 20px;
  font-size: 13px; z-index: 999;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
  animation: popIn .2s ease;
}
/* 登录弹窗：标签页 + 二维码 */
.modal-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.modal-tab {
  flex: 1; padding: 8px 0; border: 1.5px solid var(--border); border-radius: 10px;
  background: #fff; color: var(--text-sub); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all .15s;
}
.modal-tab.active {
  background: linear-gradient(135deg, var(--primary-light), var(--pink-light));
  border-color: var(--primary); color: var(--primary-deep);
}
.login-tab { display: none; }
.login-tab.active { display: block; }
.qr-area {
  display: flex; align-items: center; justify-content: center;
  background: #fff; border: 1.5px dashed var(--border); border-radius: 12px;
  padding: 16px; min-height: 260px; margin-bottom: 12px;
}
.qr-area img { width: 220px; height: 220px; border-radius: 8px; }
.qr-placeholder { color: var(--text-sub); font-size: 13px; }
.qr-url {
  font-size: 11px; color: var(--text-sub); word-break: break-all;
  background: var(--gray-light); border-radius: 8px; padding: 6px 10px; margin-top: 8px;
  text-align: center; user-select: text;
}
.lib-select-toolbar { display:flex; align-items:center; gap:8px; margin-bottom:8px; }
.lib-select-toolbar .lib-select-count { margin-left:auto; font-size:12px; color:#8a97a8; }

/* ==================== 登录弹窗：扫码引导 ==================== */
.login-qr-row {
  display: flex; gap: 20px; align-items: center;
  margin-bottom: 14px;
}
.login-qr-box {
  flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: #fff;
  border: 1.5px dashed var(--border);
  border-radius: 12px;
  padding: 14px;
}
.login-qr-box img { width: 190px; height: 190px; border-radius: 8px; display: block; }
.login-qr-tip { font-size: 12px; color: var(--pink-deep); font-weight: 600; }
.login-steps { flex: 1; }
.login-steps ol { margin: 0; padding-left: 20px; }
.login-steps li { font-size: 13px; color: var(--text-sub); line-height: 2; }
.login-steps b { color: var(--primary-deep); }
@media (max-width: 920px) {
  .login-qr-row { flex-direction: column; align-items: center; }
  .login-qr-box img { width: 160px; height: 160px; }
  .login-steps li { font-size: 12px; line-height: 1.9; }
}

/* ==================== PWA 移动端 / 窄屏响应式 ==================== */
@media (max-width: 920px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 46px auto 1fr 220px;
    grid-template-areas: "titlebar" "sidebar" "content" "log";
  }
  /* 侧边栏 → 顶部横向导航 */
  .sidebar {
    flex-direction: row; align-items: center;
    padding: 6px 10px;
    border-right: none; border-bottom: 1px solid var(--border);
    gap: 8px;
  }
  .logo, .login-card, .sidebar-footer { display: none; }
  .nav { flex-direction: row; overflow-x: auto; gap: 6px; padding-bottom: 2px; }
  .nav-btn { padding: 8px 12px; white-space: nowrap; font-size: 13px; gap: 6px; }
  .nav-btn .nav-ico { width: auto; }
  .content { padding: 14px 12px; }
  .form-row { flex-direction: column; align-items: stretch; gap: 12px; }
  .field input, .field select { width: 100%; }
  .seat-grid { grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); }
  .titlebar-title { font-size: 14px; }
  .quota-badge { padding: 0 10px; font-size: 11px; }
  .log-bar { min-height: 220px; }
}
