:root {
  --palantir-sidebar-width: 17rem;
  --palantir-sidebar-bg: #f8f9fa;
  --palantir-sidebar-link: #212529;
  --palantir-sidebar-link-muted: #495057;
  --palantir-sidebar-link-hover-bg: rgba(0, 0, 0, 0.04);
  --palantir-sidebar-link-active-bg: #ffffff;
  --palantir-sidebar-link-active-border: var(--bs-primary);
}

body {
  min-height: 100vh;
}

.navbar.app-navbar {
  background-color: #fff;
}

.layout-sidebar {
  background: var(--palantir-sidebar-bg);
}

.layout-sidebar .border-bottom {
  background: var(--palantir-sidebar-bg);
}

/* Dark theme overrides (Bootstrap 5.1 compatible) */
:root[data-theme="dark"] {
  color-scheme: dark;
  --palantir-sidebar-bg: #111827;
  --palantir-sidebar-link: #e5e7eb;
  --palantir-sidebar-link-muted: #cbd5e1;
  --palantir-sidebar-link-hover-bg: rgba(255, 255, 255, 0.08);
  --palantir-sidebar-link-active-bg: rgba(255, 255, 255, 0.06);
  --palantir-sidebar-link-active-border: #60a5fa;
}

:root[data-theme="dark"] body.bg-light {
  background-color: #0b1220 !important;
  color: #e5e7eb;
}

:root[data-theme="dark"] a {
  color: #93c5fd;
}

:root[data-theme="dark"] a:hover {
  color: #bfdbfe;
}

:root[data-theme="dark"] .navbar,
:root[data-theme="dark"] .bg-white {
  background-color: #0f172a !important;
}

:root[data-theme="dark"] .navbar-brand,
:root[data-theme="dark"] .navbar .btn-link,
:root[data-theme="dark"] .btn-link,
:root[data-theme="dark"] .nav-link {
  color: #e5e7eb;
}

:root[data-theme="dark"] .btn-link:hover {
  color: #ffffff;
}

:root[data-theme="dark"] .border-bottom,
:root[data-theme="dark"] .border,
:root[data-theme="dark"] .border-end,
:root[data-theme="dark"] .border-start,
:root[data-theme="dark"] .border-top {
  border-color: rgba(255, 255, 255, 0.12) !important;
}

:root[data-theme="dark"] .text-dark {
  color: #e5e7eb !important;
}

:root[data-theme="dark"] .text-muted {
  color: rgba(229, 231, 235, 0.7) !important;
}

:root[data-theme="dark"] .dropdown-menu {
  background-color: #0f172a;
  border-color: rgba(255, 255, 255, 0.12);
}

:root[data-theme="dark"] .dropdown-item {
  color: #e5e7eb;
}

:root[data-theme="dark"] .dropdown-item:hover,
:root[data-theme="dark"] .dropdown-item:focus {
  background-color: rgba(255, 255, 255, 0.08);
}

:root[data-theme="dark"] .card,
:root[data-theme="dark"] .table-responsive.bg-white,
:root[data-theme="dark"] .table-responsive.border.rounded.bg-white {
  background-color: #0f172a !important;
}

:root[data-theme="dark"] .card,
:root[data-theme="dark"] .table-responsive {
  border-color: rgba(255, 255, 255, 0.12) !important;
}

:root[data-theme="dark"] .table {
  color: #e5e7eb;
}

:root[data-theme="dark"] .table thead th,
:root[data-theme="dark"] .table thead td,
:root[data-theme="dark"] .table th {
  color: #e5e7eb;
}

:root[data-theme="dark"] .table-light {
  --bs-table-bg: rgba(255, 255, 255, 0.04);
  --bs-table-striped-bg: rgba(255, 255, 255, 0.02);
  --bs-table-striped-color: #e5e7eb;
  --bs-table-hover-bg: rgba(255, 255, 255, 0.06);
  --bs-table-hover-color: #e5e7eb;
}

:root[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > * {
  color: #e5e7eb;
}

:root[data-theme="dark"] .form-control,
:root[data-theme="dark"] .form-select {
  background-color: #0b1220;
  border-color: rgba(255, 255, 255, 0.18);
  color: #e5e7eb;
}

:root[data-theme="dark"] .form-control::placeholder {
  color: rgba(229, 231, 235, 0.55);
}

:root[data-theme="dark"] .btn-outline-secondary {
  color: #e5e7eb;
  border-color: rgba(255, 255, 255, 0.25);
}

:root[data-theme="dark"] .btn-outline-secondary:hover {
  background-color: rgba(255, 255, 255, 0.08);
}

/* Fixed language + theme toggles (top-right corner) */
.palantir-top-toggles {
  position: fixed;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 1100; /* above offcanvas/backdrop */
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

/* Theme toggle stays circular inside the group */
.palantir-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border-radius: 999px;
  backdrop-filter: blur(6px);
}

.palantir-lang-toggle .btn {
  min-height: 44px;
  padding: 0.35rem 0.6rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

:root[data-theme="dark"] .palantir-theme-toggle {
  background-color: rgba(15, 23, 42, 0.9);
}

.app-navbar {
  min-height: 3.25rem;
}

.app-navbar-spacer {
  width: 44px;
  flex: 0 0 44px;
}

.sidebar-nav .nav-link {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 0.5rem 0.75rem;
  color: var(--palantir-sidebar-link-muted);
  border-radius: 0.375rem;
  gap: 0.5rem;
  font-size: 0.925rem;
}

.sidebar-nav .nav-link i.bi {
  width: 1.25rem;
  font-size: 1.05rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.sidebar-nav .nav-link.text-uppercase.small {
  font-size: 0.75rem;
  letter-spacing: 0.03em;
}

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link:focus {
  color: var(--palantir-sidebar-link);
  background: var(--palantir-sidebar-link-hover-bg);
}

.sidebar-nav .nav-link.active,
.sidebar-nav .nav-link[aria-current="page"] {
  color: var(--palantir-sidebar-link);
  background: var(--palantir-sidebar-link-active-bg);
  font-weight: 600;
  border-left: 0.25rem solid var(--palantir-sidebar-link-active-border);
  padding-left: 0.5rem;
}

.sidebar-nav .nav-link.ms-3 {
  min-height: 44px;
}

.sidebar-nav .collapse .nav-link {
  padding-left: 1.25rem;
}

@media (min-width: 768px) {
  .layout-shell {
    display: flex;
    min-height: calc(100vh - 3.25rem);
  }

  .layout-sidebar {
    width: var(--palantir-sidebar-width);
    flex: 0 0 var(--palantir-sidebar-width);
    border-right: 1px solid var(--bs-border-color);
  }

  .layout-main {
    flex: 1 1 auto;
    min-width: 0;
  }

  /* Desktop: slightly tighter nav rhythm (mobile stays 44px). */
  .sidebar-nav .nav-link {
    min-height: 40px;
    padding: 0.4rem 0.75rem;
    font-size: 0.9rem;
  }
  .sidebar-nav .nav-link.ms-3 {
    min-height: 40px;
  }
}

.offcanvas.sidebar-offcanvas {
  width: min(var(--palantir-sidebar-width), 100vw);
}

.table-responsive {
  -webkit-overflow-scrolling: touch;
}

/* Tables/cards: closer to Bootstrap dashboard feel */
.card.shadow-sm {
  border-color: rgba(0, 0, 0, 0.06);
}

.layout-main h1.h3 {
  letter-spacing: -0.01em;
}
