/* ============================================================
   Lunar Calendar — Design System v2
   Enchanted Forest / Lunar Mystical Aesthetic
   Inspired by: midnight skies, glowing amber, ethereal nature
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&family=Playfair+Display:wght@400;500;600;700&display=swap');

/* === Light Theme — Warm Parchment & Earth === */
:root {
  --font: 'DM Sans', sans-serif;
  --font-display: 'Playfair Display', serif;

  /* Warm, soft backgrounds — not harsh white */
  --bg: #f5f0e8;
  --surface: #faf7f2;
  --surface2: #eee8dc;
  --surface3: #e4ddd0;
  --border: #d9d0c1;

  /* Earthy text — warm brown tones */
  --text: #2c241a;
  --text2: #6b5e4d;
  --text3: #9e9180;

  /* Primary — Deep forest violet with amber warmth */
  --primary: #7c5c3a;
  --primary-rgb: 124, 92, 58;
  --primary-soft: rgba(124, 92, 58, 0.1);
  --primary-hover: #5e4429;

  /* Accent — Golden amber (from the glowing tree) */
  --accent: #c9956b;
  --accent-soft: rgba(201, 149, 107, 0.15);
  --accent-glow: rgba(201, 149, 107, 0.3);

  /* Phase colours — Earthy, muted, warm */
  --phase-men: #a85044;
  --phase-men-soft: rgba(168, 80, 68, 0.12);
  --phase-fol: #5e8c61;
  --phase-fol-soft: rgba(94, 140, 97, 0.12);
  --phase-ovu: #c08840;
  --phase-ovu-soft: rgba(192, 136, 64, 0.12);
  --phase-lut: #6b7ba8;
  --phase-lut-soft: rgba(107, 123, 168, 0.12);

  /* Status */
  --success: #4d8b5a;
  --success-soft: rgba(77, 139, 90, 0.12);
  --error: #b84444;
  --error-soft: rgba(184, 68, 68, 0.1);
  --warning: #c08840;
  --warning-soft: rgba(192, 136, 64, 0.12);

  /* Structural */
  --radius: 14px;
  --radius-sm: 8px;
  --radius-lg: 22px;
  --shadow: 0 1px 3px rgba(44, 36, 26, 0.06), 0 4px 16px rgba(44, 36, 26, 0.04);
  --shadow-lg: 0 8px 40px rgba(44, 36, 26, 0.1);
  --shadow-glow: 0 0 30px rgba(201, 149, 107, 0.08);

  /* Nav */
  --nav-bg: rgba(250, 247, 242, 0.85);
  --nav-blur: blur(16px);
}

/* === Dark Theme — Midnight Forest & Starlight === */
[data-theme="dark"] {
  /* Deep midnight — not pure black, has warm depth */
  --bg: #0c0f18;
  --surface: #141a28;
  --surface2: #1a2236;
  --surface3: #212b42;
  --border: #263048;

  /* Soft, warm text — not harsh white */
  --text: #e4ddd0;
  --text2: #a09484;
  --text3: #6b6058;

  /* Primary — Ethereal amber-gold */
  --primary: #d4a574;
  --primary-rgb: 212, 165, 116;
  --primary-soft: rgba(212, 165, 116, 0.12);
  --primary-hover: #e8c09a;

  /* Accent — Warm glow */
  --accent: #e8b87a;
  --accent-soft: rgba(232, 184, 122, 0.1);
  --accent-glow: rgba(232, 184, 122, 0.15);

  /* Phase colours — Softer, glowing in dark */
  --phase-men: #d4726a;
  --phase-men-soft: rgba(212, 114, 106, 0.12);
  --phase-fol: #6db876;
  --phase-fol-soft: rgba(109, 184, 118, 0.1);
  --phase-ovu: #e8b87a;
  --phase-ovu-soft: rgba(232, 184, 122, 0.1);
  --phase-lut: #7a9dd4;
  --phase-lut-soft: rgba(122, 157, 212, 0.1);

  /* Status */
  --success-soft: rgba(109, 184, 118, 0.1);
  --error-soft: rgba(212, 114, 106, 0.1);
  --warning-soft: rgba(232, 184, 122, 0.1);

  --shadow: 0 1px 4px rgba(0, 0, 0, 0.3), 0 4px 20px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 40px rgba(212, 165, 116, 0.06);

  --nav-bg: rgba(12, 15, 24, 0.8);
  --nav-blur: blur(20px);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.65;
  transition: background 0.4s ease, color 0.3s ease;
  -webkit-font-smoothing: antialiased;
}

/* Selection colour */
::selection {
  background: rgba(var(--primary-rgb), 0.2);
  color: var(--text);
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--primary-hover);
}

img {
  max-width: 100%;
}

/* Display font for titles */
h1,
h2,
h3 {
  font-family: var(--font-display);
}

/* === Layout === */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px;
}

.container-sm {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 24px;
}

/* === Top Nav — Frosted Glass === */
.nav {
  background: var(--nav-bg);
  backdrop-filter: var(--nav-blur);
  -webkit-backdrop-filter: var(--nav-blur);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background 0.3s;
}

.nav-brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 20px;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.02em;
}

.nav-brand:hover {
  text-decoration: none;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-link {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.nav-link:hover {
  color: var(--primary);
  background: var(--primary-soft);
  text-decoration: none;
}

.nav-link.active {
  color: var(--primary);
  background: var(--primary-soft);
}

.nav-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent-soft);
  transition: border-color 0.2s;
}

.nav-avatar:hover {
  border-color: var(--accent);
}

/* === Cards — Soft, glowing edges === */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 28px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.3s, transform 0.2s;
}

.card:hover {
  box-shadow: var(--shadow), var(--shadow-glow);
}

.card--phase {
  text-align: center;
  padding: 36px 28px;
  position: relative;
  overflow: hidden;
}

/* Subtle inner glow for phase cards */
.card--phase::before {
  content: '';
  position: absolute;
  top: -50%;
  left: 50%;
  transform: translateX(-50%);
  width: 200%;
  height: 100%;
  background: radial-gradient(ellipse, var(--accent-glow) 0%, transparent 70%);
  pointer-events: none;
}

/* === Phase Badge — Pill with soft glow === */
.phase-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 22px;
  border-radius: 100px;
  font-weight: 600;
  font-size: 15px;
  font-family: var(--font);
  letter-spacing: 0.01em;
  transition: all 0.2s;
}

.phase-badge.menstruation {
  background: var(--phase-men-soft);
  color: var(--phase-men);
}

.phase-badge.follicular {
  background: var(--phase-fol-soft);
  color: var(--phase-fol);
}

.phase-badge.ovulation {
  background: var(--phase-ovu-soft);
  color: var(--phase-ovu);
}

.phase-badge.luteal {
  background: var(--phase-lut-soft);
  color: var(--phase-lut);
}

/* === Confidence Meter === */
.confidence {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text3);
  padding: 5px 14px;
  border-radius: 100px;
  background: var(--surface2);
}

.confidence-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.confidence-dot.low {
  background: var(--error);
  box-shadow: 0 0 6px var(--error);
}

.confidence-dot.medium {
  background: var(--warning);
  box-shadow: 0 0 6px var(--warning);
}

.confidence-dot.high {
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
}

/* === Stats Grid — Glowing tiles === */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin: 24px 0;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  transition: all 0.3s;
}

.stat:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.stat-value {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--text2);
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* === Buttons — Warm, tactile === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.25s ease;
  text-decoration: none;
  font-family: var(--font);
  letter-spacing: 0.01em;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  box-shadow: 0 2px 12px rgba(var(--primary-rgb), 0.25);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(var(--primary-rgb), 0.35);
  text-decoration: none;
  color: #fff;
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--surface3);
  text-decoration: none;
}

.btn-danger {
  background: var(--error-soft);
  color: var(--error);
}

.btn-danger:hover {
  background: var(--error);
  color: white;
  text-decoration: none;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
}

.btn-lg {
  padding: 14px 32px;
  font-size: 16px;
}

.btn--full {
  width: 100%;
  justify-content: center;
}

/* === Forms — Warm & inviting === */
.form-group {
  margin-bottom: 22px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-family: var(--font);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-hint {
  font-size: 12px;
  color: var(--text3);
  margin-top: 5px;
}

.form-checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
}

/* === Alerts — Warm tones === */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 20px;
  border-left: 3px solid;
}

.alert-error {
  background: var(--error-soft);
  color: var(--error);
  border-color: var(--error);
}

.alert-success {
  background: var(--success-soft);
  color: var(--success);
  border-color: var(--success);
}

.alert-info {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary);
}

.alert-warning {
  background: var(--warning-soft);
  color: var(--warning);
  border-color: var(--warning);
}

/* === Knowledge Cards — Enchanted feel === */
.knowledge-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  background: var(--surface);
  transition: all 0.3s;
  position: relative;
}

.knowledge-card:hover {
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
  border-color: var(--accent-soft);
}

.knowledge-card h3 {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
}

.knowledge-card p {
  font-size: 14px;
  color: var(--text2);
  line-height: 1.7;
}

/* === Table — Clean & warm === */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  background: var(--surface2);
  color: var(--text3);
  padding: 12px 14px;
  text-align: left;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

td {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

tr:hover td {
  background: var(--surface2);
}

/* === Badges === */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 12px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
}

.badge-purple {
  background: var(--primary-soft);
  color: var(--primary);
}

.badge-green {
  background: var(--success-soft);
  color: var(--success);
}

.badge-red {
  background: var(--error-soft);
  color: var(--error);
}

.badge-gray {
  background: var(--surface3);
  color: var(--text2);
}

/* === Auth Pages — Mystical Dark Portal === */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  /* Deep enchanted forest gradient */
  background: linear-gradient(160deg, #06080f 0%, #0d1420 25%, #12192e 50%, #0e1118 75%, #080a12 100%);
  position: relative;
  overflow: hidden;
}

/* Floating amber glow — like fireflies */
.auth-page::before {
  content: '';
  position: absolute;
  top: 20%;
  left: 15%;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(212, 165, 116, 0.08) 0%, transparent 70%);
  animation: firefly1 14s ease-in-out infinite;
}

.auth-page::after {
  content: '';
  position: absolute;
  bottom: 15%;
  right: 20%;
  width: 250px;
  height: 250px;
  background: radial-gradient(circle, rgba(122, 157, 212, 0.06) 0%, transparent 65%);
  animation: firefly2 18s ease-in-out infinite;
}

@keyframes firefly1 {

  0%,
  100% {
    transform: translate(0, 0) scale(1);
    opacity: 0.6;
  }

  25% {
    transform: translate(40px, -30px) scale(1.1);
    opacity: 1;
  }

  50% {
    transform: translate(-20px, 50px) scale(0.9);
    opacity: 0.4;
  }

  75% {
    transform: translate(30px, 20px) scale(1.05);
    opacity: 0.8;
  }
}

@keyframes firefly2 {

  0%,
  100% {
    transform: translate(0, 0) scale(1);
    opacity: 0.5;
  }

  33% {
    transform: translate(-30px, 40px) scale(1.15);
    opacity: 0.9;
  }

  66% {
    transform: translate(50px, -20px) scale(0.85);
    opacity: 0.3;
  }
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: rgba(18, 22, 35, 0.75);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-radius: var(--radius-lg);
  padding: 44px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(212, 165, 116, 0.1);
  position: relative;
  z-index: 1;
}

.auth-logo {
  text-align: center;
  font-size: 52px;
  margin-bottom: 12px;
  filter: drop-shadow(0 0 24px rgba(212, 165, 116, 0.3));
}

.auth-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 6px;
  color: #e4ddd0;
  letter-spacing: -0.02em;
}

.auth-subtitle {
  font-size: 14px;
  color: #a09484;
  text-align: center;
  margin-bottom: 32px;
}

/* Dark inputs on auth pages */
.auth-page .form-input {
  background: rgba(12, 15, 24, 0.6);
  border-color: rgba(212, 165, 116, 0.15);
  color: #e4ddd0;
}

.auth-page .form-input::placeholder {
  color: #6b6058;
}

.auth-page .form-input:focus {
  border-color: #d4a574;
  box-shadow: 0 0 0 3px rgba(212, 165, 116, 0.12);
}

.auth-page .form-label {
  color: #a09484;
}

.auth-page .form-hint {
  color: #6b6058;
}

.auth-page a {
  color: #d4a574;
}

.auth-page .btn-primary {
  background: linear-gradient(135deg, #7c5c3a, #d4a574);
}

/* === Dashboard Grid === */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 24px;
}

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

/* === Page Header === */
.page-header {
  padding: 36px 0 28px;
}

.page-title {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
}

.page-subtitle {
  font-size: 15px;
  color: var(--text2);
  margin-top: 6px;
}

/* === Theme Toggle Button === */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  cursor: pointer;
  font-size: 16px;
  color: var(--text2);
  transition: all 0.25s;
}

.theme-toggle:hover {
  background: var(--surface2);
  border-color: var(--accent);
  color: var(--accent);
}

/* === Markdown Preview === */
.markdown-preview {
  font-size: 14px;
  color: var(--text);
  line-height: 1.7;
}

.markdown-preview strong {
  font-weight: 600;
}

.markdown-preview li {
  margin-left: 20px;
  margin-bottom: 4px;
}

/* === Avatar === */
.avatar {
  border-radius: 50%;
  object-fit: cover;
}

.avatar-placeholder {
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 20px;
}

/* === Admin Sidebar Layout === */
.admin-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 0;
  min-height: calc(100vh - 64px);
}

.admin-sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 28px 18px;
}

.admin-content {
  padding: 36px;
}

.admin-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s;
  margin-bottom: 4px;
}

.admin-nav-item:hover,
.admin-nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  text-decoration: none;
}

/* === Responsive === */
@media (max-width: 768px) {
  .admin-layout {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
  }

  .admin-sidebar p {
    display: none;
  }

  .admin-sidebar hr {
    display: none;
  }

  .admin-content {
    padding: 20px;
  }

  .nav-links .nav-link span {
    display: none;
  }

  .auth-card {
    padding: 32px 24px;
  }
}

/* === Disclaimer — Subtle === */
.disclaimer {
  font-size: 11px;
  color: var(--text3);
  text-align: center;
  padding: 10px 16px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  margin-top: 16px;
  border: 1px solid var(--border);
}

/* === Cycle Timeline Strip === */
.cycle-strip {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: none;
}

.cycle-strip::-webkit-scrollbar {
  display: none;
}

.cycle-day {
  flex-shrink: 0;
  width: 42px;
  height: 50px;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 500;
  color: var(--text2);
  background: var(--surface2);
  gap: 2px;
  transition: all 0.2s;
}

.cycle-day:hover {
  transform: scale(1.05);
}

.cycle-day.today {
  outline: 2px solid var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}

.cycle-day.menstruation {
  background: var(--phase-men-soft);
  color: var(--phase-men);
}

.cycle-day.follicular {
  background: var(--phase-fol-soft);
  color: var(--phase-fol);
}

.cycle-day.ovulation {
  background: var(--phase-ovu-soft);
  color: var(--phase-ovu);
}

.cycle-day.luteal {
  background: var(--phase-lut-soft);
  color: var(--phase-lut);
}

.cycle-day .day-num {
  font-size: 14px;
  font-weight: 700;
}

/* === Smooth transitions for all themed elements === */
.card,
.stat,
.nav,
.knowledge-card,
.btn,
.form-input,
.form-select,
.admin-sidebar,
.admin-nav-item,
.badge,
.phase-badge,
.cycle-day {
  transition: background 0.3s, color 0.3s, border-color 0.3s, box-shadow 0.3s;
}