/* RSSHub 风格：浅灰底、白卡片、橙色主色、细边框与轻阴影 */
:root {
  --app-bg: #f5f7f9;
  --app-surface: #ffffff;
  --app-text: #222222;
  --app-text-secondary: #666666;
  --app-text-muted: #999999;
  --app-accent: #ff6b00;
  --app-accent-hover: #e85d00;
  --app-border: #dcdfe6;
  --app-success: #52c41a;
  --app-radius-lg: 10px;
  --app-radius-md: 6px;
  --app-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
  --app-shadow-hover: 0 4px 12px rgba(15, 23, 42, 0.08);
  --app-zebra: rgba(0, 0, 0, 0.02);
  --app-zebra-alt: rgba(0, 0, 0, 0.035);

  --bs-body-bg: var(--app-bg);
  --bs-body-color: var(--app-text);
  --bs-secondary-color: var(--app-text-secondary);
  --bs-tertiary-color: var(--app-text-muted);
  --bs-primary: var(--app-accent);
  --bs-primary-rgb: 255, 107, 0;
  --bs-link-color: var(--app-accent);
  --bs-link-hover-color: var(--app-accent-hover);
  --bs-border-color: var(--app-border);
  --bs-focus-ring-color: rgba(255, 107, 0, 0.35);

  --schedule-hour-height: 2.25rem;
  --schedule-time-col-width: 3.75rem;
}

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

/* 白卡片容器 */
.app-surface-card {
  background: var(--app-surface);
  border-radius: var(--app-radius-lg);
  border: 1px solid rgba(0, 0, 0, 0.04);
  box-shadow: var(--app-shadow);
}

/* 站点名：橙色点缀 */
.schedule-brand {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--app-accent);
  line-height: 1.2;
}

.schedule-brand:hover {
  color: var(--app-accent-hover);
  opacity: 1;
}

/* 左栏设置 + 右栏日程 */
.schedule-layout {
  min-height: 100vh;
}

.schedule-sidebar {
  border-bottom: 1px solid var(--app-border);
}

@media (min-width: 992px) {
  .schedule-sidebar {
    border-bottom: none;
    border-right: 1px solid var(--app-border);
    position: sticky;
    top: 0;
    align-self: flex-start;
    max-height: 100vh;
    overflow-y: auto;
    background-color: transparent;
  }
}

.schedule-sidebar-inner {
  max-width: 22rem;
}

/* 左栏区块标题：层次清晰，不压过正文 */
.sidebar-section-title {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--app-text);
  text-transform: none;
}

.schedule-page .form-label {
  color: var(--app-text-secondary);
  font-weight: 500;
}

.schedule-page-title {
  font-size: clamp(1.2rem, 3.8vw, 1.5rem);
  font-weight: 600;
  color: var(--app-text);
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.schedule-meta {
  font-size: 0.8125rem;
  color: var(--app-text-muted);
}

.app-badge-success {
  background-color: var(--app-success) !important;
  color: #fff !important;
  font-weight: 500;
  font-size: 0.75rem;
  padding: 0.35em 0.65em;
  border-radius: 999px;
}

/* 表单控件：圆角、浅边框 */
.schedule-page .form-control,
.schedule-page .form-select {
  border-color: var(--app-border);
  border-radius: var(--app-radius-md);
  color: var(--app-text);
}

.schedule-page .form-control:focus,
.schedule-page .form-select:focus {
  border-color: var(--app-accent);
  box-shadow: 0 0 0 3px rgba(255, 107, 0, 0.12);
}

.schedule-page .btn-primary {
  --bs-btn-bg: var(--app-accent);
  --bs-btn-border-color: var(--app-accent);
  --bs-btn-hover-bg: var(--app-accent-hover);
  --bs-btn-hover-border-color: var(--app-accent-hover);
  --bs-btn-active-bg: var(--app-accent-hover);
  --bs-btn-active-border-color: var(--app-accent-hover);
  font-weight: 600;
  border-radius: var(--app-radius-md);
}

/* Tab：白底描边，激活态橙色实心 */
.schedule-main-tabs {
  gap: 0.5rem;
  border-bottom: none !important;
}

.schedule-main-tabs .nav-item {
  flex: 1 1 0;
}

.schedule-main-tabs .nav-link {
  border: 1px solid var(--app-border) !important;
  border-radius: var(--app-radius-md) !important;
  color: var(--app-text-secondary);
  background: var(--app-surface);
  margin-bottom: 0;
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
}

.schedule-main-tabs .nav-link:hover {
  border-color: rgba(255, 107, 0, 0.45) !important;
  color: var(--app-text);
}

.schedule-main-tabs .nav-link.active {
  background: var(--app-accent) !important;
  border-color: var(--app-accent) !important;
  color: #fff !important;
}

.schedule-page .alert-warning {
  background: rgba(255, 107, 0, 0.07);
  border: 1px solid rgba(255, 107, 0, 0.22);
  color: var(--app-text);
  border-radius: var(--app-radius-md);
}

.schedule-page .alert-secondary {
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid var(--app-border);
  color: var(--app-text-secondary);
  border-radius: var(--app-radius-md);
}

.attraction-pick {
  border-color: var(--app-border) !important;
  border-radius: var(--app-radius-md) !important;
}

.app-map-frame {
  border-radius: var(--app-radius-md);
  border: 1px solid var(--app-border);
  overflow: hidden;
}

@media (min-width: 992px) {
  .schedule-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
  }

  .schedule-main-inner {
    min-height: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
  }

  .schedule-main-inner .schedule-tab-content {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  .schedule-tab-content > .tab-pane.schedule-tab-pane-flex.active.show {
    display: flex !important;
    flex-direction: column;
    flex: 1 1 0;
    min-height: 0;
  }

  .schedule-main-inner .schedule-scroll {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  .schedule-main-inner .schedule-table-wrap {
    flex: 1 1 auto;
    min-height: 0;
  }

  /* 地图 Tab：卡片与容器占满 Tab 剩余高度，避免高度为 0 或塌陷 */
  #pane-map .map-card {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  #pane-map .map-card .card-body {
    flex: 1 1 0;
    min-height: 0;
  }

  .map-card {
    min-height: 0;
    flex: 1 1 auto;
  }
}

/* 日程表：横轴日期、纵轴 24 小时 */
.schedule-page .schedule-table-wrap {
  max-height: min(75vh, 900px);
  overflow: auto;
}

.schedule-tab-content {
  min-height: 0;
}

.amap-container {
  width: 100%;
  /* 小屏：给地图稳定高度（父级链未必有明确高度） */
  min-height: min(420px, 52vh);
  flex: 1 1 auto;
}

@media (min-width: 992px) {
  .schedule-page .schedule-table-wrap {
    max-height: calc(100vh - 10rem);
  }

  /* 大屏：在 flex 子项内铺满剩余空间；clamp 防止父链异常时高度为 0 */
  .amap-container {
    min-height: clamp(280px, calc(100vh - 18rem), 85vh);
    height: auto;
    flex: 1 1 0;
    max-height: none;
  }
}

/* Bootstrap 未提供 min-h-0 时，flex 子项需可收缩，地图区才能分到高度 */
.schedule-page .min-h-0 {
  min-height: 0 !important;
}

.schedule-grid {
  table-layout: fixed;
  border-color: var(--app-border);
  --bs-table-bg: transparent;
}

.schedule-grid thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background-color: var(--app-surface);
  box-shadow: inset 0 -1px 0 var(--app-border);
  vertical-align: middle;
  min-width: 6.5rem;
}

.schedule-grid .schedule-corner,
.schedule-grid .schedule-hour-label {
  position: sticky;
  left: 0;
  z-index: 1;
  background-color: var(--app-surface);
  width: var(--schedule-time-col-width);
  min-width: var(--schedule-time-col-width);
  max-width: var(--schedule-time-col-width);
  box-shadow: inset -1px 0 0 var(--app-border);
}

.schedule-grid thead .schedule-corner {
  z-index: 3;
  left: 0;
  top: 0;
}

.schedule-grid tbody th {
  top: auto;
}

.schedule-grid .schedule-hour-label {
  padding-top: 0;
  padding-bottom: 0;
  height: var(--schedule-hour-height);
  line-height: var(--schedule-hour-height);
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}

.schedule-grid .schedule-cell {
  height: var(--schedule-hour-height);
  padding: 0;
  background-color: var(--app-zebra);
  vertical-align: top;
}

.schedule-grid tbody tr:nth-child(even) .schedule-cell {
  background-color: var(--app-zebra-alt);
}

.schedule-day-head .fw-semibold {
  font-weight: 600;
  color: var(--app-text);
}

.schedule-day-head .schedule-weekday {
  font-weight: 400;
  color: var(--app-text-muted);
  font-size: 0.75rem;
}

.schedule-grid .schedule-cell.schedule-block {
  border-color: rgba(0, 0, 0, 0.08);
  vertical-align: top;
}

.schedule-block-inner {
  padding: 0.35rem 0.45rem;
  min-height: 100%;
  font-size: 0.75rem;
  line-height: 1.25;
}

.schedule-block-title {
  font-weight: 600;
  color: var(--app-text);
}

.schedule-block-sub {
  margin-top: 0.15rem;
  color: var(--app-text-secondary);
  white-space: pre-line;
}

.schedule-block-visit {
  background: rgba(82, 196, 26, 0.1) !important;
  box-shadow: inset 0 0 0 1px rgba(82, 196, 26, 0.32);
}

.schedule-block-booking {
  background: rgba(255, 107, 0, 0.1) !important;
  box-shadow: inset 0 0 0 1px rgba(255, 107, 0, 0.35);
}

.schedule-page .form-check-input:checked {
  background-color: var(--app-accent);
  border-color: var(--app-accent);
}

/* ========== 移动端友好（触控、安全区、横向滚动） ========== */
html {
  -webkit-text-size-adjust: 100%;
}

.schedule-body {
  touch-action: manipulation;
}

.schedule-main-shell {
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
}

.schedule-sidebar-inner.schedule-sidebar-safe {
  padding-bottom: max(1.25rem, env(safe-area-inset-bottom, 0)) !important;
}

.schedule-main-inner.schedule-main-safe {
  padding-bottom: max(0.75rem, env(safe-area-inset-bottom, 0)) !important;
}

@media (max-width: 991.98px) {
  :root {
    --schedule-hour-height: 2.5rem;
  }

  /* iOS：输入框字号小于 16px 会在聚焦时强制放大页面 */
  .schedule-page .touch-field {
    min-height: 2.75rem;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    font-size: 1rem;
  }

  .schedule-page .schedule-submit-btn {
    min-height: 2.875rem;
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
    font-size: 1rem;
    font-weight: 600;
  }

  .schedule-page .form-check-touch {
    min-height: 2.75rem;
    display: flex;
    align-items: center;
    padding-top: 0.2rem;
    padding-bottom: 0.2rem;
    margin-bottom: 0.15rem;
  }

  .schedule-page .form-check-touch .form-check-input {
    width: 1.2em;
    height: 1.2em;
    margin-top: 0;
    flex-shrink: 0;
  }

  .schedule-page .form-check-touch .form-check-label {
    font-size: 0.9375rem;
    padding-left: 0.35rem;
    line-height: 1.35;
  }

  .schedule-page .attraction-pick-mobile {
    max-height: min(14rem, 40vh);
    -webkit-overflow-scrolling: touch;
  }

  .schedule-main-tabs .nav-link {
    min-height: 2.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9375rem;
    padding: 0.5rem 0.35rem;
  }

  .schedule-page .schedule-table-wrap {
    max-height: min(65vh, 28rem);
    max-height: min(65dvh, 28rem);
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    border-radius: 0.375rem;
  }

  .schedule-page .schedule-block-inner {
    font-size: 0.8125rem;
    padding: 0.3rem 0.4rem;
  }

  .schedule-page .amap-container {
    min-height: max(16rem, 42vh);
    min-height: max(16rem, 42dvh);
    border-radius: 0.375rem;
  }

  .schedule-page #pane-map .card-body {
    padding: 0.75rem !important;
  }
}
