
/* Color Swatches / Reference */
/* Day Mode */
/* Clinical White: #F3F5F7 */
/* Silver Metallic: #C7CBD1 */
/* Emerald Green: #13C296 */

/* Night Mode */
/* Clinical White: #1F2937 */
/* Silver Metallic: #4B5563 */
/* Emerald Green: #10B981 */

:root {
  /* --- DAY MODE (Default) --- */
  --medical-blue: #0A2342;
  --emerald-green: #13C296;
  --neon-green: #36FFB5;
  --silver-metallic: #C7CBD1;
  --clinical-white: #F3F5F7;
  --midnight-black: #0A0A0A;

  /* Semantic Color Mapping */
  --bg-page: #FFFFFF;
  --bg-section: #FFFFFF;
  --bg-section-alt: var(--clinical-white);
  --bg-header: var(--medical-blue);
  --bg-card: var(--clinical-white);
  --bg-input: #FFFFFF;
  
  --text-primary: var(--midnight-black);
  --text-secondary: #4B5563;
  --text-header: #FFFFFF;
  --text-header-nav: rgba(255, 255, 255, 0.8);
  
  --border-color: var(--silver-metallic);
  --border-focus: var(--emerald-green);
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --transition-base: 0.3s ease;
}

html.night-mode {
  /* --- NIGHT MODE (Override) --- */
  --medical-blue: #1E3A5F;
  --emerald-green: #10B981;
  --neon-green: #2DD4BF;
  --silver-metallic: #4B5563;
  --clinical-white: #1F2937;
  --midnight-black: #F3F5F7; /* Swapped to light for text */

  /* Semantic Color Mapping */
  --bg-page: #111827;
  --bg-section: #111827;
  --bg-section-alt: #1F2937;
  --bg-header: #0F172A;
  --bg-card: #1F2937;
  --bg-input: #111827;
  
  --text-primary: var(--midnight-black);
  --text-secondary: #9CA3AF;
  --text-header: #FFFFFF;
  --text-header-nav: rgba(255, 255, 255, 0.8);
  
  --border-color: #374151;
  --border-focus: var(--neon-green);
}

/* 3) Global Styles */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  /* 14) Smooth color transitions */
  transition: background-color var(--transition-base), color var(--transition-base), border-color var(--transition-base), box-shadow var(--transition-base);
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.6;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* 4) Container and Layout */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }

/* Sections */
section {
  padding: 5rem 0;
  background-color: var(--bg-section);
  border-bottom: 1px solid var(--border-color);
}
section:nth-of-type(even) {
  background-color: var(--bg-section-alt);
}
section:last-child {
  border-bottom: none;
}

/* 5) Header Styles */
header {
  background-color: var(--bg-header);
  color: var(--text-header);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: var(--shadow-md);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

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

.logo {
  font-size: 1.25rem;
  font-weight: 800;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
}
.logo:hover { color: var(--emerald-green); }

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

.nav-link {
  color: var(--text-header-nav);
  font-weight: 500;
  font-size: 0.95rem;
  padding: 0.5rem;
  border-radius: 4px;
  text-decoration: none;
}
.nav-link:hover {
  color: var(--neon-green);
}
.nav-link.active {
  color: #0A0A0A; /* Always dark text on active bg */
  background-color: var(--emerald-green);
}

.mobile-toggle {
  display: none;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 0.5rem;
}

.theme-toggle {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0.5rem 1rem;
  border-radius: 2rem;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  transition: var(--transition-base);
}
.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: var(--neon-green);
  color: var(--neon-green);
}
/* 13) Accessibility Focus */
.theme-toggle:focus-visible, .btn:focus-visible, .nav-link:focus-visible, a:focus-visible {
  outline: 2px solid var(--neon-green);
  outline-offset: 2px;
}

/* --- DROPDOWN MENU STYLES --- */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-toggle {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.dropdown-toggle::after {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 0.25rem;
  vertical-align: middle;
  border-top: 0.3em solid;
  border-right: 0.3em solid transparent;
  border-bottom: 0;
  border-left: 0.3em solid transparent;
  transition: transform 0.2s;
}
.dropdown.open .dropdown-toggle::after {
  transform: rotate(180deg);
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 1050; /* High Z-Index to appear above content */
  min-width: 14rem;
  padding: 0.5rem 0;
  margin: 0.5rem 0 0;
  font-size: 0.95rem;
  color: var(--text-primary);
  text-align: left;
  list-style: none;
  background-color: var(--bg-card);
  background-clip: padding-box;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  box-shadow: var(--shadow-md);
  
  /* Animation/Transition States */
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  pointer-events: none; /* Prevent clicks when hidden */
}

.dropdown-item {
  display: block;
  width: 100%;
  padding: 0.65rem 1.25rem;
  clear: both;
  font-weight: 500;
  color: var(--text-primary);
  text-align: inherit;
  text-decoration: none;
  white-space: nowrap;
  background-color: transparent;
  border: 0;
  cursor: pointer; /* Ensure pointer cursor */
  pointer-events: auto; /* Ensure clickable */
  transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out;
}

.dropdown-item:hover, .dropdown-item:focus {
  color: var(--emerald-green);
  background-color: var(--bg-section-alt);
  outline: none;
}

/* Desktop Hover Behavior */
@media (min-width: 1024px) {
  .dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
  }
  /* Invisible bridge to prevent menu closing during mouse transition */
  .dropdown-menu::before {
    content: '';
    position: absolute;
    top: -0.5rem;
    left: 0;
    width: 100%;
    height: 0.5rem;
  }
}

/* 6) Footer Styles */
footer {
  background-color: var(--bg-header);
  color: var(--silver-metallic);
  padding: 4rem 0 2rem;
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
  margin-bottom: 3rem;
}

footer h4 {
  color: #fff;
  margin-bottom: 1.5rem;
  font-size: 1.125rem;
}

.footer-links { list-style: none; }
.footer-links li { margin-bottom: 0.75rem; }
.footer-links a { 
  color: var(--silver-metallic); 
  text-decoration: none;
}
.footer-links a:hover { color: var(--neon-green); }

.copyright {
  text-align: center;
  padding-top: 2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.4);
}

/* 7) Button Styles */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: var(--transition-base);
  border: 2px solid transparent;
  text-decoration: none;
  line-height: 1;
}

.btn-lg {
  padding: 1rem 2rem;
  font-size: 1.125rem;
}

.btn-primary {
  background-color: var(--emerald-green);
  color: #0A0A0A; /* Always dark text on emerald */
}
.btn-primary:hover {
  background-color: var(--neon-green);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(19, 194, 150, 0.3);
}

.btn-secondary {
  background-color: transparent;
  border-color: var(--emerald-green);
  color: var(--emerald-green);
}
.btn-secondary:hover {
  background-color: rgba(19, 194, 150, 0.1);
  border-color: var(--neon-green);
  color: var(--neon-green);
}

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

/* 8) Form Styles */
.form-group { margin-bottom: 1.5rem; }

label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-primary);
  font-size: 0.95rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  background-color: var(--bg-input);
  color: var(--text-primary);
  border-radius: 0.5rem;
  font-family: inherit;
  font-size: 1rem;
  transition: var(--transition-base);
}

textarea { min-height: 120px; resize: vertical; }

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--emerald-green);
  box-shadow: 0 0 0 3px rgba(19, 194, 150, 0.2);
}

input.error, textarea.error {
  border-color: #ef4444;
}
input.success, textarea.success {
  border-color: var(--emerald-green);
}

/* 9) Card Styles */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 2rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.3s, box-shadow 0.3s, border-color 0.3s;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-md);
  border-color: var(--emerald-green);
}

.card h3 { margin-top: 0; }

/* 10) Typography */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  font-weight: 700;
  line-height: 1.2;
  margin-top: 0;
  margin-bottom: 1rem;
}

h1 { font-size: 3rem; letter-spacing: -0.02em; }
h2 { font-size: 2.25rem; letter-spacing: -0.01em; }
h3 { font-size: 1.5rem; }
p { margin-bottom: 1.5rem; color: var(--text-primary); opacity: 0.9; }

a {
  color: var(--emerald-green);
  text-decoration: none;
  font-weight: 500;
}
a:hover { color: var(--neon-green); }

code, pre {
  font-family: 'IBM Plex Mono', monospace;
  background-color: #0A0A0A;
  color: #36FFB5;
  padding: 0.2em 0.4em;
  border-radius: 4px;
  font-size: 0.9em;
}
html.night-mode code, html.night-mode pre {
  background-color: #000000;
  color: #2DD4BF;
}
pre {
  display: block;
  padding: 1rem;
  overflow-x: auto;
  border: 1px solid var(--border-color);
}
pre code {
  background: none;
  padding: 0;
  border: none;
}

ul { list-style: disc inside; margin-bottom: 1.5rem; }
ol { list-style: decimal inside; margin-bottom: 1.5rem; }

/* 11) Utilities */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-emerald { color: var(--emerald-green); }
.text-highlight { color: var(--neon-green); }
.mb-4 { margin-bottom: 1rem; }
.mb-8 { margin-bottom: 2rem; }
.w-full { width: 100%; }
.bg-midnight { 
  background-color: var(--bg-header) !important; 
}
.bg-midnight h2, .bg-midnight p {
  color: #fff !important;
}

/* Custom Color Utilities */
/* Text Colors */
.text-clinical-white { color: var(--clinical-white); }
.text-silver { color: var(--silver-metallic); }

/* Background Colors */
.bg-clinical-white { background-color: var(--clinical-white); }
.bg-silver { background-color: var(--silver-metallic); }
.bg-emerald { background-color: var(--emerald-green); }

/* Border Colors */
.border-clinical-white { border-color: var(--clinical-white); }
.border-silver { border-color: var(--silver-metallic); }
.border-emerald { border-color: var(--emerald-green); }


.grid {
  display: grid;
  gap: 2rem;
}
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }

/* 12) Mobile Responsive */
/* Desktop */
@media (min-width: 1024px) {
  .mobile-toggle { display: none; }
}

/* Tablet */
@media (max-width: 1023px) {
  .nav-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--bg-header);
    flex-direction: column;
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    max-height: 80vh;
    overflow-y: auto;
  }
  .nav-menu.open { display: flex; }
  .mobile-toggle { display: block; }
  
  .grid-3 { grid-template-columns: repeat(2, 1fr); }

  /* Mobile Dropdown Styles */
  .dropdown-menu {
    position: static;
    display: none; /* Hidden by default */
    width: 100%;
    margin-top: 0.5rem;
    padding: 0 0 0.5rem 0;
    background-color: transparent;
    border: none;
    box-shadow: none;
    opacity: 1;
    visibility: visible;
    transform: none;
    padding-left: 1.5rem;
    pointer-events: auto;
    border-left: 2px solid rgba(255,255,255,0.1);
    margin-left: 0.5rem;
  }
  
  .dropdown.open .dropdown-menu {
    display: block;
  }

  .dropdown-toggle {
    width: 100%;
    justify-content: space-between;
  }
}

/* Mobile */
@media (max-width: 767px) {
  h1 { font-size: 2.25rem; }
  h2 { font-size: 1.75rem; }
  
  .header-inner { padding: 0 1rem; }
  .container { padding: 0 1rem; }
  
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  
  .btn-lg { width: 100%; }
}

/* 15) High Contrast / Print tweaks if needed */
@media print {
  body { background: #fff; color: #000; }
  .btn, .theme-toggle { display: none; }
}
