/* === Lá Số Tử Vi — Traditional Warm Theme === */
@import url('https://cdn.jsdelivr.net/npm/@tabler/icons-webfont@3/dist/tabler-icons.min.css');
.ti { line-height: 1; vertical-align: -0.125em; display: inline-block; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

:root {
  --cream: #fdf6e3;
  --cream-mid: #f5e6c8;
  --cream-deep: #f0ddc0;
  --white: #ffffff;
  --amber: #e8930a;
  --amber-dark: #c97808;
  --brown: #8b6020;
  --brown-mid: #a07030;
  --brown-light: #ddd0b0;
  --border-cell: #c8a870;
  --text: #1a0800;
  --text-mid: #5c3d1e;
  --text-soft: #9a7a5a;

  /* Star colors */
  --s-main: #cc0000;
  --s-hoa-tot: #cc5500;
  --s-hoa-ky: #880000;
  --s-good: #0044bb;
  --s-bad: #cc3300;
  --s-neutral: #2c2c2c;
  --s-gray: #888888;

  /* Five Elements Colors for Light Background */
  --color-kim: #374151;         /* Dark Gray */
  --color-moc: #16a34a;         /* Green */
  --color-thuy: #1e3a8a;        /* Navy Blue */
  --color-hoa: #b91c1c;         /* Crimson Red */
  --color-tho: #d97706;         /* Amber/Gold */
}

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

body {
  font-family: 'Be Vietnam Pro', sans-serif;
  background: linear-gradient(160deg, var(--cream) 0%, var(--cream-deep) 100%);
  min-height: 100vh;
  color: var(--text);
}

/* ==================== NAV ==================== */
.top-nav {
  padding: 12px 20px;
  display: flex;
  align-items: center;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--amber-dark);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  padding: 6px 0;
}

.back-btn:hover { color: var(--amber); }

/* ==================== FORM SECTION ==================== */
.form-wrapper {
  max-width: 460px;
  margin: 0 auto;
  padding: 0 16px 32px;
}

.form-card {
  background: var(--white);
  border-radius: 20px;
  padding: 28px 24px 22px;
  box-shadow: 0 8px 40px rgba(180, 100, 20, 0.14);
}

.form-title {
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 4px;
}

.form-subtitle {
  text-align: center;
  font-size: 13px;
  color: var(--text-soft);
  margin-bottom: 22px;
}

.field-row { margin-bottom: 10px; }

.field-input,
.field-select {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid #e0cdb0;
  border-radius: 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--white);
  outline: none;
  transition: border-color 0.2s;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23aaa' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.field-input {
  background-image: none;
  padding-right: 14px;
}

.field-input:focus,
.field-select:focus { border-color: var(--amber); }

.field-input::placeholder { color: #bbb; }

/* Date row */
.date-row { display: flex; gap: 7px; }
.date-row .day-sel   { flex: 1; }
.date-row .month-sel { flex: 1.1; }
.date-row .year-sel  { flex: 1.25; }

/* Three-column row */
.three-col-row { display: flex; gap: 7px; }
.three-col-row .cal-sel    { flex: 1.2; }
.three-col-row .gender-sel { flex: 1; }
.three-col-row .namxem-sel { flex: 1.35; }

/* Submit button */
.btn-submit {
  width: 100%;
  padding: 14px;
  background: var(--amber);
  color: var(--white);
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
  transition: background 0.2s, transform 0.1s;
  letter-spacing: 0.2px;
}

.btn-submit:hover  { background: var(--amber-dark); }
.btn-submit:active { transform: scale(0.99); }

/* Demo link */
.form-demo-link {
  text-align: center;
  font-size: 13px;
  color: var(--text-soft);
  margin-top: 14px;
}

.form-demo-link a {
  color: var(--amber);
  text-decoration: none;
  font-weight: 700;
}

/* ==================== CHART SECTION ==================== */
.chart-wrapper {
  max-width: 920px;
  margin: 0 auto 32px;
  padding: 0 16px;
}

.chart-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--brown-light);
  padding: 10px 2px 8px;
  margin-bottom: 10px;
  gap: 12px;
}

.chart-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-mid);
}

.btn-export {
  background: var(--white);
  border: 1.5px solid var(--amber);
  color: var(--amber-dark);
  padding: 6px 12px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  box-shadow: 0 2px 8px rgba(180, 100, 20, 0.06);
}

.btn-export:hover:not(:disabled) {
  background: #fffcf0;
  border-color: var(--amber-dark);
  color: var(--amber-dark);
}

.btn-export:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.chart-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.chart-scroll::-webkit-scrollbar { height: 0; }

.chart-outer {
  border: 2px solid var(--brown);
  background: var(--brown);
  min-width: 600px;
  position: relative;
}

/* Chiếu highlight states */
.palace-card.is-chieu-self {
  outline: 2px solid var(--amber);
  outline-offset: -2px;
  background: rgba(232, 147, 10, 0.09);
  z-index: 2;
}
.palace-card.is-chieu {
  outline: 1.5px dashed rgba(200, 115, 15, 0.65);
  outline-offset: -2px;
  background-color: rgba(200, 115, 15, 0.05);
  z-index: 2;
}
.palace-card.is-chieu-dim::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(210, 208, 204, 0.76);
  pointer-events: none;
  z-index: 1;
}

/* Animated dash lines */
@keyframes chieuDash {
  to { stroke-dashoffset: -18; }
}
#chieu-svg line {
  animation: chieuDash 0.65s linear infinite;
}

.chart-container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, minmax(150px, auto));
  gap: 1px;
}

/* ==================== PALACE CARD ==================== */
.palace-card {
  background: #fffdf5;
  padding: 5px 6px 4px;
  display: flex;
  flex-direction: column;
  min-height: 150px;
  position: relative;
}

/* Header row */
.pc-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  border-bottom: 1px solid var(--brown-light);
  padding-bottom: 2px;
  margin-bottom: 3px;
  gap: 4px;
}

.pc-chi {
  font-size: 9.5px;
  color: var(--brown-mid);
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}

.pc-cung-wrap {
  flex: 1;
  text-align: center;
}

.pc-cung {
  font-size: 11px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: 0.3px;
}


.pc-than-badge {
  display: inline-block;
  font-size: 8.5px;
  color: var(--s-good);
  font-weight: 700;
  border: 1px solid var(--s-good);
  padding: 0 3px;
  border-radius: 2px;
  margin-left: 2px;
  vertical-align: middle;
}

.pc-tt-badge {
  display: inline-block;
  font-size: 8px;
  font-weight: 800;
  padding: 0 2px;
  border-radius: 2px;
  margin-left: 2px;
  text-transform: uppercase;
  vertical-align: middle;
}
.pc-tt-badge.blue {
  color: #0044bb;
  border: 1px solid #0044bb;
  background: #f0f5ff;
}
.pc-tt-badge.red {
  color: #cc0000;
  border: 1px solid #cc0000;
  background: #fff0f0;
}
.pc-tt-badge.black {
  color: #1a0800;
  border: 1px solid #1a0800;
  background: #f5f5f5;
}

.pc-daihan {
  font-size: 11.5px;
  font-weight: 800;
  color: var(--brown-mid);
  flex-shrink: 0;
  margin-top: 1px;
}

/* Stars section */
.pc-stars {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5px;
}

.pc-chinh .star-main {
  display: block;
  font-size: 11.5px;
  font-weight: 800;
  color: var(--s-main);
  line-height: 1.35;
}

/* Two-column phụ tinh grid */
.pc-phu {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 4px;
  align-content: start;
}

.phu-col-left, .phu-col-right {
  display: flex;
  flex-direction: column;
  gap: 1.5px;
}

.phu-col-left .star-item, .phu-col-right .star-item {
  font-size: 9.5px;
  line-height: 1.3;
  font-weight: 600;
}

.star-hoa-tot  { color: var(--s-hoa-tot); font-weight: 700; }
.star-hoa-ky   { color: var(--s-hoa-ky);  font-weight: 700; }
.star-good     { color: var(--s-good);    font-weight: 600; }
.star-bad      { color: var(--s-bad);     font-weight: 600; }
.star-neutral  { color: var(--s-neutral); }
.star-gray     { color: var(--s-gray);    }

/* Element Colors Classes for Stars */
.color-kim  { color: var(--color-kim) !important; }
.color-moc  { color: var(--color-moc) !important; }
.color-thuy { color: var(--color-thuy) !important; }
.color-hoa  { color: var(--color-hoa) !important; }
.color-tho  { color: var(--color-tho) !important; }

/* Badge for Mệnh cung in header */
.badge-menh {
  background: #cc0000;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 3px;
  letter-spacing: 0.5px;
}

/* Footer row */
.pc-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--brown-light);
  padding-top: 2px;
  margin-top: 3px;
  font-size: 10px;
  font-weight: 700;
}

.pc-footer .pc-trangs {
  color: #5c3a00;
  font-style: italic;
}

.pc-footer .pc-nguyet {
  color: var(--brown-mid);
  background: var(--cream-mid);
  padding: 0 4px;
  border-radius: 3px;
  font-size: 9.5px;
}

/* ==================== CENTER PANEL ==================== */
.center-panel {
  grid-area: 2 / 2 / 4 / 4;
  background: #fffdf5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.drum-watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 65%;
  height: 65%;
  color: rgba(139, 96, 32, 0.05);
  pointer-events: none;
  z-index: 0;
}

.cp-side-decor {
  position: absolute;
  right: 6px;
  bottom: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  opacity: 0.85;
  pointer-events: none;
  z-index: 1;
}

.cp-calligraphy {
  font-family: 'Be Vietnam Pro', serif;
  writing-mode: vertical-rl;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  color: rgba(26, 8, 0, 0.08);
  text-transform: uppercase;
}

.cp-seal {
  width: 32px;
  height: 32px;
  border: 1.5px solid #cc0000;
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transform: rotate(-5deg);
  background: rgba(204, 0, 0, 0.03);
}

.cp-seal-inner {
  color: #cc0000;
  font-size: 6px;
  font-weight: 900;
  line-height: 1.1;
  text-align: center;
  font-family: monospace, serif;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cp-name {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 2px;
  position: relative;
  z-index: 2;
}

.cp-badge {
  display: inline-block;
  background: #fff0d0;
  border: 1px solid var(--amber);
  color: var(--amber-dark);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 20px;
  margin-bottom: 4px;
  position: relative;
  z-index: 2;
}

.cp-table {
  width: 100%;
  font-size: 10.5px;
  border-collapse: collapse;
  text-align: left;
  position: relative;
  z-index: 2;
}

.cp-table tr td { padding: 1px 2px; }

.cp-label {
  color: var(--text-soft);
  font-weight: 500;
  white-space: nowrap;
  width: 64px;
}

.cp-value {
  color: var(--text);
  font-weight: 700;
}

.cp-value.red  { color: #cc0000; }
.cp-value.blue { color: var(--s-good); }
.cp-value.green { color: #16a34a; }
.cp-value.amber { color: var(--amber-dark); }

.cp-divider {
  border: none;
  border-top: 1px solid var(--brown-light);
  width: 100%;
  margin: 4px 0;
  position: relative;
  z-index: 2;
}

/* Chart legend wrapper */
.chart-legends-wrapper {
  margin-top: 1px;
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-mid);
  width: 100%;
  background: #fffdf5;
}

.rating-legend {
  font-weight: 500;
}

.legend-label {
  font-weight: 700;
  color: var(--text);
}

.element-legend {
  display: flex;
  gap: 12px;
}

.legend-dot {
  font-size: 13px;
  vertical-align: middle;
  margin-right: 2px;
}

/* ==================== AI SECTION ==================== */
.ai-section {
  max-width: 860px;
  margin: 0 auto 48px;
  padding: 0 12px;
}

.ai-container {
  background: var(--white);
  border: 1px solid var(--brown-light);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 4px 20px rgba(180, 100, 20, 0.08);
}

.ai-header {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--brown-light);
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.ai-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.ai-icon { font-size: 20px; }

.ai-chat-log {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
  min-height: 60px;
}

.ai-message {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.6;
  max-width: 88%;
  animation: msgIn 0.25s ease;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ai-message.assistant {
  align-self: flex-start;
  background: var(--cream);
  border: 1px solid var(--brown-light);
  color: var(--text);
  border-top-left-radius: 2px;
}

.ai-message.user {
  align-self: flex-end;
  background: #fff0d0;
  border: 1px solid var(--amber);
  color: var(--text-mid);
  border-top-right-radius: 2px;
}

/* Markdown */
.md-content h4 {
  color: var(--amber-dark);
  font-size: 13.5px;
  font-weight: 700;
  margin: 10px 0 3px;
  padding-bottom: 3px;
  border-bottom: 1px solid var(--cream-mid);
}

.md-content h4:first-child { margin-top: 0; }
.md-content p { margin: 0 0 5px; line-height: 1.55; }
.md-content p:last-child { margin-bottom: 0; }
.md-content strong { color: var(--amber-dark); }
.md-content ul { margin: 2px 0 4px 16px; }
.md-content li { margin-bottom: 3px; line-height: 1.5; }
.md-content li:last-child { margin-bottom: 0; }
.md-content hr { border: none; border-top: 1px solid var(--brown-light); margin: 5px 0; }
.md-content br { display: block; content: ''; margin-top: 5px; line-height: 0; font-size: 0; }

/* AI input area */
.ai-input-area {
  border-top: 1px solid var(--brown-light);
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-prompts { display: flex; flex-wrap: wrap; gap: 6px; }

.prompt-chip {
  background: #fff0d0;
  border: 1px solid var(--amber);
  color: var(--amber-dark);
  padding: 5px 12px;
  border-radius: 20px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.prompt-chip:hover:not(:disabled) { background: #ffe0a0; }
.prompt-chip:disabled { opacity: 0.5; cursor: not-allowed; }

.ai-input-row { display: flex; gap: 8px; }

#ai-question {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid var(--brown-light);
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
  background: var(--white);
}

#ai-question:focus { border-color: var(--amber); }

.btn-ask {
  background: var(--amber);
  color: var(--white);
  border: none;
  border-radius: 10px;
  padding: 10px 20px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}

.btn-ask:hover:not(:disabled) { background: var(--amber-dark); }
.btn-ask:disabled { opacity: 0.6; cursor: not-allowed; }

/* Typing dots */
.typing-dots { display: flex; align-items: center; gap: 4px; padding: 4px 0; }

.typing-dots span {
  width: 6px;
  height: 6px;
  background: var(--text-soft);
  border-radius: 50%;
  opacity: 0.5;
  animation: tdot 1.4s infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes tdot {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.3; }
  40%           { transform: scale(1);   opacity: 1; }
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 520px) {
  .form-card  { padding: 22px 16px 18px; }
  .field-input,
  .field-select {
    padding-left: 8px;
    padding-right: 24px;
    background-position: right 8px center;
    font-size: 13px;
  }
}

/* ---- SEO + FAQ section (form page) ---- */
.tuvi-seo-content {
  width: 100%; max-width: 540px;
  margin: 28px auto 40px;
  padding: 0 20px;
  text-align: left;
}
.tuvi-seo-title {
  font-size: 16px; font-weight: 800;
  color: var(--amber);
  margin-bottom: 12px;
  position: relative; padding-bottom: 8px;
}
.tuvi-seo-title::after {
  content: ''; position: absolute;
  bottom: 0; left: 0;
  width: 36px; height: 2px;
  background: var(--amber); border-radius: 2px;
}
.tuvi-seo-content h3 {
  font-size: 13.5px; font-weight: 700;
  color: var(--text-mid); margin: 18px 0 8px;
}
.tuvi-seo-content p {
  font-size: 13.5px; color: var(--text-soft);
  line-height: 1.65; margin-bottom: 12px;
}
.tuvi-seo-content strong { color: var(--text-mid); }
.tuvi-seo-content .faq-section {
  margin-top: 28px;
  border-top: 1px solid rgba(200,168,112,0.4);
  padding-top: 20px;
}
.tuvi-seo-content .faq-title {
  font-size: 14px; font-weight: 700;
  color: var(--text-mid); margin-bottom: 10px;
}
.tuvi-seo-content details.faq-item {
  border-bottom: 1px solid rgba(200,168,112,0.3);
  padding: 13px 0;
}
.tuvi-seo-content details.faq-item summary {
  list-style: none; cursor: pointer;
  color: var(--text); font-size: 13.5px; font-weight: 600;
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px;
}
.tuvi-seo-content details.faq-item summary::-webkit-details-marker { display: none; }
.tuvi-seo-content details.faq-item summary::after {
  content: '▼'; font-size: 10px;
  color: var(--text-soft); flex-shrink: 0;
  transition: transform 0.25s ease;
}
.tuvi-seo-content details.faq-item[open] summary::after {
  transform: rotate(180deg); color: var(--amber);
}
.tuvi-seo-content details.faq-item p {
  margin-top: 10px; margin-bottom: 0;
  color: var(--text-soft); font-size: 13px; line-height: 1.65;
}
