/* Modern CSS Reset and Base Styles */
*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-weight: 400;
  line-height: 1.6;
  color: #111827; /* gray-900 */
  background: #f8fafc; /* slate-50 */
  min-height: 100vh;
  overflow-x: hidden;
}

/* Header */
.main-header {
  background: #ffffff;
  backdrop-filter: blur(8px);
  border-bottom: 1px solid #e5e7eb; /* gray-200 */
  position: sticky;
  top: 0;
  z-index: 1000;
  padding: 1rem 0;
}

.header-content {
  text-align: center;
}

.header-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1f2937; /* gray-800 */
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.header-subtitle {
  font-size: 0.9rem;
  color: #6b7280; /* gray-500 */
  margin: 0.25rem 0 0 0;
  font-weight: 400;
}

/* Main Content */
.main-content {
  padding: 2rem 0;
}

/* Card System */
.simulation-card {
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
  border: 1px solid #e5e7eb; /* gray-200 */
  margin-bottom: 2rem;
  overflow: hidden;
}

.card-header {
  background: #f8fafc; /* subtle light header */
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  color: #111827; /* gray-900 */
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Mobile collapse toggle */
.mobile-collapse-toggle {
  padding: 0.25rem 0.5rem;
  border: none;
  background: transparent;
  color: #6b7280;
  font-size: 1.25rem;
  line-height: 1;
  transition: all 0.2s ease;
  border-radius: 6px;
}

.mobile-collapse-toggle:hover {
  color: #2563eb;
  background: rgba(37, 99, 235, 0.1);
}

.mobile-collapse-toggle:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.mobile-collapse-toggle i {
  transition: transform 0.2s ease;
}

.mobile-collapse-toggle[aria-expanded="false"] i {
  transform: rotate(180deg);
}

.card-body {
  padding: 2rem;
}

/* Parameter Sections */
.parameter-section {
  margin-bottom: 2.5rem;
}

.parameter-section:last-of-type {
  margin-bottom: 0;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #e5e7eb;
}

.parameter-grid {
  display: grid;
  gap: 1.5rem;
}

.parameter-item {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.parameter-label {
  font-weight: 500;
  color: #374151;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

.help-icon {
  color: #94a3b8; /* slate-400 */
  cursor: help;
  transition: color 0.2s ease;
}

.help-icon:hover {
  color: #2563eb; /* blue-600 */
}

/* Range Controls */
.range-container {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Improved slider track for better visibility */
/* Custom colored slider track with blue accent for filled portion */
.form-range {
  flex: 1;
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  outline: none;
  border: none;
  box-shadow: none;
  -webkit-appearance: none;
  appearance: none;
  position: relative;
}

/* Webkit browsers: colored track */
.form-range::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(to right, #2563eb var(--progress, 0%), #e5e7eb var(--progress, 0%));
}
.form-range::-webkit-slider-thumb {
  position: relative;
  z-index: 2;
}

/* Firefox: colored track */
.form-range::-moz-range-track {
  height: 8px;
  border-radius: 4px;
  background: #e5e7eb;
}
.form-range::-moz-range-progress {
  height: 8px;
  border-radius: 4px;
  background: #2563eb;
}

/* IE/Edge */
.form-range::-ms-fill-lower {
  background: #2563eb;
  border-radius: 4px;
}
.form-range::-ms-fill-upper {
  background: #e5e7eb;
  border-radius: 4px;
}


.form-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #2563eb; /* blue-600 */
  cursor: pointer;
  border: 2px solid #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease;
}

.form-range::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

.form-range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #2563eb;
  cursor: pointer;
  border: 2px solid #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.range-value {
  min-width: 3rem;
  text-align: center;
  font-weight: 600;
  color: #1e3a8a; /* blue-900 */
  background: #eef2ff; /* indigo-50 */
  padding: 0.25rem 0.75rem;
  border-radius: 6px;
  font-size: 0.9rem;
}

/* Inline Controls (for initial females) */
.inline-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.multiplier-input {
  width: 80px;
  padding: 0.5rem;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-weight: 500;
  transition: border-color 0.2s ease;
}

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

.multiplier-text {
  font-weight: 500;
  color: #6b7280;
}

/* Age Range Controls */
.fertility-ranges .parameter-label {
  margin-bottom: 1rem;
}

.age-range-controls {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.age-range-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.range-label {
  min-width: 60px;
  font-weight: 500;
  color: #374151;
}

.age-input {
  width: 80px;
  padding: 0.5rem;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-weight: 500;
  transition: border-color 0.2s ease;
}

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

.range-separator {
  color: #9ca3af;
  font-weight: 500;
}

/* Action Buttons */
.action-buttons {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 2px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.calculate-btn {
  background: #2563eb; /* blue-600 */
  border: none;
  color: #ffffff;
  font-weight: 600;
  padding: 1rem 2rem;
  border-radius: 12px;
  font-size: 1.05rem;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.25);
}

.calculate-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.28);
  background: #1d4ed8; /* blue-700 */
}

.calculate-btn:disabled {
  background: #cbd5e1; /* slate-300 */
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  opacity: 0.7;
}

.reset-btn {
  border: 2px solid #e5e7eb;
  color: #6b7280;
  background: transparent;
  padding: 0.75rem 1.5rem;
  border-radius: 10px;
  font-weight: 500;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.reset-btn:hover {
  border-color: #cbd5e1;
  color: #111827;
  background: #f3f4f6;
}

/* Chart Containers */
.chart-container {
  background: #fafbfc;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  padding: 1rem;
  min-height: 400px;
}

/* Year Selector */
.year-selector {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-left: auto;
  background: #f1f5f9; /* slate-100 */
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
}

.year-label {
  color: #111827;
  font-weight: 500;
  margin: 0;
  white-space: nowrap;
}

.year-slider-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.year-slider {
  width: 120px;
  height: 4px;
  background: #e5e7eb;
  border-radius: 2px;
}

.year-slider::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  background: white;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.year-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: white;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.year-value {
  color: #111827;
  font-weight: 600;
  min-width: 2rem;
  text-align: center;
  background: #e5e7eb;
  padding: 0.1rem 0.5rem;
  border-radius: 4px;
}

/* Responsive Design */

/* Mobile First - Default styles above are for mobile */

/* Small tablets and large phones */
@media (min-width: 576px) {
  .main-content {
    padding: 2.5rem 0;
  }
  
  .card-body {
    padding: 2.5rem;
  }
  
  .parameter-grid {
    grid-template-columns: 1fr;
  }
  
  .header-title {
    font-size: 1.75rem;
  }
  
  .action-buttons {
    flex-direction: row;
    justify-content: space-between;
  }
  
  .calculate-btn {
    flex: 2;
  }
  
  .reset-btn {
    flex: 1;
    margin-left: 1rem;
  }
}

/* Tablets */
@media (min-width: 768px) {
  .main-content {
    padding: 3rem 0;
  }
  
  .parameter-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .fertility-ranges {
    grid-column: 1 / -1;
  }
  
  .header-title {
    font-size: 2rem;
  }
  
  .year-selector {
    flex-direction: row;
  }
  
  .year-slider {
    width: 150px;
  }
}

/* Desktop */
@media (min-width: 992px) {
  .main-content > .container-fluid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    grid-template-areas: 
      "controls charts";
    gap: 3rem;
    align-items: start;
  }
  
  .controls-card {
    grid-area: controls;
    position: sticky;
    top: 100px;
  }
  
  .results-section {
    grid-area: charts;
    display: flex;
    flex-direction: column;
    gap: 2rem;
  }
  
  .chart-container {
    min-height: 450px;
  }
  
  .parameter-grid {
    grid-template-columns: 1fr;
  }
  
  /* Hide mobile collapse toggle on desktop */
  .mobile-collapse-toggle {
    display: none;
  }
  
  /* Ensure parameters are always visible on desktop */
  #parametersCollapse {
    display: block !important;
  }
}

/* Large Desktop */
@media (min-width: 1200px) {
  .main-content > .container-fluid {
    grid-template-columns: 1fr 2.25fr;
  }
  .parameter-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .fertility-ranges {
    grid-column: 1 / -1;
  }
  
  .chart-container {
    min-height: 500px;
  }
}

/* Extra Large Desktop */
@media (min-width: 1400px) {
  .main-content > .container-fluid {
    grid-template-columns: 1fr 2.5fr;
  }
}

/* Accessibility and Interactions */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus styles for better accessibility */
button:focus-visible,
input:focus-visible,
.form-range:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .simulation-card {
    border: 2px solid #000;
  }
  
  .calculate-btn {
    border: 2px solid #000;
  }
}
