/* ===== 全局主题：北大红 =====
   品牌主色 #94070A（北大红）。
   Bootstrap 5.3 的按钮/胶囊/分页等组件颜色为编译期字面量（非 var(--bs-primary)），
   因此除覆盖 CSS 变量外，还需显式覆盖各组件的 --bs-btn-* / --bs-nav-* 等变量。 */
:root {
  --app-brand: #94070a;            /* 北大红 */
  --app-brand-strong: #6e0406;      /* 深红：hover / 强调场景 */
  --app-brand-bright: #b52b2e;      /* 亮红：备用色（当前未使用） */
  --app-brand-rgb: 148, 7, 10;

  --bs-primary: #94070a;
  --bs-primary-rgb: 148, 7, 10;
  --bs-link-color: #94070a;
  --bs-link-color-rgb: 148, 7, 10;

  --app-focus-ring: rgba(148, 7, 10, 0.16);
  --app-focus-border: #f0b8b9;
  --app-navbar-grad: #7a0507;

  --app-radius: 0.75rem;
  --app-shadow-sm: 0 1px 2px rgba(0,0,0,0.06), 0 1px 1px rgba(0,0,0,0.04);
  --app-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

/* 暗黑模式：主色提亮为亮红，保证文字 / 图标对比度；
   背景类元素仍用深红，避免浅底白字对比不足 */
[data-bs-theme="dark"] {
  --app-brand: #e0565a;
  --app-brand-strong: #c73a3d;
  --app-brand-bright: #ef7c7f;
  --app-brand-rgb: 224, 86, 90;

  --bs-primary: #e0565a;
  --bs-primary-rgb: 224, 86, 90;
  --bs-link-color: #ef8a8c;
  --bs-link-color-rgb: 239, 138, 140;

  --app-focus-ring: rgba(224, 86, 90, 0.28);
  --app-focus-border: #a3484b;
  --app-navbar-grad: #6e0406;

  --app-shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
  --app-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

/* ===== Bootstrap 组件主色统一为北大红 ===== */
.btn-primary {
  background-color: var(--app-brand);
  border: none;
}
.btn-primary:hover, .btn-primary:focus {
  background-color: var(--app-brand-strong);
}
.btn-outline-primary {
  --bs-btn-color: var(--app-brand);
  --bs-btn-border-color: var(--app-brand);
  --bs-btn-hover-bg: var(--app-brand);
  --bs-btn-hover-border-color: var(--app-brand);
  --bs-btn-active-bg: var(--app-brand-strong);
  --bs-btn-active-border-color: var(--app-brand-strong);
  --bs-btn-disabled-color: var(--app-brand);
  --bs-btn-disabled-border-color: var(--app-brand);
}
/* 暗黑模式：bg-primary 保持深红（亮红底 + 白字对比不足） */
[data-bs-theme="dark"] .bg-primary { background-color: #94070a !important; }
.nav-pills {
  --bs-nav-pills-link-active-bg: #94070a;
  --bs-nav-pills-link-active-color: #fff;
}
.list-group {
  --bs-list-group-active-bg: #94070a;
  --bs-list-group-active-border-color: #94070a;
}
.pagination {
  --bs-pagination-hover-color: var(--app-brand);
  --bs-pagination-focus-color: var(--app-brand);
  --bs-pagination-focus-box-shadow: 0 0 0 0.25rem var(--app-focus-ring);
  --bs-pagination-active-bg: #94070a;
  --bs-pagination-active-border-color: #94070a;
}
.dropdown-item.active, .dropdown-item:active { background-color: #94070a; }
[data-bs-theme="dark"] .dropdown-item.active,
[data-bs-theme="dark"] .dropdown-item:active { background-color: #94070a; }
.form-check-input:checked {
  background-color: #94070a;
  border-color: #94070a;
}
.form-check-input:focus {
  border-color: var(--app-focus-border);
  box-shadow: 0 0 0 0.25rem var(--app-focus-ring);
}

html, body { height: 100%; }
body {
  background-color: #f5f7fb;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
}
[data-bs-theme="dark"] body {
  background-color: #111827;
}

/* ===== 导航 ===== */
.navbar.app-navbar {
  box-shadow: var(--app-shadow);
  background: var(--app-navbar-grad) !important;
}
.navbar.app-navbar .navbar-brand {
  font-weight: 700;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.navbar.app-navbar .navbar-brand img {
  height: 28px; width: 28px; object-fit: contain;
}

/* ===== 卡片 ===== */
.app-card {
  background: var(--bs-body-bg);
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow-sm);
  padding: 1.25rem;
  transition: box-shadow 0.2s, transform 0.2s;
}
.app-card:hover { box-shadow: var(--app-shadow); }
.app-card-stat { color: #fff; border-radius: var(--app-radius); padding: 1.25rem; }
.app-card-stat.primary { background-color: #94070a; }
.app-card-stat.success { background-color: #047857; }
.app-card-stat.warning { background-color: #d97706; }
.app-card-stat.info    { background-color: #0891b2; }
.app-card-stat.danger  { background-color: #b91c1c; }
.app-card-stat .stat-value { font-size: 2.25rem; font-weight: 700; line-height: 1; }
.app-card-stat .stat-label { font-size: 0.875rem; opacity: 0.9; }

/* ===== 按钮 ===== */
.btn { transition: transform 0.15s, box-shadow 0.2s; border-radius: 0.5rem; }
.btn:active { transform: translateY(1px); }

/* ===== 表单：避免 iOS 自动 zoom ===== */
input, select, textarea, .form-control, .form-select {
  font-size: 16px !important;
}
.form-control:focus, .form-select:focus {
  box-shadow: 0 0 0 0.2rem var(--app-focus-ring);
  border-color: var(--app-focus-border);
}

/* ===== 表格响应式容器：保留 Bootstrap 默认边框样式，仅做容器装饰 ===== */
.table-responsive-shell {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--bs-border-color);
  border-radius: var(--app-radius);
  background: var(--bs-body-bg);
  box-shadow: var(--app-shadow-sm);
}
/* 容器只加边框，不覆盖表格的内部边框（避免与 Bootstrap 默认 border-collapse 冲突造成横线断开） */
.table-responsive-shell > .table { margin-bottom: 0; }
.table-responsive-shell > .table > :not(caption) > * > * {
  padding: 0.65rem 0.85rem;
  /* 强制让 td/th 都共享一条完整的横线 */
  border-bottom-width: 1px;
  border-bottom-color: var(--bs-border-color);
}
.table-responsive-shell > .table > :not(caption) > *:last-child > * {
  border-bottom-width: 0;
}
.table-responsive-shell > .table > thead th {
  background: rgba(var(--bs-primary-rgb), 0.06);
  font-weight: 600;
  white-space: nowrap;
  border-bottom-width: 2px !important;
  border-bottom-color: rgba(var(--bs-primary-rgb), 0.35) !important;
}
[data-bs-theme="dark"] .table-responsive-shell > .table > thead th {
  background: rgba(var(--bs-primary-rgb), 0.18);
}
.table-responsive-shell > .table > tbody > tr:hover > * {
  background: rgba(var(--bs-primary-rgb), 0.05);
}
[data-bs-theme="dark"] .table-responsive-shell > .table > tbody > tr:hover > * {
  background: rgba(var(--bs-primary-rgb), 0.14);
}

/* ===== 移动端：表格转卡片 ===== */
@media (max-width: 768px) {
  .table-cards-mobile thead { display: none; }
  .table-cards-mobile, .table-cards-mobile tbody {
    display: block;
    width: 100%;
  }
  .table-cards-mobile tbody tr {
    display: block;
    margin: 0 0 0.75rem;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--app-radius);
    padding: 0.5rem 0.75rem;
    background: var(--bs-body-bg);
  }
  .table-cards-mobile tbody tr:last-child { margin-bottom: 0; }
  .table-cards-mobile tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0;
    border: 0;
    border-bottom: 1px dashed var(--bs-border-color);
    gap: 0.5rem;
    text-align: right;
    word-break: break-word;
  }
  .table-cards-mobile tbody td:last-child { border-bottom: 0; }
  .table-cards-mobile tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--bs-secondary-color);
    flex-shrink: 0;
    text-align: left;
  }
  /* colspan 的空数据提示行：居中显示，不带 data-label */
  .table-cards-mobile tbody td[colspan] {
    display: block;
    text-align: center;
    border-bottom: 0;
  }
  .table-cards-mobile tbody td[colspan]::before { content: none !important; }
  .table-cards-mobile tbody td .btn-group { flex-wrap: wrap; justify-content: flex-end; }
  .container { padding-left: 0.75rem; padding-right: 0.75rem; }
  h1, h2, h3, h4 { font-size: 1.1rem !important; }
}

/* ===== 状态徽章 ===== */
.badge-status {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-status.pending { background: #fef3c7; color: #92400e; }
.badge-status.approved { background: #d1fae5; color: #065f46; }
.badge-status.rejected { background: #fee2e2; color: #991b1b; }
.badge-status.suspended { background: #e5e7eb; color: #374151; }
.badge-status.cancelled { background: #f3f4f6; color: #6b7280; text-decoration: line-through; }
[data-bs-theme="dark"] .badge-status.pending { background: #78350f; color: #fbbf24; }
[data-bs-theme="dark"] .badge-status.approved { background: #064e3b; color: #6ee7b7; }
[data-bs-theme="dark"] .badge-status.rejected { background: #7f1d1d; color: #fca5a5; }
[data-bs-theme="dark"] .badge-status.suspended { background: #374151; color: #d1d5db; }
[data-bs-theme="dark"] .badge-status.cancelled { background: #1f2937; color: #9ca3af; }

/* ===== Toast ===== */
.app-toast-container {
  position: fixed;
  top: 1rem; right: 1rem;
  z-index: 1090;
  display: flex; flex-direction: column;
  gap: 0.5rem;
  max-width: 360px;
}
.app-toast {
  background: var(--bs-body-bg);
  border-left: 4px solid var(--bs-primary);
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow);
  padding: 0.75rem 1rem;
  display: flex; align-items: flex-start;
  gap: 0.5rem;
  animation: app-toast-in 0.25s ease-out;
}
.app-toast.success { border-color: #10b981; }
.app-toast.danger, .app-toast.error { border-color: #ef4444; }
.app-toast.warning { border-color: #f59e0b; }
.app-toast.info { border-color: #06b6d4; }
.app-toast .icon { font-size: 1.1rem; line-height: 1.2; }
.app-toast .body { flex: 1; font-size: 0.9rem; }
.app-toast .close { background: transparent; border: 0; font-size: 1.2rem; line-height: 1; cursor: pointer; color: var(--bs-secondary-color); }

@keyframes app-toast-in {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ===== 模态框：日历 ===== */
.modal-calendar { max-width: 900px; }
#calendar-modal-body .fc { font-size: 0.9rem; }

/* ===== 冲突横幅 ===== */
.conflict-banner {
  background: #fef3c7;
  color: #92400e;
  padding: 0.75rem 1rem;
  border-radius: var(--app-radius);
  margin-bottom: 1rem;
  border-left: 4px solid #f59e0b;
}
[data-bs-theme="dark"] .conflict-banner {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

/* ===== 验证码图片 ===== */
.captcha-img { height: 38px; cursor: pointer; vertical-align: middle; }

/* ===== 工具 ===== */
.text-truncate-2 {
  /* display: -webkit-box; */
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ===== 登录页（无导航栏，居中卡片布局） ===== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bs-body-bg);
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 1rem;
  box-shadow: var(--app-shadow);
  padding: 2rem 1.75rem;
}
[data-bs-theme="dark"] .login-card { border-color: rgba(255,255,255,0.1); }
.login-brand { text-align: center; margin-bottom: 1.5rem; }
.login-brand i { font-size: 3rem; color: var(--bs-primary); }
.login-brand h3 { font-weight: 700; }
.login-hint code { font-size: 0.8rem; }
@media (max-width: 576px) {
  .login-card { padding: 1.5rem 1.25rem; border-radius: 0.75rem; }
}

/* ===== 系统 Logo 自适应（升级需求一）=====
   登录页 / 导航栏共用同一 logo_url；
   限制最大宽高并保持等比，避免尺寸比例不一致导致拉伸变形或布局错位。 */
.login-logo {
  display: inline-block;
  max-height: 72px;
  max-width: 220px;
  width: auto;
  height: auto;
  object-fit: contain;
}
.navbar-brand .brand-logo {
  height: 28px;
  width: auto;
  max-width: 120px;
  object-fit: contain;
  margin-right: .5rem;
  vertical-align: middle;
}
@media (max-width: 576px) {
  .login-logo { max-height: 56px; max-width: 160px; }
  .navbar-brand .brand-logo { height: 24px; max-width: 84px; }
}

/* ===== 公告展示（升级需求二）===== */
.login-announcements { max-height: 30vh; overflow-y: auto; }
.login-announcement-content { line-height: 1.5; word-break: break-word; }
.login-announcement-content p:last-child { margin-bottom: 0; }

.announcement-item {
  padding: .5rem 0;
  border-bottom: 1px dashed var(--bs-border-color);
}
.announcement-item:last-child { border-bottom: 0; padding-bottom: 0; }
.announcement-content {
  line-height: 1.6;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.announcement-content p:last-child { margin-bottom: 0; }
.announcement-content ul,
.announcement-content ol { margin-bottom: .25rem; padding-left: 1.25rem; }
.announcement-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
.announcement-content th,
.announcement-content td {
  border: 1px solid var(--bs-border-color);
  padding: .25rem .5rem;
}

/* 管理员联系方式列表 */
.admin-contact-list li { word-break: break-word; overflow-wrap: anywhere; }

/* ===== 分页 ===== */
.pagination .page-link { border-radius: 0.4rem; margin: 0 2px; }

/* ===== 内部会议遮蔽 ===== */
.internal-mask { font-style: italic; color: var(--bs-secondary-color); }

/* ===== 日历组件：文字溢出控制 =====
   桌面端 + 移动端均不溢出方框；长文本通过 ellipsis / line-clamp 截断；
   完整内容通过 Bootstrap tooltip / 点击模态框查看。
*/
.fc, .fc-view-harness, .fc-daygrid, .fc-daygrid-day-frame,
.fc-daygrid-day-events, .fc-daygrid-event, .fc-timegrid-event {
  min-width: 0;
}
.fc .fc-event {
  overflow: hidden;
  cursor: pointer;
}
.fc .fc-event .fc-event-main,
.fc .fc-event .ev-inner,
.fc .fc-event .fc-event-title,
.fc .fc-event .ev-title,
.fc .fc-event .ev-sub {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  min-width: 0;
  max-width: 100%;
}
/* 时间网格视图（周/日）允许两行省略 */
.fc-timegrid-event .fc-event-main,
.fc-timegrid-event .ev-inner {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  white-space: normal;
}
.fc-list-event-title { word-break: break-word; overflow-wrap: anywhere; }
/* 自定义 tooltip 样式（多行 HTML） */
.tooltip.ev-tooltip .tooltip-inner {
  max-width: 320px;
  text-align: left;
  background: #1f2937;
  color: #fff;
  font-size: 0.85rem;
  line-height: 1.4;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
}
.tooltip.ev-tooltip .tooltip-inner .ev-tip > div { white-space: nowrap; }
.tooltip.ev-tooltip .tooltip-arrow::before { border-top-color: #1f2937; }

/* ===== 日历预览模态框（由 reservation_form 使用）排版优化 ===== */
.modal-calendar { max-width: 900px; }
#calendar-modal-body { padding: 0.5rem 0.75rem; }
#calendar-modal-body .fc { font-size: 0.85rem; }
#calendar-modal-body .cal-inline-host { min-width: 0; }
#calendar-modal-body .fc .fc-toolbar.fc-header-toolbar {
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
#calendar-modal-body .fc .fc-toolbar-title { font-size: 1rem !important; }
#calendar-modal-body .fc .fc-toolbar .fc-button {
  font-size: 0.78rem !important;
  padding: 0.2rem 0.5rem !important;
}
/* 列表视图：紧凑排版 */
#calendar-modal-body .fc-list {
  border: 1px solid var(--bs-border-color);
  border-radius: var(--app-radius);
}
#calendar-modal-body .fc-list-day-cushion {
  background: rgba(var(--bs-primary-rgb), 0.06);
  font-weight: 600;
}
[data-bs-theme="dark"] #calendar-modal-body .fc-list-day-cushion {
  background: rgba(var(--bs-primary-rgb), 0.2);
}
#calendar-modal-body .fc-list-event { cursor: pointer; }
#calendar-modal-body .fc-list-event:hover {
  background: rgba(var(--bs-primary-rgb), 0.05);
}
#calendar-modal-body .fc-list-event-time,
#calendar-modal-body .fc-list-event-title { font-size: 0.85rem; }
/* 详情面板 */
#calendar-modal-body .modal-ical-detail { padding: 0.5rem 0.25rem; }
#calendar-modal-body .modal-ical-detail > div { word-break: break-word; }
#calendar-modal-body .modal-ical-detail strong {
  color: var(--bs-secondary-color);
  font-weight: 600;
}
/* 移动端：日历预览 modal 占满屏幕 */
@media (max-width: 768px) {
  .modal-calendar { max-width: 100%; margin: 0.5rem; }
  #calendarModal .modal-dialog { max-width: 100%; margin: 0.5rem; }
  #calendar-modal-body .fc { font-size: 0.75rem; }
  #calendar-modal-body .fc .fc-toolbar.fc-header-toolbar {
    flex-direction: column;
    gap: 0.25rem;
    align-items: stretch;
  }
  #calendar-modal-body .fc .fc-toolbar .fc-button {
    padding: 0.15rem 0.35rem !important;
  }
  #calendar-modal-body .fc-list-event-time,
  #calendar-modal-body .fc-list-event-title { font-size: 0.78rem; }
}