/* Base styles + small Bootstrap-like utilities used by templates (minimal subset) */
:root {
  --fg: #24292f;
  --bg: #ffffff;
  --gray-100: #f6f8fa;
  --gray-300: #d0d7de;
  --navbar-height: 56px;
  /* JLCA-912 Chat Role Color Tokens (helles Standard-Theme) */
  --chat-user-bg: #e3f2fd;
  --chat-user-fg: #0d47a1;
  --chat-assistant-bg: #fff9c4;
  --chat-assistant-fg: #4e4e00;
}
html,
body {
  margin: 0;
  padding: 0;
  color: var(--fg);
  background: var(--bg);
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    Helvetica,
    Arial,
    Noto Sans,
    "Apple Color Emoji",
    "Segoe UI Emoji";
}
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Local Bootstrap-compatible layout/utility subset.
   The UI intentionally uses no external CDN; these classes cover the grid and
   spacing utilities used by the shell templates. */
.container-fluid {
  width: 100%;
  box-sizing: border-box;
  padding-right: 16px;
  padding-left: 16px;
  margin-right: auto;
  margin-left: auto;
}
.row {
  --bs-gutter-x: 0;
  --bs-gutter-y: 0;
  display: flex;
  flex-wrap: wrap;
  margin-top: calc(-1 * var(--bs-gutter-y));
  margin-right: calc(-0.5 * var(--bs-gutter-x));
  margin-left: calc(-0.5 * var(--bs-gutter-x));
}
.row > * {
  box-sizing: border-box;
  flex-shrink: 0;
  width: 100%;
  max-width: 100%;
  padding-right: calc(var(--bs-gutter-x) * 0.5);
  padding-left: calc(var(--bs-gutter-x) * 0.5);
  margin-top: var(--bs-gutter-y);
}
.g-3 {
  --bs-gutter-x: 1rem;
  --bs-gutter-y: 1rem;
}
.col-12 {
  flex: 0 0 auto;
  width: 100%;
}
.py-3 {
  padding-top: 1rem;
  padding-bottom: 1rem;
}
.d-flex {
  display: flex;
}
.align-items-center {
  align-items: center;
}
.align-items-stretch {
  align-items: stretch;
}
.justify-content-between {
  justify-content: space-between;
}
.gap-2 {
  gap: 0.5rem;
}
.me-auto {
  margin-right: auto;
}
.mb-2 {
  margin-bottom: 0.5rem;
}

@media (min-width: 768px) {
  .col-md-3 {
    flex: 0 0 auto;
    width: 25%;
  }
  .col-md-6 {
    flex: 0 0 auto;
    width: 50%;
  }
  .col-md-9 {
    flex: 0 0 auto;
    width: 75%;
  }
  .mb-md-0 {
    margin-bottom: 0;
  }
}

@media (min-width: 992px) {
  .col-lg-2 {
    flex: 0 0 auto;
    width: 16.66666667%;
  }
  .col-lg-3 {
    flex: 0 0 auto;
    width: 25%;
  }
  .col-lg-7 {
    flex: 0 0 auto;
    width: 58.33333333%;
  }
  .col-lg-8 {
    flex: 0 0 auto;
    width: 66.66666667%;
  }
}

/* Sticky-Footer Layout via Flexbox (wrapper uses min-vh-100 equivalent) */
.layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.app-main {
  flex: 1 0 auto;
}

/* Navbar/Offcanvas minimal Bootstrap-like styles */
.navbar {
  border-bottom: 1px solid var(--gray-300);
  background: #fff;
  min-height: var(--navbar-height);
}
.navbar .navbar-brand {
  text-decoration: none;
  color: inherit;
  font-weight: 600;
}
.navbar .navbar-toggler {
  border: 1px solid var(--gray-300);
  padding: 6px 10px;
  background: #fff;
  border-radius: 6px;
}
.navbar .navbar-toggler:focus {
  outline: 2px solid #1f6feb;
  outline-offset: 2px;
}
.navbar .navbar-toggler-icon {
  display: inline-block;
  width: 24px;
  height: 2px;
  background: currentColor;
  position: relative;
}
.navbar .navbar-toggler-icon::before,
.navbar .navbar-toggler-icon::after {
  content: "";
  position: absolute;
  left: 0;
  width: 24px;
  height: 2px;
  background: currentColor;
}
.navbar .navbar-toggler-icon::before {
  top: -6px;
}
.navbar .navbar-toggler-icon::after {
  top: 6px;
}
.navbar-nav {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  gap: 12px;
}
.navbar-nav .nav-link {
  display: block;
  padding: 8px 10px;
  text-decoration: none;
  color: inherit;
  border-radius: 6px;
}
.navbar-nav .nav-link:hover,
.navbar-nav .nav-link:focus {
  background: var(--gray-100);
  outline: none;
}
.navbar-nav .nav-link.active,
.navbar-nav .nav-link[aria-current="page"] {
  font-weight: 600;
  border-bottom: 2px solid #1f6feb;
}

/* Offcanvas (left) */
.offcanvas {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: 280px;
  background: #fff;
  border-right: 1px solid var(--gray-300);
  transform: translateX(-100%);
  transition: transform 0.2s ease;
  z-index: 1045;
}
.offcanvas.show {
  transform: none;
}
.offcanvas-header,
.offcanvas-body {
  padding: 16px;
}
.btn-close {
  border: none;
  width: 32px;
  height: 32px;
  background: transparent;
  cursor: pointer;
}
.btn-close:focus {
  outline: 2px solid #1f6feb;
  outline-offset: 2px;
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  gap: 8px;
  list-style: none;
  padding: 8px 0;
  margin: 0;
  font-size: 14px;
  color: #64748b;
}
.breadcrumb-item,
.breadcrumb-item.active {
  color: #64748b;
}
.breadcrumb-item a {
  text-decoration: none;
  color: #0969da;
}
.breadcrumb-item.active {
  color: #64748b;
}

/* Footer */
.app-footer {
  background: #fff;
  border-top: 1px solid var(--gray-300);
  height: var(--navbar-height);
  display: flex;
  align-items: center;
}

/* Simple responsive helpers */
@media (min-width: 768px) {
  .navbar-expand-md .navbar-toggler {
    display: none;
  }
  .navbar-expand-md .offcanvas {
    position: static;
    transform: none;
    width: auto;
    border-right: 0;
  }
  .navbar-expand-md .offcanvas-header {
    display: none;
  }
  .navbar-expand-md .offcanvas-body {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0;
  }
}

/* Chat page styles (JLCA-926/JLCA-2100):
   - eigener Scrollbereich (.chat-scroll-area) mit overflow-y: auto
   - Seite selbst scrollt nicht im BA-Chat-Kontext (app-main overflow hidden)
   - alle Parent-Flex-Container begrenzen Höhe und setzen min-height: 0
   - Composer bleibt außerhalb des Nachrichten-Scrollbereichs sichtbar
   - Mobile: Nutzung dynamischer VH-Einheiten, Composer erreichbar
*/
/* Aktiv nur auf der BA-Chat-Seite */
body[data-page="ba-chat"] {
  overflow: hidden;
}
body[data-page="ba-chat"] .layout {
  min-height: 100svh;
  overflow: hidden;
}
body[data-page="ba-chat"] .app-main {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
}

.chat-container {
  max-width: 100%;
  width: 100%;
  margin: 0;
  padding: 2px;
  box-sizing: border-box;
  /* füllt den verbleibenden Platz innerhalb von app-main */
  flex: 1 1 auto;
  height: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow: hidden;
}
.ba-chat-quick-actions {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
  margin: 2px 0 4px;
  padding: 24px 20px;
  border: 1px solid #edf2f7;
  border-radius: 16px;
  background: #fbfcfe;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.ba-chat-quick-action {
  min-height: 72px;
  display: inline-flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 8px;
  padding: 24px 20px;
  border: 1px solid #edf2f7;
  border-radius: 16px;
  background: #fff;
  color: var(--fg);
  box-shadow: none;
  font: inherit;
  font-weight: 500;
  line-height: 1.25;
  text-align: left;
  cursor: default;
  transition:
    box-shadow 0.2s ease,
    border-color 0.2s ease,
    transform 0.2s ease;
}
.ba-chat-quick-action:hover {
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
}
.ba-chat-quick-action:focus {
  outline: 2px solid #1f6feb;
  outline-offset: 2px;
}
.ba-chat-quick-action .bi-plus-lg {
  flex: 0 0 auto;
  font-size: 1.15rem;
  line-height: 1;
}
.chat-workspace {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 12px;
  padding: 24px;
  border: 1px solid #edf2f7;
  border-radius: 20px;
  background: #fbfcfe;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.02);
  box-sizing: border-box;
  overflow: hidden;
}
.chat-log {
  /* eigener Scrollbereich; visuell in die Shell-Card integriert statt als zweite Card */
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
}
.chat-log::-webkit-scrollbar {
  width: 8px;
}
.chat-log::-webkit-scrollbar-track {
  background: transparent;
}
.chat-log::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}
.chat-scroll-area {
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
  overflow-y: auto;
}
.chat-empty-state {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 20px;
  line-height: 1.4;
  text-align: center;
  pointer-events: none;
}
.chat-log:has(.chat-message) .chat-empty-state {
  display: none;
}
.chat-composer {
  flex: 0 0 auto;
  display: flex;
  margin-top: auto;
  flex-direction: column;
  gap: 8px;
  position: relative;
  padding: 16px;
  border: 1px solid #e7edf5;
  border-radius: 20px;
  background: #fff;
  z-index: 1;
}
.chat-input-row {
  display: flex;
  flex: 0 0 auto;
  gap: 10px;
  /* sticky ist hier nicht erforderlich, explizit als normaler Block belassen */
  position: relative;
  bottom: auto;
  background: #fff;
  padding: 2px 0 env(safe-area-inset-bottom);
  z-index: 1;
}
.chat-actions-row {
  display: flex;
  flex: 0 0 auto;
  justify-content: flex-end;
  gap: 8px;
  margin: 0;
  padding: 0;
  background: #fff;
  z-index: 1;
}
.chat-actions-row button {
  padding: 6px 10px;
  border: 1px solid var(--gray-300);
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
}
.chat-actions-row button:focus {
  outline: 2px solid #1f6feb;
  outline-offset: 2px;
}
.chat-input-row input,
.chat-input-row textarea {
  flex: 1;
  padding: 0;
  border: 0;
  border-radius: 14px;
  box-sizing: border-box;
  background: transparent;
}
.chat-input-row textarea {
  min-height: 72px;
  resize: none;
  overflow-y: hidden;
}
.chat-input-row input:focus,
.chat-input-row textarea:focus {
  outline: 0;
}
.chat-composer:focus-within {
  outline: 2px solid #1f6feb;
  outline-offset: 2px;
}
.chat-input-row button {
  min-width: 100px;
  padding: 10px 14px;
  border: 1px solid var(--gray-300);
  background: #fff;
  border-radius: 14px;
  cursor: pointer;
}
.chat-input-row #chat-send {
  border-radius: 14px;
}
.chat-input-row button:focus {
  outline: 2px solid #1f6feb;
  outline-offset: 2px;
}
.chat-container .hint {
  flex: 0 0 auto;
  margin: 0;
}

/* JLCA-2098: Conversation-Bubbles mit Avatar und Zeitstempel. */
.chat-message-row {
  display: flex;
  align-items: flex-end;
  margin-bottom: 24px;
  gap: 8px;
  width: 100%;
}
.chat-message-row-user {
  justify-content: flex-end;
}
.chat-message-row-assistant {
  justify-content: flex-start;
}
.chat-message-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.chat-message-row-user .chat-message-content {
  align-items: flex-end;
  max-width: min(100%, 640px);
}
.chat-message-row-assistant .chat-message-content {
  align-items: flex-start;
  max-width: min(100%, 720px);
}
.chat-message-bubble {
  white-space: pre-wrap;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid transparent;
  overflow-wrap: anywhere;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.chat-message-bubble-user,
.chat-message.user,
.chat-message[data-role="user"] {
  background: #eef5ff;
  color: var(--chat-user-fg);
  border-color: #cfe0ff;
}
.chat-message-bubble-assistant,
.chat-message.assistant,
.chat-message[data-role="assistant"] {
  background: #fff8cc;
  color: var(--chat-assistant-fg);
  border-color: #f4e7a3;
}
.chat-message-meta {
  color: #94a3b8;
  font-size: 0.75rem;
  line-height: 1.2;
  margin-top: 6px;
}
.chat-avatar {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: #f8fafc;
  box-shadow: none;
  font-size: 1.05rem;
  line-height: 1;
}
.chat-avatar-user {
  background: #eaf5ff;
}
.chat-avatar-paul {
  background: #fff9e5;
}
.chat-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}
.chat-message-row-thinking .chat-message-bubble {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-message-bubble pre,
.chat-message-bubble code {
  max-width: 100%;
  white-space: pre-wrap;
  overflow-x: auto;
}

/* JLCA-677: Thinking indicator (spinner + label) */
.chat-log .chat-message-thinking .spinning-wheel {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(0, 0, 0, 0.2);
  border-top-color: rgba(0, 0, 0, 0.6);
  border-radius: 50%;
  display: inline-block;
  animation: ba-chat-spin 0.9s linear infinite;
}

@keyframes ba-chat-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 767.98px) {
  body[data-page="ba-chat"] {
    overflow: hidden;
  }

  .chat-container {
    max-width: 100%;
    gap: 10px;
    padding: 0;
  }

  .ba-chat-quick-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 16px;
  }

  .ba-chat-quick-action {
    min-height: 64px;
    padding: 18px 16px;
    font-size: 0.95rem;
  }

  .chat-workspace {
    gap: 10px;
    min-height: 0;
    padding: 14px;
  }

  .chat-log {
    padding: 0;
  }

  .chat-message-row-assistant .chat-message-content,
  .chat-message-row-user .chat-message-content {
    max-width: 100%;
  }

  .chat-avatar {
    flex-basis: 32px;
    width: 32px;
    height: 32px;
    font-size: 0.95rem;
  }

  .chat-composer {
    padding: 16px;
  }

  .chat-input-row {
    flex-direction: column;
    gap: 8px;
    padding-right: 0;
    padding-left: 0;
  }

  .chat-input-row button {
    width: 100%;
    min-width: 0;
  }

  .chat-actions-row {
    justify-content: stretch;
  }

  .chat-actions-row button {
    width: 100%;
  }
}

@media (max-width: 419.98px) {
  .ba-chat-quick-actions {
    grid-template-columns: 1fr;
  }
}
