/* ===================================
   易經裝掛系統 - Premium 中國風主題
   兩欄佈局版
   =================================== */

:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #121829;
  --bg-card: #1a2035;
  --bg-card-header: #1e2640;
  --border-color: rgba(212, 175, 55, 0.2);
  --border-glow: rgba(212, 175, 55, 0.4);
  --gold-primary: #d4af37;
  --gold-light: #f0d060;
  --gold-dark: #a08520;
  --text-primary: #e8e0d0;
  --text-secondary: #a0987e;
  --text-muted: #6e6650;
  --red-accent: #dc3545;
  --green-accent: #28a745;
  --yang-color: #d4af37;
  --yin-color: #d4af37;
  --changing-color: #ff6b6b;
  --beast-color: #7ecbf5;
  --liuqin-color: #e8e0d0;
  --shadow-gold: 0 0 20px rgba(212, 175, 55, 0.1);
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Noto Sans TC', 'Microsoft JhengHei', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* 背景紋理 */
.bg-pattern {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(212, 175, 55, 0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(126, 203, 245, 0.02) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(212, 175, 55, 0.01) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* 導航列 */
.navbar {
  background: linear-gradient(135deg, var(--bg-secondary), var(--bg-card));
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 0;
  position: relative;
  z-index: 10;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  font-size: 1.5rem;
  color: var(--gold-primary);
  text-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
}

.brand-text {
  font-family: 'Noto Serif TC', serif;
  font-size: 1.4rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--gold-light), var(--gold-primary), var(--gold-dark));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 2px;
}

/* 主要內容 */
main {
  position: relative;
  z-index: 5;
  max-width: 920px;
  margin: 0 auto;
}

/* 卡片 */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: var(--transition);
  width: 890px;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
}

.card:hover {
  border-color: var(--border-glow);
  box-shadow: var(--shadow-card), var(--shadow-gold);
}

.card-header {
  background: var(--bg-card-header);
  border-bottom: 1px solid var(--border-color);
  padding: 1.25rem 1.5rem;
}

.card-title {
  font-family: 'Noto Serif TC', serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--gold-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .icon {
  font-size: 1.2rem;
}

.card-subtitle {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 4px;
  margin-bottom: 0;
}

.card-body {
  padding: 1.5rem;
}

/* 表單元素 */
.form-label {
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 6px;
}

.form-control,
.form-select {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.95rem;
  transition: var(--transition);
}

.form-control:focus,
.form-select:focus {
  background: var(--bg-secondary);
  border-color: var(--gold-primary);
  color: var(--text-primary);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15);
}

.form-select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* 裝卦按鈕 */
.btn-divine {
  background: linear-gradient(135deg, var(--gold-primary), var(--gold-dark));
  border: none;
  color: #0a0e1a;
  font-weight: 700;
  font-size: 1rem;
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  letter-spacing: 2px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.btn-divine::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s;
}

.btn-divine:hover {
  background: linear-gradient(135deg, var(--gold-light), var(--gold-primary));
  color: #0a0e1a;
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3);
}

.btn-divine:hover::before {
  left: 100%;
}

.btn-divine:active {
  transform: translateY(0);
}

/* ===================================
   兩欄佈局
   =================================== */

/* 兩欄佈局容器，設定固定寬度以對齊上方卡片 */
.result-container {
  width: 890px;
  max-width: 100%;
  margin: 0 auto;
}

.two-column-layout {
  display: flex;
  justify-content: center;
  gap: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  animation: fadeInUp 0.5s ease-out;
  width: 100%;
}

/* ===================================
   左欄 - 卦名標題
   =================================== */

.hexagram-title-block {
  display: grid;
  grid-template-columns: 110px 56px 48px 12em 36px 56px;
  gap: 4px;
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--border-color);
  align-items: center;
}

.title-left {
  grid-column: 4;
  text-align: center;
}

.palace-badge {
  grid-column: 5 / span 2;
  justify-self: start;
  margin-left: 10px;
  font-family: 'Noto Serif TC', serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gold-primary);
  padding: 6px 14px;
  border-radius: 20px;
  background: rgba(212, 175, 55, 0.1);
  border: 1px solid rgba(212, 175, 55, 0.3);
  white-space: nowrap;
}

.hexagram-name {
  font-family: 'Noto Serif TC', serif;
  font-size: 1.8rem;
  font-weight: 900;
  background: linear-gradient(180deg, var(--gold-light), var(--gold-primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0;
  letter-spacing: 3px;
}

.hexagram-sub {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 4px;
  margin-bottom: 0;
}

/* ===================================
   左欄 - 六爻排盤圖
   =================================== */

.hexagram-display {
  padding: 16px 12px;
}

/* 單爻行 grid: 變爻區 | 六親 | 地支(含五行) | 爻線 | 世/應 | 六獸 */
.yao-row {
  display: grid;
  grid-template-columns: 110px 56px 48px 12em 36px 56px;
  align-items: center;
  padding: 14px 8px;
  border-bottom: 1px solid rgba(212, 175, 55, 0.08);
  transition: var(--transition);
  gap: 4px;
  justify-content: center;
}

.yao-row:first-child {
  border-top: none;
}

.yao-row:last-child {
  border-bottom: none;
}

.yao-row:hover {
  background: rgba(212, 175, 55, 0.03);
}

/* 變爻行 */
.yao-row.changing {
  background: rgba(255, 107, 107, 0.05);
}

.yao-row.changing:hover {
  background: rgba(255, 107, 107, 0.08);
}

/* ===================================
   變爻區（左側箭頭欄位）
   =================================== */

.yao-changed-area {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  min-height: 28px;
  white-space: nowrap;
}

.yao-changed-area .changed-liuqin {
  font-family: 'Noto Serif TC', serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--changing-color);
}

.yao-changed-area .changed-dizhi {
  font-family: 'Noto Serif TC', serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--changing-color);
}

.yao-changed-area .change-arrow {
  font-size: 1rem;
  color: var(--changing-color);
  margin: 0 2px;
}

.yao-changed-area .changed-element {
  font-family: 'Noto Sans TC', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  margin-left: 1px;
}

/* 六親 */
.yao-liuqin {
  font-family: 'Noto Serif TC', serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--liuqin-color);
  text-align: left;
  white-space: nowrap;
}

/* 地支 + 五行右下小字包裹 */
.yao-dizhi-wrap {
  position: relative;
  display: inline-block;
  text-align: center;
  line-height: 1.4;
}

.yao-dizhi {
  font-family: 'Noto Serif TC', serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gold-primary);
}

.yao-dizhi-wrap .yao-dizhi-element {
  position: absolute;
  right: -0.85em;
  bottom: -0.1em;
  font-family: 'Noto Sans TC', sans-serif;
  font-size: 0.6rem;
  font-weight: 500;
}

/* 爻線 */
.yao-line {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  position: relative;
  padding: 0 10px;
}

/* 陽爻 ━━━ */
.yao-line.yang .line-bar {
  width: 100%;
  height: 8px;
  background: linear-gradient(90deg, var(--gold-dark), var(--gold-primary), var(--gold-dark));
  border-radius: 3px;
  box-shadow: 0 0 6px rgba(212, 175, 55, 0.2);
}

/* 陰爻 ━ ━ */
.yao-line.yin {
  gap: 16px;
}

.yao-line.yin .line-bar {
  flex: 1;
  height: 8px;
  background: linear-gradient(90deg, var(--gold-dark), var(--gold-primary), var(--gold-dark));
  border-radius: 3px;
  box-shadow: 0 0 6px rgba(212, 175, 55, 0.2);
}

/* 變爻的爻線共用 */
/* 陽變爻：整條線 + ○ */

.yao-line.changing-yang .line-bar {
  width: 100%;
  height: 8px;
  background: linear-gradient(90deg, #cc3333, #ff6b6b, #cc3333);
  border-radius: 3px;
  box-shadow: 0 0 8px rgba(255, 107, 107, 0.3);
}

.yao-line.changing-yin {
  gap: 16px;
}

.yao-line.changing-yin .line-bar {
  flex: 1;
  height: 8px;
  background: linear-gradient(90deg, #cc3333, #ff6b6b, #cc3333);
  border-radius: 3px;
  box-shadow: 0 0 8px rgba(255, 107, 107, 0.3);
}

.yao-line .change-mark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--changing-color);
  text-shadow: 0 0 8px rgba(255, 107, 107, 0.5);
  z-index: 2;
}

/* 世/應 標記 */
.yao-marker {
  text-align: center;
  min-width: 32px;
}

.marker-badge {
  display: inline-block;
  width: 30px;
  height: 30px;
  line-height: 30px;
  border-radius: 50%;
  font-family: 'Noto Serif TC', serif;
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
}

.marker-shi {
  background: rgba(212, 175, 55, 0.15);
  border: 2px solid var(--gold-primary);
  color: var(--gold-primary);
}

.marker-ying {
  background: rgba(126, 203, 245, 0.1);
  border: 2px solid #7ecbf5;
  color: #7ecbf5;
}

/* 六獸 */
.yao-beast {
  font-family: 'Noto Serif TC', serif;
  font-size: 1rem;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}

/* 六獸顏色 */
.beast-青龍 {
  color: #4ade80;
}

.beast-朱雀 {
  color: #f87171;
}

.beast-勾陳 {
  color: #fbbf24;
}

.beast-騰蛇 {
  color: #a78bfa;
}

.beast-白虎 {
  color: #f0f0f0;
}

.beast-玄武 {
  color: #60a5fa;
}

/* 右欄容器：四柱 + 空亡，緊靠卦象 */
.right-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px 18px 24px 12px;
  align-items: flex-start;
  justify-content: center;
  flex-shrink: 0;
  margin-left: 30px;
}

/* 四柱垂直堆疊 */
.ganzhi-block {
  display: flex;
  flex-direction: column;
  gap: 0;
  align-items: flex-start;
}

/* 每柱垂直（天干 / 地支+五行 / 標籤） */
.ganzhi-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  width: 2.4em;
}

.ganzhi-gan {
  font-family: 'Noto Serif TC', serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--gold-primary);
  line-height: 1.8;
}

/* 地支 + 五行下標包裹 */
.ganzhi-zhi-wrap {
  position: relative;
  display: inline-block;
  line-height: 1.8;
}

.ganzhi-zhi {
  font-family: 'Noto Serif TC', serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--gold-primary);
}

/* 五行：絕對定位在地支右下角，不影響對齊 */
.ganzhi-zhi-wrap .ganzhi-element {
  position: absolute;
  right: -0.9em;
  bottom: 0.1em;
  font-family: 'Noto Sans TC', sans-serif;
  font-size: 0.6rem;
  font-weight: 500;
}

.ganzhi-label {
  font-family: 'Noto Serif TC', serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-secondary);
  line-height: 1.8;
}

/* 空亡（四柱下方） */
.kongwang-line {
  font-family: 'Noto Serif TC', serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: #ff8a8a;
  text-align: left;
  letter-spacing: 2px;
  white-space: nowrap;
  margin-top: 4px;
}

/* ===================================
   五行顏色
   =================================== */
.element-金 {
  color: #e0d4b0;
}

.element-木 {
  color: #4ade80;
}

.element-水 {
  color: #60a5fa;
}

.element-火 {
  color: #f87171;
}

.element-土 {
  color: #fbbf24;
}

/* ===================================
   錯誤提示
   =================================== */

.alert-danger {
  background: rgba(220, 53, 69, 0.1);
  border: 1px solid rgba(220, 53, 69, 0.3);
  color: #ff8a8a;
  border-radius: var(--radius);
}

/* ===================================
   頁腳
   =================================== */

.footer {
  padding: 2rem 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border-color);
  margin-top: 3rem;
  position: relative;
  z-index: 5;
}

/* ===================================
   動畫
   =================================== */

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.yao-row {
  animation: slideIn 0.3s ease-out backwards;
}

.yao-row:nth-child(1) {
  animation-delay: 0.05s;
}

.yao-row:nth-child(2) {
  animation-delay: 0.1s;
}

.yao-row:nth-child(3) {
  animation-delay: 0.15s;
}

.yao-row:nth-child(4) {
  animation-delay: 0.2s;
}

.yao-row:nth-child(5) {
  animation-delay: 0.25s;
}

.yao-row:nth-child(6) {
  animation-delay: 0.3s;
}

/* ===================================
   響應式
   =================================== */

@media (max-width: 900px) {
  .two-column-layout {
    flex-direction: row;
    justify-content: center;
    align-items: stretch;
  }

  .left-column {
    border-right: 1px solid var(--border-color);
    border-bottom: none;
  }

  .right-column {
    flex-wrap: nowrap;
    justify-content: flex-start;
    padding: 24px 12px;
    margin-left: 15px;
  }
}

@media (max-width: 768px) {
  .yao-row {
    grid-template-columns: 90px 46px 40px 7.5em 30px 46px;
    padding: 10px 4px;
    gap: 3px;
  }

  .yao-liuqin {
    font-size: 0.9rem;
  }

  .yao-dizhi {
    font-size: 0.95rem;
  }

  .yao-beast {
    font-size: 0.85rem;
  }

  .hexagram-name {
    font-size: 1.4rem;
  }

  .hexagram-title-block {
    grid-template-columns: 90px 46px 40px 7.5em 30px 46px;
    gap: 3px;
  }

  .yao-changed-area {
    font-size: 0.85rem;
  }

  .right-column {
    padding-left: 8px;
    margin-left: 8px;
  }
}

@media (max-width: 576px) {
  main.container {
    padding-left: 4px;
    padding-right: 4px;
  }

  .card,
  .result-container {
    width: 100% !important;
  }

  .two-column-layout {
    width: 100%;
    gap: 0;
  }

  .left-column {
    flex: 1;
  }

  .yao-row {
    grid-template-columns: 92px 34px 28px 4.5em 22px 34px;
    padding: 8px 0;
    gap: 2px;
    font-size: 0.82rem;
  }

  .yao-liuqin {
    font-size: 0.82rem;
  }

  .yao-dizhi-wrap {
    width: 28px;
  }

  .yao-dizhi {
    font-size: 0.85rem;
  }

  .yao-beast {
    font-size: 0.78rem;
  }

  .yao-line {
    padding: 0 2px;
  }

  .yao-marker {
    min-width: 22px;
  }

  .marker-badge {
    width: 22px;
    height: 22px;
    line-height: 22px;
    font-size: 0.75rem;
  }

  .right-column {
    margin-left: 2px;
    padding: 16px 2px;
    border-left: 1px solid var(--border-color);
  }

  .ganzhi-col {
    width: 1.8em;
  }

  .ganzhi-gan,
  .ganzhi-zhi {
    font-size: 1.1rem;
  }

  .ganzhi-label {
    font-size: 0.85rem;
  }

  .ganzhi-zhi-wrap .ganzhi-element {
    right: -0.6em;
  }

  .kongwang-line {
    font-size: 0.7rem;
    letter-spacing: 0.5px;
    margin-top: 10px;
  }

  .hexagram-name {
    font-size: 1.25rem;
  }

  .hexagram-title-block {
    grid-template-columns: 92px 34px 28px 4.5em 22px 34px;
    gap: 2px;
    padding: 16px 4px 10px;
  }

  .palace-badge {
    padding: 4px 8px;
    font-size: 0.8rem;
  }
}