/* --- Eflora.info Unified Stylesheet --- */

/* ## 1. Color & Font Variables (Light Mode Default) ## */
:root {
  --bg-color: #f9f9f9;
  --text-color: #333333;
  --link-color: #2a7f62;
  --link-hover-color: #225f4a;

  /* Phytochemicals Table Colors (Light Mode) */
  --table-info-bg: #b3f0ff;
  --table-alkaloids-bg: #ffcc99;
  --table-alkamides-bg: #401B40;
  --table-amines-bg: #ccccff;
  --table-phenols-bg: #e6ffb3;
  --table-peptides-bg: #ffcc66;
  --table-npaas-bg: #ffff99;
}

/* ## 2. General Body & Typography Styles ## */
body {
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: Arial, sans-serif;
  font-size: large;
  line-height: 1.6;
  padding-bottom: 20px;
}

/* Hyperlink styling */
a {
  color: var(--link-color);
  text-decoration: none;
}

a:hover,
a:focus {
  color: var(--link-hover-color);
  text-decoration: underline;
}

/* ## 3. Page Layout & Core Components ## */
.main-wrapper {
  display: flex;
  flex-direction: column;
}

main {
  flex-grow: 1;
  padding: 0 20px;
}

/* Fix for long text strings stretching the layout */
main p {
  word-wrap: break-word;
}

#popup {
  position: absolute;
  background: #222;
  color: #fff;
  padding: 8px;
  border-radius: 5px;
  display: none;
  font-size: 14px;
  max-width: 250px;
  z-index: 1000;
}

/* --- Content Cards (Used in AI generated sections) --- */
.content-stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 20px;
}

.content-card {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* --- Image gallery styles --- */
.image-gallery img {
  max-width: 100%;
  height: auto;
  display: block; /* Removes tiny gap at bottom of images */
  margin: 0 auto; /* Centers image in the figure if it's smaller */
}

.image-gallery {
  text-align: center;
}
.image-gallery figure {
  display: inline-block;
  vertical-align: top;
  width: 256px;
  margin: 10px;
}

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

@media (max-width: 768px) {
    .species-gallery {
        grid-template-columns: 1fr;
    }
}

/* ## 4. Navigation & Sidebar Styles (Mobile First) ## */
nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Mobile Menu Controls */
.hamburger {
  display: block;
}

#sidebar-toggle, #close-nav-btn {
  display: none;
}

.nav-links {
  display: none;
  position: fixed;
  top: 0;
  right: -300px;
  width: 250px;
  max-width: 80vw;
  height: 100%;
  background-color: #f9f9f9;
  flex-direction: column;
  padding: 50px 10px;
  align-items: flex-start;
  box-sizing: border-box;
  box-shadow: -2px 0 5px rgba(0,0,0,0.5);
  transition: right 0.3s ease-in-out;
  z-index: 1000;
  overflow-y: auto;
}

.nav-links.active {
  display: flex;
  right: 0;
}

/* Default state for dropdowns: CLOSED */
.dropdown-content {
  display: none;
}

/* Active state for dropdowns: OPEN */
/* UPDATED: Support for both .active and .dropdown-active classes */
.dropdown.active .dropdown-content,
.dropdown.dropdown-active .dropdown-content {
  display: block;
}

.nav-links.active #close-nav-btn {
  display: block;
  position: absolute;
  top: 10px;
  right: 15px;
  background: none;
  border: none;
  font-size: 28px;
  font-weight: bold;
  color: #333;
  cursor: pointer;
}

/* Navigation Dropdowns */
.header-content {
  width: 100%;
  text-align: center;
}
.header-content img {
  max-height: 140px;
  margin: 10px 0;
}
.dropbtn, .dropbtn2 {
  background-color: #4CAF50;
  color: white;
  padding: 10px;
  font-size: 16px;
  border: none;
  cursor: pointer;
  text-align: left;
  width: 100%;
}
.dropdown-content a {
  color: black;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
}
.dropdown-content a:hover {
  background-color: #f1f1f1;
}

/* Sidebar Controls & Info */
.sidebar-controls {
  width: 90%;
  margin-top: 30px;
}
#modeToggleBtn {
  width: 100%;
  padding: 12px 20px;
  font-size: 1em;
  border: 1px solid #ccc;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}

.sidebar-info {
  margin-top: 30px;
  padding: 15px;
  font-size: 0.8em;
  color: #777;
  text-align: center;
  width: 90%;
}
.sidebar-info p {
  margin: 5px 0;
}
.sidebar-info a {
  color: #555;
  text-decoration: none;
}
.sidebar-info a:hover {
  text-decoration: underline;
}

/* ## 5. Table Styles ## */
.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  border: 1px solid #ddd;
  padding: 8px;
}
th {
  background-color: #f2f2f2;
}

/* Styling for phytochemicals tables */
.table-info { background-color: var(--table-info-bg); }
.table-alkaloids { background-color: var(--table-alkaloids-bg); }
.table-alkamides { background-color: var(--table-alkamides-bg); }
.table-amines { background-color: var(--table-amines-bg); }
.table-phenols { background-color: var(--table-phenols-bg); }
.table-peptides { background-color: var(--table-peptides-bg); }
.table-npaas { background-color: var(--table-npaas-bg); }

/* Table Sorting */
#myTable th.sortable {
  cursor: pointer;
  position: relative;
  user-select: none;
}
#myTable th.sortable::after {
  content: '\2195';
  opacity: 0.3;
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
}
#myTable th.sorted-asc::after {
  content: '\2191';
  opacity: 1;
}
#myTable th.sorted-desc::after {
  content: '\2193';
  opacity: 1;
}

/* Styling for specific table header columns */
#myTable th.hazards {
  background-color: yellow;
  color: brown;
  font-weight: bold;
}
#myTable th.edible {
  background-color: #00ff00;
  color: brown;
  font-weight: bold;
}
#myTable th.other-use {
  background-color: #cc9900;
  font-weight: bold;
}
#myTable th.medicinal {
  background-color: #ff5353;
  font-weight: bold;
}

/* Phytochemical Grid Layout */
.phytochemical-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin-top: 20px;
}

/* On larger screens, switch to 2 columns */
@media (min-width: 992px) {
  .phytochemical-grid {
    grid-template-columns: repeat(2, 1fr);
    align-items: start; /* Prevents cards from stretching to match height */
  }
}

/* Ensure inner tables don't overflow card */
.phytochemical-grid .table-container {
  max-height: 400px; /* Optional: Scrollable if list is too long */
  overflow-y: auto;
}

/* ## 6. Dark Mode Styles ## */
body.dark-mode {
  background-color: black;
  color: white;
  
  /* Phytochemicals Table Colors (Dark Mode) */
  --table-info-bg: #1A3E4D; 
  --table-alkaloids-bg: #402E1B; 
  --table-alkamides-bg: #401B40; 
  --table-amines-bg: #2C2C40; 
  --table-phenols-bg: #2E3D10; 
  --table-peptides-bg: #403010; 
  --table-npaas-bg: #404010; 
}

/* --- SIDEBAR DARK MODE FIX --- */
body.dark-mode header {
  background-color: #1a1a1a !important; /* Force sidebar background */
  border-left: 1px solid #333 !important;
}

body.dark-mode .nav-links {
  background-color: #1a1a1a !important; /* Matches header for seamless look */
}

body.dark-mode .dropdown-content a {
  color: #9e9eff !important;
}

body.dark-mode .dropdown-content a:hover {
  background-color: #333 !important;
}

body.dark-mode #modeToggleBtn {
  background-color: #333 !important;
  color: white !important;
  border-color: #555 !important;
}

body.dark-mode .sidebar-info,
body.dark-mode .sidebar-info a {
  color: #aaa !important;
}

/* --- END SIDEBAR FIX --- */

body.dark-mode a {
  color: #9e9eff;
}

/* New: Ensure text in color-coded dark mode cells is white/light for readability */
body.dark-mode .table-info,
body.dark-mode .table-alkaloids,
body.dark-mode .table-alkamides,
body.dark-mode .table-amines,
body.dark-mode .table-phenols,
body.dark-mode .table-peptides,
body.dark-mode .table-npaas {
    color: #f0f0f0; /* Light text color for dark backgrounds */
}

/* Content Cards Dark Mode */
body.dark-mode .content-card {
  background: #2a2a2a;
  border-color: #444;
}
body.dark-mode .content-card h2, 
body.dark-mode .content-card h3 {
  color: #fff; /* Ensure headers inside cards are readable */
}

/* Pharmacological & Nutritional Dark Mode Overrides */
body.dark-mode .bio-dashboard {
    background: #222;
    border: 1px solid #444;
}
body.dark-mode .bio-panel,
body.dark-mode .nutri-col {
    background: #2a2a2a;
    border-color: #444;
}
body.dark-mode .panel-header {
    border-bottom-color: #444;
}
body.dark-mode .tag-pill {
    background-color: #333;
    color: #ddd;
    border-color: #555;
}
body.dark-mode .nutri-table td {
    border-bottom-color: #444;
    color: #ccc;
}


/* ## 7. Responsive Desktop Layout ## */
@media (min-width: 992px) {
  .main-wrapper {
    flex-direction: row;
    flex-wrap: nowrap;
  }

  header {
    width: 250px;
    flex-shrink: 0;
    height: 100vh;
    position: sticky;
    top: 0;
    order: 2; /* Sidebar on RIGHT */
    border-left: 1px solid #e0e0e0;
    overflow-y: auto;
    transition: width 0.3s ease-in-out;
  }

  main {
    flex-grow: 1;
  }

  .header-content img {
    max-height: 100px !important;
  }

  #sidebar-toggle {
    display: block;
    margin: 10px;
    padding: 5px 10px;
    cursor: pointer;
    border: 1px solid #ccc;
    background-color: #f1f1f1;
    width: 90%;
  }

  .hamburger, #close-nav-btn {
    display: none;
  }

  header.collapsed {
    width: 60px;
  }
  header.collapsed nav {
    display: none;
  }
  
  body:not(.dark-mode) header {
    background-color: var(--bg-color); 
  }
  
  header.collapsed #sidebar-toggle {
    width: auto;
  }

  nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    height: 100%;
  }

  .nav-links {
    display: flex;
    position: static;
    flex-direction: column;
    align-items: center;
    width: 100%;
    height: 100%;
    background-color: transparent;
    padding: 0;
    box-shadow: none;
  }

  .dropdown {
    width: 90%;
    margin-bottom: 5px;
  }

  .dropdown-content {
    position: static;
    box-shadow: none;
    background-color: transparent;
    display: none;
  }

  /* UPDATED: Support for active classes in desktop view */
  .dropdown.active .dropdown-content,
  .dropdown.dropdown-active .dropdown-content {
    display: block;
  }

  .dropdown-content a {
    padding-left: 20px;
  }
}

/* For larger desktops */
@media (min-width: 1441px) {
  header {
    width: 250px;
  }
  .dropdown {
    width: 90%;
  }
}

/* ## 8. Print Styles ## */
@media print {
  /* 1. Hide non-essential UI elements */
  header, 
  nav, 
  footer, 
  .sidebar-controls, 
  .hamburger, 
  #popup,
  .speech-btn,
  #bg-slideshow,
  .search-bar,
  audio {
    display: none !important;
  }

  /* 2. Reset Layout: Expand main content to full page width */
  .main-wrapper {
    display: block !important;
  }

  main {
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
  }

  /* 3. Force Data Boxes to stay open for printing */
  .full-width-data {
    display: block !important;
    border: 1px solid #ccc !important;
  }

  .full-width-data summary {
    display: block !important;
    font-size: 1.2em;
    border-bottom: 2px solid #333;
    padding-bottom: 5px;
    margin-bottom: 10px;
  }

  /* Force display of the 'hidden' content */
  .full-width-data .content,
  details .content {
    display: block !important;
    max-height: none !important; /* Remove scrollbars */
    overflow: visible !important;
  }

  /* Ensure pre-formatted data wraps and fits on paper */
  .full-width-data pre {
    white-space: pre-wrap !important;
    font-size: 10pt !important;
    color: #000 !important;
    background: transparent !important;
  }

  /* 4. Table Optimization */
  table {
    width: 100% !important;
    table-layout: auto !important;
    border-collapse: collapse !important;
    page-break-inside: auto;
  }

  tr {
    page-break-inside: avoid;
    page-break-after: auto;
  }

  th, td {
    font-size: 10pt !important;
    border: 1px solid #999 !important;
    padding: 4px !important;
    word-wrap: break-word !important;
  }

  /* 5. Handle Colors: Browsers often disable backgrounds for printing */
  /* This helps keep your category colors visible if 'Print Background Graphics' is on */
  .status-tag, .stat-box, .bio-panel {
    border: 1px solid #000 !important;
    background-color: transparent !important;
    color: #000 !important;
    box-shadow: none !important;
  }

  /* Force links to be black and remove underlines for a cleaner look */
  a {
    color: #000 !important;
    text-decoration: none !important;
  }

  /* 6. Typography adjustments for paper */
  body {
    background-color: white !important;
    color: black !important;
    font-size: 12pt !important;
  }
}

/* ## 9. HOMEPAGE SPECIFIC STYLES ## */

/* Image Slideshow Background */
#bg-slideshow {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    animation: kenburns 20s ease-out forwards;
}

#bg-slideshow::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    z-index: -1;
}

@keyframes kenburns {
    from { background-size: 100% 100%; }
    to { background-size: 120% 120%; }
}

/* Main Container on Homepage */
.homepage-container {
    max-width: 1200px;
    margin: 40px auto;
    padding: 20px;
    background: rgba(0, 0, 0, 0.65);
    border-radius: 10px;
    color: #f0f0f0;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
}

/* Homepage Header Area */
.homepage-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 10px;
    margin-bottom: 20px;
    color: #333;
    text-shadow: none; 
}

.homepage-logo img {
    max-height: 150px;
    width: auto;
}

.homepage-title {
    width: 100%;
    padding: 0 10px;
    text-align: center;
}

.homepage-title h1 {
    font-size: clamp(1.2em, 4vw, 2.5em);
    overflow-wrap: break-word;
    word-wrap: break-word;
    hyphens: auto;
    color: #333;
}

/* Search Bar */
.search-bar {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.search-bar input {
    padding: 10px;
    width: 70%;
    max-width: 600px;
    font-size: 1em;
    border: 2px solid #ccc;
    border-radius: 5px;
    margin-right: 10px;
}

.search-bar input:focus {
    border-color: #1aff1a;
    outline: none;
}

.search-bar button {
    padding: 10px 20px;
    font-size: 0.9em;
    background-color: #1aff1a;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: white;
}

.search-bar button:hover {
    background-color: #0056b3;
}

/* Dropdown Section */
.dropdown-section {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
}

.dropdown-section label {
    font-weight: bold;
}

.dropdown-section select {
    padding: 10px;
    font-size: 1em;
    border: 2px solid #ccc;
    border-radius: 5px;
    width: 200px;
}

/* Recent Updates Section */
#php-recent-updates {
    background: rgba(0, 0, 0, 0.85);
    padding: 15px;
    border-radius: 10px;
    margin-top: 20px;
    width: 100%;
    color: #fff;
}

.recent-columns {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
}

.recent-column {
    flex: 0 0 48%;
}

.php-file-item {
    margin-bottom: 10px;
    white-space: nowrap;
}

/* Stats */
#stats {
    font-size: 2em;
    font-weight: bold;
    margin-bottom: 20px;
    text-align: center;
}

/* Footer */
footer {
    background-color: #222;
    color: #ccc;
    padding: 15px;
    text-align: center;
    font-size: 0.9em;
    margin-top: 30px;
}

/* --- MOBILE FIX: STACKED LOGO --- */
/* On screens smaller than 768px (Tablets/Phones) */
@media (max-width: 768px) {
    /* Hide the logo in the main content area to prevent stacking */
    .homepage-logo {
        display: none;
    }
    
    /* Center the title since the logo is gone */
    .homepage-header {
        justify-content: center;
        text-align: center;
        padding: 15px;
    }

    .homepage-title h1 {
        font-size: 1.5em; /* Make font manageable on mobile */
    }

    /* Stack the recent updates columns */
    .recent-column {
        flex: 0 0 100%;
    }
}

/* ## 10. PHARMACOLOGICAL & NUTRITIONAL COMPONENTS (New) ## */

/* Pharmacological Dashboard (Diagram Style) */
.bio-dashboard {
    background: linear-gradient(to bottom right, #ffffff, #f4f8f4);
}

.bio-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Panels */
.bio-panel {
    background: rgba(255,255,255,0.8);
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    flex: 1;
    box-shadow: 0 2px 5px rgba(0,0,0,0.03);
}

.panel-header {
    border-bottom: 2px solid #eee;
    margin-bottom: 15px;
    padding-bottom: 5px;
}

.panel-header h4 {
    margin: 0;
    color: #2a7f62;
    font-size: 1.1em;
}

.subtitle {
    font-size: 0.8em;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Activity Pills (Tags) */
.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-pill {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: bold;
    color: #444;
    border: 1px solid transparent;
}

/* Semantic Coloring for Activities */
.category-digestive { background-color: #e3f2fd; border-color: #bbdefb; color: #0d47a1; } /* Blue */
.category-micro { background-color: #ffebee; border-color: #ffcdd2; color: #b71c1c; } /* Red */
.category-sys { background-color: #f3e5f5; border-color: #e1bee7; color: #4a148c; } /* Purple */

/* Indication List */
.indication-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.indication-list li {
    padding: 8px 0;
    border-bottom: 1px dashed #eee;
    font-size: 0.9em;
}

.indication-list li:last-child {
    border-bottom: none;
}

/* The Arrow Connector (Desktop) */
.bio-connector {
    display: none; /* Hidden on mobile */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #ccc;
}

.bio-connector .arrow {
    font-size: 2em;
    color: #2a7f62;
}

.bio-connector .label {
    font-size: 0.7em;
    text-transform: uppercase;
    margin-top: -5px;
}

/* --- Nutritional Comparison Styles --- */
.nutri-comparison {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.nutri-col {
    flex: 1;
    background: #fdfdfd;
    border: 1px solid #eee;
    border-radius: 8px;
    overflow: hidden;
}

.nutri-header {
    margin: 0;
    padding: 10px;
    text-align: center;
    color: white;
}

.leaf-header { background-color: #66bb6a; }
.seed-header { background-color: #8d6e63; }

.nutri-table {
    width: 100%;
    border-collapse: collapse;
}

.nutri-table td {
    padding: 8px 15px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.9em;
}

.nutri-table tr:last-child td {
    border-bottom: none;
}

.nutri-table td:last-child {
    text-align: right;
    font-weight: bold;
    color: #555;
}

/* Component Specific Media Queries */
@media (min-width: 992px) {
    /* Flow Chart Layout */
    .bio-grid {
        flex-direction: row;
        align-items: stretch;
    }
    
    .bio-connector {
        display: flex;
        padding: 0 10px;
    }

    /* Side-by-Side Nutrition */
    .nutri-comparison {
        flex-direction: row;
    }
}

/* --- Status Tags for Tables --- */
.status-tag {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: bold;
    display: inline-block;
    margin: 2px;
}

/* Individual Status Colors */
.status-hazard { background-color: #ffd700; color: #5a3e1b; } /* Yellow/Brown */
.status-edible { background-color: #4cd964; color: #fff; }     /* Green */
.status-medicinal { background-color: #ff5353; color: #fff; } /* Red */
.status-gemini { background-color: #ff884d; color: #fff; }    /* Orange */
.status-gpt { background-color: #D5A4FF; color: #333; }       /* Purple */
.status-other { background-color: #cc9900; color: #fff; }    /* Gold/Brown */
.status-myth { background-color: #5c6bc0; color: #ffffff; }  /* Indigo Blue */

/* Modern Grid for the List */
.species-list {
    column-width: 280px; /* Creates responsive columns automatically */
    column-gap: 2rem;
    padding-left: 20px;
}
.species-list li {
    break-inside: avoid; /* Prevents items from splitting across columns */
    margin-bottom: 8px;
}

/* ## 11. STAT BOX COMPONENT (Search Infographic) ## */
/* Default (Light Mode) */
.stat-box {
    padding: 10px;
    border-radius: 5px;
    border: 1px solid;
    margin-bottom: 10px;
    color: #333; /* Dark text for light bg */
}
.stat-box.green {
    background-color: #f4f8f4;
    border-color: #cce5cc;
}
.stat-box.green strong { color: #2a7f62; }

.stat-box.yellow {
    background-color: #fff3cd;
    border-color: #ffeeba;
}
.stat-box.yellow strong { color: #856404; }

/* Dark Mode Overrides - FORCE FIX */
body.dark-mode .stat-box {
    color: #f0f0f0 !important; /* Force White Text */
}
body.dark-mode .stat-box.green {
    background-color: #1a3b2f !important; /* Force Dark Forest Green */
    border-color: #2a7f62 !important;
}
body.dark-mode .stat-box.green strong { color: #66bb6a !important; } /* Light Green Title */

body.dark-mode .stat-box.yellow {
    background-color: #3d3215 !important; /* Force Dark Earthy Brown */
    border-color: #856404 !important;
}
body.dark-mode .stat-box.yellow strong { color: #ffd700 !important; } /* Gold Title */

/* Make the small sub-text (e.g., '/ 100 vols') readable in both modes */
body.dark-mode .stat-box span { color: #aaa !important; }

/* --- DARK MODE READABILITY HOTFIX --- */

/* 1. Global Card & Background Overrides for Dark Mode */
body.dark-mode .content-card {
    background-color: #1a1a1a !important;
    border-color: #444 !important;
    color: #f0f0f0 !important;
}

/* 2. Target specific inline background colors used in cards */
body.dark-mode [style*="background: #f9f9f9"],
body.dark-mode [style*="background: #fdfdfd"],
body.dark-mode [style*="background: rgba(128, 128, 128, 0.1)"] {
    background-color: rgba(255, 255, 255, 0.05) !important;
    color: #e0e0e0 !important;
}

/* 3. Ensure "Status" backgrounds (Green/Yellow) remain readable */
/* Edible/Green sections */
body.dark-mode .status-edible,
body.dark-mode [style*="background: #f0fff0"] {
    background-color: #1b3d21 !important; /* Dark Forest Green */
    color: #ffffff !important;
}

/* Toxic/Yellow sections */
body.dark-mode .status-hazard,
body.dark-mode [style*="background: #fffdf0"] {
    background-color: #3d3615 !important; /* Dark Muted Gold */
    color: #ffffff !important;
}

/* 4. Text Contrast Fixes */
body.dark-mode .panel-header strong,
body.dark-mode .content-card h3 {
    color: #9e9eff !important; /* Brighter accent color for titles */
}

body.dark-mode .text-sm,
body.dark-mode .indication-list li,
body.dark-mode p {
    color: #d1d1d1 !important;
}

/* 5. List items and borders in Species List */
body.dark-mode [style*="border-bottom: 1px solid #eee"],
body.dark-mode [style*="border-bottom: 1px solid #444"] {
    border-bottom-color: #333 !important;
}

/* 6. Mythology/Okanagan Card Specific Border */
body.dark-mode [style*="border-left: 5px solid #ffcc00"] {
    background-color: #2d2a15 !important;
}

/* --- COMPONENT UPDATES & DARK MODE FIXES --- */

/* --- UNIVERSAL HAZARD COLOR LOCK --- */
/* This prevents hazards from shifting to dark colors in Dark Mode */
.status-hazard, 
body.dark-mode .status-hazard,
body.dark-mode [style*="background: yellow"],
body.dark-mode [style*="background-color: yellow"] {
    background-color: yellow !important; 
    color: brown !important; 
    font-weight: bold !important;
    opacity: 1 !important;
}

/* Ensures the recency-180 class also stays yellow/brown if you prefer that look for the dashboard */
.recency-180,
body.dark-mode .recency-180 {
    background-color: #fff9c4 !important; /* Soft Yellow */
    color: brown !important;
    border: 1px solid #fbc02d !important;
}

/* Ensures the Species Grid is readable and compact */
.compact-grid {
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); 
    gap: 10px; 
    font-size: 0.9em;
}

/* Fix for background contrast in Cultural/Phytochem cards */
.sub-panel {
    background: rgba(128, 128, 128, 0.08); 
    padding: 12px; 
    border-radius: 6px; 
    margin-top: 10px; 
    font-size: 0.85em;
}

body.dark-mode .sub-panel {
    background: rgba(255, 255, 255, 0.05) !important;
    color: #d1d1d1 !important;
}

/* Specific fix for Table 1 and Table 2 text in Dark Mode */
body.dark-mode .content-card p,
body.dark-mode .content-card li,
body.dark-mode .content-card td {
    color: #e0e0e0 !important;
}

body.dark-mode .panel-header h4 {
    color: #9e9eff !important;
}

/* Maintenance: Prevent column breakage in long lists */
.lichen-flex-list {
    column-width: 280px;
    column-gap: 20px;
}

/* Mythology Dark Mode specific contrast */
body.dark-mode .status-myth {
    background-color: #3949ab !important; /* Deeper Indigo */
    color: #e8eaf6 !important;
}

/* Specific Border for Mythology Card */
.myth-card-border {
    border-left: 5px solid #5c6bc0 !important;
}

body.dark-mode .myth-card-border {
    border-left-color: #3949ab !important;
}

/* ## 12. DASHBOARD LEGEND & RECENCY COLORS (Dark Mode Fix) ## */
/* Target the inline background styles used in the legend boxes and cards */

body.dark-mode .legend-box[style*="background:#e8f5e9"],
body.dark-mode .inv-card[style*="background-color: #e8f5e9"] {
    background-color: #1b3d21 !important; /* Dark Forest Green */
    border-left-color: #4caf50 !important;
}

body.dark-mode .legend-box[style*="background:#fff9c4"],
body.dark-mode .inv-card[style*="background-color: #fff9c4"] {
    background-color: #3d3615 !important; /* Dark Muted Gold */
    border-left-color: #fbc02d !important;
}

body.dark-mode .legend-box[style*="background:#ffe0b2"],
body.dark-mode .inv-card[style*="background-color: #ffe0b2"] {
    background-color: #4e342e !important; /* Dark Burnt Orange */
    border-left-color: #fb8c00 !important;
}

/* Ensure card text is visible on these darker backgrounds */
body.dark-mode .inv-card a {
    color: #f0f0f0 !important;
}

/* ## 13. RECENCY & DASHBOARD CLASSES ## */

/* --- Light Mode (Default) --- */
.recency-30 { 
    background-color: #e8f5e9 !important; 
    border-color: #4caf50 !important; 
    color: #1b5e20 !important; 
}
.recency-180 { 
    background-color: #fff9c4 !important; /* Yellow */
    border-color: #fbc02d !important; 
    color: brown !important; /* High contrast brown text */
}
.recency-year { 
    background-color: #ffe0b2 !important; 
    border-color: #fb8c00 !important; 
    color: #5d4037 !important; 
}

/* --- Dark Mode Overrides --- */
body.dark-mode .recency-30 { 
    background-color: #1b3d21 !important; 
    color: #e8f5e9 !important; 
}
body.dark-mode .recency-180 { 
    background-color: #3d3615 !important; /* Muted Gold */
    color: #fff9c4 !important; /* Light Yellow Text */
    border-color: #fbc02d !important;
}
body.dark-mode .recency-year { 
    background-color: #4e342e !important; 
    color: #ffe0b2 !important; 
}

/* --- Legend Box Helper --- */
.legend-box {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid #ccc;
    display: inline-block;
}

/* --- DARK MODE TABLE HEADER FIXES --- */
body.dark-mode th {
    background-color: #333333 !important; /* Dark grey background */
    color: #ffffff !important;           /* Pure white text */
    border-color: #555555 !important;
}

/* Fix for the Bryoria Phytochemical Dashboard specifically */
body.dark-mode .content-stack table thead tr {
    background: #222222 !important;
}

/* Fix for VulpinicAcid.php Chemical Profile header */
body.dark-mode table.table-info thead tr th {
    background-color: #1A3E4D !important; /* Matches your --table-info-bg variable */
    color: #b3f0ff !important;           /* Light blue accent text */
}

/* Fix for General/Contrasting Evidence table in VulpinicAcid.php */
body.dark-mode .table-container table thead tr th {
    background-color: #2d2d2d !important;
    color: #9e9eff !important;
}

/* --- LICHENS.PHP DARK MODE HEADER COLOR MATCH --- */

/* Targets the specific non-colored headers to match the Hazards/Edible brown text */
body.dark-mode #myTable th.species h3,
body.dark-mode #myTable th.common-name h3,
body.dark-mode #myTable th.family h3,
body.dark-mode #myTable th.status h3,
body.dark-mode #myTable th.photo h3 {
    color: brown !important;
}

/* Ensure the background remains dark for these specific headers so the brown is legible */
body.dark-mode #myTable th:not(.hazards):not(.edible):not(.other-use):not(.medicinal) {
    background-color: #333333 !important;
    border-color: #555555 !important;
}