/* ==================== DESIGN SYSTEM ====================
   Style: Luxury Dark + Traditional Vietnamese Astrology
   Colors: Deep Black + Gold + Crimson accents
   Typography: Playfair Display (headings) + Inter (body)
   Based on UI UX Pro Max recommendations
   ========================================================= */

/* Google Fonts Import */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Playfair+Display:wght@400;500;600;700&display=swap');

/* CSS Variables - Default Dark Theme */
:root,
html.dark-mode {
  /* Primary Colors */
  --color-primary: #1C1917;      /* Deep Black */
  --color-secondary: #44403C;    /* Dark Stone */
  --color-accent: #CA8A04;       /* Gold */
  --color-accent-light: #EAB308; /* Bright Gold */
  --color-crimson: #8B0000;      /* Traditional Crimson */
  --color-crimson-light: #B91C1C;

  /* Background Colors */
  --bg-dark: #0A0A0A;
  --bg-card: #1C1917;
  --bg-card-hover: #292524;
  --bg-gradient: linear-gradient(135deg, #0A0A0A 0%, #1C1917 50%, #0A0A0A 100%);

  /* Text Colors */
  --text-primary: #FAFAF9;
  --text-secondary: #A8A29E;
  --text-muted: #78716C;

  /* Border */
  --border-color: #44403C;
  --border-gold: rgba(202, 138, 4, 0.3);

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
  --shadow-gold: 0 4px 20px rgba(202, 138, 4, 0.2);

  /* Typography */
  --font-heading: 'Playfair Display', serif;
  --font-body: 'Inter', sans-serif;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms ease;
}

/* Light Theme Variables */
html.light-mode {
  /* Primary Colors */
  --color-primary: #FAFAF9;
  --color-secondary: #E7E5E4;
  --color-accent: #8B0000;        /* Crimson as accent in light mode */
  --color-accent-light: #B91C1C;
  --color-crimson: #8B0000;
  --color-crimson-light: #DC2626;

  /* Background Colors */
  --bg-dark: #FFFFFF;
  --bg-card: #FAFAF9;
  --bg-card-hover: #F5F5F4;
  --bg-gradient: linear-gradient(135deg, #FFFFFF 0%, #FAFAF9 50%, #FFFFFF 100%);

  /* Text Colors */
  --text-primary: #1C1917;
  --text-secondary: #57534E;
  --text-muted: #78716C;

  /* Border */
  --border-color: #D6D3D1;
  --border-gold: rgba(139, 0, 0, 0.2);

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.15);
  --shadow-gold: 0 4px 20px rgba(139, 0, 0, 0.15);
}

/* Reset & Base */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-dark);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
}

h1 { font-size: clamp(2rem, 5vw, 3rem); }
h2 { font-size: clamp(1.5rem, 4vw, 2.25rem); }
h3 { font-size: clamp(1.25rem, 3vw, 1.5rem); }

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-accent-light);
}

/* Selection */
::selection {
  background: var(--color-accent);
  color: var(--color-primary);
}

/* ==================== HEADER & NAVIGATION ==================== */

.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 10, 10, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
}

html.light-mode .header {
  background: rgba(255, 255, 255, 0.95);
}

.nav {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-accent);
  letter-spacing: -0.02em;
  transition: color var(--transition-fast);
}

.logo:hover {
  color: var(--color-accent-light);
}

.nav-links {
  list-style: none;
  display: flex;
  gap: 8px;
}

.nav-links a {
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.95rem;
  padding: 10px 18px;
  border-radius: 8px;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.nav-links a:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}

.nav-links a.active {
  color: var(--color-accent);
  background: rgba(202, 138, 4, 0.1);
}

html.light-mode .nav-links a.active {
  background: rgba(139, 0, 0, 0.1);
}

/* Theme Toggle Button */
.theme-toggle {
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  margin-left: 16px;
}

.theme-toggle:hover {
  color: var(--color-accent);
  border-color: var(--color-accent);
  background: rgba(202, 138, 4, 0.1);
}

html.light-mode .theme-toggle:hover {
  background: rgba(139, 0, 0, 0.1);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
}

.theme-toggle .icon-sun {
  display: block;
}

.theme-toggle .icon-moon {
  display: none;
}

html.light-mode .theme-toggle .icon-sun {
  display: none;
}

html.light-mode .theme-toggle .icon-moon {
  display: block;
}

/* Nav with theme toggle */
.nav-right {
  display: flex;
  align-items: center;
}

/* ==================== MAIN CONTENT ==================== */

.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px;
  min-height: calc(100vh - 180px);
}

/* ==================== HERO SECTION ==================== */

.hero {
  text-align: center;
  padding: 60px 24px;
  background: var(--bg-card);
  border-radius: 24px;
  margin-bottom: 32px;
  border: 1px solid var(--border-color);
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at 50% 0%, rgba(202, 138, 4, 0.15) 0%, transparent 60%);
  pointer-events: none;
}

.hero h1 {
  color: var(--color-accent);
  margin-bottom: 16px;
  position: relative;
}

.hero p {
  color: var(--text-secondary);
  font-size: 1.15rem;
  max-width: 500px;
  margin: 0 auto;
  position: relative;
}

/* ==================== FORM SECTION ==================== */

.form-section {
  background: var(--bg-card);
  border-radius: 24px;
  padding: 40px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  margin-bottom: 32px;
}

.tuvi-form h2 {
  text-align: center;
  color: var(--color-accent);
  margin-bottom: 32px;
  font-size: 1.5rem;
}

.form-row {
  margin-bottom: 24px;
}

.form-row.two-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.form-row.three-cols {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
}

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

.form-group label {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.form-group input,
.form-group select {
  padding: 14px 18px;
  background: var(--bg-dark);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  font-size: 1rem;
  color: var(--text-primary);
  font-family: var(--font-body);
  transition: all var(--transition-fast);
}

.form-group input::placeholder {
  color: var(--text-muted);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 4px rgba(202, 138, 4, 0.15);
}

.form-group select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23A8A29E' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 18px;
  padding-right: 48px;
}

.form-group select option {
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 12px;
}

.checkbox-group {
  flex-direction: row;
  align-items: center;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-weight: 500;
  color: var(--text-secondary);
}

.checkbox-group input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--color-accent);
}

.btn-submit {
  width: 100%;
  padding: 18px;
  background: linear-gradient(135deg, var(--color-accent) 0%, #B45309 100%);
  color: var(--color-primary);
  border: none;
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 700;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all var(--transition-normal);
  margin-top: 16px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btn-submit:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-gold);
}

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

/* ==================== FEATURES SECTION ==================== */

.features {
  margin-bottom: 32px;
}

.features h2 {
  text-align: center;
  color: var(--color-accent);
  margin-bottom: 32px;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.feature-card {
  background: var(--bg-card);
  border-radius: 20px;
  padding: 28px;
  text-align: center;
  border: 1px solid var(--border-color);
  transition: all var(--transition-normal);
  cursor: pointer;
}

.feature-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-gold);
  box-shadow: var(--shadow-gold);
}

.feature-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(202, 138, 4, 0.1);
  border-radius: 16px;
  color: var(--color-accent);
}

.feature-icon svg {
  width: 28px;
  height: 28px;
}

.feature-card h3 {
  color: var(--text-primary);
  margin-bottom: 8px;
  font-size: 1.1rem;
}

.feature-card p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.5;
}

/* ==================== FOOTER ==================== */

.footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  text-align: center;
  padding: 24px;
  margin-top: auto;
}

.footer p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.footer a {
  color: var(--color-accent);
}

/* ==================== RESULT PAGE STYLES ==================== */

/* Back Button */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: var(--bg-card);
  color: var(--text-primary);
  border-radius: 12px;
  margin-bottom: 24px;
  border: 1px solid var(--border-color);
  font-weight: 500;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.back-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-gold);
  color: var(--color-accent);
}

/* Action Buttons */
.action-buttons {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
}

.btn-print,
.btn-new {
  padding: 12px 28px;
  border: none;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: var(--font-body);
}

.btn-print {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-print:hover {
  background: var(--bg-card-hover);
}

.btn-new {
  background: linear-gradient(135deg, var(--color-accent) 0%, #B45309 100%);
  color: var(--color-primary);
}

.btn-new:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-gold);
}

/* Info Box */
.info-box {
  background: var(--bg-card);
  border: 1px solid var(--border-gold);
  padding: 20px 28px;
  margin-bottom: 24px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px 32px;
  border-radius: 16px;
}

.info-box .info-item {
  display: flex;
  gap: 8px;
  align-items: center;
}

.info-box .info-label {
  color: var(--color-accent);
  font-weight: 600;
  font-size: 0.9rem;
}

.info-box .info-value {
  color: var(--text-primary);
  font-size: 0.95rem;
}

.info-box .underline {
  border-bottom: 1px solid var(--border-color);
  min-width: 80px;
}

/* Grid Container - La so */
.grid-container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, minmax(150px, auto));
  border: 2px solid var(--color-accent);
  background: var(--border-color);
  gap: 1px;
  margin-bottom: 24px;
  border-radius: 4px;
  overflow: hidden;
}

.cung {
  background: var(--bg-card);
  padding: 10px;
  position: relative;
  min-height: 150px;
  display: flex;
  flex-direction: column;
}

.cung-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cung-label {
  color: var(--color-accent);
  font-weight: 700;
  font-size: 14px;
  font-family: var(--font-heading);
}

.dai-han {
  background: transparent;
  border: 2px solid var(--color-accent);
  color: var(--color-accent);
  padding: 2px 0;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  min-width: 30px;
  text-align: center;
}

.sao-list {
  flex: 1;
  line-height: 1.8;
  font-size: 11px;
}

.chinh-tinh {
  font-weight: 700;
}

.hoa-tinh {
  color: var(--color-crimson-light) !important;
  font-weight: 700;
  text-decoration: underline;
}

.cung-footer {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: auto;
}

.badge {
  font-size: 10px;
  padding: 4px 10px;
  font-weight: 700;
  border-radius: 4px;
}

.badge-than {
  background: var(--color-crimson);
  color: var(--color-accent);
}

.badge-tuan {
  background: #1D4ED8;
  color: #fff;
}

.badge-triet {
  background: var(--color-crimson);
  color: #fff;
}

/* Center Box */
.center-box {
  grid-column: 2 / 4;
  grid-row: 2 / 4;
  background: linear-gradient(135deg, #1C1917 0%, #0A0A0A 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 24px;
  border: 1px solid var(--border-gold);
}

.center-title {
  font-family: var(--font-heading);
  font-size: 32px;
  font-weight: 700;
  color: var(--color-accent);
  margin-bottom: 24px;
  text-shadow: 0 2px 20px rgba(202, 138, 4, 0.3);
}

.center-info {
  font-size: 15px;
  line-height: 2;
  color: var(--text-secondary);
}

.center-info p {
  margin: 4px 0;
}

.center-info strong {
  color: var(--color-accent);
}

/* Legend */
.legend {
  background: var(--bg-card);
  padding: 20px 28px;
  border-radius: 16px;
  border: 1px solid var(--border-color);
}

.legend h3 {
  color: var(--color-accent);
  margin-bottom: 16px;
  font-size: 1rem;
}

.legend-items {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.legend-items span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-items strong {
  color: var(--text-primary);
}

.color-box {
  width: 18px;
  height: 18px;
  display: inline-block;
  border-radius: 4px;
}

.color-kim { background: #DAA520; }
.color-moc { background: #228B22; }
.color-thuy { background: #1E90FF; }
.color-hoa { background: #DC143C; }
.color-tho { background: #8B4513; }

/* ==================== CONTENT PAGE STYLES ==================== */

.content-page {
  background: var(--bg-card);
  border-radius: 24px;
  padding: 40px;
  border: 1px solid var(--border-color);
  margin-bottom: 32px;
}

.content-page h1 {
  color: var(--color-accent);
  margin-bottom: 24px;
}

.content-page h2 {
  color: var(--color-accent);
  margin: 32px 0 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border-gold);
  font-size: 1.5rem;
}

.content-page h3 {
  color: var(--text-primary);
  margin: 24px 0 12px;
}

.content-page p,
.content-page li {
  line-height: 1.8;
  margin-bottom: 12px;
  color: var(--text-secondary);
}

.content-page ul {
  padding-left: 28px;
}

.content-page strong {
  color: var(--text-primary);
}

.highlight-box {
  background: rgba(202, 138, 4, 0.1);
  border-left: 4px solid var(--color-accent);
  padding: 20px 24px;
  margin: 24px 0;
  border-radius: 0 12px 12px 0;
}

.highlight-box strong {
  color: var(--color-accent);
}

.step-list {
  counter-reset: step;
  list-style: none;
  padding-left: 0;
}

.step-list li {
  counter-increment: step;
  padding: 20px 20px 20px 70px;
  position: relative;
  background: var(--bg-dark);
  margin-bottom: 12px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

.step-list li::before {
  content: counter(step);
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--color-accent);
  color: var(--color-primary);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.tech-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 20px 0;
}

.tech-stack span {
  background: var(--bg-dark);
  padding: 10px 18px;
  border-radius: 24px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

/* ==================== RESPONSIVE ==================== */

@media (max-width: 900px) {
  .nav {
    flex-direction: column;
    gap: 16px;
  }

  .nav-links {
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
  }

  .hero {
    padding: 48px 20px;
  }

  .form-section {
    padding: 28px;
  }

  .form-row.two-cols,
  .form-row.three-cols {
    grid-template-columns: 1fr;
  }

  .feature-grid {
    grid-template-columns: 1fr 1fr;
  }

  .grid-container {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: auto;
  }

  .center-box {
    grid-column: 1 / 3;
    grid-row: auto;
    order: -1;
  }

  .info-box {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 600px) {
  .main {
    padding: 20px 16px;
  }

  .hero h1 {
    font-size: 1.75rem;
  }

  .feature-grid {
    grid-template-columns: 1fr;
  }

  .info-box {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .content-page {
    padding: 24px;
  }

  .action-buttons {
    flex-direction: column;
  }
}

/* ==================== PRINT STYLES ==================== */

@media print {
  .header,
  .footer,
  .back-btn,
  .action-buttons {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
  }

  .main {
    padding: 0;
    max-width: 100%;
  }

  .grid-container {
    border-color: #000;
  }

  .cung {
    background: #fff;
  }

  .cung-label,
  .center-title,
  .legend h3 {
    color: #8B0000;
  }

  .info-box {
    border-color: #8B0000;
    background: #fff;
  }

  .legend {
    background: #fff;
  }
}

/* ==================== ACCESSIBILITY ==================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus styles for keyboard navigation */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
