/***************************************
 * BLUE THUMB DASHBOARD STYLESHEET
 ********************************
/* =================================
   CSS VARIABLES
   ================================= */
:root {
  --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
  --font-heading: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
  --color-text: #374151;
  --color-border-light: #eee;
  --color-border-medium: #ddd;
  --color-primary: #2E8B57;
  --color-primary-dark: #267349;
  --color-muted: #666;
  --color-bg-light: #F8F5F0;
  --color-bg-active: #EBE6DD;
}

/* =================================
   BASE TYPOGRAPHY
   ================================= */
body {
  font-family: var(--font-primary);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.7;
  color: var(--color-text);
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--color-text);
  margin-top: 1rem;
  margin-bottom: 1rem;
}

/* Main section headers used in markdown content */
h3, .tab-header {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border-light);
  padding-bottom: 0.5rem;
  margin-top: 1rem;
  margin-bottom: 1.5rem;
}

h4 {
  font-size: 1.3rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 1rem;
}

h5 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 1rem;
  margin-bottom: 0.75rem;
}

p {
  margin-bottom: 1.25rem;
  font-size: 16px;
  line-height: 1.7;
}

ul {
  margin-left: 1.5rem;
  margin-bottom: 1.5rem;
}

li {
  margin-bottom: 0.5rem;
}

/* =================================
   LAYOUT & CONTAINERS
   ================================= */
.dash-tab-content {
  padding: 15px;
  border-left: 1px solid var(--color-border-medium);
  border-right: 1px solid var(--color-border-medium);
  border-bottom: 1px solid var(--color-border-medium);
}

/* Consistent spacing across all tabs */
.tab-content-wrapper {
  margin-top: 0;
  padding-top: 0;
}

.tab-content-wrapper > .markdown-content {
  margin-top: 0;
}

.tab-content-wrapper > .markdown-content h3:first-child {
  margin-top: 0;
}

.markdown-content {
  margin-top: 0;
}

.dash-markdown {
  font-family: var(--font-primary);
}

.dash-markdown h3:first-child {
  margin-top: 0;
}

/* Non-markdown tab headers that need the same styling as h3 */
.tab-header {
  display: block;
}

/* Graph container spacing */
#chemical-graph-container, 
#biological-content-container {
  margin-bottom: 1rem;
}

/* =================================
   TAB STYLING
   ================================= */

/* Make tabs extend full width with even spacing */
#main-tabs {
  margin-left: 0;
  margin-right: 0;
  padding-left: 0;
  padding-right: 0;
}

.nav-tabs {
  width: 100%;
  display: flex;
  margin-left: 0;
  margin-right: 0;
  padding-left: 0;
  padding-right: 0;
}

.nav-tabs .nav-item {
  flex: 1;
  margin-left: 0;
  margin-right: 0;
}

.nav-tabs .nav-link {
  text-align: center;
  width: 100%;
  font-weight: bold;
  white-space: nowrap;
}

.nav-tabs .nav-link.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

/* =================================
   COMPONENTS
   ================================= */

/* BUTTONS */
.btn-primary {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
}

.btn-primary:hover {
  background-color: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
}



/* CARDS - Protect Our Streams tab styling */
.action-card .card-header {
  background-color: rgba(46, 139, 87, 0.1);
  height: 60px;
  display: flex;
  align-items: center;
  padding: 0.75rem 1.25rem;
}

.action-header-content {
  display: flex;
  align-items: center;
  width: 100%;
}

.action-icon {
  height: 40px;
  width: 40px;
  margin-right: 12px;
  flex-shrink: 0;
}

.action-title {
  margin: 0;
  padding: 0;
  line-height: 1.2;
  padding-top: 6px; /* Fixes subtle vertical alignment */
  display: flex;
  align-items: center;
  height: 40px;
  font-size: 1.1rem;
  font-weight: 600;
}

/* DROPDOWNS */
.Select-control {
  border-radius: 4px;
  border-color: var(--color-border-medium);
}

/* ACCORDIONS */
.accordion-item {
  margin-top: 0;
  padding-top: 0;
}

.accordion-header {
  margin-top: 0;
  padding-top: 0;
}

.accordion-button {
  font-weight: 600;
  background-color: var(--color-bg-light);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin-top: 0;
  padding: 0.75rem 1.25rem;
  height: auto;
  min-height: 45px;
}

.accordion-button:not(.collapsed) {
  background-color: var(--color-bg-active);
  color: var(--color-text);
}

.accordion-button:focus {
  box-shadow: none;
  border-color: var(--color-border-medium);
}

/* Position expand/collapse icon */
.accordion-button::after {
  position: absolute;
  right: 1.25rem;
}

.accordion-button > * {
  margin-top: 0;
  padding-top: 0;
}

.accordion + .accordion {
  margin-top: 1rem;
}

/* =================================
   UTILITIES
   ================================= */

/* Spacing for image containers in tabs */
.tab-image-container {
  margin-top: 30px;
}

figcaption {
  font-style: italic;
  color: var(--color-muted);
  font-size: 0.9rem;
  margin-top: 0.5rem;
  text-align: center;
  margin-bottom: 1rem;
}

/* Make the description/interpretation sections more readable */
.dash-markdown p {
  font-size: 16px;
  line-height: 1.7;
  margin-bottom: 1.25rem;
}

/* =================================
   MOBILE QUICK FIXES
   ================================= */

/* Mobile devices */
@media (max-width: 768px) {
  /* Responsive header height */
  header {
    min-height: 150px !important;
  }
  
  header h1 {
    font-size: 1.8rem !important;
    padding: 1rem !important;
  }
  
  /* Reduce container padding but keep some breathing room */
  .container-fluid {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }
  
  /* Tab content padding - more generous than before */
  .dash-tab-content {
    padding: 15px 10px;
  }
  
  /* Tab labels - better touch targets */
  .nav-tabs .nav-link {
    font-size: 0.9rem;
    padding: 0.75rem 0.5rem;
    white-space: normal;
    line-height: 1.3;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  /* Larger buttons for better touch targets */
  .btn-sm {
    font-size: 0.9rem !important;
    padding: 0.5rem 1rem !important;
    min-height: 44px;
  }
  
  .btn {
    min-height: 48px;
    font-size: 1rem;
  }
  
  /* Better dropdown touch targets */
  .dropdown-toggle {
    min-height: 44px;
    font-size: 1rem;
  }
  
  /* Larger form controls */
  .form-control, .form-select {
    min-height: 44px;
    font-size: 1rem;
  }
  
  /* Better label sizing */
  label, .form-label {
    font-size: 1rem !important;
    font-weight: 600 !important;
  }
  
  /* Stack side-by-side content vertically */
  .mobile-stack {
    flex-direction: column !important;
  }
  
  .mobile-stack > .col-6,
  .mobile-stack > [class*="col-"] {
    width: 100% !important;
    max-width: 100% !important;
    margin-bottom: 2rem;
  }
  
  /* Species gallery mobile improvements */
  .create-macro-dual-display {
    flex-direction: column !important;
  }
  
  .create-macro-dual-display > div {
    width: 100% !important;
    margin-left: 0 !important;
    margin-bottom: 1rem;
  }
  
  /* Action cards - ensure proper stacking */
  .action-card {
    margin-bottom: 1.5rem !important;
  }
  
  /* Improve season/month selector on mobile */
  .mobile-season-stack {
    flex-direction: column !important;
    gap: 1rem;
  }
  
  .mobile-season-stack .col-5,
  .mobile-season-stack .col-7 {
    width: 100% !important;
    max-width: 100% !important;
  }
  
  /* Button group improvements */
  .btn-group .btn {
    font-size: 0.8rem;
    padding: 0.4rem 0.6rem;
  }
  
  /* Checklist improvements */
  .checklist-mobile {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-top: 0.5rem;
  }
  
  /* Footer - stack vertically */
  .mobile-footer-stack {
    flex-direction: column !important;
    gap: 1rem;
  }
  
  /* Footer image sizing */
  .mobile-footer-stack img {
    height: 40px !important;
    margin-right: 0 !important;
    margin-bottom: 0.5rem;
  }
  
  /* Make graphs responsive with better mobile height */
  .js-plotly-plot {
    width: 100% !important;
    min-height: 400px !important;
  }
  
  /* Map specific mobile improvements */
  #site-map-graph {
    min-height: 350px !important;
  }
  
  /* Improve modal sizing on mobile */
  .modal-dialog {
    margin: 1rem;
    max-width: calc(100% - 2rem);
  }
  
  /* Better spacing for form rows */
  .row.mb-2, .row.mb-3 {
    margin-bottom: 1.5rem !important;
  }
  
  /* Improve accordion touch targets */
  .accordion-button {
    min-height: 50px !important;
    font-size: 1rem !important;
  }
}

/* =================================
   CHATBOT STYLING
   ================================= */

.chat-panel {
  border: 1px solid var(--color-border-medium);
  box-shadow: 0 5px 15px rgba(0,0,0,0.15);
}

.chat-panel-header {
  background-color: var(--color-primary);
  color: white;
}

.chat-panel-header h5 {
  color: white;
  font-weight: 600;
}

.chat-panel-header .btn-close {
  filter: invert(1) grayscale(100%) brightness(200%);
}

/* General container for each chat row (avatar + bubble) */
.chat-row {
  display: flex;
  align-items: flex-end; /* Align avatar and bubble at the bottom */
  gap: 10px;
  margin-bottom: 5px;
}

.assistant-message-row {
  justify-content: flex-start; /* Assistant messages on the left */
}

.user-message-row {
  justify-content: flex-end; /* User messages on the right */
}

/* Avatar styling */
.chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Base styling for the message bubbles */
.chat-message {
  padding: 12px 18px;
  border-radius: 20px;
  max-width: 100%; /* Max-width is now controlled by the container */
  word-wrap: break-word;
  line-height: 1.5;
}

/* User message bubble */
.user-message {
  background-color: #E9E9EB;
  color: black;
  border-bottom-right-radius: 5px; /* "Tail" for the bubble */
}

/* Assistant message bubble */
.assistant-message {
  background-color: var(--color-primary);
  color: white;
  border-bottom-left-radius: 5px; /* "Tail" for the bubble */
}

/* Timestamp base styles */
.chat-timestamp {
  font-size: 0.7rem;
  color: var(--color-muted);
  margin-top: 2px;
  margin-bottom: 15px; /* Space between messages */
}

.assistant-timestamp {
  text-align: left;
  padding-left: 50px; /* Indent to align with the start of the bubble */
}

.user-timestamp {
  text-align: right;
  padding-right: 50px; /* Indent to align with the end of the bubble */
}

/* Mobile responsiveness for chat */
@media (max-width: 768px) {
  #chat-collapse {
    width: 90% !important;
    left: 5% !important;
    right: 5% !important;
  }
  #chat-toggle {
    bottom: 10px !important;
    right: 10px !important;
  }
}

/* =================================
   ANIMATIONS
   ================================= */
.chat-callout {
  position: fixed;
  right: 280px; /* Positioned to the left of the button */
  bottom: 25px;
  background-color: #ffffff;
  padding: 10px 15px;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
  z-index: 1051;
  font-weight: 600;
  color: var(--color-text);
  opacity: 0;
  transform: translateY(10px);
  animation: fadeIn-callout 0.5s forwards, fadeOut-callout 0.5s 7s forwards;
}

.callout-arrow {
  position: absolute;
  top: 50%;
  right: -10px;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  border-left: 10px solid #ffffff;
}

@keyframes fadeIn-callout {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeOut-callout {
  to {
    opacity: 0;
    transform: translateY(10px);
    display: none;
  }
}