/* Main CSS - Non-critical styles loaded asynchronously */

/* Extended color palette */
:root {
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 0 0% 98%;
  --accent: 0 0% 96.1%;
  --accent-foreground: 0 0% 9%;
  --popover: 0 0% 100%;
  --popover-foreground: 0 0% 3.9%;
  --chart-1: 12 76% 61%;
  --chart-2: 173 58% 39%;
  --chart-3: 197 37% 24%;
  --chart-4: 43 74% 66%;
  --chart-5: 27 87% 67%;
  
  /* Brand Colors for Financial Theme */
  --primary-green: #047857;
  --primary-green-dark: #065f46;
  --primary-green-border: #064e3b;
  --hover-light: #ecfdf5;
}

/* SEO Optimized Classes - Replacing Inline Styles */

/* Header Styles */
.header-primary {
  background-color: var(--primary-green);
  border-bottom-color: var(--primary-green-border);
}

.nav-link-primary {
  color: white;
  transition: color 0.2s ease;
  font-weight: 500;
}

.nav-link-primary:hover {
  color: var(--hover-light);
}

/* Footer Styles */
.footer-primary {
  background-color: var(--primary-green);
  border-top: 1px solid var(--primary-green-border);
}

.footer-divider {
  border-top: 1px solid var(--primary-green-border);
}

/* Calculator Button */
.calc-button-primary {
  background-color: var(--primary-green);
}

.calc-button-primary:hover:not(:disabled) {
  background-color: var(--primary-green-dark);
}

.calc-button-primary:disabled {
  background-color: #d1d5db;
}

/* Recommendation Circles */
.recommendation-circle {
  background-color: var(--hover-light);
}

.recommendation-number {
  color: var(--primary-green);
}

/* Form Optimization Classes for SEO */
.calc-form {
  width: 100%;
  max-width: 64rem;
  margin: 0 auto;
}

.calc-fieldset {
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  padding: 1rem;
  margin-bottom: 1.5rem;
  background-color: #f9fafb;
}

.calc-legend {
  font-weight: 600;
  color: #374151;
  padding: 0 0.5rem;
  font-size: 0.875rem;
}

.calc-input-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 1rem;
}

.calc-input-primary {
  width: 100%;
  height: 2.25rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.calc-input-primary:focus {
  outline: none;
  border-color: var(--primary-green);
  box-shadow: 0 0 0 3px rgba(4, 120, 87, 0.1);
}

.calc-input-primary:invalid {
  border-color: #ef4444;
}

.calc-select-primary {
  width: 100%;
  height: 2.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  background-color: white;
  font-size: 1rem;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.calc-select-primary:focus {
  outline: none;
  border-color: var(--primary-green);
  box-shadow: 0 0 0 3px rgba(4, 120, 87, 0.1);
}

.calc-checkbox-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: 2.5rem;
}

.calc-checkbox-primary {
  width: 1rem;
  height: 1rem;
  border: 2px solid #d1d5db;
  border-radius: 0.25rem;
  background-color: white;
  cursor: pointer;
  transition: all 0.2s ease;
}

.calc-checkbox-primary:checked {
  background-color: var(--primary-green);
  border-color: var(--primary-green);
}

.calc-checkbox-primary:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(4, 120, 87, 0.1);
}

.calc-label-primary {
  font-weight: 500;
  color: #374151;
  font-size: 0.875rem;
  cursor: pointer;
}

.calc-label-secondary {
  font-size: 0.75rem;
  color: #6b7280;
  margin-bottom: 0.25rem;
  display: block;
}

.calc-exam-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  padding: 0.75rem;
  background-color: #f9fafb;
  border-radius: 0.5rem;
  margin-bottom: 0.75rem;
}

@media (min-width: 640px) {
  .calc-exam-row {
    grid-template-columns: 2fr 1fr 1fr auto;
    gap: 0.75rem;
  }
}

.calc-button-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  background-color: white;
  color: #374151;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.calc-button-secondary:hover:not(:disabled) {
  background-color: #f3f4f6;
  border-color: #9ca3af;
}

.calc-button-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.calc-button-danger {
  color: #dc2626;
  border-color: #fecaca;
}

.calc-button-danger:hover:not(:disabled) {
  background-color: #fef2f2;
  border-color: #fca5a5;
}

/* Results Section Optimization */
.calc-results-section {
  margin-top: 1.5rem;
}

.calc-results-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

@media (min-width: 640px) {
  .calc-results-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .calc-results-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.calc-result-card {
  text-align: center;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  border: 1px solid;
}

.calc-result-card-blue {
  background-color: #eff6ff;
  border-color: #dbeafe;
}

.calc-result-card-green {
  background-color: #f0fdf4;
  border-color: #dcfce7;
}

.calc-result-card-purple {
  background-color: #faf5ff;
  border-color: #f3e8ff;
}

/* Accessibility Improvements */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus Management */
.calc-form *:focus {
  outline: 2px solid var(--primary-green);
  outline-offset: 2px;
}

/* Error States */
.calc-input-error {
  border-color: #ef4444;
  background-color: #fef2f2;
}

.calc-error-message {
  color: #dc2626;
  font-size: 0.75rem;
  margin-top: 0.25rem;
}

/* Loading States */
.calc-loading {
  opacity: 0.6;
  pointer-events: none;
}

.calc-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1rem;
  height: 1rem;
  margin: -0.5rem 0 0 -0.5rem;
  border: 2px solid #f3f4f6;
  border-top: 2px solid var(--primary-green);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.dark {
  --background: 0 0% 3.9%;
  --foreground: 0 0% 98%;
  --card: 0 0% 3.9%;
  --card-foreground: 0 0% 98%;
  --popover: 0 0% 3.9%;
  --popover-foreground: 0 0% 98%;
  --primary: 0 0% 98%;
  --primary-foreground: 0 0% 9%;
  --secondary: 0 0% 14.9%;
  --secondary-foreground: 0 0% 98%;
  --muted: 0 0% 14.9%;
  --muted-foreground: 0 0% 63.9%;
  --accent: 0 0% 14.9%;
  --accent-foreground: 0 0% 98%;
  --destructive: 0 62.8% 30.6%;
  --destructive-foreground: 0 0% 98%;
  --border: 0 0% 14.9%;
  --input: 0 0% 14.9%;
  --ring: 0 0% 83.1%;
  --chart-1: 220 70% 50%;
  --chart-2: 160 60% 45%;
  --chart-3: 30 80% 55%;
  --chart-4: 280 65% 60%;
  --chart-5: 340 75% 55%;
}

/* Results section styles */
.results-container {
  background-color: white;
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
}

.results-header {
  padding: 1.5rem 1.5rem 0;
  text-align: center;
}

.results-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: rgb(21 128 61);
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 1.5rem;
  padding: 1.5rem;
}

@media (min-width: 768px) {
  .results-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .results-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* Result card styles */
.result-card {
  text-align: center;
  padding: 1rem;
  border-radius: 0.5rem;
}

.result-card-blue {
  background-color: rgb(239 246 255);
}

.result-card-green {
  background-color: rgb(240 253 244);
}

.result-card-purple {
  background-color: rgb(250 245 255);
}

.result-card-orange {
  background-color: rgb(255 247 237);
}

.result-card-red {
  background-color: rgb(254 242 242);
}

.result-card-yellow {
  background-color: rgb(254 252 232);
}

.result-card-indigo {
  background-color: rgb(238 242 255);
}

.result-label {
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.result-label-blue {
  color: rgb(29 78 216);
}

.result-label-green {
  color: rgb(21 128 61);
}

.result-label-purple {
  color: rgb(126 34 206);
}

.result-label-orange {
  color: rgb(194 65 12);
}

.result-label-red {
  color: rgb(185 28 28);
}

.result-label-yellow {
  color: rgb(161 98 7);
}

.result-label-indigo {
  color: rgb(67 56 202);
}

.result-value {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.result-value-blue {
  color: rgb(30 58 138);
}

.result-value-green {
  color: rgb(20 83 45);
}

.result-value-purple {
  color: rgb(88 28 135);
}

.result-value-orange {
  color: rgb(154 52 18);
}

.result-value-red {
  color: rgb(153 27 27);
}

.result-value-yellow {
  color: rgb(133 77 14);
}

.result-value-indigo {
  color: rgb(55 48 163);
}

.result-unit {
  font-size: 0.875rem;
  color: rgb(75 85 99);
}

/* Macronutrients section */
.macros-section {
  margin-top: 2rem;
}

.macros-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 1rem;
  text-align: center;
}

.macros-grid {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 1rem;
}

@media (min-width: 768px) {
  .macros-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Educational content styles */
.educational-section {
  padding: 4rem 1rem;
  background-color: white;
}

.educational-container {
  max-width: 64rem;
  margin: 0 auto;
}

.educational-title {
  font-size: 1.875rem;
  text-align: center;
  color: rgb(17 24 39);
  margin-bottom: 2rem;
}

.educational-content {
  padding: 2rem;
}

.educational-text {
  font-size: 1.125rem;
  color: rgb(55 65 81);
  margin-bottom: 1.5rem;
  line-height: 1.7;
}

.educational-subtitle {
  font-size: 1.5rem;
  font-weight: 700;
  color: rgb(17 24 39);
  margin: 2rem 0 1.5rem;
}

.educational-subheading {
  font-size: 1.25rem;
  font-weight: 600;
  color: rgb(31 41 55);
  margin: 1.5rem 0 0.75rem;
}

.educational-list {
  list-style-type: disc;
  list-style-position: inside;
  color: rgb(55 65 81);
  margin-left: 1rem;
}

.educational-list li {
  margin-bottom: 0.25rem;
}

/* Pie chart representation */
.pie-chart-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
  margin-bottom: 2rem;
}

@media (min-width: 768px) {
  .pie-chart-container {
    flex-direction: row;
  }
}

.pie-chart {
  position: relative;
  width: 16rem;
  height: 16rem;
  margin: 0 auto;
}

.pie-chart-circle {
  width: 16rem;
  height: 16rem;
  border-radius: 50%;
  position: relative;
  overflow: hidden;
}

.pie-chart-center {
  position: absolute;
  inset: 1rem;
  background-color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pie-chart-label {
  font-size: 1.5rem;
  font-weight: 700;
  color: rgb(31 41 55);
}

.pie-legend {
  flex: 1;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.legend-color {
  width: 1rem;
  height: 1rem;
  border-radius: 0.25rem;
}

.legend-color-blue {
  background-color: rgb(96 165 250);
}

.legend-color-red {
  background-color: rgb(248 113 113);
}

.legend-color-green {
  background-color: rgb(74 222 128);
}

.legend-text {
  color: rgb(55 65 81);
}

/* Footer styles */
.footer {
  background-color: rgb(31 41 55);
  color: white;
  padding: 3rem 1rem 2rem;
}

.footer-container {
  max-width: 80rem;
  margin: 0 auto;
}

.footer-content {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
}

@media (min-width: 768px) {
  .footer-content {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.footer-section h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.footer-links {
  list-style: none;
  padding: 0;
}

.footer-links li {
  margin-bottom: 0.5rem;
}

.footer-links a {
  color: rgb(209 213 219);
  text-decoration: none;
  transition: color 0.2s;
}

.footer-links a:hover {
  color: white;
}

.footer-bottom {
  border-top: 1px solid rgb(75 85 99);
  padding-top: 2rem;
  text-align: center;
  color: rgb(156 163 175);
}

/* Form elements */
.radio-group {
  display: flex;
  gap: 1.5rem;
}

.radio-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.radio-input {
  width: 1rem;
  height: 1rem;
  border: 2px solid hsl(var(--border));
  border-radius: 50%;
  background-color: white;
}

.radio-input:checked {
  border-color: rgb(59 130 246);
  background-color: rgb(59 130 246);
}

.select-trigger {
  display: flex;
  align-items: center;
  justify-content: between;
  width: 100%;
  max-width: 28rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid hsl(var(--border));
  border-radius: 0.375rem;
  background-color: white;
  font-size: 0.875rem;
  cursor: pointer;
}

.select-trigger:focus {
  outline: 2px solid rgb(59 130 246);
  outline-offset: 2px;
  border-color: rgb(59 130 246);
}

/* Utility classes */
.space-y-6 > * + * {
  margin-top: 1.5rem;
}

.space-y-4 > * + * {
  margin-top: 1rem;
}

.space-y-2 > * + * {
  margin-top: 0.5rem;
}

.space-y-8 > * + * {
  margin-top: 2rem;
}

.max-w-md {
  max-width: 28rem;
}

.max-w-3xl {
  max-width: 48rem;
}

.max-w-4xl {
  max-width: 56rem;
}

.mx-auto {
  margin-left: auto;
  margin-right: auto;
}

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

.leading-relaxed {
  line-height: 1.625;
}

/* Performance optimizations */
.lazy-load {
  content-visibility: auto;
  contain-intrinsic-size: 200px;
}

/* Reduce paint complexity */
.rounded-lg {
  will-change: transform;
}

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

/* Print styles */
@media print {
  .no-print {
    display: none !important;
  }
  
  body {
    background: white !important;
    color: black !important;
  }
  
  .calculator-card,
  .results-container {
    box-shadow: none !important;
    border: 1px solid #ccc !important;
  }
}
