* {
  border-radius: 2px !important;
  font-family: 'Noto Sans', sans-serif;
}

/* Prevent body scroll on chat page */
body:has(#chat-container) {
  overflow: hidden;
  height: 100vh;
  max-height: 100vh;
}

/* Chat input container adjustments for left nav */
#chat-input-container {
  margin-left: 300px;
  transition: margin-right 0.3s ease;
}

body:has(.right-nav.active) #chat-input-container {
  margin-right: 300px;
}

/* Footer always visible, adjust for chat input */
footer {
  z-index: 50;
  font-size: 0.65rem;
  line-height: 1;
}

body:has(#chat-container) footer {
  bottom: 0;
  margin-left: 300px;
  transition: margin-right 0.3s ease;
}

body:has(#chat-container):has(.right-nav.active) footer {
  margin-right: 300px;
}

@media (max-width: 768px) {
  body:has(#chat-container) footer {
    margin-left: 0;
  }
}

@media (max-width: 768px) {
  #chat-input-container {
    margin-left: 0;
  }

  #top-messages-container {
    margin-left: 0 !important;
  }
}

.dropdown-content {
  z-index: 1000 !important;
}

/* Navbar must be above left-nav so tooltip pseudoelements escape its stacking context */
nav.navbar {
  z-index: 70;
}

/* Left nav styles */
.left-nav {
  position: fixed;
  left: 0;
  top: 4rem;
  width: 300px;
  height: calc(100vh - 4rem);
  background: var(--fallback-b1, oklch(var(--b1)));
  z-index: 60;
  transition: transform 0.3s ease;
  transform: translateX(0);
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}
.left-nav-content {
  flex-grow: 1; /* This pushes the footer to the bottom */
  overflow-y: auto;
  overflow-x: hidden;
}

.left-nav-footer {
  flex-shrink: 0; /* Ensures the footer doesn't compress */
}
.left-nav-header,
.left-nav-content {
  overflow-x: hidden;
}

.content-container {
  margin-left: 300px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-right 0.3s ease;
}

.content-container.right-nav-active {
  margin-right: 300px;
}

/* For pages with forms that need scrolling */
.content-container:not(:has(#chat-container)) {
  overflow-y: auto;
}

/* For chat page that needs fixed height */
.content-container:has(#chat-container) {
  height: calc(100vh - 4rem);
  max-height: calc(100vh - 4rem);
  overflow: hidden;
  padding-top: 0;
}

.content-container:has(#chat-container) > div {
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}

/* Constrain chat container to leave space for input */
#chat-container {
  margin-bottom: 100px;
}

@media (max-width: 768px) {
  #chat-container {
    margin-bottom: 170px;
  }
}

/* Right nav styles */
.right-nav {
  position: fixed;
  right: 0;
  top: 4rem;
  width: 300px;
  height: calc(100vh - 4rem);
  background: var(--fallback-b1, oklch(var(--b1)));
  z-index: 65;
  transition: transform 0.3s ease;
  transform: translateX(100%);
  display: flex;
  flex-direction: column;
  overflow-x: visible;
}

.right-nav.active {
  transform: translateX(0);
}

.right-nav-content {
  flex-grow: 1;
  overflow-y: auto;
  overflow-x: clip;
}

/* Allow tooltips in user list to escape right-nav boundaries */
#user-list {
  overflow: visible;
}

#user-list li {
  overflow: visible;
}

/* Position user list tooltips outside the overflow container */
#user-list .tooltip.tooltip-left::before,
#user-list .tooltip.tooltip-left::after {
  position: fixed !important;
  right: 300px !important;
  left: auto !important;
}

#user-list .tooltip.tooltip-left::before {
  transform: translateX(0) translateY(-50%) !important;
}

#user-list .tooltip.tooltip-left::after {
  transform: translateX(4px) translateY(-50%) rotate(45deg) !important;
}

.right-nav-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 55;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.right-nav-overlay.active {
  display: block;
  opacity: 1;
}

/* Dialog container positioning */
.chaos-dialog-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chaos-dialog-container .modal .modal-box {
  border: 1px solid oklch(var(--p) / 0.5);
}

/* Overlay for mobile */
.left-nav-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 55;
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* Desktop styles */
@media (min-width: 769px) {
  .left-nav {
    transform: translateX(0) !important;
    /*display: block !important;*/
  }

  .left-nav-overlay {
    display: none !important;
  }

  .content-container {
    margin-left: 300px !important;
  }
}

/* Mobile styles */
@media (max-width: 768px) {
  .left-nav {
    transform: translateX(-100%);
  }

  .left-nav.active {
    transform: translateX(0);
  }

  .left-nav-overlay.active {
    display: block;
    opacity: 1;
  }

  .content-container {
    margin-left: 0 !important;
  }

  .content-container.right-nav-active {
    margin-right: 0 !important;
  }

  body:has(.right-nav.active) #chat-input-container {
    margin-right: 0 !important;
  }

  body:has(#chat-container):has(.right-nav.active) footer {
    margin-right: 0 !important;
  }
}

/* Subdued body backgrounds for light themes that default to pure white.
   --b1 (cards) stays near-white; body uses --b2 (slightly darker) for contrast. */
[data-theme='light']     { --b1: 99% 0.002 256; --b2: 95% 0.003 256; }  /* cool gray */
[data-theme='bumblebee'] { --b1: 99% 0.006 95;  --b2: 95% 0.012 95;  }  /* warm yellow */
[data-theme='emerald']   { --b1: 99% 0.004 160; --b2: 95% 0.008 160; }  /* soft green */
[data-theme='corporate'] { --b1: 99% 0.001 210; --b2: 96% 0.002 210; }  /* cool neutral */
[data-theme='lofi']      { --b1: 98% 0 0;       --b2: 93% 0 0;       }  /* medium gray */
[data-theme='pastel']    { --b1: 99% 0.003 340; --b2: 96% 0.006 340; }  /* blush */
[data-theme='fantasy']   { --b1: 99% 0.003 290; --b2: 95% 0.005 290; }  /* soft lavender */
[data-theme='wireframe'] { --b1: 98% 0 0;       --b2: 93% 0 0;       }  /* gray */
[data-theme='cmyk']      { --b1: 99% 0.002 200; --b2: 95% 0.004 200; }  /* soft cyan */
[data-theme='winter']    { --b1: 99% 0.006 230; --b2: 94% 0.012 230; }  /* icy blue */

/* Use b2 as the page body background so cards (b1) stand out slightly lighter.
   Scoped to only the light themes overridden above. */
[data-theme='light'] body,
[data-theme='bumblebee'] body,
[data-theme='emerald'] body,
[data-theme='corporate'] body,
[data-theme='lofi'] body,
[data-theme='pastel'] body,
[data-theme='fantasy'] body,
[data-theme='wireframe'] body,
[data-theme='cmyk'] body,
[data-theme='winter'] body {
  background-color: var(--fallback-b2, oklch(var(--b2)));
}

.tooltip::before,
.tooltip::after {
  z-index: 99999;
}