/* 在线排盘页样式（本站黑白灰口径）
 *
 * 页面骨架用 Tailwind（cms/base.html 已加载），本文件只负责两类：
 *   1) Tailwind 不好表达的组件：星盘元信息表格、提示条、星盘内小徽标（由
 *      chart-calculator.js 运行时拼 HTML 时使用 calc-* 类名）；
 *   2) 表单控件的细节收口（复选 chip、分段选择器、弹层）。
 */

/* ---------------- 星盘数据表格（JS 生成，类名由 tools/patch_calc_js.py 映射） ---------------- */
.calc-scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.calc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: #171717;
}
.calc-table th,
.calc-table td {
  border: 1px solid #e5e5e5;
  padding: 5px 8px;
  text-align: left;
  vertical-align: top;
}
.calc-table th {
  background: #fafafa;
  font-weight: 600;
  white-space: nowrap;
}
.calc-table-sm th,
.calc-table-sm td {
  padding: 3px 6px;
  font-size: 0.75rem;
}
.calc-table-striped tbody tr:nth-child(even) {
  background: #fafafa;
}
.calc-table-hover tbody tr:hover {
  background: #f5f5f5;
}
.calc-table-head th {
  background: #f5f5f5;
}
.calc-table-invert {
  background: #171717;
  color: #fafafa;
  border-color: #404040;
}
.calc-table-invert th,
.calc-table-invert td {
  border-color: #404040;
  color: #fafafa;
}
.calc-table-invert th {
  background: #262626;
}
.calc-table-invert .calc-table-striped tbody tr:nth-child(even) {
  background: #1f1f1f;
}

/* ---------------- 提示条 / 徽标 / 按钮（JS 生成） ---------------- */
.calc-note {
  border: 1px solid #e5e5e5;
  background: #fafafa;
  color: #171717;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.8125rem;
  margin-bottom: 12px;
}
.calc-note-title {
  font-weight: 600;
  margin-bottom: 4px;
}
.calc-note-err {
  border-color: #171717;
  background: #f5f5f5;
  font-weight: 500;
}
.calc-badge {
  display: inline-block;
  border-radius: 4px;
  padding: 0 6px;
  font-size: 0.6875rem;
  line-height: 1.5;
  border: 1px solid #d4d4d4;
  background: #f5f5f5;
  color: #171717;
  white-space: nowrap;
}
.calc-badge-strong { background: #171717; color: #fafafa; border-color: #171717; }
.calc-badge-mid { background: #525252; color: #fafafa; border-color: #525252; }
.calc-badge-soft { background: #d4d4d4; color: #171717; border-color: #d4d4d4; }
.calc-badge-mute { background: #f5f5f5; color: #737373; }

.calc-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid #171717;
  background: #171717;
  color: #fff;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 0.8125rem;
  cursor: pointer;
  line-height: 1.4;
}
.calc-btn:hover { background: #404040; border-color: #404040; }
.calc-btn-sm { padding: 3px 9px; font-size: 0.75rem; }
.calc-btn-ghost {
  background: #fff;
  color: #171717;
  border-color: #d4d4d4;
}
.calc-btn-ghost:hover { background: #f5f5f5; border-color: #a3a3a3; }

.calc-spinner {
  width: 2.4rem;
  height: 2.4rem;
  border: 3px solid #e5e5e5;
  border-top-color: #171717;
  border-radius: 50%;
  animation: calc-spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes calc-spin {
  to { transform: rotate(360deg); }
}

/* 星盘绘制区里的行星符号 / 中心圈（JS 生成） */
.planet-symbol { display: inline-block; min-width: 1.6em; font-weight: 600; }
.chart-circle {
  position: relative;
  width: 260px;
  height: 260px;
  margin: 0 auto;
  border-radius: 50%;
  border: 1px solid #e5e5e5;
}
.chart-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  background: #171717;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
}

/* ---------------- 表单控件 ---------------- */
.field-label {
  display: block;
  font-size: 0.75rem;
  color: #3f3f3f;
  margin-bottom: 4px;
  font-weight: 500;
}
.field {
  width: 100%;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  background: #fff;
  padding: 6px 10px;
  font-size: 0.875rem;
  color: #171717;
  outline: none;
}
.field:focus {
  border-color: #a3a3a3;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}
.field:read-only {
  background: #fafafa;
  color: #3f3f3f;
}
select.field {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23737373'%3E%3Cpath d='M5.5 7.5l4.5 5 4.5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  background-size: 18px;
  padding-right: 28px;
}

/* 分段选择器（radio 组） */
.seg {
  display: flex;
  flex-wrap: wrap;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  overflow: hidden;
}
.seg-item {
  flex: 1 1 auto;
  text-align: center;
  font-size: 0.8125rem;
  padding: 6px 8px;
  color: #3f3f3f;
  cursor: pointer;
  border-right: 1px solid #e5e5e5;
  background: #fff;
  white-space: nowrap;
}
.seg-item:last-child { border-right: 0; }
.seg-item:hover { background: #fafafa; }
.seg input:checked + .seg-item,
.seg .seg-item:has(input:checked) {
  background: #171717;
  color: #fff;
}

/* 选项 chip（复选框） */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid #e5e5e5;
  border-radius: 999px;
  padding: 2px 10px 2px 6px;
  font-size: 0.75rem;
  color: #3f3f3f;
  cursor: pointer;
  background: #fff;
  user-select: none;
}
.chip:hover { border-color: #a3a3a3; }
.chip input {
  width: 13px;
  height: 13px;
  accent-color: #171717;
  margin: 0;
}
.chip:has(input:checked) {
  background: #171717;
  border-color: #171717;
  color: #fff;
}

/* 折叠区 */
.fold-body[hidden] { display: none; }

/* 城市搜索结果：输入框下方就地展开 */
.loc-results {
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  background: #fff;
  max-height: 260px;
  overflow-y: auto;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
}
.loc-results[hidden] { display: none; }
.loc-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
}
.loc-item:last-child { border-bottom: 0; }
.loc-item:hover { background: #fafafa; }
.loc-item-name {
  display: block;
  font-size: 0.8125rem;
  color: #171717;
}
.loc-item-sub {
  display: block;
  font-size: 0.6875rem;
  color: #737373;
}

/* 页面提示条（window.showAlert）：滑入出现，消失前加 .calc-notice-out 淡出。
   宿主是 fixed 定位，弹窗只动画、不影响页面布局与滚动。 */
.calc-notice {
  background: #171717;
  color: #fafafa;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.8125rem;
  line-height: 1.5;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  margin-bottom: 8px;
  animation: calc-notice-in 0.22s ease-out;
}

@keyframes calc-notice-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.calc-notice.calc-notice-out {
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.22s ease-in, transform 0.22s ease-in;
}

/* ---------------- 星盘结果区（chart-calculator.js 生成，类名由 tools/patch_calc_js.py 映射） ---------------- */
/* 元信息压成一行，宽度与星盘一致（--calc-chart-w） */
:root {
  --calc-chart-w: 700px;
}
.calc-meta-panel {
  width: 100%;
  max-width: var(--calc-chart-w);
  margin-left: auto;
  margin-right: auto;
}
.calc-meta-head {
  background: #fafafa;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  padding: 10px 12px;
  text-align: center;
}
.calc-meta-head h6 {
  margin: 0;
  font-size: 0.95rem;
  color: #171717;
  font-weight: 600;
}
.calc-meta-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  column-gap: 10px;
  row-gap: 2px;
  margin-top: 6px;
  font-size: 11.5px;
  color: #3f3f3f;
  text-align: left;
}
.calc-meta-list-col {
  display: block;
}
.calc-meta-item {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.calc-meta-item strong {
  color: #171717;
  font-weight: 600;
  margin-right: 3px;
}
/* 第二行（返照 / 推运时间）：跨整行加分隔线，内部同样四列，
   日期落在第 1 列、时间落在第 2 列，于是与上一行的出生日期 / 出生时间对齐 */
.calc-meta-list > .w-full {
  grid-column: 1 / -1;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid #e5e5e5;
}
.calc-meta-list > .w-full > .flex {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  column-gap: 10px;
}
.calc-meta-list > .w-full > .flex > :first-child {
  grid-column: 1;
  margin-left: 0 !important;   /* 覆盖 JS 里的 md:ml-1/4 偏移 */
}
.calc-meta-list > .w-full > .flex > :nth-child(2) {
  grid-column: 2;
}
@media (max-width: 640px) {
  .calc-meta-list,
  .calc-meta-list > .w-full > .flex {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
.calc-meta-col {
  width: 100%;
}
@media (min-width: 768px) {
  .calc-meta-col-l { border-right: 1px solid #e5e5e5; }
}

/* ---------------- 星盘图 ---------------- */
#chartVisualization svg {
  max-width: min(100%, var(--calc-chart-w));
  height: auto;
  display: block;
}
#chartVisualization {
  min-height: 320px;
}

/* 手机端：让星盘元信息表格更好读 */
@media (max-width: 640px) {
  .calc-table { font-size: 0.75rem; }
  .calc-table th, .calc-table td { padding: 4px 6px; }
  .calc-scroll-x { -webkit-overflow-scrolling: touch; }
}

/* 双盘信息（内圈/外圈两卡）：md+ 左右各占一半，窄屏上下堆叠。
   容器 .calc-meta-list 是单盘信息用的 4 列网格，每卡跨 2 列即各得一半。 */
.calc-meta-list > .calc-meta-col {
  grid-column: span 2;
}
.calc-meta-list > .calc-meta-col + .calc-meta-col {
  margin-top: 12px;
}
@media (min-width: 768px) {
  .calc-meta-list > .calc-meta-col + .calc-meta-col {
    margin-top: 0;
    padding-left: 12px;
  }
}

/* 成功类状态行（window.showCalcStatus）：悬浮在星盘容器底部，
   浅色小字、无背景、绝对定位——出现/消失零布局位移，不干扰操作。 */
#calcStatusLine {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 4px;
  text-align: center;
  font-size: 12px;
  line-height: 1.4;
  color: #a8a8a8;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
  z-index: 6;
}
#calcStatusLine.calc-status-on {
  opacity: 1;
}
