/* Traffic light: a single round indicator */
.traffic {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  border: 1px solid rgba(255,255,255,.2);
}
.traffic-green { background: #2ecc71; box-shadow: 0 0 6px #2ecc71aa; }
.traffic-red   { background: #e74c3c; box-shadow: 0 0 6px #e74c3caa; }

/* Messages */
.message {
  border: 1px solid var(--bs-border-color);
  border-radius: .75rem;
  padding: .75rem .9rem;
  background: var(--bs-body-bg);
}
.message.user { border-left: .3rem solid #6ea8fe; }
.message.assistant { border-left: .3rem solid #2ecc71; }
.message .meta {
  font-size: .75rem;
  color: var(--bs-secondary-color);
  margin-bottom: .25rem;
}
.message pre, .message code { white-space: pre-wrap; word-break: break-word; }
.message code { background: rgba(255,255,255,.06); padding: .1rem .3rem; border-radius: .25rem; }

/* Event log pills */
#event-log li + li { margin-top: .25rem; }
#event-log .evt { padding: .25rem .5rem; border-radius: .25rem; }
#event-log .evt.ready { background: rgba(108, 117, 125, .15); }
#event-log .evt.embed { background: rgba(111, 66, 193, .15); }
#event-log .evt.retrieve { background: rgba(13, 110, 253, .15); }
#event-log .evt.gen { background: rgba(25, 135, 84, .15); }
#event-log .evt.token { background: rgba(255, 193, 7, .15); }
#event-log .evt.error { background: rgba(220, 53, 69, .15); }

#history { scroll-behavior: smooth; }

/* Ensure full-height layout works consistently */
html, body { height: 100%; }

details > summary {
  cursor: pointer;
  user-select: none;
}
details[open] > summary {
  color: var(--bs-body-color);
}
details > div.small {
  border-left: 3px solid rgba(255,255,255,.12);
  padding-left: .6rem;
}

/* ---- Auth card tweaks ---- */
#auth-status.signed-in { color: #8bd7a7; }
#auth-status.signed-out { color: var(--bs-secondary-color); }

.card .card-header .btn.active {
  border-color: var(--bs-primary);
  color: #fff;
  background: var(--bs-primary);
}

input.is-invalid, textarea.is-invalid {
  border-color: #e55353;
}

/* ---- Auth status color ---- */

#auth-status.signed-in { color: #8bd7a7; }
#auth-status.signed-out { color: var(--bs-secondary-color); }
input.is-invalid { border-color: #e55353; }

/* ===== App layout (main + 50px rail + right drawer) ===== */
.app-layout {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 50px auto; /* main | rail | right drawer */
  grid-template-rows: 100%;
  height: 100%;
  min-height: 100vh;
  overflow: hidden;
}

/* Main pane gets full width when drawer collapsed (right col width becomes 0) */
.app-main {
  min-width: 0; /* allow flexing */
  padding-right: 0.5rem;
}

/* 50px rail */
.app-rail {
  width: 50px;
  border-left: 1px solid var(--bs-border-color, #2a2a2a);
  background: rgba(0,0,0,.15);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: .5rem;
}
.app-rail .rail-btn {
  width: 36px; height: 36px;
  border-radius: 8px;
  border: 1px solid var(--bs-border-color, #2a2a2a);
  background: #1b1b1b;
  color: #ddd;
  cursor: pointer;
}
.app-rail .rail-btn:focus { outline: 2px solid #4c8bf5; }

/* Right drawer */
.app-right {
  width: 380px;            /* open width */
  max-width: 45vw;
  border-left: 1px solid var(--bs-border-color, #2a2a2a);
  background: #101010;
  display: flex;
  flex-direction: column;
  transition: width .18s ease, transform .18s ease, opacity .18s ease;
}

/* Hidden state */
.app-right.collapsed {
  width: 0;
  transform: translateX(8px);
  opacity: 0;
  pointer-events: none;
}

/* Right header */
.app-right .right-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .5rem .75rem;
  border-bottom: 1px solid var(--bs-border-color, #2a2a2a);
}
.app-right .right-header .title {
  font-weight: 600;
  color: var(--bs-secondary-color, #9aa0a6);
}
.app-right .close-btn {
  width: 32px; height: 32px;
  border-radius: 6px;
  border: 1px solid var(--bs-border-color, #2a2a2a);
  background: #1b1b1b;
  color: #ddd;
  cursor: pointer;
}

/* Right body scroll */
.app-right .right-body {
  overflow: auto;
  padding: .75rem;
}

/* Event log spacing (already present but safe to repeat) */
#event-log li + li { margin-top: .25rem; }

/* Optional: when drawer open, subtly highlight the rail button */
.app-right:not(.collapsed) ~ .app-rail .rail-btn,
.app-right:not(.collapsed) + .app-rail .rail-btn {
  /* if DOM order differs, keep the style rule anyway */
  border-color: var(--bs-primary, #0d6efd);
  color: #fff;
  background: var(--bs-primary, #0d6efd);
}



@media (max-width: 992px) {
  .app-layout {
    grid-template-columns: 1fr 50px 0; /* reserve 0 for right when collapsed; overlay when open */
  }
  .app-right {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: min(90vw, 420px);
    max-width: 100vw;
    z-index: 1040; /* above content */
    box-shadow: -16px 0 32px rgba(0,0,0,.5);
  }
}

/* Make the main (left) pane a column flex container that fills the viewport */
#main-pane {
  display: flex;
  flex-direction: column;
  min-height: 100vh;        /* ensure full-height column */
}

/* History: take all available vertical space and scroll */
#history {
  flex: 1 1 auto;           /* grow to fill the space above the ask form */
  overflow: auto;           /* scroll the messages */
  min-height: 0;            /* allow the flex child to shrink properly */
}

/* Ask form: sticky to the bottom of the main pane */
#ask-form {
  position: sticky;
  bottom: 0;
  z-index: 5;               /* keep above content shadows */
  background: var(--bs-body-bg, #0b0b0b);
  border-top: 1px solid var(--bs-border-color, #2a2a2a);
  padding-top: .75rem;
  padding-bottom: .75rem;
  margin-bottom: 0;         /* avoid extra gap at the very bottom */
}

/* Optional: nicer look on small screens */
@media (max-width: 576px) {
  #ask-form .form-label { display: none; }
  #question { min-height: 72px; }
}

.bg-custom {
  background-color: rgb(8 16 20) !important;
}

#drop-zone.dragover {
  border-color: var(--bs-primary);
  background: rgba(13,110,253,.08);
}
#attach-list li + li { margin-top: .25rem; }
#attach-list .badge { font-weight: 500; }

/* Attachments strip under a message */
.attachments { border-left: 3px solid rgba(255,255,255,.08); padding-left: .5rem; }
.attachments-title { font-size: .8rem; margin-bottom: .25rem; }
.attachments-list { gap: .4rem; }
.chip {
  display: inline-block;
  font-size: .8rem;
  padding: .15rem .5rem;
  border: 1px solid var(--bs-border-color, #2a2a2a);
  border-radius: .5rem;
  background: #1b1b1b;
  color: #cbd5e1;
}
.chip-pending {
  border-style: dashed;
  color: #a8b3cf;
  background: #151515;
}