/* Professional Medical Calculator Styles */
:root {
  --primary-color: #2c3e50;
  --secondary-color: #3498db;
  --accent-color: #e74c3c;
  --success-color: #27ae60;
  --warning-color: #f39c12;
  --background-color: #f8f9fa;
  --card-background: #ffffff;
  --border-color: #e9ecef;
  --text-primary: #2c3e50;
  --text-secondary: #6c757d;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  --border-radius: 8px;
  --transition: all 0.3s ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  padding: 20px;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  background: var(--card-background);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 40px);
}

.header {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  color: white;
  padding: 40px 30px;
  text-align: center;
}

.header h1 {
  font-size: 2.4rem;
  font-weight: 300;
  margin-bottom: 10px;
  letter-spacing: 0.5px;
  line-height: 1.2;
}

.subtitle {
  font-size: 1.1rem;
  opacity: 0.9;
  font-weight: 300;
  margin-top: 10px;
}

.main-content {
  padding: 40px;
  flex: 1;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 30px;
  margin-bottom: 40px;
}

.fieldset {
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 25px;
  background: var(--background-color);
  transition: var(--transition);
  position: relative;
}

.fieldset:hover {
  border-color: var(--secondary-color);
  box-shadow: 0 4px 15px rgba(52, 152, 219, 0.1);
}

.legend {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--primary-color);
  padding: 0 15px;
  margin-bottom: 15px;
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--secondary-color);
  padding-bottom: 8px;
}

/* Help text styling */
.help-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 8px;
  font-style: italic;
  line-height: 1.4;
}

/* Age input styling */
.age-input {
  display: flex;
  align-items: center;
  gap: 10px;
}

.age-input input {
  flex: 1;
  padding: 12px 15px;
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 1.1rem;
  transition: var(--transition);
}

.age-input input:focus {
  outline: none;
  border-color: var(--secondary-color);
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.age-input input:invalid {
  border-color: var(--accent-color);
}

.age-input label {
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* Checkbox styling */
.checkbox-group {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  transition: var(--transition);
}

.checkbox-group:hover {
  background: rgba(52, 152, 219, 0.05);
  border-radius: 4px;
  padding-left: 8px;
}

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

.checkbox-group label {
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  flex: 1;
}

/* Select styling */
select {
  width: 100%;
  padding: 12px 15px;
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 1rem;
  background: white;
  cursor: pointer;
  transition: var(--transition);
}

select:focus {
  outline: none;
  border-color: var(--secondary-color);
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* Results section */
.results {
  background: #2c3e50; /* Default black/dark state */
  color: white;
  padding: 30px;
  border-radius: var(--border-radius);
  text-align: center;
  margin-top: 30px;
  transition: var(--transition);
}

.results.success {
  background: linear-gradient(135deg, var(--success-color) 0%, #2ecc71 100%);
}

.results.warning {
  background: linear-gradient(135deg, var(--warning-color) 0%, #e67e22 100%);
}

.results.error {
  background: linear-gradient(135deg, var(--accent-color) 0%, #c0392b 100%);
}

.result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.result-item:last-child {
  border-bottom: none;
}

.result-label {
  font-weight: 300;
  font-size: 1.5rem;
  letter-spacing: 0.5px;
}

.result-value {
  font-size: 1.3rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.2);
  padding: 8px 15px;
  border-radius: var(--border-radius);
  min-width: 120px;
}

/* Confidence interval styling */
.confidence-interval {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 0.9rem;
  opacity: 0.9;
}

.ci-label {
  font-weight: 500;
  margin-right: 10px;
}

.ci-value {
  font-weight: 600;
  background: rgba(255, 255, 255, 0.15);
  padding: 4px 8px;
  border-radius: 4px;
}

/* Clinical guidance styling */
.clinical-guidance {
  margin-top: 30px;
  padding: 25px;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-radius: var(--border-radius);
  border-left: 4px solid var(--secondary-color);
}

.clinical-guidance h3 {
  color: var(--primary-color);
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 15px;
  letter-spacing: 0.5px;
}

.guidance-content {
  color: var(--text-primary);
  line-height: 1.6;
}

.guidance-content ul {
  margin-left: 20px;
  margin-top: 10px;
}

.guidance-content li {
  margin-bottom: 8px;
}

/* Footer styling */
.footer {
  background: var(--primary-color);
  color: white;
  padding: 25px 30px;
  margin-top: auto;
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.institutional-info p {
  margin-bottom: 5px;
  font-size: 0.95rem;
}

.disclaimer {
  max-width: 400px;
  font-size: 0.85rem;
  opacity: 0.8;
  line-height: 1.4;
}

/* Footnote styling */
.footnote {
  margin-top: 15px;
  padding: 12px 15px;
  background: rgba(52, 152, 219, 0.05);
  border-left: 3px solid var(--secondary-color);
  border-radius: 4px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.footnote sup {
  color: var(--secondary-color);
  font-weight: 600;
  margin-right: 4px;
}

/* Bottom banner: reverse the diagonal so deeper color lands bottom-right */
.footer {
  background: linear-gradient(135deg, var(--secondary-color) 0%, var(--primary-color) 100%);
  color: #fff;
  padding: 32px 30px;
  margin-top: auto;
}

/* One-column footer card with high contrast */
.footer-card {
  background: #fff;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-top: 3px solid var(--primary-color); /* tasteful accent */
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 18px 20px;
  max-width: 1100px;
  margin: 0 auto;
}

/* Typography & hierarchy */
.footer-institution {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.2px;
  margin-bottom: 2px;
}
.footer-sub {
  margin: 0 0 10px 0;
  color: var(--text-secondary);
}

.footer-disclosure-title {
  margin: 8px 0 4px;
  color: var(--primary-color);
  font-weight: 600;
}
.footer-line { margin: 6px 0 10px; }

/* Intended Use inside footer */
.footer-intended {
  margin-top: 10px;
}
.footer-intended h3 {
  font-size: 1.05rem;
  margin-bottom: 6px;
}
.simple-list { margin: 0.25rem 0 0; padding-left: 1.1rem; }
.simple-list li { margin: 0.25rem 0; }

/* Methods & Citations (collapsed by default) */
.footer-methods { margin-top: 10px; }
.footer-methods details { margin-top: 6px; }
.footer-methods summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  color: var(--secondary-color);
  padding: 6px 0;
}
.footer-methods summary::-webkit-details-marker { display: none; }
.footer-methods .icon { font-size: 1rem; }
.methods-body a {
  color: var(--secondary-color);
  text-decoration: none;
  border-bottom: 1px dotted var(--secondary-color);
}
.methods-body a:hover { text-decoration: underline; }
.card-divider {
  border: none;
  border-top: 1px dashed var(--border-color);
  margin: 10px 0;
}

/* Make sure footer content stacks nicely on small screens */
.footer-content { display: block; }

/* Panel Styles */
.panel {
  margin-top: 1.25rem;
  padding: 1rem 1.25rem;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #ffffff;
}

.panel h2 { 
  margin: 0 0 0.5rem; 
  font-size: 1.125rem; 
  color: var(--primary-color);
}

.simple-list { 
  margin: 0.25rem 0 0; 
  padding-left: 1rem; 
}

.simple-list li { 
  margin: 0.25rem 0; 
  line-height: 1.5;
}

.methods-body { 
  margin-top: 0.5rem; 
}

details > summary { 
  cursor: pointer; 
  user-select: none; 
  color: var(--secondary-color);
  font-weight: 500;
  padding: 0.5rem 0;
}

details > summary:hover {
  color: var(--primary-color);
}

.methods-body p {
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

.methods-body a {
  color: var(--secondary-color);
  text-decoration: none;
}

.methods-body a:hover {
  text-decoration: underline;
}

.methods-body hr {
  margin: 1rem 0;
  border: none;
  border-top: 1px solid var(--border-color);
}

/* Responsive design */
@media (max-width: 768px) {
  body {
    padding: 10px;
  }
  
  .main-content {
    padding: 20px;
  }
  
  .form-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  
  .header h1 {
    font-size: 1.8rem;
  }
  
  .result-item {
    flex-direction: column;
    gap: 10px;
    text-align: center;
  }
  
  .footer-content {
    flex-direction: column;
    text-align: center;
  }
  
  .disclaimer {
    max-width: none;
  }
  
  .footer-card {
    margin: 1rem 0;
    padding: 16px 18px;
  }
  
  .panel {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
  }
}

/* Print styles for medical documentation */
@media print {
  body {
    background: white;
    padding: 0;
  }
  
  .container {
    box-shadow: none;
    border: 1px solid #ccc;
  }
  
  .header {
    background: #f8f9fa !important;
    color: var(--text-primary) !important;
  }
  
  .results {
    background: #f8f9fa !important;
    color: var(--text-primary) !important;
  }
  
  .footer { 
    background: #f8f9fa !important; 
    color: var(--text-primary) !important; 
  }
  
  details[open] > summary { 
    display: none; 
  }
  
  .panel, .footer-card { 
    break-inside: avoid; 
  }
  
  .footer-methods details[open] > summary { 
    display: none; 
  }
}

/* Focus styles for accessibility */
*:focus {
  outline: 2px solid var(--secondary-color);
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --border-color: #000;
    --text-secondary: #000;
  }
  
  .fieldset {
    border-width: 3px;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

/* Screen reader only text */
.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;
}

/* Remove lines between % and 95% CI */
.results .result-item {
  border-bottom: none;
  padding-bottom: 10px;   /* keep a little breathing room */
}

.results .confidence-interval {
  border-top: none;
  padding-top: 0;
  margin-top: 6px;        /* subtle spacing without a rule line */
}

/* One-line result: % and 95% CI side-by-side */
.results {
  text-align: center;
}

.results .result-item {
  display: inline-flex;          /* was block flex */
  align-items: baseline;
  gap: 10px;
  border-bottom: none;           /* remove the divider line */
  padding-bottom: 0;
}

.results .confidence-interval {
  display: inline-flex !important;  /* override inline style="display:block" */
  align-items: baseline;
  gap: 8px;
  margin-left: 14px;                /* small gap between % and CI */
  padding-top: 0;
  border-top: none;                 /* remove the divider line */
}

/* (Optional) slightly de-emphasize the CI label */
.results .ci-label {
  opacity: 0.85;
}

/* Wrap to two lines on very narrow screens so it never overflows */
@media (max-width: 420px) {
  .results .result-item,
  .results .confidence-interval {
    display: block !important;
    margin-left: 0;
  }
}

/* Hide confidence interval by default and only show when explicitly displayed */
.results .confidence-interval {
  display: none !important;
}

/* Only show confidence interval when JavaScript sets it to display: block */
.results .confidence-interval[style*="display: block"] {
  display: inline-flex !important;
}
