/* ==========================================================================
   TỬ VI ĐẨU SỐ - HỆ THỐNG THIÊN KỶ NGHÊ HẢI HẠ (OURANIC ENGINE v4.0)
   Bản Việt Hóa Học Thuật 100% - Sẵn sàng triển khai lên Static Host
   ========================================================================== */

:root {
  --bg-deep: #0b0c10;
  --bg-card: #12141c;
  --bg-palace: #161924;
  --bg-palace-hover: #1e2230;
  --bg-palace-active: #25293a;
  --bg-center: #10121a;
  --gold-primary: #d4af37;
  --gold-light: #f3e5ab;
  --gold-dim: #8a7322;
  --crimson: #c0392b;
  --jade: #27ae60;
  --cyan: #2980b9;
  --purple: #8e44ad;
  --text-main: #e8e6e3;
  --text-muted: #9aa0a6;
  --text-dim: #686de0;
  --border-gold: rgba(212, 175, 55, 0.28);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --lu-color: #2ecc71;     /* Hóa Lộc - Mộc/Thổ */
  --quan-color: #e67e22;   /* Hóa Quyền - Hỏa */
  --khoa-color: #3498db;   /* Hóa Khoa - Thủy */
  --ky-color: #e74c3c;     /* Hóa Kỵ - Thủy xung */
}

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

body {
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
}

h1, h2, h3, h4, .serif-title {
  font-family: 'Noto Serif SC', 'Playfair Display', Georgia, serif;
}

/* Header */
.app-header {
  background: linear-gradient(180deg, rgba(22,25,36,0.98) 0%, rgba(11,12,16,0.95) 100%);
  border-bottom: 1px solid var(--border-gold);
  padding: 1rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}

.header-inner {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.bagua- emblem {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px solid var(--gold-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--gold-primary);
  background: radial-gradient(circle, rgba(212,175,55,0.15) 0%, transparent 70%);
}

.brand-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--gold-light);
  letter-spacing: 0.5px;
}

.brand-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Control Bar */
.control-panel {
  max-width: 1600px;
  margin: 1rem auto;
  padding: 0 1.25rem;
}

.control-card {
  background: var(--bg-card);
  border: 1px solid var(--border-gold);
  border-radius: 10px;
  padding: 1.1rem 1.25rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 0.9rem;
  align-items: end;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group label {
  font-size: 0.76rem;
  color: var(--gold-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.form-control {
  background: #1a1d29;
  border: 1px solid rgba(255,255,255,0.14);
  color: var(--text-main);
  padding: 0.55rem 0.75rem;
  border-radius: 6px;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-control:focus {
  border-color: var(--gold-primary);
}

.btn-primary {
  background: linear-gradient(135deg, #d4af37 0%, #aa820a 100%);
  color: #0b0c10;
  font-weight: 700;
  border: none;
  padding: 0.6rem 1.1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: transform 0.15s, box-shadow 0.2s;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(212, 175, 55, 0.35);
}

/* Famous presets bar */
.presets-bar {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.preset-label {
  font-size: 0.78rem;
  color: var(--gold-primary);
  font-weight: 600;
  margin-right: 0.25rem;
}

.preset-chip {
  background: rgba(212, 175, 55, 0.08);
  border: 1px solid rgba(212, 175, 55, 0.28);
  color: var(--text-main);
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.2s;
}

.preset-chip:hover, .preset-chip.active {
  background: var(--gold-primary);
  color: #0b0c10;
  font-weight: 600;
}

/* Solar Time Banner */
.solar-banner {
  margin-top: 0.65rem;
  background: rgba(41, 128, 185, 0.12);
  border-left: 3px solid var(--gold-primary);
  padding: 0.5rem 0.85rem;
  border-radius: 4px;
  font-size: 0.8rem;
  color: #d0d7de;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
}

/* Main Workspace Layout */
.workspace {
  max-width: 1600px;
  margin: 0 auto 2.5rem;
  padding: 0 1.25rem;
  display: grid;
  grid-template-columns: 7fr 5fr;
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 1200px) {
  .workspace {
    grid-template-columns: 1fr;
  }
}

/* 12 Palace Chart Grid */
.chart-wrapper {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-gold);
  border-radius: 10px;
  padding: 0.5rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.45);
}

.ziwei-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, minmax(175px, auto));
  gap: 5px;
  position: relative;
}

.svg-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

.palace-cell {
  background: var(--bg-palace);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 0.55rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  cursor: pointer;
  transition: all 0.18s ease;
  z-index: 2;
  min-height: 178px;
}

.palace-cell:hover {
  background: var(--bg-palace-hover);
  border-color: rgba(212, 175, 55, 0.5);
}

.palace-cell.selected {
  background: var(--bg-palace-active);
  border: 1.5px solid var(--gold-primary);
  box-shadow: inset 0 0 15px rgba(212, 175, 55, 0.15);
}

.palace-cell.sanfang-highlight {
  border: 1px dashed rgba(46, 204, 113, 0.65);
  background: rgba(46, 204, 113, 0.05);
}

.palace-cell.duigong-highlight {
  border: 1px dashed rgba(231, 76, 60, 0.75);
  background: rgba(231, 76, 60, 0.06);
}

/* Palace Top Row: Stars */
.palace-stars {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: flex-start;
}

.star-item {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 2px 4px;
  border-radius: 4px;
  background: rgba(255,255,255,0.03);
  border: 1px solid transparent;
}

.star-major {
  color: #ff6b6b;
  font-weight: 700;
  font-size: 0.86rem;
}

.star-auspicious {
  color: #54a0ff;
  font-weight: 600;
  font-size: 0.78rem;
}

.star-malefic {
  color: #ff9f43;
  font-weight: 600;
  font-size: 0.78rem;
}

.star-minor {
  color: #a4b0be;
  font-size: 0.72rem;
}

.brightness-badge {
  font-size: 0.63rem;
  padding: 0 3px;
  border-radius: 3px;
  margin-top: 1px;
  font-weight: 600;
}

.b-Mieu, .b-Vuong {
  background: rgba(212, 175, 55, 0.22);
  color: var(--gold-light);
}

.b-Dac, .b-Loi {
  background: rgba(46, 204, 113, 0.18);
  color: #7bed9f;
}

.b-Binh, .b-Bat {
  background: rgba(255, 255, 255, 0.08);
  color: #ced6e0;
}

.b-Ham {
  background: rgba(231, 76, 60, 0.25);
  color: #ff7f50;
}

/* Sihua Badges */
.sihua-tag {
  font-size: 0.62rem;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  margin-top: 2px;
  color: #fff;
}

.sihua-Loc { background: var(--lu-color); color: #000; }
.sihua-Quyen { background: var(--quan-color); }
.sihua-Khoa { background: var(--khoa-color); }
.sihua-Ky { background: var(--ky-color); }

/* Palace Footer */
.palace-footer {
  border-top: 1px solid rgba(255,255,255,0.07);
  padding-top: 0.35rem;
  margin-top: 0.45rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  font-size: 0.74rem;
}

.palace-name-badge {
  background: rgba(212, 175, 55, 0.16);
  border: 1px solid rgba(212, 175, 55, 0.4);
  color: var(--gold-light);
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.78rem;
}

.palace-name-badge.menh-badge {
  background: var(--crimson);
  border-color: #ff6b6b;
  color: #fff;
}

.than-badge {
  background: var(--purple);
  color: #fff;
  font-size: 0.65rem;
  padding: 1px 4px;
  border-radius: 3px;
  margin-left: 3px;
}

.lainhan-badge {
  background: rgba(46, 204, 113, 0.2);
  border: 1px solid #2ecc71;
  color: #2ecc71;
  font-size: 0.63rem;
  padding: 0 4px;
  border-radius: 3px;
  margin-left: 3px;
}

.dahan-range {
  font-size: 0.7rem;
  color: var(--gold-primary);
  font-weight: 600;
}

.stem-branch-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 700;
}

/* Center Heaven Pool (Thiên Trì Trung Cung) */
.center-pool {
  grid-column: 2 / 4;
  grid-row: 2 / 4;
  background: var(--bg-center);
  border: 1px solid var(--border-gold);
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  z-index: 1;
}

.center-header {
  text-align: center;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0.6rem;
}

.center-header h2 {
  color: var(--gold-light);
  font-size: 1.2rem;
}

.bazi-pillars {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
  margin: 0.65rem 0;
  text-align: center;
}

.pillar-box {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 0.35rem;
}

.pillar-label {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.pillar-gz {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--gold-primary);
}

.center-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.4rem 0.8rem;
  font-size: 0.78rem;
}

.meta-item span.k {
  color: var(--text-muted);
}

.meta-item span.v {
  color: var(--text-main);
  font-weight: 600;
}

/* Right Insight Panel (13 Dimensions) */
.insight-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-gold);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 860px;
}

.insight-header {
  background: linear-gradient(90deg, rgba(212,175,55,0.16) 0%, transparent 100%);
  padding: 0.9rem 1.15rem;
  border-bottom: 1px solid var(--border-gold);
}

.insight-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.65rem 1rem;
  background: #101219;
  border-bottom: 1px solid var(--border-subtle);
}

.tab-btn {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 0.35rem 0.7rem;
  border-radius: 5px;
  font-size: 0.76rem;
  cursor: pointer;
  transition: all 0.18s;
}

.tab-btn.active, .tab-btn:hover {
  background: var(--gold-primary);
  color: #0b0c10;
  font-weight: 700;
  border-color: var(--gold-primary);
}

.insight-body {
  padding: 1.1rem 1.25rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
}

.dim-card {
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--gold-primary);
  border-radius: 6px;
  padding: 0.85rem 1rem;
}

.dim-card.ni-quote {
  border-left-color: var(--crimson);
  background: rgba(192, 57, 43, 0.07);
}

.dim-card.tcm-box {
  border-left-color: var(--jade);
  background: rgba(39, 174, 96, 0.07);
}

.dim-card.fengshui-box {
  border-left-color: var(--cyan);
  background: rgba(41, 128, 185, 0.08);
}

.dim-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--gold-light);
  margin-bottom: 0.4rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dim-tag {
  font-size: 0.68rem;
  background: rgba(212,175,55,0.18);
  color: var(--gold-primary);
  padding: 1px 6px;
  border-radius: 4px;
}

.dim-content {
  font-size: 0.84rem;
  color: #d8dee9;
}

.dim-content ul {
  padding-left: 1.2rem;
  margin-top: 0.35rem;
}

.dim-content li {
  margin-bottom: 0.3rem;
}
