/*******************************
 * Global UI Element Overrides
 *******************************/

/* Hide default Chainlit elements */
.watermark,
#new-chat-button,
#readme-button,
div[data-variant="sidebar"] {
  display: none !important;
}

/*******************************
 * Chat Messages
 *******************************/

/* Message spacing */
.ai-message .message-content {
  margin-bottom: 0.5rem !important;
}

/* Message links styling */
.message-link {
  border-radius: 10px;
  color: #bf202c !important;
  text-decoration: none !important;
  line-height: 1.3 !important;
  padding: 0.1rem 0.4rem !important;
  background-color: rgba(255, 242, 0, 0.3) !important;
  border: 2px solid #bf202c !important;
  font-family: "Montserrat Alternates", sans-serif !important;
  font-weight: normal !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/*******************************
 * Action Buttons
 *******************************/

/* Hide default buttons */
button:has(svg.lucide-copy),
button:has(svg.lucide-thumbs-down),
button:has(svg.lucide-thumbs-up) {
  display: none !important;
}

/* Common button styles */
.ai-message button,
aside button {
  font-family: "Montserrat Alternates", sans-serif !important;
  font-weight: 600;
  border: 2px solid #bf202c !important;
  margin-left: 0.5rem;
  margin-right: 0.5rem;
  background-color: rgba(255, 242, 0, 0.3) !important;
  color: #222 !important;
  transition: all 0.3s ease !important;

  /* Dark mode */
  .dark & {
    color: #fff !important;
  }
}

/* Button hover effects */
.ai-message button:hover,
aside button:hover {
  background-color: rgba(255, 242, 0, 0.6) !important;
}

/*******************************
 * Language Switcher - Header Integration
 *******************************/

/* Ensure header right section uses proper flex spacing */
#header div:last-child {
  gap: 6px !important;
}

/* Hide README button */
#readme-button {
  display: none !important;
}

/* Universal header button styling */
#header button:not(#readme-button),
#language-switcher button {
  align-items: center !important;
  background: rgba(128, 128, 128, 0.15) !important;
  border: none !important;
  border-radius: 12px !important;
  color: rgba(0, 0, 0, 0.75) !important;
  cursor: pointer !important;
  display: inline-flex !important;
  font-family: inherit !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  height: 40px !important;
  justify-content: center !important;
  min-width: 40px !important;
  padding: 0 12px !important;
  transition: all 0.2s ease !important;
  white-space: nowrap !important;
}

/* Dark theme - better contrast */
.dark #header button:not(#readme-button),
.dark #language-switcher button {
  background: rgba(128, 128, 128, 0.15) !important;
  color: rgba(255, 255, 255, 0.85) !important;
}

/* Hover state for all header buttons (except active language button) */
#header button:hover,
#language-switcher button:hover:not([data-active="true"]) {
  background: rgba(128, 128, 128, 0.25) !important;
  transform: scale(1.05) !important;
}

/* Language switcher active button hover */
#language-switcher button[data-active="true"]:hover {
  color: #bf202c !important;
  transform: scale(1.05) !important;
}

/* Active/selected state */
#language-switcher button[data-active="true"],
#language-switcher button:disabled {
  background: rgba(128, 128, 128, 0.15) !important;
  color: #bf202c !important;
  font-weight: 700 !important;
  cursor: default !important;
  border: none !important;
}

/* Hide all language switchers by default to prevent flashing */
#language-switcher {
  display: none !important;
}

/* Only show the language switcher when it's in the header */
#header #language-switcher {
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
}

/*******************************
 * Sidebar Styling
 *******************************/

/* Sidebar container */
aside>div {
  background: linear-gradient(to right, rgba(255, 255, 255, 0.1), rgba(255, 242, 0, 0.2)) !important;
  border: 0 !important;
  position: relative !important;
}

/* Sidebar background image */
aside>div::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background-image: url("sidebar_bg.png") !important;
  background-position: bottom right !important;
  background-repeat: no-repeat !important;
  background-size: 70% !important;
  opacity: 0.2;
  z-index: 0;
}

/* Ensure sidebar content appears above background */
aside>div>* {
  position: relative;
  z-index: 1;
}

/* Sidebar icon color */
aside .icon {
  color: #bf202c;
}

/* Sidebar title styling */
#side-view-title {
  background-image: url("sidebar_title_bg.png") !important;
  background-repeat: no-repeat !important;
  background-size: 35px !important;
  background-position: 1rem center !important;
  color: #333 !important;
  font-family: "Montserrat Alternates", sans-serif !important;
  font-size: 1.1rem !important;
  font-weight: bold !important;
  line-height: 1rem !important;
  margin-bottom: 1rem !important;
  padding-left: 3.5rem !important;
}

/* Hide sidebar close button */
#side-view-title>button {
  display: none !important;
}

/* Sidebar content area */
#side-view-content {
  padding-bottom: 2.3rem 0 !important;
}

/* Debrief section styling */
aside .debrief {
  background-color: #fff !important;
  position: relative;

  .dark & {
    background-color: #000 !important;
    color: #fff !important;
  }
}

aside .debrief button {
  background-color: #fff !important;
  border: 0 !important;
  position: absolute;
  top: 10px;
  right: 0;
  z-index: 1;
}

/*******************************
 * Sidebar Action Buttons
 *******************************/

/* Common positioning for bottom buttons */
aside #reset-button,
aside #print-facts-button,
aside #exit-button,
aside #ai-respond-button {
  zoom: 0.75 !important;
  position: absolute;
  bottom: 1rem;
}

/* Individual button positioning */
aside #reset-button {
  background-color: rgba(191, 32, 44, 0.2) !important;
  right: 5.5rem;
}

aside #exit-button {
  background-color: rgba(191, 32, 44, 0.2) !important;
  right: 1.4rem;
}

aside #print-facts-button {
  background-color: #f0f0f0 !important;
  right: 12.4rem;
}

aside #ai-respond-button {
  background-color: #f0f0f0 !important;
  right: 21.5rem;
}

/*******************************
 * Switch/Toggle Button Styling
 *******************************/

/* Switch button base styling */
input[type="checkbox"],
.switch,
.toggle,
[role="switch"] {
  background-color: #cccccc !important;
  /* Grey background (unchecked) */
}

/* Switch button checked state */
input[type="checkbox"]:checked,
.switch:checked,
.toggle:checked,
[role="switch"][aria-checked="true"] {
  background-color: #28a745 !important;
  /* Green background when checked */
}

/* Switch handles - always white */
input[type="checkbox"]::before,
.switch::before,
.toggle::before,
[role="switch"]::before {
  background-color: #ffffff !important;
}

/* Switch containers */
.switch-container:has(input:checked),
.toggle-container:has(input:checked) {
  background-color: #28a745 !important;
}

.switch-container:has(input:not(:checked)),
.toggle-container:has(input:not(:checked)) {
  background-color: #cccccc !important;
}

/*******************************
 * Tablet & Small Desktop Responsiveness
 *******************************/
@media (min-width: 769px) and (max-width: 1200px) {

  /* Adjust sidebar width for smaller desktop screens */
  aside {
    /* width: 340px !important; */
  }

  /* Adjust title styling */
  #side-view-title {
    font-size: 1rem !important;
    padding-left: 4.5rem !important;
    margin-left: 1rem !important;
    background-size: 2.5rem !important;
  }

  /* Adjust button sizes and positions to prevent overlap */
  aside #reset-button,
  aside #print-facts-button,
  aside #exit-button,
  aside #ai-respond-button {
    zoom: 0.7 !important;
  }

  aside #ai-respond-button {
    right: 14.5rem;
  }

  aside #print-facts-button {
    right: 10rem;
  }

  aside #reset-button {
    right: 5.5rem;
  }

  aside #exit-button {
    right: 1rem;
  }
}

/*******************************
 * Action Cards
 *******************************/

.card-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin: 30px 0;
}

.action-card {
  background: white;
  border-radius: 12px;
  padding: 25px;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  border: 1px solid #e2e8f0;
  transition: transform 0.3s ease;
  margin: 20px auto;
  max-width: 300px;
}

.action-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.card-icon {
  font-size: 32px;
  margin-bottom: 15px;
}

.card-title {
  font-size: 18px;
  font-weight: 600;
  color: #2d3748;
  margin-bottom: 10px;
  font-family: "Montserrat Alternates", sans-serif !important;
}

.card-description {
  font-size: 14px;
  color: #718096;
  margin-bottom: 20px;
}

.card-btn {
  padding: 12px 24px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
  background-color: rgba(255, 242, 0, 0.3) !important;
  color: #222 !important;
  border: 2px solid #bf202c !important;
  min-width: 160px;
  font-family: "Montserrat Alternates", sans-serif !important;
}

.card-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
  background-color: rgba(255, 242, 0, 0.6) !important;
  color: #222 !important;
}

/*******************************
 * Mobile Responsiveness
 *******************************/
@media (max-width: 768px) {

  /* Mobile header button adjustments */
  #header button,
  #language-switcher button {
    height: 36px !important;
    min-width: 36px !important;
    padding: 0 8px !important;
    font-size: 13px !important;
  }

  /* Adjust header spacing for mobile */
  #header div:last-child {
    gap: 4px !important;
  }

  #header div:last-child>button:last-child {
    margin-right: 8px !important;
  }

  /* Make sidebar full screen */
  div[role="dialog"][data-state="open"] {
    width: auto !important;
    height: 100% !important;
    left: auto !important;
    right: 0 !important;
    padding: 1rem !important;
    border-radius: 0 !important;
    border: none !important;
  }

  #side-view-content {
    gap: 0 !important;
  }

  /* Align title to the left and add space below */
  div[role="dialog"][data-state="open"] #side-view-title {
    padding-left: 5rem !important;
    margin-left: 0 !important;
    text-align: left !important;
    margin-bottom: 1rem !important;
  }

  /* Remove backgrounds and borders from all content blocks */
  div[role="dialog"][data-state="open"] .bg-card {
    padding: 0.5rem !important;
  }

  div[role="dialog"][data-state="open"] .debrief {
    background-color: #FFF !important;
    box-shadow: none !important;
    padding: 0.4rem !important;
  }

  /* Clean up inner padding and margins for a seamless look */
  div[role="dialog"][data-state="open"] .bg-card>div[class*="p-"] {
    padding: 0 !important;
  }

  div[role="dialog"][data-state="open"] .space-y-4 {
    margin-top: 0 !important;
  }

  div[role="dialog"][data-state="open"] .mt-8 {
    margin-top: 1.5rem !important;
  }

  /* Hide unnecessary elements on mobile */
  button[data-state="closed"] svg[width="24"][height="24"],
  #new-progress-check-button,
  div[role="dialog"][data-state="open"] #ai-respond-button,
  div[role="dialog"][data-state="open"] #print-facts-button,
  div[role="dialog"][data-state="open"] #send-test-email-button {
    display: none !important;
  }

  /* Position remaining buttons at the bottom of the screen */
  div[role="dialog"][data-state="open"] #exit-button,
  div[role="dialog"][data-state="open"] #reset-button {
    position: fixed;
    bottom: 1.5rem;
    zoom: 0.9;
  }

  div[role="dialog"][data-state="open"] #exit-button {
    right: 1.5rem;
  }

  div[role="dialog"][data-state="open"] #reset-button {
    right: 6rem;
  }
}
