/* ==============================
   font sizes
============================== */
html {
  font-size: 1.25em;
}

aside {
  font-size: 0.8em !important;
}

main {
  max-width: 70rem;
  height: auto;
}

.main-with-sidebar {
  padding-left: 20rem;
}

[id] {
  scroll-margin-top: 10rem; /* adjust to match header height */
}

/* ==============================
   Custom Colors
============================== */
.bg-honolulu-blue { background-color: #007EC3; }
.text-honolulu-blue { color: #007EC3; }

.bg-steel-blue { background-color: #365E8A; }
.bg-steel-blue:hover { background-color: #447BB0; }
.text-steel-blue { color: #447BB0; }

.bg-alice-blue { background-color: #E6F4FA; }
.text-alice-blue { color: #E6F4FA; }

.bg-white-smoke { background-color: #F2F2F2; }
.text-white-smoke { color: #F2F2F2; }

.hover-bg-honolulu-blue:hover { background-color: #007EC3; }
.hover-bg-steel-blue:hover { background-color: #447BB0; }
.hover-bg-honolulu-blue-opacity:hover { background-color: rgba(0,126,195,0.8); }
.hover-bg-steel-blue-opacity:hover { background-color: rgba(68,123,176,0.8); }

/* ==============================
   Fonts
============================== */
.font-montserrat { font-family: 'Montserrat', sans-serif; }
.font-open-sans { font-family: 'Open Sans', sans-serif; }

/* ==============================
   Utility Classes
============================== */
.hidden { display: none !important; }

/* ==============================
   Region Buttons (Sidebar)
============================== */
.region-btn {
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-radius: 0.25rem;
  font-size: 0.9rem;
  transition: background-color 0.2s, color 0.2s;
}

.region-btn:hover {
  background-color: #bfdbfe;
  color: #1e40af;
  cursor: pointer;
}

.region-btn.active {
  background-color: #3b82f6;
  color: #fff;
  font-weight: 600;
}

/* ==============================
   Suburb Contact Boxes
============================== */
.suburb-header {
  background-color: #DBEAFE;
  color: #1E40AF;
  font-weight: 600;
  padding: 0.5rem 1rem;
  font-size: 1.125rem;
  border-radius: 0.25rem;
}

.contact-box {
  width: 20rem;
  height: 18rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.contact-box:hover {
  box-shadow: 0 0.25rem 0.375rem rgba(0,0,0,0.15);
  transform: translateY(-0.125rem);
}

.contact-content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.5rem;
}

.contact-content p.label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  color: #374151;
  margin: 0;
  font-size: 0.875rem;
}

.contact-content p.value {
  margin: 0 0 0.75rem 1.5rem;
  font-size: 0.875rem;
  color: #1F2937;
  word-wrap: break-word;
}

.contact-content p.value:last-child { margin-bottom: 0; }
.contact-content i { font-size: 1rem; }

/* ==============================
   Fixed-size Section
============================== */
.fixed-size-section {
  max-width: 48rem;
  margin: 0 auto;
  padding: 1.5rem;
  overflow-x: hidden;
}

/* ==============================
   Grid Layout
============================== */
.grid {
  display: grid;
  gap: 1.5rem;
  justify-items: center;
  grid-template-columns: 1fr;
}

/* ==============================
   Sidebar (General)
============================== */
.sidebar {
  position: sticky;
  top: 4rem;
  align-self: flex-start;
  width: 16rem;
  background-color: #fff;
  padding: 1rem;
  border-radius: 0.5rem;
  box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,0.1);
  overflow-y: auto;
  max-height: calc(100vh - 5rem);
}

.sidebar h2 {
  font-size: 1.125rem;
  font-weight: 600;
  color: #1E40AF;
  margin-bottom: 0.75rem;
}

.sidebar ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* ==============================
   Fixed Sidebar (Desktop, Stages)
============================== */
.fixed-sidebar {
  position: fixed;
  top: 6rem;
  left: 1.5rem;
  width: 22rem;
  max-height: 80vh;
  overflow-y: auto;
  background: #E0F2FE;
  padding: 1.5rem;
  border-radius: 1rem;
  box-shadow: 0 0.375rem 0.9375rem rgba(0,0,0,0.1);
  font-family: 'Montserrat', sans-serif;
  z-index: 40;
  font-size: 1em;
  line-height: 1.5;
}

.fixed-sidebar h3 {
  font-size: 1.25rem;
  color: #0369A1;
  font-weight: 700;
  margin-bottom: 1rem;
  text-align: center;
}

.fixed-sidebar ul li {
  display: flex;
  align-items: center;
  padding: 0.75rem 0.625rem;
  background: #fff;
  border-radius: 0.5rem;
  box-shadow: 0 0.125rem 0.375rem rgba(0,0,0,0.05);
  transition: transform 0.2s, box-shadow 0.2s;
}

.fixed-sidebar ul li:hover {
  transform: translateY(-0.125rem);
  box-shadow: 0 0.25rem 0.75rem rgba(0,0,0,0.1);
}

/* Stage link */
.fixed-sidebar ul li a.stage-link {
  display: block;
  width: 100%;
  padding: 0.5rem 0.625rem;
  border-radius: 0.5rem;
  text-decoration: none;
  color: #1e40af;
  transition: background-color 0.2s, color 0.2s;
}

.fixed-sidebar ul li a.stage-link:hover {
  background-color: #bfdbfe;
  color: #1e3a8a;
}

.fixed-sidebar ul li a.stage-link .stage-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  margin-right: 0.75rem;
  background: #0369A1;
  color: #fff;
  border-radius: 50%;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1;
  text-align: center;
  flex-shrink: 0;
}

#infoDropdown li a {
  display: block;
  width: 100%;
  padding: 0.4em 1em;
  box-sizing: border-box;
}

#infoDropdown li a:hover {
  background-color: rgba(10, 20, 80, 0.5);
  width: 100%;
  border-radius: 0;
}

/* ==============================
   AI Chatbox Styling (Enhanced)
============================== */

/* Chat button (already good, keeping same) */
#chatToggle {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 50;
}

/* Bigger chatbox for comfortable reading */
#chatbox {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 50;
  width: 30rem;
  max-height: 38rem;
  display: none;
  flex-direction: column;
  border-radius: 1rem;
  overflow: hidden;
}

/* When chatbox is visible */
#chatbox:not(.hidden) {
  display: flex;
}

/* Message area styling */
#chatMessages {
  flex-grow: 1;
  overflow-y: auto;
  padding: 1rem;
  background: #f9fafb;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  white-space: pre-wrap;   /* preserves line breaks from backend */
  line-height: 1.6;        /* more space between lines */
  font-family: Arial, sans-serif;
  font-size: 0.95rem;      /* adjust font to fit small box */
}

/* Chat input area */
.input-area {
  display: flex;
  align-items: center;
  border-top: 1px solid #ddd;
  padding: 0.75rem;
  background: white;
  gap: 0.5rem;
}

/* Make search bar longer */
.input-area input {
  flex: 1;
  padding: 0.75rem 1rem;
  border-radius: 1rem;
  border: 1px solid #ccc;
  font-size: 1rem;
  outline: none;
}

.input-area input:focus {
  border-color: #007EC3;
  box-shadow: 0 0 0 2px rgba(0,126,195,0.2);
}

/* Send button bottom-right */
.input-area button {
  background-color: #007EC3;
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.input-area button:hover {
  background-color: #005f91;
}

/* ==============================
   Chat Message Bubbles
============================== */

.message-row {
  display: flex;
  width: 100%;
  margin-bottom: 0.75rem;
}

/* AI messages aligned to left */
.message-row.ai {
  justify-content: flex-start;
}

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

.message {
  max-width: 75%;
  padding: 0.75rem 1rem;
  border-radius: 1rem;
  line-height: 1.4;
  font-size: 0.95rem;
  word-wrap: break-word;
}

/* AI bubble (left) */
.message.ai {
  background-color: #e6f2fb;
  color: #333;
  border-top-left-radius: 0.25rem;
}

/* User bubble (right) */
.message.user {
  background-color: #007EC3;
  color: #fff;
  border-top-right-radius: 0.25rem;
}

/* ==============================
   Mobile Dropdown
============================== */
.mobile-region-select {
  display: none;
}

.mobile-region-select label {
  color: #007EC3;
  font-weight: 700;
  font-family: 'Montserrat', sans-serif;
}

.mobile-region-select select {
  width: 100%;
  padding: 0.6rem 1rem;
  border: 2px solid #007EC3;
  border-radius: 0.5rem;
  background-color: #E6F2FA;
  color: #003B73;
  font-weight: 600;
  font-family: 'Open Sans', sans-serif;
  transition: all 0.2s ease-in-out;
}

.mobile-region-select select:focus {
  outline: none;
  border-color: #365E8A;
  box-shadow: 0 0 6px rgba(0,126,195,0.4);
  background-color: #fff;
}

.mobile-region-select option {
  background-color: #fff;
  color: #003B73;
}

/* ==============================
   Header & Navbar Fixes
============================== */
header .max-w-6xl {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

header nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

header nav a {
  white-space: nowrap;
}

header > .max-w-6xl > a {
  flex-shrink: 0;
}

/* ==============================
   Age Slider Width Adjustment
============================== */
#ageSlider {
  width: 90%;
  max-width: 25rem;
  display: block;
}


/* ==============================
   Responsive Design
============================== */
@media (max-width: 48rem) {
  /* Hide desktop sidebar, show mobile dropdown */
  .sidebar { display: none !important; }
  .mobile-region-select { display: block !important; margin-bottom: 1.5rem; width: 100%; text-align: left; }

  /* Make fixed-sidebar static on mobile */
  .fixed-sidebar {
    width: 100%;
    position: static;
    max-height: none;
    overflow: visible;
    margin-bottom: 1.5rem;
    border-radius: 0.5rem;
    box-shadow: none;
    background-color: #f8fafc;
  }

  .sidebar h2,
  .fixed-sidebar h3 {
    background-color: #007EC3;
    color: #fff;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem 0.5rem 0 0;
    margin: 0;
    font-size: 1rem;
    text-align: left;
  }

  .main-with-sidebar {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .grid { grid-template-columns: 1fr; }

  /* Header responsive adjustments */
  header .flex.items-center.gap-4 {
    width: 100%;
    justify-content: center;
    order: 1;
    margin-bottom: 0.5rem;
  }

  header nav {
    width: 100%;
    justify-content: center;
    order: 2;
    margin-bottom: 0.5rem;
  }

  header > .max-w-6xl > a {
    order: 3;
    width: 100%;
    justify-content: center;
    margin-top: 0.5rem;
  }
}

@media (min-width: 48rem) {
  .grid { grid-template-columns: repeat(2, 1fr); }
}

/* ==============================
   Responsive Design for AI Chatbox
============================== */
@media (max-width: 48rem) {
  /* Adjust chatbox size and position for tablets and small laptops */
  #chatbox {
    right: 1rem;
    bottom: 1rem;
    width: 85%;
    max-height: 70vh;
  }

  #chatMessages {
    font-size: 0.9rem;
    padding: 0.75rem;
  }

  .input-area {
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
  }

  .input-area input {
    width: 100%;
    font-size: 1rem;
  }

  .input-area button {
    width: 100%;
    font-size: 1rem;
  }

  #infoDropdown {
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: 95% !important;        /* wider than before */
    max-width: 24rem !important;  /* slightly bigger max width */
    box-sizing: border-box;       /* include padding in width */
  }

  #infoDropdown li a {
    white-space: normal;
    word-wrap: break-word;
    padding-left: 1rem;
    padding-right: 1rem;
  }
}

/* ==============================
   Mobile Optimization
============================== */
@media (max-width: 480px) {
  #chatbox {
    right: 0.5rem;
    left: 0.5rem;
    bottom: 0.5rem;
    width: auto;
    height: 80vh;
    max-height: none;
  }

  #chatMessages {
    font-size: 0.9rem;
    line-height: 1.4;
  }

  .input-area {
    padding: 0.5rem;
  }

  .input-area input {
    padding: 0.6rem 0.8rem;
    font-size: 1rem;
  }

  .input-area button {
    padding: 0.6rem;
    font-size: 1rem;
  }

  /* Resize chat toggle button for smaller screens */
  #chatToggle {
    bottom: 1rem;
    right: 1rem;
    width: 3.5rem;
    height: 3.5rem;
    font-size: 1.25rem;
  }

  /* Ensure text bubbles scale gracefully */
  .message {
    max-width: 90%;
    font-size: 0.95rem;
  }

  .message.ai {
    background-color: #f1f5f9;
  }
}
