/* Tử Vi AI Full Clean */
.tvai-app {
  max-width: 820px;
  margin: 35px auto;
  padding: 0 15px;
  font-family: inherit;
  color: #2b1b1b;
}

.tvai-shell {
  background: #fff;
  border-radius: 26px;
  padding: 24px;
  border: 1px solid #f1d6d6;
  box-shadow: 0 18px 45px rgba(120, 20, 40, 0.08);
}

.tvai-hero {
  background: linear-gradient(135deg, #8b0000, #c0182f);
  border-radius: 22px;
  padding: 28px;
  color: #fff;
  margin-bottom: 22px;
  overflow: hidden;
  position: relative;
}

.tvai-hero:after {
  content: "";
  position: absolute;
  width: 180px;
  height: 180px;
  right: -70px;
  top: -70px;
  background: rgba(255,255,255,.13);
  border-radius: 999px;
}

.tvai-hero-content {
  position: relative;
  z-index: 2;
}

.tvai-chip {
  display: inline-block;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(255,255,255,.18);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 12px;
  color: #fff;
}

.tvai-chip-light {
  background: #fff5f5;
  color: #8b0000;
  border: 1px solid #f1d6d6;
}

.tvai-hero h2 {
  margin: 0 0 8px;
  font-size: 34px;
  line-height: 1.2;
  color: #fff;
}

.tvai-hero p {
  margin: 0;
  font-size: 16px;
  line-height: 1.6;
  color: #ffecec;
}

.tvai-card {
  background: #fffaf8;
  border: 1px solid #f2d3d3;
  border-radius: 22px;
  padding: 22px;
}

.tvai-section-title {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.tvai-section-title > span {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: #8b0000;
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13px;
  flex: 0 0 auto;
}

.tvai-section-title strong {
  display: block;
  font-size: 17px;
  color: #7a0f1b;
}

.tvai-section-title small {
  color: #7b6b6b;
  font-size: 13px;
}

.tvai-section-title-space {
  margin-top: 24px;
}

.tvai-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 13px;
}

.tvai-field {
  display: block;
}

.tvai-field span {
  display: block;
  font-weight: 700;
  margin-bottom: 6px;
  color: #4a2525;
  font-size: 14px;
}

.tvai-field input,
.tvai-field select {
  width: 100%;
  height: 42px;
  border-radius: 12px;
  border: 1px solid #e7c3c3;
  background: #fff;
  padding: 8px 12px;
  font-size: 14px;
  color: #2b1b1b;
  outline: none;
  box-sizing: border-box;
}

.tvai-field input:focus,
.tvai-field select:focus {
  border-color: #b31226;
  box-shadow: 0 0 0 4px rgba(179, 18, 38, 0.08);
}

.tvai-consent {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  font-size: 13px;
  line-height: 1.5;
  color: #6b5555;
}

.tvai-consent input {
  margin-top: 3px;
}

.tvai-submit-row {
  margin-top: 16px;
}

.tvai-submit {
  width: auto;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #8b0000, #c0182f);
  color: #fff;
  padding: 11px 22px;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(192, 24, 47, 0.18);
}

.tvai-submit:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.tvai-loading {
  display: none;
  margin-top: 18px;
  padding: 20px;
  border-radius: 18px;
  background: #fff5f5;
  border: 1px solid #f1d6d6;
  text-align: center;
}

.tvai-spinner {
  width: 38px;
  height: 38px;
  border: 4px solid #f3d0d0;
  border-top-color: #b31226;
  border-radius: 50%;
  margin: 0 auto 10px;
  animation: tvaiSpin 1s linear infinite;
}

@keyframes tvaiSpin {
  to { transform: rotate(360deg); }
}

.tvai-loading strong {
  color: #7a0f1b;
}

.tvai-loading p {
  margin: 6px 0 0;
  color: #6b5555;
  font-size: 14px;
}

.tvai-result {
  margin-top: 20px;
}

.tvai-result-card {
  background: #fff;
  border: 1px solid #f1d6d6;
  border-radius: 22px;
  padding: 22px;
  box-shadow: 0 16px 36px rgba(120, 20, 40, 0.08);
}

.tvai-result-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid #f1d6d6;
}

.tvai-result-head h2 {
  margin: 10px 0 5px;
  color: #7a0f1b;
  font-size: 28px;
  line-height: 1.2;
}

.tvai-result-head p {
  margin: 0;
  color: #7b6b6b;
  font-size: 14px;
}

.tvai-ai-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 15px;
  background: #fff5f5;
  color: #8b0000;
  border: 1px solid #f1d6d6;
  font-weight: 900;
  flex: 0 0 auto;
}

.tvai-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 9px;
  margin: 18px 0;
}

.tvai-metrics div {
  background: #fffaf8;
  border: 1px solid #f1d6d6;
  border-radius: 14px;
  padding: 10px;
  min-width: 0;
}

.tvai-metrics strong {
  display: block;
  color: #7a0f1b;
  font-size: 14px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tvai-metrics span {
  display: block;
  color: #8a7373;
  font-size: 12px;
  margin-top: 3px;
}

.tvai-tabs {
  display: flex;
  gap: 8px;
  background: #fff5f5;
  border: 1px solid #f1d6d6;
  border-radius: 14px;
  padding: 5px;
  margin-bottom: 18px;
}

.tvai-tabs button {
  flex: 1;
  border: 0;
  background: transparent;
  border-radius: 10px;
  padding: 9px 10px;
  color: #7a0f1b;
  font-weight: 800;
  cursor: pointer;
}

.tvai-tabs button.active {
  background: #fff;
  box-shadow: 0 6px 15px rgba(120, 20, 40, 0.08);
}

.tvai-tab-content {
  display: none;
  font-size: 16px;
  line-height: 1.75;
  color: #2b1b1b;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.tvai-tab-content.active {
  display: block;
}

.tvai-tab-content h3 {
  color: #7a0f1b;
  font-size: 22px;
  margin: 22px 0 8px;
}

.tvai-tab-content h4 {
  color: #9f1239;
  font-size: 18px;
  margin: 18px 0 7px;
}

.tvai-tab-content p {
  margin: 0 0 14px;
}

.tvai-tab-content ul {
  padding-left: 22px;
}

.tvai-lucky-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 11px;
}

.tvai-lucky-grid div {
  background: #fffaf8;
  border: 1px solid #f1d6d6;
  border-radius: 14px;
  padding: 14px;
}

.tvai-lucky-grid span {
  display: block;
  color: #8a7373;
  font-size: 13px;
}

.tvai-lucky-grid strong {
  display: block;
  color: #7a0f1b;
  margin-top: 4px;
}

.tvai-actions {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  border-top: 1px solid #f1d6d6;
  padding-top: 16px;
  margin-top: 18px;
}

.tvai-actions button,
.tvai-actions a {
  border: 1px solid #f1d6d6;
  background: #fff;
  border-radius: 999px;
  color: #7a0f1b !important;
  text-decoration: none !important;
  padding: 8px 14px;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
}

.tvai-actions button:hover,
.tvai-actions a:hover {
  background: #fff5f5;
}

.tvai-error {
  padding: 16px;
  border-radius: 16px;
  background: #fff1f2;
  color: #9f1239;
  border: 1px solid #fecdd3;
}

.tvai-footer-note {
  margin-top: 14px;
  text-align: center;
  font-size: 13px;
  color: #8a7373;
}

.tvai-copied {
  display: inline-flex;
  align-items: center;
  color: #15803d;
  font-weight: 800;
  padding: 8px 3px;
}

@media (max-width: 700px) {
  .tvai-shell {
    padding: 16px;
    border-radius: 20px;
  }

  .tvai-hero {
    padding: 22px;
  }

  .tvai-hero h2 {
    font-size: 28px;
  }

  .tvai-submit {
    width: 100%;
  }

  .tvai-result-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .tvai-metrics,
  .tvai-lucky-grid {
    grid-template-columns: 1fr;
  }

  .tvai-tabs {
    flex-direction: column;
  }
}

@media print {
  body * { visibility: hidden !important; }
  #tvai-print-area,
  #tvai-print-area * { visibility: visible !important; }
  #tvai-print-area {
    position: absolute !important;
    top: 0;
    left: 0;
    width: 100%;
    box-shadow: none !important;
  }
  .tvai-tabs,
  .tvai-actions { display: none !important; }
  .tvai-tab-content { display: block !important; }
}


/* ===== FIX 4.1: TỰ XUỐNG DÒNG LUẬN GIẢI DÀI ===== */
.tvai-tab-content,
.tvai-tab-content p,
.tvai-tab-content li,
.tvai-tab-content h3,
.tvai-tab-content h4,
.tvai-result-card,
.tvai-result-card * {
    overflow-wrap: break-word !important;
    word-wrap: break-word !important;
    word-break: break-word !important;
    white-space: normal !important;
    max-width: 100% !important;
}

.tvai-tab-content {
    overflow: hidden !important;
}

.tvai-tab-content p {
    margin-bottom: 16px !important;
    line-height: 1.85 !important;
}

.tvai-tab-content ul {
    padding-left: 22px !important;
    margin-top: 10px !important;
    margin-bottom: 18px !important;
}

.tvai-tab-content li {
    margin-bottom: 9px !important;
    line-height: 1.75 !important;
}

.tvai-tab-content strong,
.tvai-tab-content em,
.tvai-tab-content span,
.tvai-tab-content a {
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
}

.tvai-tab-content h3 {
    margin-top: 26px !important;
    margin-bottom: 10px !important;
    line-height: 1.35 !important;
}

.tvai-tab-content h4 {
    margin-top: 20px !important;
    margin-bottom: 8px !important;
    line-height: 1.4 !important;
}

/* Giữ khối kết quả không bị tràn ngang */
.tvai-result-card {
    overflow: hidden !important;
}

/* Mobile: chữ nhỏ và thoáng hơn */
@media (max-width: 768px) {
    .tvai-tab-content {
        font-size: 15px !important;
        line-height: 1.78 !important;
    }

    .tvai-tab-content p {
        line-height: 1.78 !important;
    }
}


/* ===== UPDATE 4.3: LABEL NẰM CÙNG DÒNG VỚI TEXTBOX ===== */

.tvai-fields {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
}

/* mỗi field là 1 hàng ngang */
.tvai-field {
    display: flex !important;
    align-items: center !important;
    gap: 14px !important;
    width: 100% !important;
    margin: 0 !important;
}

/* LABEL */
.tvai-field span {
    width: 180px !important;
    min-width: 180px !important;
    max-width: 180px !important;

    margin: 0 !important;

    font-size: 14px !important;
    font-weight: 700 !important;

    color: #4a2525 !important;

    line-height: 1.3 !important;
}

/* TEXTBOX + SELECT */
.tvai-field input,
.tvai-field select {
    width: 100% !important;
    max-width: 420px !important;

    height: 38px !important;
    min-height: 38px !important;

    padding: 7px 12px !important;

    border-radius: 10px !important;

    font-size: 14px !important;

    box-sizing: border-box !important;
}

/* NÚT */
.tvai-submit-row {
    padding-left: 194px !important;
}

.tvai-submit {
    width: auto !important;
    min-width: 170px !important;
    height: 38px !important;
    padding: 8px 18px !important;
    border-radius: 10px !important;
    font-size: 14px !important;
    line-height: 1 !important;
}

.tvai-consent {
    margin-left: 194px !important;
    max-width: 420px !important;
}

/* MOBILE */
@media (max-width: 768px) {

    .tvai-field {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 6px !important;
    }

    .tvai-field span {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
    }

    .tvai-field input,
    .tvai-field select {
        width: 100% !important;
        max-width: 100% !important;
        height: 42px !important;
    }

    .tvai-submit-row {
        padding-left: 0 !important;
    }

    .tvai-submit {
        width: 100% !important;
        height: 42px !important;
    }

    .tvai-consent {
        margin-left: 0 !important;
        max-width: 100% !important;
    }
}


/* ===== UPDATE 5.0: LOGIN + TÙY BIẾN MÀU SẮC ===== */
.tvai-app {
  color: var(--tvai-text, #2b1b1b) !important;
}

.tvai-shell,
.tvai-result-card {
  background: var(--tvai-bg, #fff) !important;
}

.tvai-card,
.tvai-metrics div,
.tvai-lucky-grid div {
  background: var(--tvai-card-bg, #fffaf8) !important;
}

.tvai-hero,
.tvai-submit,
.tvai-section-title > span,
.tvai-login-button {
  background: linear-gradient(135deg, var(--tvai-primary, #8b0000), var(--tvai-secondary, #c0182f)) !important;
}

.tvai-field span,
.tvai-tab-content,
.tvai-result-card,
.tvai-footer-note {
  color: var(--tvai-text, #2b1b1b) !important;
}

.tvai-result-head h2,
.tvai-tab-content h3,
.tvai-tab-content h4,
.tvai-loading strong,
.tvai-metrics strong,
.tvai-lucky-grid strong,
.tvai-ai-mark,
.tvai-tabs button,
.tvai-actions button,
.tvai-actions a {
  color: var(--tvai-primary, #8b0000) !important;
}

.tvai-field input:focus,
.tvai-field select:focus {
  border-color: var(--tvai-secondary, #c0182f) !important;
}

.tvai-spinner {
  border-top-color: var(--tvai-secondary, #c0182f) !important;
}

.tvai-login-box {
  text-align: left;
}

.tvai-login-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 18px;
  padding: 11px 22px;
  border-radius: 12px;
  color: #fff !important;
  text-decoration: none !important;
  font-weight: 800;
  box-shadow: 0 10px 22px rgba(192, 24, 47, 0.18);
}

.tvai-login-button:hover {
  filter: brightness(1.05);
}
