html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}

/* ===== Professional UI layer (shared across app pages) ===== */
:root {
  --cosmo-grad: linear-gradient(135deg, #6d5efc 0%, #22b8cf 100%);
  --cosmo-primary: #6d5efc;
  --cosmo-accent: #22b8cf;
  --cosmo-surface: #ffffff;
  --cosmo-muted: #6b7280;
  --cosmo-ring: rgba(109, 94, 252, .15);
}

/* Page header banner */
.page-header {
  position: relative;
  background: var(--cosmo-grad);
  color: #fff;
  border-radius: 1rem;
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 .75rem 1.5rem rgba(109, 94, 252, .25);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.page-header .page-header-titles {
  min-width: 0;
}

.page-header h1 {
  font-weight: 700;
  margin: 0;
  line-height: 1.2;
}

.page-header .page-subtitle {
  margin: .25rem 0 0;
  opacity: .9;
  font-size: .95rem;
}

.page-header .page-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
}

/* Status pill (layered on the JS-managed #authStatus badge) */
.status-pill.badge {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem .75rem;
  border-radius: 999px;
  font-weight: 600;
  background: rgba(255, 255, 255, .18) !important;
  color: #fff !important;
}

.status-pill.badge::before {
  content: "";
  width: .55rem;
  height: .55rem;
  border-radius: 50%;
  background: currentColor;
  opacity: .95;
}

.status-pill.bg-success { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .35); }
.status-pill.bg-warning { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .35); }

.page-header .btn-header {
  border-radius: 999px;
  font-weight: 600;
}

/* App cards */
.app-card {
  border: 0;
  border-radius: 1rem;
  background: var(--cosmo-surface);
  box-shadow: 0 .25rem .75rem rgba(17, 24, 39, .06);
  overflow: hidden;
}

.app-card > .card-header {
  background: transparent;
  border-bottom: 1px solid rgba(17, 24, 39, .06);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .85rem 1.1rem;
}

.app-card > .card-header .bi {
  color: var(--cosmo-primary);
}

/* Chat panel */
.chat-panel .chat-log {
  height: 340px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: .75rem;
  background: #f8f9fb;
  border-radius: .75rem;
  border: 1px solid rgba(17, 24, 39, .05);
}

.chat-panel .chat-log > div {
  margin-bottom: .6rem !important;
}

.chat-panel .chat-log .badge {
  display: inline-block;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  text-align: left;
  max-width: 85%;
  font-size: .95rem;
  font-weight: 400;
  line-height: 1.5;
  padding: .6rem .85rem;
  border-radius: 1rem;
  box-shadow: 0 1px 2px rgba(17, 24, 39, .06);
}

/* Assistant bubble */
.chat-panel .chat-log .badge.bg-light {
  background: var(--cosmo-surface) !important;
  border: 1px solid rgba(17, 24, 39, .08) !important;
  color: #1f2937 !important;
  border-bottom-left-radius: .35rem;
}

/* User bubble */
.chat-panel .chat-log .badge.bg-primary {
  background: var(--cosmo-grad) !important;
  color: #fff !important;
  border-bottom-right-radius: .35rem;
}

  content: "Ask the assistant anything to get started…";
  display: block;
  color: var(--cosmo-muted);
  font-size: .85rem;
  text-align: center;
  padding: 1.25rem .5rem;
}

.chat-panel .input-group .form-control:focus {
  box-shadow: 0 0 0 .2rem var(--cosmo-ring);
  border-color: var(--cosmo-primary);
}

/* Empty state for tables */
.empty-state {
  text-align: center;
  color: var(--cosmo-muted);
  padding: 2.25rem 1rem;
}

.empty-state .bi {
  font-size: 1.75rem;
  color: var(--cosmo-accent);
  display: block;
  margin-bottom: .5rem;
}

/* Feature rows (capabilities) */
.feature-row {
  display: flex;
  align-items: flex-start;
  gap: .85rem;
  padding: .75rem 0;
  border-bottom: 1px solid rgba(17, 24, 39, .06);
}

.feature-row:last-of-type {
  border-bottom: 0;
}

.feature-row .feature-icon {
  flex: 0 0 auto;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: .75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--cosmo-ring);
  color: var(--cosmo-primary);
  font-size: 1.15rem;
}

.feature-row .feature-title {
  font-weight: 600;
  margin: 0;
}

.feature-row .feature-desc {
  margin: 0;
  font-size: .9rem;
  color: var(--cosmo-muted);
}

/* Callout note */
.callout {
  border-left: 3px solid var(--cosmo-accent);
  background: rgba(34, 184, 207, .07);
  border-radius: .5rem;
  padding: .75rem .9rem;
  font-size: .85rem;
  color: #374151;
}

@media (max-width: 575.98px) {
  .page-header {
    padding: 1.25rem;
  }
  .page-header .page-toolbar {
    width: 100%;
  }
}

/* ===== Dark theme ===== */
[data-theme="dark"] {
  --cosmo-surface: #1e222b;
  --cosmo-muted: #9aa4b2;
  --cosmo-ring: rgba(139, 128, 255, .22);
  --bs-body-bg: #14171d;
  --bs-body-color: #e5e7eb;
}

[data-theme="dark"] body {
  background-color: #14171d;
  color: #e5e7eb;
}

[data-theme="dark"] .bg-white {
  background-color: #1e222b !important;
}

[data-theme="dark"] .navbar.bg-white {
  background-color: #1a1d24 !important;
  border-bottom-color: rgba(255, 255, 255, .08) !important;
}

[data-theme="dark"] .navbar .nav-link.text-dark,
[data-theme="dark"] .navbar .navbar-brand .fw-semibold {
  color: #e5e7eb !important;
}

[data-theme="dark"] .text-dark {
  color: #e5e7eb !important;
}

[data-theme="dark"] .text-muted {
  color: var(--cosmo-muted) !important;
}

[data-theme="dark"] .app-card {
  background: var(--cosmo-surface);
  box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .4);
}

[data-theme="dark"] .app-card > .card-header {
  border-bottom-color: rgba(255, 255, 255, .08);
  color: #e5e7eb;
}

[data-theme="dark"] .card {
  background-color: var(--cosmo-surface);
  color: #e5e7eb;
}

[data-theme="dark"] .chat-panel .chat-log {
  background: #14171d;
  border-color: rgba(255, 255, 255, .06);
}

[data-theme="dark"] .chat-panel .chat-log .badge.bg-light {
  background: #232834 !important;
  border-color: rgba(255, 255, 255, .1) !important;
  color: #e5e7eb !important;
}

[data-theme="dark"] .table {
  --bs-table-bg: transparent;
  --bs-table-color: #e5e7eb;
  color: #e5e7eb;
}

[data-theme="dark"] .table-hover > tbody > tr:hover > * {
  --bs-table-hover-bg: rgba(255, 255, 255, .05);
  --bs-table-hover-color: #e5e7eb;
}

[data-theme="dark"] .list-group-item {
  background-color: transparent;
  color: #e5e7eb;
  border-color: rgba(255, 255, 255, .08);
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
  background-color: #14171d;
  border-color: rgba(255, 255, 255, .12);
  color: #e5e7eb;
}

[data-theme="dark"] .form-control::placeholder {
  color: #6b7280;
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
  background-color: #14171d;
  color: #e5e7eb;
  border-color: var(--cosmo-primary);
}

[data-theme="dark"] .modal-content {
  background-color: var(--cosmo-surface);
  color: #e5e7eb;
}

[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer {
  border-color: rgba(255, 255, 255, .08);
}

[data-theme="dark"] .btn-close {
  filter: invert(1) grayscale(100%) brightness(200%);
}

[data-theme="dark"] .callout {
  color: #cbd5e1;
}

[data-theme="dark"] .btn-outline-secondary {
  color: #cbd5e1;
  border-color: rgba(255, 255, 255, .2);
}

[data-theme="dark"] footer.text-muted {
  color: var(--cosmo-muted) !important;
}

[data-theme="dark"] .border-top,
[data-theme="dark"] .border-bottom {
  border-color: rgba(255, 255, 255, .08) !important;
}

/* Theme toggle button */
.theme-toggle {
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 1.15rem;
  line-height: 1;
  padding: .35rem .5rem;
  border-radius: .5rem;
  cursor: pointer;
}

.theme-toggle:hover {
  background: rgba(127, 127, 127, .15);
}
