/* Chart Styles - Bảng Lá Số Tử Vi 4x4 Grid */
/* Font: Be Vietnam Pro - Màu sắc cổ điển */

/* Chart Container - không có thanh cuộn riêng */
.chart-container {
  width: 100%;
  position: relative;
}

/* Main Chart Table */
.table-la-so {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  table-layout: fixed;
  background: var(--bg-paper, #FFFAF0);
  border: 3px solid var(--border-dark, #5C3317);
  font-family: 'Be Vietnam Pro', sans-serif;
  position: relative;
}

/* SVG Lines Container for hover effect */
/* Đường vẽ nằm dưới nội dung (z-index thấp) */
.chart-lines-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.chart-lines-container svg {
  width: 100%;
  height: 100%;
}

.chart-line {
  stroke: #DC143C;
  stroke-width: 2;
  fill: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.chart-line.active {
  opacity: 1;
}

/* Palace Cell (Cung) */
.cung {
  border: 2px solid var(--border-color, #8B4513);
  vertical-align: top;
  padding: 0;
  width: 25%;
  height: 280px;
  position: relative;
  background: var(--bg-paper, #FFFAF0);
  transition: all 0.3s ease;
}

.cung:hover {
  background: var(--bg-highlight, #FFF8DC);
  box-shadow: inset 0 0 15px rgba(218, 165, 32, 0.3);
}

.cung.highlighted {
  background: var(--bg-highlight, #FFF8DC);
  box-shadow: inset 0 0 20px rgba(218, 165, 32, 0.5);
}

.cung.hover-active {
  background: linear-gradient(135deg, #FFF8DC 0%, #FFEFD5 100%);
  box-shadow: inset 0 0 20px rgba(220, 20, 60, 0.2);
}

.cung-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 6px 8px;
  position: relative;
}

/* ===== PALACE TOP - Thiên Can Địa Chi & Tên Cung ===== */
.cung-top {
  border-bottom: 1px dashed var(--border-light, #D2B48C);
  padding-bottom: 4px;
  margin-bottom: 4px;
}

.view-cung-top {
  display: flex;
  justify-content: space-between;
  width: 100%;
  align-items: flex-start;
}

/* Thiên Can Địa Chi - góc trái */
.cung-top > .view-cung-top > div:first-child {
  min-width: 50px;
}

/* Earthly Branch and Element */
.text-dia-chi {
  font-size: 11px;
  color: var(--text-muted, #5D4E37);
  margin: 0;
  font-weight: 500;
  line-height: 1.3;
}

/* Palace Name - Tên cung ở giữa */
.text-sao-chinh-tinh {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
}

/* Life Palace (Mệnh) - Gold color */
.text-sao-chinh-tinh[data-cung="menh"],
.text-sao-chinh-tinh[data-cung="mệnh"] {
  color: var(--palace-menh, #DAA520) !important;
}

/* Body Palace (Thân) */
.text-sao-chinh-tinh[data-cung="than"],
.text-sao-chinh-tinh[data-cung="thân"] {
  color: var(--palace-than, #DAA520) !important;
}

/* Other palaces - Red color */
.cung .text-sao-chinh-tinh {
  color: var(--palace-normal, #B22222);
}

/* ===== CHÍNH TINH - Main Stars Section ===== */
.chinh-tinh {
  text-align: center;
  flex: 1;
}

/* Main Star Name */
.text-chinh-chinh {
  font-size: 14px;
  font-weight: 600;
  color: var(--star-major, #000);
  margin: 2px 0;
  line-height: 1.3;
}

/* Star Brightness Status */
.text-chinh-chinh .brightness,
.brightness-indicator {
  font-weight: 500;
  font-size: 10px;
  color: var(--text-muted, #5D4E37);
}

/* Đại vận - góc phải */
.view-cung-dai-van {
  text-align: right;
  min-width: 45px;
}

.text-dai-van-number {
  font-size: 12px;
  color: var(--hoa-color, #DC143C);
  font-weight: 700;
  white-space: nowrap;
}



/* Trường sinh */
.changsheng {
  color: var(--tho-color, #8B4513);
}

/* ===== CUNG MIDDLE - Phụ Tinh & Hung Tinh ===== */
.cung-middle {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
  padding: 4px 0;
  min-height: 80px;
}

/* Good Stars (Cát Tinh) */
.sao-tot {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 6px;
  align-content: flex-start;
}

.sao-tot .text-sao-xau-tot {
  color: var(--star-good, #228B22);
}

/* Bad Stars (Hung Tinh) */
.sao-xau {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 6px;
  align-content: flex-start;
}

.sao-xau .text-sao-xau-tot {
  color: var(--star-bad, #8B0000);
}

/* Star Text */
.text-sao-xau-tot {
  font-size: 11px;
  white-space: nowrap;
  font-weight: 500;
}

.txt-tiny {
  font-size: 11px;
}

.txt-tiny-mid {
  font-size: 12px;
}

.txt-tiny-bold {
  font-size: 11px;
  font-weight: 600;
}

/* Mutagen (Tứ Hóa) Colors */
.hoa-loc, .mutagen-loc {
  color: var(--hoa-loc, #228B22) !important;
}

.hoa-quyen, .mutagen-quyen {
  color: var(--hoa-quyen, #000) !important;
}

.hoa-khoa, .mutagen-khoa {
  color: var(--hoa-khoa, #1E90FF) !important;
}

.hoa-ky, .mutagen-ky {
  color: var(--hoa-ky, #DC143C) !important;
}

/* Mutagen indicator */
.mutagen {
  font-size: 13px;
  font-weight: 700;
  margin-left: 2px;
  padding: 1px 3px;
  border-radius: 2px;
}

/* ===== CUNG FOOTER - Đại vận, Tiểu hạn, Địa chi ===== */
.cung-footer {
  margin-top: auto;
  border-top: 1px dashed var(--border-light, #D2B48C);
  padding-top: 4px;
}

.cung-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 0;
}

.text-tieu-van {
  font-size: 10px;
  color: var(--text-muted, #5D4E37);
  font-weight: 500;
}



/* Địa chi góc dưới phải */
.dia-chi-corner {
  text-align: right;
  font-size: 12px;
  color: var(--border-color, #8B4513);
  font-weight: 700;
  margin-top: 2px;
}

/* Tiểu hạn text - đơn giản */
.tieu-han-text {
  font-size: 11px;
  color: #2F1810;
  text-align: center;
  margin: 2px 0;
  font-weight: 600;
}

/* Trường sinh */
.changsheng {
  color: var(--tho-color, #8B4513);
  font-weight: 600;
  font-size: 11px;
}

/* 12 Thần - Bác Sĩ, Tướng Tiền, Tuế Tiền */
.twelve-spirits {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  margin: 2px 0;
  font-size: 10px;
  font-weight: 500;
}

/* Bác Sĩ 12 thần - Thủy (xanh dương) */
.spirit-boshi {
  color: #0055AA;
}

/* Tướng Tiền 12 thần - Mộc (xanh lá) */
.spirit-jiangqian {
  color: #006400;
}

/* Tuế Tiền 12 thần - Kim (vàng cam) */
.spirit-suiqian {
  color: #CC7722;
}

/* Tooltip icon cho các sao 12 thần */
.tooltip-icon {
  font-size: 9px;
  color: #999;
  cursor: help;
  margin-left: 1px;
  vertical-align: super;
}

/* Custom tooltip - hiển thị phía trên */
.star-tooltip {
  position: relative;
  cursor: help;
  display: inline-block;
}

.star-tooltip::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 5px 10px;
  background: #2F1810;
  color: #FFF;
  font-size: 11px;
  font-weight: 400;
  white-space: nowrap;
  border-radius: 4px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  z-index: 1000;
  margin-bottom: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.star-tooltip::after {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #2F1810;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  z-index: 1000;
}

.star-tooltip:hover::before,
.star-tooltip:hover::after {
  opacity: 1;
  visibility: visible;
}

/* Hover effect cho các sao có tooltip */
.star-tooltip:hover {
  text-decoration: underline dotted;
}

/* Small Fortune Indicator - deprecated, use .dia-chi-corner instead */

/* ===== CENTER SECTION - Thông tin trung tâm ===== */
.center-info {
  border: 2px solid var(--border-color, #8B4513);
  padding: 12px;
  background: var(--bg-paper, #FFFAF0);
  vertical-align: top;
  position: relative;
}

.center-info-content {
  display: flex;
  flex-direction: column;
  gap: 3px;
  height: 100%;
}

.center-info h3 {
  font-size: 16px;
  color: var(--primary-color, #8B0000);
  text-align: center;
  margin-bottom: 8px;
  border-bottom: 2px solid var(--gold-color, #DAA520);
  padding-bottom: 6px;
  font-weight: 700;
}

.center-info-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  padding: 2px 0;
}

.center-info-label {
  color: var(--text-muted, #5D4E37);
  font-weight: 500;
  font-size: 11px;
}

.center-info-value {
  color: var(--text-color, #2F1810);
  font-weight: 600;
  font-size: 11px;
  text-align: right;
}

.center-info-value.highlight {
  color: var(--primary-color, #8B0000);
  font-weight: 700;
}

/* Bone Weight Display */
.bone-weight {
  text-align: center;
  padding: 8px;
  margin-top: 8px;
  border-top: 1px dashed var(--border-light, #D2B48C);
}

.bone-weight .center-info-label {
  font-size: 10px;
  margin-bottom: 4px;
  display: block;
}

.bone-weight-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary-color, #8B0000);
}

/* Tứ Hóa Phi Section */
.cung-middle-tu-hoa-phai {
  padding: 5px;
  margin-top: 4px;
  font-size: 10px;
}

.cung-middle-tu-hoa-phai p {
  margin: 2px 0;
}

.color-highlight {
  color: var(--gold-color, #DAA520);
  font-weight: 700;
}

/* Ngũ Hành Colors */
.ngu-hanh-kim { color: var(--kim-color, #FFD700); }
.ngu-hanh-moc { color: var(--moc-color, #228B22); }
.ngu-hanh-thuy { color: var(--thuy-color, #1E90FF); }
.ngu-hanh-hoa { color: var(--hoa-color, #DC143C); }
.ngu-hanh-tho { color: var(--tho-color, #8B4513); }

/* Legend for Ngũ Hành */
.ngu-hanh-legend {
  display: flex;
  justify-content: center;
  gap: 15px;
  padding: 8px;
  font-size: 14px;
  border-top: 1px solid var(--border-light, #D2B48C);
  margin-top: 10px;
}

.ngu-hanh-legend span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ngu-hanh-legend .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.ngu-hanh-legend .dot.kim { background: #CC7722; }
.ngu-hanh-legend .dot.moc { background: #006400; }
.ngu-hanh-legend .dot.thuy { background: #0055AA; }
.ngu-hanh-legend .dot.hoa { background: #CC0000; }
.ngu-hanh-legend .dot.tho { background: #6B3A5B; }

/* Brightness Legend */
.brightness-legend {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 6px;
  font-size: 10px;
  color: var(--text-muted, #5D4E37);
}

/* Responsive Chart */
/* Breakpoint 1024px - Tablet landscape */
@media (max-width: 1024px) {
  .table-la-so {
    font-size: 16px;
  }

  .cung {
    height: 240px;
  }

  /* Palace name - scaled from 23px */
  .text-sao-chinh-tinh {
    font-size: 20px;
  }

  /* Major star name - scaled from 21px */
  .text-chinh-chinh {
    font-size: 18px;
  }

  /* Minor star - scaled from 17px */
  .text-sao-xau-tot {
    font-size: 15px;
  }

  /* Earthly branch - scaled from 18px */
  .text-dia-chi {
    font-size: 16px;
  }

  /* Tiny text classes */
  .txt-tiny {
    font-size: 15px;
  }

  .txt-tiny-mid {
    font-size: 16px;
  }

  /* Decadal fortune number - scaled from 18px */
  .text-dai-van-number {
    font-size: 16px;
  }

  /* Center info section */
  .center-info h3 {
    font-size: 23px;
  }

  .center-info-label,
  .center-info-value {
    font-size: 18px;
  }

  .bone-weight-value {
    font-size: 23px;
  }
  
  /* Legend */
  .ngu-hanh-legend {
    font-size: 19px;
  }
}

/* Breakpoint 768px - Tablet portrait */
@media (max-width: 768px) {
  .table-la-so {
    min-width: 800px;
    font-size: 15px;
  }

  .cung {
    height: 220px;
  }

  /* Palace name - scaled from 23px */
  .text-sao-chinh-tinh {
    font-size: 18px;
  }

  /* Major star name - scaled from 21px */
  .text-chinh-chinh {
    font-size: 16px;
  }

  /* Minor star - scaled from 17px */
  .text-sao-xau-tot {
    font-size: 14px;
  }

  /* Earthly branch - scaled from 18px */
  .text-dia-chi {
    font-size: 15px;
  }

  /* Tiny text classes */
  .txt-tiny {
    font-size: 14px;
  }

  .txt-tiny-mid {
    font-size: 15px;
  }

  /* Decadal fortune number */
  .text-dai-van-number {
    font-size: 15px;
  }

  /* Center info section */
  .center-info h3 {
    font-size: 20px;
  }

  .center-info-label,
  .center-info-value {
    font-size: 16px;
  }

  .bone-weight-value {
    font-size: 20px;
  }

  /* Reduce padding for smaller screens */
  .cung-view {
    padding: 6px;
  }

  .center-info {
    padding: 10px;
  }
  
  /* Legend */
  .ngu-hanh-legend {
    font-size: 17px;
  }
}

/* Breakpoint 480px - Mobile */
@media (max-width: 480px) {
  .table-la-so {
    min-width: 700px;
    font-size: 14px;
  }

  .cung {
    height: 200px;
  }

  /* Palace name - scaled from 23px */
  .text-sao-chinh-tinh {
    font-size: 16px;
  }

  /* Major star name - scaled from 21px */
  .text-chinh-chinh {
    font-size: 14px;
  }

  /* Minor star - scaled from 17px */
  .text-sao-xau-tot {
    font-size: 12px;
  }

  /* Earthly branch - scaled from 18px */
  .text-dia-chi {
    font-size: 13px;
  }

  /* Tiny text classes */
  .txt-tiny {
    font-size: 12px;
  }

  .txt-tiny-mid {
    font-size: 13px;
  }

  .txt-tiny-bold {
    font-size: 12px;
  }

  /* Decadal fortune number */
  .text-dai-van-number {
    font-size: 13px;
  }

  /* Center info section */
  .center-info h3 {
    font-size: 17px;
    padding-bottom: 6px;
    margin-bottom: 8px;
  }

  .center-info-label,
  .center-info-value {
    font-size: 14px;
  }

  .center-info-row {
    font-size: 13px;
  }

  .bone-weight-value {
    font-size: 17px;
  }

  /* Reduce padding for mobile */
  .cung-view {
    padding: 4px;
  }

  .center-info {
    padding: 8px;
  }

  .cung-top {
    padding-bottom: 4px;
    margin-bottom: 4px;
  }

  .cung-bottom {
    padding-top: 4px;
  }

  /* Smaller indicators */
  .text-tieu-van {
    font-size: 11px;
  }

  .khoi-tieu-han-bottom,
  .khoi-tieu-han-bottom-0,
  .khoi-tieu-han-bottom-3,
  .khoi-tieu-han-mid-0 {
    font-size: 11px;
  }

  /* Brightness indicator */
  .text-chinh-chinh .brightness,
  .brightness-indicator {
    font-size: 11px;
  }

  /* Mutagen indicator */
  .mutagen {
    font-size: 11px;
    padding: 1px 2px;
  }

  /* Ngu hanh legend */
  .ngu-hanh-legend {
    gap: 8px;
    font-size: 14px;
  }

  .ngu-hanh-legend .dot {
    width: 10px;
    height: 10px;
  }

  /* Brightness legend */
  .brightness-legend {
    gap: 8px;
    font-size: 11px;
  }
}

/* Hidden elements */
.d-none {
  display: none !important;
}

/* Flex utilities */
.d-flex {
  display: flex;
}

.justify-content-center {
  justify-content: center;
}

.font-weight-bold {
  font-weight: 700;
}

.font-italic {
  font-style: italic;
}

.mb-0 {
  margin-bottom: 0;
}

.m-b-5 {
  margin-bottom: 5px;
}

.m-b-10 {
  margin-bottom: 10px;
}

.white-space-nowrap {
  white-space: nowrap;
}

/* Hover Lines - Đường vẽ khi hover */
.hover-line {
  position: absolute;
  background: var(--hoa-color, #DC143C);
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.hover-line.active {
  opacity: 1;
}

/* Triệt indicator */
.triet-indicator {
  position: absolute;
  bottom: 50%;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--hoa-color, #DC143C);
  display: flex;
  align-items: center;
  justify-content: center;
}

.triet-indicator span {
  background: var(--bg-paper, #FFFAF0);
  padding: 0 4px;
  font-size: 10px;
  color: var(--hoa-color, #DC143C);
  font-weight: 600;
}

/* Tuần indicator */
.tuan-indicator {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--moc-color, #228B22);
  display: flex;
  align-items: center;
  justify-content: center;
}

.tuan-indicator span {
  background: var(--bg-paper, #FFFAF0);
  padding: 0 4px;
  font-size: 10px;
  color: var(--moc-color, #228B22);
  font-weight: 600;
}

/* Logo in center */
.logo-dia-ban {
  text-align: center;
  margin-top: 10px;
}

.logo-la-so {
  opacity: 0.7;
}

/* Website info in center */
.website-info {
  text-align: center;
  margin-bottom: 10px;
}

.website-info .title {
  font-size: 12px;
  color: var(--text-color, #2F1810);
  font-weight: 600;
}

.website-info .url {
  font-size: 14px;
  color: var(--thuy-color, #1E90FF);
  font-weight: 700;
  text-decoration: none;
}

.website-info .hotline {
  font-size: 11px;
  color: var(--text-muted, #5D4E37);
}

.website-info .hotline span {
  color: var(--thuy-color, #1E90FF);
  font-weight: 600;
}

/* La so number */
.la-so-number {
  position: absolute;
  bottom: 5px;
  right: 10px;
  font-size: 10px;
  color: var(--text-muted, #5D4E37);
}

/* ============================================
   CENTER HOVER EFFECT STYLES
   Requirement 1.3, 1.5: Connection lines and dimming effect
   ============================================ */

/* Center cell hover active state - highlight effect */
.center-info.hover-active {
  background: linear-gradient(135deg, #FFF8DC 0%, #FFE4B5 50%, #FFEFD5 100%);
  box-shadow: 
    inset 0 0 30px rgba(218, 165, 32, 0.4),
    0 0 15px rgba(218, 165, 32, 0.3);
  border-color: var(--gold-color, #DAA520);
  transition: all 0.3s ease;
}

/* Palace dimmed state - opacity 0.3 for unrelated palaces */
/* Requirement 1.3: reduce opacity of unrelated palaces to 0.3 */
.cung.dimmed {
  opacity: 0.3;
  transition: opacity 0.3s ease;
}

/* SVG Lines Container - positioned absolutely over the chart table */
/* Requirement 1.5: SVG elements positioned absolutely over the chart table */
/* z-index: 1 để nằm dưới nội dung */
.svg-lines-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  overflow: visible;
}

.svg-lines-container svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* Lớp làm mờ nền cho hình vẽ trong ô giữa */
.center-lines-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 250, 240, 0.7);
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.center-lines-overlay.active {
  opacity: 1;
}

/* Connection line base styles */
/* Requirement 1.5: Connection lines drawn using SVG elements */
.center-connection-line {
  fill: none;
  stroke-width: 2;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.center-connection-line.active {
  opacity: 1;
}

/* Tam phương lines - Red (#DC143C) dashed */
/* Requirement 1.2: distinct colors for tam phương lines (red dashed) */
.center-connection-line.tam-phuong {
  stroke: #DC143C;
  stroke-dasharray: 5, 3;
}

/* Đối cung lines - Green (#228B22) solid */
/* Requirement 1.2: distinct colors for đối cung lines (green solid) */
.center-connection-line.doi-cung {
  stroke: #228B22;
  stroke-dasharray: none;
}

/* Animation for connection lines appearing */
@keyframes lineAppear {
  from {
    stroke-dashoffset: 100;
    opacity: 0;
  }
  to {
    stroke-dashoffset: 0;
    opacity: 1;
  }
}

.center-connection-line.animate {
  animation: lineAppear 0.3s ease forwards;
}
