/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --color-primary: #0071E3;
  --color-primary-hover: #0051D5;
  --color-text: #1d1d1f;
  --color-text-secondary: #86868b;
  --color-background: #FFFFFF;
  --color-surface: #F5F5F7;
  --color-border: #d2d2d7;
  --color-success: #34C759;
  --color-warning: #FF9500;
  --color-error: #FF3B30;
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --font-body: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --transition: 200ms ease;
}

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

body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--color-text);
  background-color: var(--color-background);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: 1rem;
}

h1 {
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 2.25rem;
  letter-spacing: -0.01em;
}

h3 {
  font-size: 1.5rem;
}

h4 {
  font-size: 1.25rem;
}

h5 {
  font-size: 1.125rem;
}

h6 {
  font-size: 1rem;
}

p {
  margin-bottom: 1rem;
  color: var(--color-text);
}

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

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

/* Layout Components */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.container-narrow {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.section {
  padding: 4rem 0;
}

/* Grid System */
.grid {
  display: grid;
  gap: 1.5rem;
}

.grid-cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid-cols-4 {
  grid-template-columns: repeat(4, 1fr);
}

/* Header */
.header {
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
}

.logo {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--color-text);
  text-decoration: none;
}

.nav {
  display: flex;
  gap: 2rem;
  align-items: center;
}

.nav-link {
  color: var(--color-text);
  font-weight: 400;
  transition: color var(--transition);
}

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

/* Hero Section */
.hero {
  padding: 5rem 0;
  text-align: center;
  background: linear-gradient(to bottom, var(--color-surface), var(--color-background));
}

.hero h1 {
  margin-bottom: 1.5rem;
}

.hero-subtitle {
  font-size: 1.5rem;
  color: var(--color-text-secondary);
  margin-bottom: 3rem;
  font-weight: 400;
}

/* Search Box */
.search-container {
  max-width: 600px;
  margin: 0 auto 3rem;
  position: relative;
}

.search-box {
  width: 100%;
  padding: 1rem 1rem 1rem 3rem;
  font-size: 1.125rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-background);
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}

.search-box:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.1);
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-secondary);
}

/* Cards */
.card {
  background: var(--color-background);
  border-radius: var(--radius-md);
  padding: 2rem;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
  border: 1px solid var(--color-border);
}

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

.card h3 {
  margin-bottom: 0.5rem;
}

.card p {
  color: var(--color-text-secondary);
  margin-bottom: 0;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 500;
  text-align: center;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  cursor: pointer;
  border: none;
  text-decoration: none;
}

.btn-primary {
  background: var(--color-primary);
  color: white;
}

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

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
}

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

/* Symptom and Condition Tags */
.tag {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background: var(--color-surface);
  color: var(--color-text);
  border-radius: 999px;
  font-size: 0.875rem;
  margin: 0.25rem;
  transition: all var(--transition);
  text-decoration: none;
}

.tag:hover {
  background: var(--color-primary);
  color: white;
  text-decoration: none;
}

/* Content Sections */
.content-section {
  margin-bottom: 3rem;
}

.content-section h2 {
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
}

/* Table of Contents */
.toc {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.toc h3 {
  font-size: 1.125rem;
  margin-bottom: 1rem;
}

.toc ul {
  list-style: none;
}

.toc li {
  margin-bottom: 0.5rem;
}

.toc a {
  color: var(--color-text);
  font-weight: 400;
}

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

/* Medical Disclaimer */
.disclaimer {
  background: #FFF3CD;
  border: 1px solid #FFEAA7;
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin: 2rem 0;
  font-size: 0.875rem;
  color: #856404;
}

/* Footer */
.footer {
  background: var(--color-surface);
  padding: 3rem 0 2rem;
  margin-top: 5rem;
  border-top: 1px solid var(--color-border);
}

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

.footer-section h4 {
  font-size: 1rem;
  margin-bottom: 1rem;
}

.footer-section ul {
  list-style: none;
}

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

.footer-section a {
  color: var(--color-text-secondary);
  font-size: 0.875rem;
}

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

.footer-bottom {
  text-align: center;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  font-size: 0.875rem;
}

/* Breadcrumbs */
.breadcrumb {
  display: flex;
  align-items: center;
  margin-bottom: 2rem;
  font-size: 0.875rem;
}

.breadcrumb a {
  color: var(--color-text-secondary);
}

.breadcrumb-separator {
  margin: 0 0.5rem;
  color: var(--color-text-secondary);
}

.breadcrumb-current {
  color: var(--color-text);
}

/* FAQ Section */
.faq-item {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

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

.faq-question {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

/* Related Items Grid */
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.related-item {
  background: var(--color-surface);
  padding: 1rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.related-item:hover {
  background: var(--color-border);
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
}

.mobile-menu-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--color-text);
  margin-bottom: 5px;
  transition: all var(--transition);
}

/* Responsive Design */
@media (max-width: 768px) {
  h1 {
    font-size: 2rem;
  }
  
  h2 {
    font-size: 1.5rem;
  }
  
  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4 {
    grid-template-columns: 1fr;
  }
  
  .footer-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--color-background);
    border-bottom: 1px solid var(--color-border);
    flex-direction: column;
    padding: 1rem;
  }
  
  .nav.active {
    display: flex;
  }
  
  .mobile-menu-toggle {
    display: block;
  }
  
  .hero {
    padding: 3rem 0;
  }
  
  .hero-subtitle {
    font-size: 1.25rem;
  }
}

@media (max-width: 480px) {
  .footer-grid {
    grid-template-columns: 1fr;
  }
  
  .container,
  .container-narrow {
    padding: 0 1rem;
  }
  
  .section {
    padding: 2rem 0;
  }
}

/* Print Styles */
@media print {
  .header,
  .footer,
  .search-container,
  .nav {
    display: none;
  }
  
  body {
    font-size: 12pt;
  }
  
  a {
    color: inherit;
    text-decoration: none;
  }
  
  .disclaimer {
    border: 1px solid #000;
  }
}

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

/* Performance Optimizations */
.lazy-load {
  opacity: 0;
  transition: opacity var(--transition);
}

.lazy-load.loaded {
  opacity: 1;
}

/* Skeleton Loading */
.skeleton {
  background: linear-gradient(90deg, var(--color-surface) 25%, var(--color-border) 50%, var(--color-surface) 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Directory Pages Styles */
.hero--compact {
  padding: 2rem 0 1rem;
}

.hero--compact .hero__title {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.hero--compact .hero__description {
  font-size: 1.125rem;
  color: var(--color-text-secondary);
  max-width: 800px;
}

.search-box--page {
  margin: 2rem 0;
  max-width: 600px;
}

/* Stats Bar */
.stats-bar {
  display: flex;
  gap: 3rem;
  margin: 2rem 0;
  padding: 1.5rem 2rem;
  background: var(--color-surface);
  border-radius: var(--radius-md);
}

.stats-bar__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.stats-bar__value {
  font-size: 2.5rem;
  font-weight: 600;
  color: var(--color-primary);
  line-height: 1;
}

.stats-bar__label {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  margin-top: 0.25rem;
}

/* Alphabet Navigation */
.alphabet-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin: 2rem 0;
  padding: 1rem;
  background: var(--color-surface);
  border-radius: var(--radius-md);
}

.alphabet-nav__link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  font-weight: 500;
  color: var(--color-text);
  background: var(--color-background);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.alphabet-nav__link:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

/* Condition/Symptom Sections */
.condition-section,
.symptom-section {
  margin-bottom: 3rem;
}

.condition-section__heading,
.symptom-section__heading {
  font-size: 2rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--color-border);
}

/* Condition/Symptom Grid */
.condition-grid,
.symptom-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.condition-card,
.symptom-card {
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
  background: var(--color-surface);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  transition: all var(--transition);
}

.condition-card:hover,
.symptom-card:hover {
  background: var(--color-background);
  border-color: var(--color-border);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.condition-card__title,
.symptom-card__title {
  font-size: 1.125rem;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}

.condition-card__badge,
.symptom-card__badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-success);
  background: rgba(52, 199, 89, 0.1);
  border-radius: var(--radius-sm);
}

.condition-card--complete,
.symptom-card--complete {
  border-color: var(--color-success);
  background: rgba(52, 199, 89, 0.05);
}

.condition-card--complete:hover,
.symptom-card--complete:hover {
  border-color: var(--color-success);
  background: rgba(52, 199, 89, 0.1);
}

/* Responsive adjustments for directory pages */
@media (max-width: 768px) {
  .stats-bar {
    flex-direction: column;
    gap: 1.5rem;
    text-align: center;
  }
  
  .alphabet-nav {
    padding: 0.75rem;
  }
  
  .alphabet-nav__link {
    width: 32px;
    height: 32px;
    font-size: 0.875rem;
  }
  
  .condition-grid,
  .symptom-grid {
    grid-template-columns: 1fr;
  }
  
  .hero--compact .hero__title {
    font-size: 2rem;
  }
}