:root {
  --pastel-bg: #f6f7fb;
  --pastel-surface: #ffffff;
  --pastel-surface-2: #f9faff;
  --pastel-primary: #7aa7ff;
  --pastel-primary-rgb: 122, 167, 255;
  --pastel-muted: #6b7280;
  --pastel-success: #6ed3a5;
  --pastel-warning: #ffd269;
  --pastel-danger:  #ff9aa2;
  --crm-header-height: 72px; /* Slightly taller topbar/sidebar brand */
}

/* Bootstrap variable overrides */
:root {
  --bs-body-bg: var(--pastel-bg);
  --bs-body-color: #344054;
  --bs-primary: var(--pastel-primary);
  --bs-primary-rgb: var(--pastel-primary-rgb);
  --bs-link-color: var(--pastel-primary);
  --bs-link-hover-color: #5f8ff6;
  --bs-border-color: #e6e8f0;
  --bs-success: var(--pastel-success);
  --bs-warning: var(--pastel-warning);
  --bs-danger:  var(--pastel-danger);
}

/* Navbar pastel */
.navbar-pastel {
  background-color: var(--pastel-surface) !important;
  border-bottom: 1px solid #e8ecf5;
}
.navbar-pastel .navbar-brand,
.navbar-pastel .nav-link {
  color: #2b3642;
}
.navbar-pastel .nav-link.active {
  color: var(--pastel-primary);
}

/* Buttons */
.btn-primary {
  --bs-btn-color: #fff;
  --bs-btn-bg: var(--pastel-primary);
  --bs-btn-border-color: var(--pastel-primary);
  --bs-btn-hover-bg: #6b99ff;
  --bs-btn-hover-border-color: #6b99ff;
  --bs-btn-active-bg: #5c8cff;
  --bs-btn-active-border-color: #5c8cff;
}

/* Cards */
.card-pastel .card-header {
  background-color: var(--pastel-surface-2);
  color: #2b3642;
  border-bottom: 1px solid #eef1f8;
}

/* Hero background for login */
.pastel-hero {
  background: linear-gradient(135deg, #f6f7fb 0%, #fff5f7 50%, #f2fbff 100%);
  min-height: 100vh;
}

/* CRM sidebar layout */
.crm-sidebar {
  background-color: var(--pastel-surface);
  border-right: 1px solid #e8ecf5;
  width: 260px;
}
@media (min-width: 768px) {
  .crm-sidebar { position: sticky; top: 0; height: 100vh; }
}
.crm-brand { min-height: var(--crm-header-height); display: flex; align-items: center; }
.crm-brand .bi { font-size: 1.25rem; }
.crm-nav-link {
  color: #2b3642;
}
.crm-nav-link:hover { background: #f0f4ff; }
.crm-nav-link.active { background: rgba(var(--pastel-primary-rgb), .15); color: #1e3a8a; }

.crm-topbar { background-color: var(--pastel-surface); min-height: var(--crm-header-height); padding-top: 0; padding-bottom: 0; }

/* Datix header + brand alignment */
.app-header { background-color: var(--pastel-surface); min-height: var(--crm-header-height); border-bottom: 1px solid #e8ecf5; }
.app-brand { min-height: var(--crm-header-height); display: flex; align-items: center; }

/* Account block (top-right) */
.account-actions .account-name { line-height: 1.1; }
.account-actions .btn.btn-sm { padding-top: .2rem; padding-bottom: .2rem; }

/* Datix sidebar pastel overrides */
.sidebar-wrapper {
  background: linear-gradient(180deg, #f7faff 0%, #ffffff 100%);
  border-right: 1px solid #e8ecf5;
  display: flex;
  flex-direction: column;
  height: 100vh;
}
.sidebar-wrapper .app-brand {
  background-color: var(--pastel-surface);
  border-bottom: 1px solid #e8ecf5;
}
.sidebar-wrapper .sidebarMenuScroll {
  flex: 1 1 auto;
  overflow-y: auto; /* scroll only if needed */
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-bottom: 1.5rem; /* extra space at bottom when scrolled */
}
.sidebar-wrapper .sidebar-menu > li > a {
  color: #2b3642;
  border-radius: 8px;
}
.sidebar-wrapper .sidebar-menu > li > a:hover {
  background-color: #f0f4ff;
  color: #1e3a8a;
}
.sidebar-wrapper .sidebar-menu > li.active > a,
.sidebar-wrapper .sidebar-menu > li.current-page > a {
  background-color: rgba(var(--pastel-primary-rgb), .14);
  color: #1e3a8a;
}
.sidebar-wrapper .sidebar-menu > li.current-page::before,
.sidebar-wrapper .sidebar-menu > li.current-page::after {
  /* Hide curved bubble decorations from base theme
     (they assume a solid sidebar background color). */
  content: none !important;
  box-shadow: none !important;
  background: transparent !important;
}
.sidebar-wrapper .sidebar-menu > li > a .bi { color: #6b8af7; }
.sidebar-wrapper .sidebar-menu > li.active > a .bi,
.sidebar-wrapper .sidebar-menu > li.current-page > a .bi { color: var(--pastel-primary); }

/* Nested menu pastel tweaks */
.sidebar-wrapper .treeview-menu li a {
  color: #2b3642;
  border-radius: 6px;
  display: block;
  max-width: 100%;
  white-space: normal;            /* wrap lines instead of single line */
  word-break: break-word;         /* break long tokens */
  overflow-wrap: anywhere;        /* allow break anywhere if needed */
  padding-right: 1.25rem;         /* keep chevrons/icons clear on the right */
}
.sidebar-wrapper .treeview-menu li a:hover {
  background-color: #f6f9ff;
  color: #1e3a8a;
}

/* Active sublink styled in pastel primary */
.sidebar-wrapper .treeview-menu li a.active-sub {
  background-color: rgba(var(--pastel-primary-rgb), .12);
  color: #1e3a8a;
  box-shadow: inset 3px 0 4px rgba(0, 0, 0, 0.05);
}

/* Ensure nested containers don't overflow horizontally */
.sidebar-wrapper .treeview-menu,
.sidebar-wrapper .treeview-menu li { max-width: 100%; overflow-x: hidden; }
