/* =====================================================================
   会议室预定平台 v5 · 样式表
   CSS 变量 --brand-* 由 app.js 在初始化时注入 config.js 的品牌色
   ===================================================================== */

:root {
  --brand-primary: #3730a3;
  --brand-secondary: #6366f1;
  --brand-accent: #818cf8;
  --bg: #f8f9fc;
  --bg-card: #ffffff;
  --text: #1e293b;
  --text-light: #64748b;
  --border: #e2e8f0;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ===== 离线横条 ===== */
.offline-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 9999;
  background: var(--danger); color: #fff;
  text-align: center; padding: 6px; font-size: 14px;
  transition: transform 0.3s;
}
.offline-bar.hidden { transform: translateY(-100%); }

/* ===== 顶部导航 ===== */
.app-header {
  background: var(--brand-primary); color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow);
}
.company-name { font-size: 18px; font-weight: 700; }
.header-right { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.header-right .user-name { font-weight: 600; }
.header-right .role-badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; background: rgba(255,255,255,0.2);
}
.header-right .dept-badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; color: #fff;
}
.header-right .logout-btn {
  background: rgba(255,255,255,0.15); border: none; color: #fff;
  padding: 4px 12px; border-radius: var(--radius); cursor: pointer;
  font-size: 13px;
}
.header-right .logout-btn:hover { background: rgba(255,255,255,0.3); }

/* ===== Toast ===== */
.toast-container {
  position: fixed; top: 60px; right: 16px; z-index: 9998;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--bg-card); border-left: 4px solid var(--brand-primary);
  padding: 12px 16px; border-radius: var(--radius);
  box-shadow: var(--shadow-lg); max-width: 360px;
  animation: toast-in 0.3s ease-out;
  font-size: 14px;
}
.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error   { border-left-color: var(--danger); }
.toast.toast-warning { border-left-color: var(--warning); }
.toast-title { font-weight: 600; margin-bottom: 2px; }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ===== 通用 ===== */
.hidden { display: none !important; }
.section { max-width: 960px; margin: 0 auto; padding: 20px; }
.card {
  background: var(--bg-card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 24px; margin-bottom: 16px;
}
.mt-2 { margin-top: 16px; }
.hint { color: var(--text-light); font-size: 14px; margin-bottom: 16px; }

/* ===== 按钮 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 16px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text); cursor: pointer;
  font-size: 14px; font-weight: 500; transition: all 0.15s;
}
.btn:hover { box-shadow: var(--shadow); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--brand-primary); color: #fff; border-color: var(--brand-primary);
}
.btn-primary:hover { opacity: 0.9; }
.btn-secondary { background: var(--bg); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; }

/* ===== 表单 ===== */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; color: var(--text); }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 14px; outline: none;
  transition: border-color 0.15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--brand-primary);
}
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }
.checkbox-row { display: flex; gap: 20px; margin-bottom: 14px; }
.checkbox-label { display: flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }

/* ===== 登录 ===== */
.auth-section { display: flex; justify-content: center; align-items: center; min-height: 80vh; }
.auth-card {
  background: var(--bg-card); padding: 32px; border-radius: var(--radius);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 400px;
}
.auth-card h2 { text-align: center; margin-bottom: 24px; color: var(--brand-primary); }
.auth-switch { text-align: center; margin-top: 16px; font-size: 14px; color: var(--text-light); }
.auth-switch a { color: var(--brand-primary); text-decoration: none; font-weight: 600; }
.auth-error { margin-top: 12px; padding: 8px 12px; background: #fef2f2; color: var(--danger); border-radius: var(--radius); font-size: 13px; }

/* ===== Tab 导航 ===== */
.tab-nav {
  display: flex; gap: 0; max-width: 960px; margin: 0 auto;
  padding: 0 20px; border-bottom: 2px solid var(--border);
  overflow-x: auto;
}
.tab-btn {
  padding: 10px 18px; border: none; background: none; cursor: pointer;
  font-size: 14px; font-weight: 500; color: var(--text-light);
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  white-space: nowrap; transition: all 0.15s;
}
.tab-btn.active { color: var(--brand-primary); border-bottom-color: var(--brand-primary); }
.tab-btn:hover { color: var(--brand-primary); }
.tab-content { max-width: 960px; margin: 0 auto; padding: 20px; }

/* ===== 时间轴 ===== */
.schedule-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 8px; }
.date-nav { display: flex; align-items: center; gap: 8px; }
.date-nav span { font-weight: 600; min-width: 120px; text-align: center; }
.timeline-container { position: relative; overflow-x: auto; }
.timeline {
  display: grid; grid-template-columns: 60px 1fr;
  min-width: 600px;
}
.timeline-hour {
  font-size: 12px; color: var(--text-light); text-align: right;
  padding-right: 8px; height: 48px; line-height: 48px;
  border-top: 1px solid var(--border);
}
.timeline-slot {
  height: 48px; border-top: 1px solid var(--border);
  position: relative; cursor: pointer; transition: background 0.1s;
}
.timeline-slot:hover { background: rgba(99,102,241,0.05); }
.timeline-slot .slot-half {
  position: absolute; width: 100%; height: 50%;
}
.timeline-slot .slot-half:first-child { top: 0; }
.timeline-slot .slot-half:last-child { top: 50%; }
.booking-block {
  position: absolute; left: 4px; right: 4px;
  border-radius: 4px; padding: 4px 8px; font-size: 12px;
  color: #fff; overflow: hidden; cursor: default;
  z-index: 2; box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.booking-block .block-topic { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.booking-block .block-info { opacity: 0.85; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.booking-block .block-tooltip {
  display: none; position: absolute; bottom: calc(100% + 6px); left: 0;
  background: #1e293b; color: #fff; padding: 8px 12px; border-radius: 6px;
  font-size: 12px; white-space: nowrap; z-index: 10;
  box-shadow: var(--shadow-lg);
}
.booking-block:hover .block-tooltip { display: block; }

/* 当前时间线 */
.timeline-now {
  position: absolute; left: 60px; right: 0; height: 2px;
  background: var(--danger); z-index: 5; pointer-events: none;
}
.timeline-now::before {
  content: ''; position: absolute; left: -5px; top: -4px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--danger);
}

/* ===== 我的预定 ===== */
.bookings-list { display: flex; flex-direction: column; gap: 12px; }
.booking-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px; border: 1px solid var(--border); border-radius: var(--radius);
  transition: box-shadow 0.15s; flex-wrap: wrap;
}
.booking-item:hover { box-shadow: var(--shadow); }
.booking-item .bi-time {
  font-weight: 700; font-size: 15px; min-width: 120px;
  color: var(--brand-primary);
}
.booking-item .bi-topic { font-weight: 600; flex: 1; min-width: 100px; }
.booking-item .bi-dept-badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; color: #fff;
}
.booking-item .bi-status { font-size: 12px; padding: 2px 8px; border-radius: 10px; }
.booking-item .bi-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.status-confirmed  { background: #dbeafe; color: #2563eb; }
.status-signed_in  { background: #dcfce7; color: #16a34a; }
.status-completed  { background: #f1f5f9; color: #64748b; }
.status-auto_released { background: #fef3c7; color: #d97706; }
.status-cancelled  { background: #fee2e2; color: #dc2626; }

/* 即将开始脉动 */
.pulse-badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; background: var(--success); color: #fff;
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ===== 维护人卡片 ===== */
.maintainers-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.maint-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; transition: box-shadow 0.15s;
}
.maint-card:hover { box-shadow: var(--shadow); }
.maint-card .mc-category {
  font-size: 12px; color: var(--brand-primary); font-weight: 600;
  margin-bottom: 4px; text-transform: uppercase;
}
.maint-card .mc-name { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.maint-card .mc-resp { font-size: 13px; color: var(--text-light); margin-bottom: 10px; }
.maint-card .mc-contact { font-size: 13px; }
.maint-card .mc-contact a { color: var(--brand-primary); text-decoration: none; }
.maint-card .mc-backup { font-size: 12px; color: var(--text-light); margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }

/* ===== 管理后台 ===== */
.admin-tabs { display: flex; gap: 4px; margin-bottom: 20px; flex-wrap: wrap; }
.admin-tab-btn {
  padding: 6px 14px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); cursor: pointer; font-size: 13px;
  transition: all 0.15s;
}
.admin-tab-btn.active { background: var(--brand-primary); color: #fff; border-color: var(--brand-primary); }
.admin-panel { }
.report-controls { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.report-summary {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px; margin-bottom: 20px;
}
.stat-card {
  background: var(--bg); padding: 14px; border-radius: var(--radius);
  text-align: center;
}
.stat-card .stat-value { font-size: 24px; font-weight: 700; color: var(--brand-primary); }
.stat-card .stat-label { font-size: 12px; color: var(--text-light); margin-top: 4px; }

/* 表格 */
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td {
  padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border);
}
.data-table th { font-weight: 600; font-size: 13px; color: var(--text-light); background: var(--bg); }
.data-table tr:hover td { background: #f8fafc; }

/* ===== 弹窗 ===== */
.modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.4); }
.modal-content {
  position: relative; background: var(--bg-card); border-radius: 12px;
  width: 90%; max-width: 520px; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg); animation: modal-in 0.2s ease-out;
}
@keyframes modal-in { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-light); }
.modal-body { padding: 20px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 20px; border-top: 1px solid var(--border); }

/* ===== 响应式 ===== */
@media (max-width: 640px) {
  .app-header { padding: 10px 14px; }
  .company-name { font-size: 15px; }
  .header-right { font-size: 12px; gap: 6px; }
  .section, .tab-content { padding: 12px; }
  .card { padding: 16px; }
  .form-row { flex-direction: column; gap: 0; }
  .timeline { min-width: 400px; }
  .booking-item { flex-direction: column; align-items: flex-start; }
  .booking-item .bi-actions { width: 100%; }
  .booking-item .bi-actions .btn { flex: 1; }
  .report-summary { grid-template-columns: repeat(2, 1fr); }
  .maintainers-grid { grid-template-columns: 1fr; }
  .admin-tabs { flex-direction: column; }
  .modal-content { width: 95%; }
}
