:root {
  --circle-size: 16px;
  --circle-gap: 4px;
  --lived-color: #666666;
  --selected-color: #4caf50;
}

body {
  margin: 0;
  font-family: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  display: flex;
  height: 100vh;
  color: #1f2937;
  background-color: #f9fafb;
}

.wrapper {
  display: grid;
  grid-template-columns: 280px 1fr 300px;
  grid-template-rows: 1fr;
  height: 80vh;
  max-width: 1400px;
  width: 90%;
  margin: 40px auto;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.mobile-tab-nav {
  display: none;
}

/* Left: circles grid */
.grid-container {
  grid-column: 2;
  padding: 24px;
  overflow: auto;
  position: relative; /* for milestone lines */
  background: #fff;
}

.grid-header,
.section-header {
  font-size: 1rem;
  font-weight: 600;
  color: #374151;
  margin: 0 0 12px 0;
}

.grid {
  display: grid;
  grid-template-columns: repeat(30, var(--circle-size));
  grid-auto-rows: var(--circle-size);
  gap: var(--circle-gap);
  justify-content: start;
  overflow: visible;
}

.circle {
  width: var(--circle-size);
  height: var(--circle-size);
  border: 1px solid #aaa;
  border-radius: 50%;
  box-sizing: border-box;
  cursor: pointer;
  background-color: #fff;
  transition: background-color 0.15s ease, border-color 0.15s ease;
  position: relative;
}

.circle.lived {
  /* default lived months color (will be overridden by stage-specific rules) */
  background-color: var(--lived-color);
  border-color: var(--lived-color);
}

/* Stage-specific colors only when lived */
.circle.lived.childhood {
  background-color: #e3f2fd;
  border-color: #e3f2fd;
}

.circle.lived.early_adult {
  background-color: #dcedc8;
  border-color: #dcedc8;
}

.circle.lived.mid_adult {
  background-color: #fff9c4;
  border-color: #fff9c4;
}

.circle.lived.mature {
  background-color: #ffe0b2;
  border-color: #ffe0b2;
}

.circle.lived.senior {
  background-color: #e1bee7;
  border-color: #e1bee7;
}

.circle.selected {
  background-color: var(--selected-color);
  border-color: var(--selected-color);
}

/* Milestone circles (10, 30, 50, 70, 80 years) */
.circle.milestone {
  border: 1px solid #ffb74d; /* subtle light orange */
}

/* Left sidebar */
.left-sidebar {
  grid-column: 1;
  width: 280px;
  padding: 24px;
  background: #ffffff;
  border-right: 1px solid #e5e7eb;
  box-shadow: 2px 0 4px rgba(0, 0, 0, 0.03);
}

.left-sidebar h2 {
  margin-top: 0;
}

.stat {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.9rem;
  color: #374151;
}

.stat:last-child {
  margin-bottom: 0;
}

/* Base input styles */
.input-base {
  width: 100%;
  padding: 8px 10px;
  font-size: 0.95rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #f9fafb;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
}

.input-base:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
  background: #ffffff;
}

/* Specific inputs */
.dob-input {
  composes: input-base;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

input[type="date"].input-base {
  font-size: 0.85rem;
}

#dob-modal-input {
  composes: input-base;
}

/* Calculator styles */
.calc {
  margin-bottom: 20px;
  background: #f9fafb;
  padding: 12px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.calc label {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
  font-size: 0.9rem;
}

.calc .inputs {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.calc input[type="number"] {
  width: 90px;
}

.calc input[type="number"],
.calc select {
  font-size: 0.85rem;
}

.calc input[type="number"],
.calc select {
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 6px 8px;
  background: #f9fafb;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.calc input[type="number"]:focus,
.calc select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
  background: #ffffff;
}

.calc-result {
  font-size: 0.88rem;
  color: #374151;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: #ffffff;
  padding: 32px 40px;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  text-align: center;
  width: 90%;
  max-width: 400px;
}

.modal-content h2 {
  margin-top: 0;
  margin-bottom: 16px;
  font-size: 1.25rem;
}

.btn {
  padding: 8px 20px;
  font-size: 1rem;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s ease, border 0.15s ease;
}

.btn-primary {
  background: #2563eb;
  color: #fff;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.35);
}

.btn-primary:hover:not(:disabled) {
  background: #1e4ed8;
}

.btn-secondary {
  background: #f3f4f6;
  color: #1f2937;
  border-color: #d1d5db;
}

.btn-secondary:hover:not(:disabled) {
  background: #e5e7eb;
}

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

/* Input label */
.input-label {
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 4px;
  display: block;
  color: #374151;
}

.hidden {
  display: none;
}

.calculators-box {
  grid-column: 3;
  width: 300px;
  padding: 24px;
  background: #ffffff;
  border-left: 1px solid #e5e7eb;
  box-shadow: -2px 0 4px rgba(0, 0, 0, 0.03);
  overflow-y: auto;
}

/* Tab Styles */
.tabs-nav {
  display: flex;
  border-bottom: 1px solid #e5e7eb;
  margin-bottom: 16px;
}

.tab-btn {
  padding: 8px 16px;
  cursor: pointer;
  border: none;
  background: none;
  font-size: 0.95rem;
  color: #6b7280;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab-btn.active {
  color: #1f2937;
  font-weight: 600;
  border-bottom-color: #2563eb;
}

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

/* Life Events Form adjustments */
#life-events-form .input-label {
  font-size: 0.75rem;
  font-weight: 400;
  color: #4b5563;
  margin-top: 12px;
}
#life-events-form .input-label:first-of-type {
  margin-top: 4px;
}
#life-events-form #event-name {
  font-size: 0.85rem;
}

/* Stats styling */
.stats-box {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 20px;
}

/* --- Mobile responsiveness --- */
@media (max-width: 768px) {
  body {
    flex-direction: column;
    height: auto;
  }

  .wrapper {
    display: flex;
    flex-direction: column;
    height: auto;
    width: 100%;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    overflow: visible;
  }

  .mobile-tab-nav {
    display: flex;
    position: sticky;
    top: 0;
    background-color: #fff;
    z-index: 10;
    border-bottom: 1px solid #e5e7eb;
  }

  .mobile-tab-btn {
    flex: 1;
    padding: 14px 8px;
    cursor: pointer;
    border: none;
    background: none;
    font-size: 0.95rem;
    font-weight: 500;
    color: #6b7280;
    border-bottom: 3px solid transparent;
    text-align: center;
    transition: all 0.2s ease-in-out;
  }

  .mobile-tab-btn.active {
    color: #2563eb;
    font-weight: 600;
    border-bottom-color: #2563eb;
  }

  [data-mobile-tab] {
    display: none;
  }

  [data-mobile-tab].active {
    display: block;
  }

  .left-sidebar,
  .calculators-box {
    width: 100%;
    padding: 16px;
    border: none;
    box-shadow: none;
  }
  .grid {
    grid-template-columns: repeat(20, 1fr);
    gap: 4px;
    grid-auto-rows: auto;
  }
  .circle {
    width: 100%;
    height: 0;
    padding-bottom: 100%; /* Maintain aspect ratio */
  }
  :root {
    --circle-size: 14px;
    --circle-gap: 3px;
  }
}

@media (max-width: 480px) {
  .grid {
    grid-template-columns: repeat(15, 1fr);
  }
}

@media (min-width: 1024px) {
  .grid {
    grid-template-columns: repeat(40, var(--circle-size));
    justify-content: center;
  }

  .calculators-box {
    width: 320px;
  }
}

/* Ensure padding stays inside width (fixes mobile overflow) */
*,
*::before,
*::after {
  box-sizing: border-box;
}
