:root {
  --sidebar-w: 280px;
  --sidebar-w-compact: 96px;
  --nav-item-h: 56px;
  --icon-size: 1.6rem;
}

/* prevent page-wide horizontal scroll */
html, body { overflow-x: hidden; }

/* app shell layout */
.app-shell {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* sidebar column, no overlay, no fixed positioning */
.app-sidebar {
  -webkit-box-flex: 0;
      -ms-flex: 0 0 var(--sidebar-w);
          flex: 0 0 var(--sidebar-w);
  width: var(--sidebar-w);
  overflow-y: auto;
  overflow-x: hidden;
  background-color: var(--bs-danger);
  color: #fff;
  z-index: 1;
  -webkit-transition: width 200ms ease, -webkit-flex-basis 200ms ease;
  transition: width 200ms ease, -webkit-flex-basis 200ms ease;
  transition: width 200ms ease, flex-basis 200ms ease;
  transition: width 200ms ease, flex-basis 200ms ease, -webkit-flex-basis 200ms ease, -ms-flex-preferred-size 200ms ease;
  transition: width 200ms ease, flex-basis 200ms ease, -ms-flex-preferred-size 200ms ease;
}

/* compact width */
.sidebar-compact .app-sidebar {
  -ms-flex-preferred-size: var(--sidebar-w-compact);
      flex-basis: var(--sidebar-w-compact);
  width: var(--sidebar-w-compact);
}

/* main column */
.app-main {
  -webkit-box-flex: 1;
      -ms-flex: 1 1 auto;
          flex: 1 1 auto;
  min-width: 0;               /* prevents horizontal overflow with wide content */
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
      -ms-flex-direction: column;
          flex-direction: column;
}

/* header and footer stay natural height */
#appHeader,
#appFooter {
  -webkit-box-flex: 0;
      -ms-flex: 0 0 auto;
          flex: 0 0 auto;
}

/* page area grows */
#appPage {
  -webkit-box-flex: 1;
      -ms-flex: 1 1 auto;
          flex: 1 1 auto;
  min-height: 0;
}

/* Top brand + toggle row */
.sidebar-top {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
  -webkit-box-pack: justify;
      -ms-flex-pack: justify;
          justify-content: space-between;
}

.brand-full { display: inline; color: #fff; }
.brand-abbrev { display: none; font-weight: 700; letter-spacing: .5px; color: #fff; }

/* switch brand text in compact */
.sidebar-compact .brand-full { display: none; }
.sidebar-compact .brand-abbrev { display: inline; }

/* in compact, stack the toggle under AB */
.sidebar-compact .sidebar-top {
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
      -ms-flex-direction: column;
          flex-direction: column;
  -webkit-box-align: start;
      -ms-flex-align: start;
          align-items: flex-start;
  gap: .5rem;
  padding-top: .6rem;
  padding-bottom: .6rem;
}

/* hamburger button */
.btn-toggle {
  padding: .6rem .8rem;
  margin-left: .6rem;
  margin-right: .3rem;
  border-radius: .9rem;
  background-color: transparent;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.4);
}

/* when compact and stacked, pull the toggle under AB, left aligned */
.sidebar-compact .btn-toggle {
  margin-left: 0;
  margin-right: 0;
}

/* keep the icon white always */
.btn-toggle i { font-size: 1.25rem; color: #fff !important; }
.btn-toggle:hover,
.btn-toggle:focus,
.btn-toggle:active {
  color: #fff !important;
  background-color: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.55);
}
.btn-toggle:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* nav items */
.nav-item-lg {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
  -webkit-box-pack: start;
      -ms-flex-pack: start;
          justify-content: flex-start;
  gap: .6rem;
  height: var(--nav-item-h);
  border-radius: .75rem;
}
.nav-item-lg i {
  font-size: var(--icon-size);
  line-height: 1;
}
.sidebar-compact .nav-item-lg {
  -webkit-box-pack: center;
      -ms-flex-pack: center;
          justify-content: center;
  gap: 0;
}
.sidebar-compact .nav-item-lg i { margin: 0; }
.nav-label { display: inline; }
.sidebar-compact .nav-label { display: none; }

/* sidebar links/icons: white; active uses lighter overlay */
.app-sidebar .nav-link,
.app-sidebar .nav-link i { color: #fff; }
.app-sidebar .nav-link:hover,
.app-sidebar .nav-link:focus {
  color: #fff;
  background-color: rgba(255,255,255,0.15);
}
.app-sidebar .nav-link.active {
  background-color: rgba(255,255,255,0.30);
  color: #fff;
}
.app-sidebar .nav-link.active i { color: #fff; }

/* bottom placeholder block */
.sidebar-bottom {
  background: var(--bs-danger);
  position: relative;
  z-index: 2;
  color: #fff;
}
.sidebar-bottom a { color: #fff; }
.sidebar-bottom .text-muted { color: rgba(255,255,255,0.8) !important; }

.account-inline img { -webkit-box-flex: 0; -ms-flex: 0 0 auto; flex: 0 0 auto; border: 2px solid rgba(255,255,255,0.5); }
.account-icon {
  width: 32px;
  height: 32px;
  border-radius: .5rem;
  padding: 0;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.4);
  background-color: transparent;
}
.account-icon i { font-size: 1.1rem; color: #fff; }
.account-icon:hover,
.account-icon:focus { background-color: rgba(255,255,255,0.15); }

/* focus visibility */
.app-sidebar .nav-link:focus-visible,
.btn-toggle:focus-visible,
.account-icon:focus-visible,
.sidebar-bottom a:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* Reduce motion preference */
@media (prefers-reduced-motion: reduce) {
  .app-sidebar { -webkit-transition: none; transition: none; }
}

/* Optional, small screens: switch to overlay pattern if needed later
   We keep non-overlay by default to avoid content being covered. */




/* Chat left column stays fixed, internal messages scroll */
#chatColumn .chat-pane {
  position: sticky;
  top: 0;
  height: 100vh;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
      -ms-flex-direction: column;
          flex-direction: column;
}

#chatColumn .chat-header {
  -webkit-box-flex: 0;
      -ms-flex: 0 0 auto;
          flex: 0 0 auto;
}

#chatColumn .chat-messages {
  -webkit-box-flex: 1;
      -ms-flex: 1 1 auto;
          flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

#chatColumn .chat-composer {
  -webkit-box-flex: 0;
      -ms-flex: 0 0 auto;
          flex: 0 0 auto;
}
/* chat composer */
.composer-wrap {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
  gap: .75rem;
  background: #fff;
  border: 1px solid var(--bs-border-color);
  border-radius: 1rem;
  padding: .5rem .75rem;
  -webkit-box-shadow: 0 2px 8px rgba(0,0,0,.06);
          box-shadow: 0 2px 8px rgba(0,0,0,.06);
}

/* left utility group */
.composer-aux {
  display: -webkit-inline-box;
  display: -ms-inline-flexbox;
  display: inline-flex;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
  gap: .25rem;
  background: var(--bs-light);
  border-radius: .75rem;
  padding: .25rem;
}
.composer-aux .divider {
  width: 1px;
  height: 1.5rem;
  background: var(--bs-border-color);
  margin: 0 .25rem;
}

/* icon buttons */
.btn-icon {
  display: -webkit-inline-box;
  display: -ms-inline-flexbox;
  display: inline-flex;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
  -webkit-box-pack: center;
      -ms-flex-pack: center;
          justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid transparent;
  border-radius: .75rem;
  background: transparent;
  color: var(--bs-body-color);
}
.btn-icon:hover { background: rgba(0,0,0,.04); }
.btn-icon:focus-visible {
  outline: 2px solid var(--bs-primary);
  outline-offset: 2px;
}

/* main text area */
.composer-input {
  -webkit-box-flex: 1;
      -ms-flex: 1 1 auto;
          flex: 1 1 auto;
  min-height: 2.25rem;
  max-height: 30vh;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  padding: .25rem .25rem;
}
.composer-input::-webkit-input-placeholder { color: var(--bs-secondary-color); }
.composer-input::-moz-placeholder { color: var(--bs-secondary-color); }
.composer-input:-ms-input-placeholder { color: var(--bs-secondary-color); }
.composer-input::-ms-input-placeholder { color: var(--bs-secondary-color); }
.composer-input::placeholder { color: var(--bs-secondary-color); }

/* right action group */
.composer-actions {
  display: -webkit-inline-box;
  display: -ms-inline-flexbox;
  display: inline-flex;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
  gap: .25rem;
}

/* send button style */
.btn-send {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: .75rem;
  border: 1px solid var(--bs-border-color);
  background: var(--bs-light);
}
.btn-send:hover { background: rgba(0,0,0,.06); }
.btn-send:focus-visible {
  outline: 2px solid var(--bs-primary);
  outline-offset: 2px;
}
/* auto-grow textarea with max height */
.composer-input {
  overflow-y: auto;
  max-height: calc(1.5em * 7); /* about 7 lines */
}
/* Align the right actions to the bottom of the input area */
.composer-actions {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: end;
      -ms-flex-align: end;
          align-items: flex-end; /* previously center */
  gap: .25rem;
}

/* Make sure the textarea grows naturally and pushes icons upward */
.composer-wrap {
  -webkit-box-align: end;
      -ms-flex-align: end;
          align-items: flex-end;
}


/* chat thread */
.chat-thread {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
      -ms-flex-direction: column;
          flex-direction: column;
  gap: .75rem;
}

/* one message row */
.msg {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: start;
      -ms-flex-align: start;
          align-items: flex-start;
  gap: .75rem;
}

/* circular initial avatar */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: -webkit-inline-box;
  display: -ms-inline-flexbox;
  display: inline-flex;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
  -webkit-box-pack: center;
      -ms-flex-pack: center;
          justify-content: center;
  font-weight: 600;
  background: #e8eef6;
  color: #122a45;
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none;
}

/* content bubble */
.msg-bubble {
  max-width: 100%;
  background: #f6f7f9;
  border: 1px solid var(--bs-border-color);
  border-radius: .75rem;
  padding: .5rem .75rem;
  line-height: 1.5;
  -webkit-box-shadow: 0 1px 3px rgba(0,0,0,.04);
          box-shadow: 0 1px 3px rgba(0,0,0,.04);
}

/* small meta row */
.msg-meta {
  margin-top: .25rem;
  font-size: .875rem;
  color: var(--bs-secondary-color);
}
/* Different background for AI messages */
.msg.ai .msg-bubble {
  background: #e8f2ff; /* light blue tone */
  border-color: #c6ddff;
}
