/* ============================================================================
   D2K Masters Framework - Sneat-Inspired Professional UI Stylesheet
   ============================================================================
   
   Design Inspiration: Sneat Bootstrap Admin Template
   Features:
   - Professional, clean business design
   - Full dark/light theme support (Bootstrap 5.3+ compatible)
   - Sneat-inspired color palette and styling
   - Enhanced icons with professional appearance
   - Refined borders, shadows, and visual hierarchy
   - Smooth transitions and animations
   - Responsive design with mobile-first approach
   - CSP-friendly (no inline styles required)
   - Option B: brand tokens (data-brand) for satguru/travelwings/t3/default
   
   ============================================================================ */

/* ============================================================================
   Brand tokens (Option B) – canonical: default, satguru, travelwings, t3
   ============================================================================ */
:root {
  --d2k-primary: #696cff;
  --d2k-primary-hover: #8b8dff;
  --d2k-primary-muted: rgba(105, 108, 255, 0.1);
  --d2k-primary-muted-hover: rgba(105, 108, 255, 0.15);
  --d2k-navbar-bg: #fff;
  --d2k-navbar-bg-dark: #2b2c40;
  --d2k-navbar-border: rgba(60, 72, 88, 0.08);
  --d2k-navbar-border-dark: rgba(255, 255, 255, 0.08);
  --d2k-navbar-toolbar-height: 2rem;
  --d2k-navbar-toolbar-padding-y: 0.25rem;
  --d2k-navbar-toolbar-padding-x: 0.5rem;
  --d2k-sidebar-bg: #fff;
  --d2k-sidebar-bg-dark: #2b2c40;
  --d2k-sidebar-border: rgba(60, 72, 88, 0.08);
  --d2k-sidebar-border-dark: rgba(255, 255, 255, 0.08);
  --d2k-body-bg: #f5f5f9;
  --d2k-body-bg-dark: #232333;
  --d2k-text-muted: #697a8d;
  --d2k-text-muted-dark: #a1acb8;
  --d2k-placeholder-color: #cbcbcb;
  --d2k-surface: #2b2c40;
  --d2k-border: rgba(60, 72, 88, 0.08);
  --d2k-border-dark: rgba(255, 255, 255, 0.08);
  --d2k-focus-ring: #696cff;
  --d2k-btn-primary-bg: linear-gradient(135deg, #696cff 0%, #5f62e6 100%);
  --d2k-btn-primary-border: #696cff;
  --d2k-btn-primary-hover: linear-gradient(135deg, #696cff 0%, #7b7eff 100%);
  --d2k-btn-primary-hover-border: #8b8dff;
  /* Sticky offset for header/sidebar (JS updates to actual header height). */
  --d2k-sticky-top: 60px;
}

/* Brand overrides – allowlisted; only canonical keys (satguru, travelwings, t3) */
html[data-brand="satguru"] {
  --d2k-primary: #0d6efd;
  --d2k-primary-hover: #0b5ed7;
  --d2k-primary-muted: rgba(13, 110, 253, 0.1);
  --d2k-primary-muted-hover: rgba(13, 110, 253, 0.15);
  --d2k-focus-ring: #0d6efd;
  --d2k-btn-primary-bg: linear-gradient(135deg, #0d6efd 0%, #0a58ca 100%);
  --d2k-btn-primary-border: #0d6efd;
  --d2k-btn-primary-hover: linear-gradient(135deg, #0d6efd 0%, #0b5ed7 100%);
  --d2k-btn-primary-hover-border: #0b5ed7;
}

html[data-brand="travelwings"] {
  --d2k-primary: #198754;
  --d2k-primary-hover: #157347;
  --d2k-primary-muted: rgba(25, 135, 84, 0.1);
  --d2k-primary-muted-hover: rgba(25, 135, 84, 0.15);
  --d2k-focus-ring: #198754;
  --d2k-btn-primary-bg: linear-gradient(135deg, #198754 0%, #146c43 100%);
  --d2k-btn-primary-border: #198754;
  --d2k-btn-primary-hover: linear-gradient(135deg, #198754 0%, #157347 100%);
  --d2k-btn-primary-hover-border: #157347;
}

html[data-brand="t3"] {
  --d2k-primary: #fd7e14;
  --d2k-primary-hover: #e8590c;
  --d2k-primary-muted: rgba(253, 126, 20, 0.1);
  --d2k-primary-muted-hover: rgba(253, 126, 20, 0.15);
  --d2k-focus-ring: #fd7e14;
  --d2k-btn-primary-bg: linear-gradient(135deg, #fd7e14 0%, #e8590c 100%);
  --d2k-btn-primary-border: #fd7e14;
  --d2k-btn-primary-hover: linear-gradient(135deg, #fd7e14 0%, #ea6a12 100%);
  --d2k-btn-primary-hover-border: #e8590c;
}

/* ============================================================================
   Autofill trap (CSP-safe; no inline styles)
   ============================================================================ */
.d2k-autofill-trap {
  /* Keep in DOM so browser autofill can target it, but ensure it's not visible. */
  position: absolute;
  left: -10000px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}

.d2k-autofill-trap input {
  width: 1px;
  height: 1px;
  border: 0;
  padding: 0;
  margin: 0;
}

/* ============================================================================
   Theme System (Light/Dark Mode)
   ============================================================================ */

/* Theme Toggle Button */
.d2k-theme-toggle {
  position: relative;
  width: var(--d2k-navbar-toolbar-height, 2rem);
  height: var(--d2k-navbar-toolbar-height, 2rem);
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

/* ============================================================================
   Notifications (bell + dropdown)
   ============================================================================ */
.d2k-notif-bell-btn .d2k-notif-count {
  position: absolute;
  top: -0.35rem;
  right: -0.35rem;
  font-size: 0.7rem;
  line-height: 1;
}

.d2k-notif-dropdown {
  width: 22rem;
  max-height: 24rem;
  overflow: hidden;
}

.d2k-notif-list {
  max-height: 17rem;
  overflow: auto;
}

.d2k-notif-item {
  cursor: pointer;
}

.d2k-notif-item:hover {
  background: rgba(105, 108, 255, 0.08);
}

.d2k-notif-item-title {
  font-weight: 600;
}

.d2k-notif-item-meta {
  font-size: 0.75rem;
}

.d2k-theme-toggle:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(1.05);
}

.d2k-theme-icon-light,
.d2k-theme-icon-dark {
  font-size: 1.2rem;
  transition: opacity 0.3s ease, transform 0.3s ease;
  position: absolute;
}

[data-bs-theme="light"] .d2k-theme-icon-dark {
  opacity: 0;
  transform: rotate(90deg);
}

[data-bs-theme="dark"] .d2k-theme-icon-light {
  opacity: 0;
  transform: rotate(-90deg);
}

[data-bs-theme="light"] .d2k-theme-icon-light {
  opacity: 1;
  transform: rotate(0deg);
}

[data-bs-theme="dark"] .d2k-theme-icon-dark {
  opacity: 1;
  transform: rotate(0deg);
}

/* ============================================================================
   Sneat-Inspired Layout & Navigation
   ============================================================================ */

/* App Body - Sneat Style */
.d2k-app-body {
  font-family: 'Public Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  transition: background-color 0.3s ease;
  font-size: 0.9375rem;
  line-height: 1.5;
}

[data-bs-theme="light"] .d2k-app-body {
  background: var(--d2k-body-bg);
}

[data-bs-theme="dark"] .d2k-app-body {
  background: var(--d2k-body-bg-dark);
}

.d2k-app-wrapper {
  background: transparent;
  width: 100%;
  min-width: 0;
  overflow: visible;
}

/* Top Navbar - Sneat Style */
.d2k-navbar {
  background: var(--d2k-navbar-bg) !important;
  box-shadow: 0 1px 0 0 rgba(60, 72, 88, 0.15);
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--d2k-navbar-border);
  position: sticky;
  top: 0;
  z-index: 1045;
}

/* Align brand and toolbar to same top baseline */
.d2k-navbar .container-fluid {
  align-items: flex-start;
}

.d2k-navbar .container-fluid > .ms-auto {
  align-items: center;
  gap: 0.5rem;
}

/* Navbar toolbar: same height, padding and alignment for all items */
.d2k-navbar .container-fluid > .ms-auto .btn,
.d2k-navbar .container-fluid > .ms-auto .dropdown > .btn {
  height: var(--d2k-navbar-toolbar-height);
  min-height: var(--d2k-navbar-toolbar-height);
  padding-top: var(--d2k-navbar-toolbar-padding-y);
  padding-bottom: var(--d2k-navbar-toolbar-padding-y);
  padding-left: var(--d2k-navbar-toolbar-padding-x);
  padding-right: var(--d2k-navbar-toolbar-padding-x);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  border-radius: 6px;
  font-size: 0.8125rem;
}

.d2k-navbar .container-fluid > .ms-auto .d2k-theme-toggle,
.d2k-navbar .container-fluid > .ms-auto .d2k-notif-bell-btn {
  padding: 0;
  width: var(--d2k-navbar-toolbar-height);
  min-width: var(--d2k-navbar-toolbar-height);
}

.d2k-navbar .container-fluid > .ms-auto .small.text-white-50 {
  height: var(--d2k-navbar-toolbar-height);
  display: inline-flex;
  align-items: center;
  line-height: 1.25;
  padding: 0 var(--d2k-navbar-toolbar-padding-x);
  margin: 0;
  font-size: 0.8125rem;
}

[data-bs-theme="dark"] .d2k-navbar {
  background: var(--d2k-navbar-bg-dark) !important;
  box-shadow: 0 1px 0 0 rgba(0, 0, 0, 0.3);
  border-bottom-color: var(--d2k-navbar-border-dark);
}

.d2k-navbar .navbar-brand {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--d2k-primary) !important;
  text-decoration: none;
  letter-spacing: -0.5px;
}

[data-bs-theme="dark"] .d2k-navbar .navbar-brand {
  color: var(--d2k-primary-hover) !important;
}

/* Navbar buttons and text */
.d2k-navbar .btn-outline-light {
  border-color: rgba(60, 72, 88, 0.2);
  color: var(--d2k-text-muted);
  background: transparent;
}

.d2k-navbar .btn-outline-light:hover {
  background: var(--d2k-primary-muted);
  border-color: var(--d2k-primary);
  color: var(--d2k-primary);
}

[data-bs-theme="dark"] .d2k-navbar .btn-outline-light {
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--d2k-text-muted-dark);
}

[data-bs-theme="dark"] .d2k-navbar .btn-outline-light:hover {
  background: var(--d2k-primary-muted-hover);
  border-color: var(--d2k-primary-hover);
  color: var(--d2k-primary-hover);
}

/* Log out button in navbar – visible in both themes */
.d2k-navbar .d2k-logout-btn {
  border-color: rgba(60, 72, 88, 0.35);
  color: #566a7f;
}
.d2k-navbar .d2k-logout-btn:hover {
  border-color: #697a8d;
  color: #566a7f;
  background: rgba(60, 72, 88, 0.08);
}
[data-bs-theme="dark"] .d2k-navbar .d2k-logout-btn {
  border-color: rgba(255, 255, 255, 0.3);
  color: #a1acb8;
}
[data-bs-theme="dark"] .d2k-navbar .d2k-logout-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
}

.d2k-navbar .text-white-50 {
  color: var(--d2k-text-muted) !important;
}

[data-bs-theme="dark"] .d2k-navbar .text-white-50 {
  color: var(--d2k-text-muted-dark) !important;
}

.d2k-navbar .dropdown-menu {
  border: 1px solid var(--d2k-navbar-border);
  box-shadow: 0 0.25rem 0.5rem rgba(67, 89, 113, 0.15);
}

[data-bs-theme="dark"] .d2k-navbar .dropdown-menu {
  background: var(--d2k-navbar-bg-dark);
  border-color: var(--d2k-navbar-border-dark);
  box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.3);
}

[data-bs-theme="dark"] .d2k-navbar .dropdown-item {
  color: var(--d2k-text-muted-dark);
}

[data-bs-theme="dark"] .d2k-navbar .dropdown-item:hover {
  background: var(--d2k-primary-muted);
  color: var(--d2k-primary-hover);
}

.d2k-brand-icon {
  font-size: 1.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  background: var(--d2k-primary-muted);
  border-radius: 8px;
  transition: all 0.3s ease;
  margin-right: 0.5rem;
}

.d2k-brand-icon:hover {
  background: var(--d2k-primary-muted-hover);
  transform: scale(1.05);
}

/* Sidebar - Sneat Style */
.d2k-sidebar {
  position: sticky;
  top: var(--d2k-sticky-top, 60px);
  height: calc(100vh - var(--d2k-sticky-top, 60px));
  min-height: calc(100vh - var(--d2k-sticky-top, 60px));
  overflow-y: auto;
  transition: all 0.3s ease;
  width: 260px;
  flex-shrink: 0;
}

[data-bs-theme="light"] .d2k-sidebar {
  background: var(--d2k-sidebar-bg);
  border-right: 1px solid var(--d2k-sidebar-border) !important;
  box-shadow: 1px 0 0 0 rgba(60, 72, 88, 0.05);
}

[data-bs-theme="dark"] .d2k-sidebar {
  background: var(--d2k-sidebar-bg-dark) !important;
  border-right: 1px solid var(--d2k-sidebar-border-dark) !important;
  box-shadow: 1px 0 0 0 rgba(0, 0, 0, 0.2);
}

.d2k-sidebar-content {
  position: static;
  height: auto;
  padding: 1.5rem 0;
}

.d2k-sidebar-content > div:first-child,
.d2k-menu-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  padding: 0 1.5rem;
  margin-bottom: 1rem;
  transition: color 0.3s ease;
}

[data-bs-theme="light"] .d2k-sidebar-content > div:first-child,
[data-bs-theme="light"] .d2k-menu-title {
  color: var(--d2k-text-muted);
  border-bottom-color: var(--d2k-border);
}

[data-bs-theme="dark"] .d2k-sidebar-content > div:first-child,
[data-bs-theme="dark"] .d2k-menu-title {
  color: var(--d2k-text-muted-dark);
  border-bottom-color: var(--d2k-border-dark);
}

/* Mobile Sidebar Backdrop */
.d2k-sidebar-backdrop {
  position: fixed;
  top: var(--d2k-sticky-top, 60px);
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1039;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.d2k-sidebar-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 991.98px) {
  .d2k-sidebar {
    position: fixed;
    top: var(--d2k-sticky-top, 60px);
    left: 0;
    height: calc(100vh - var(--d2k-sticky-top, 60px));
    z-index: 1040;
    overflow-y: auto;
    box-shadow: 4px 0 12px rgba(0, 0, 0, 0.15);
    width: 260px;
    max-width: 85vw;
    transform: translateX(-100%);
    visibility: hidden;
    pointer-events: none;
  }

  html.d2k-mobile-sidebar-open .d2k-sidebar {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
  }
  
  /* Main content uses full width when sidebar is hidden on mobile */
  .d2k-main-container {
    padding-left: 0;
  }
  
  .d2k-main-content {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
}

/* Menu Items - Sneat Style */
.d2k-menu-nav {
  padding: 0;
}

.d2k-menu-nav .list-group {
  background: transparent;
}

[data-bs-theme="light"] .d2k-menu-nav .list-group {
  background: transparent;
}

[data-bs-theme="dark"] .d2k-menu-nav .list-group {
  background: transparent;
}

.d2k-menu-nav .list-group-item {
  background: transparent !important;
  border-color: transparent !important;
}

[data-bs-theme="light"] .d2k-menu-nav .list-group-item {
  background: transparent !important;
}

[data-bs-theme="dark"] .d2k-menu-nav .list-group-item {
  background: transparent !important;
}

.d2k-menu-item {
  padding: 0.625rem 1.5rem !important;
  text-decoration: none;
  transition: all 0.2s ease;
  border-left: 3px solid transparent !important;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.125rem 0.5rem;
  border-radius: 0.375rem;
  font-size: 0.9375rem;
  font-weight: 400;
}

[data-bs-theme="light"] .d2k-menu-item {
  color: var(--d2k-text-muted);
}

[data-bs-theme="dark"] .d2k-menu-item {
  color: var(--d2k-text-muted-dark);
}

.d2k-menu-item:hover {
  background: var(--d2k-primary-muted);
  color: var(--d2k-primary);
  border-left-color: var(--d2k-primary) !important;
}

[data-bs-theme="dark"] .d2k-menu-item:hover {
  background: var(--d2k-primary-muted-hover);
  color: var(--d2k-primary-hover);
  border-left-color: var(--d2k-primary-hover) !important;
}

.d2k-menu-item-disabled {
  cursor: not-allowed;
  opacity: 0.8;
}

.d2k-menu-item-disabled:hover {
  background: transparent;
  color: inherit;
  border-left-color: transparent !important;
}

.d2k-menu-item-disabled .badge {
  font-size: 0.7rem;
}

.d2k-menu-item.active,
.d2k-menu-item:focus {
  background: linear-gradient(90deg, var(--d2k-primary-muted) 0%, rgba(0, 0, 0, 0) 85%);
  color: var(--d2k-primary);
  border-left-color: var(--d2k-primary) !important;
  font-weight: 600;
  box-shadow: 0 1px 10px rgba(105, 108, 255, 0.12);
}

[data-bs-theme="dark"] .d2k-menu-item.active,
[data-bs-theme="dark"] .d2k-menu-item:focus {
  background: linear-gradient(90deg, var(--d2k-primary-muted-hover) 0%, rgba(0, 0, 0, 0) 85%);
  color: #ffffff;
  border-left-color: var(--d2k-primary-hover) !important;
  box-shadow: 0 1px 12px rgba(105, 108, 255, 0.18);
}

/* Parent emphasis when a child menu item is active */
.d2k-menu-parent-active {
  color: var(--d2k-primary) !important;
  font-weight: 600;
}
[data-bs-theme="dark"] .d2k-menu-parent-active {
  color: #ffffff !important;
}

/* Tree menu: search input */
.d2k-menu-search .d2k-menu-search-input {
  font-size: 0.875rem;
}

/* Tree menu: tab and menu group buttons */
.d2k-menu-tab-btn,
.d2k-menu-group-btn {
  cursor: pointer;
  user-select: none;
}

.d2k-menu-chevron {
  transition: transform 0.2s ease;
  opacity: 0.7;
}

.d2k-menu-tab-btn[aria-expanded="true"] .d2k-menu-chevron,
.d2k-menu-group-btn[aria-expanded="true"] .d2k-menu-chevron {
  transform: rotate(90deg);
}

/* Tree menu: nested indent and border */
.d2k-menu-tab-content .list-group-flush.border-start,
.d2k-menu-menu-content .list-group-flush {
  border-left-width: 1px !important;
}

[data-bs-theme="light"] .d2k-menu-tab-content .list-group-flush.border-start {
  border-left-color: var(--d2k-border) !important;
}

[data-bs-theme="dark"] .d2k-menu-tab-content .list-group-flush.border-start {
  border-left-color: var(--d2k-border-dark) !important;
}

/* Tree menu: submenu links (slightly smaller, same list-group-item style) */
.d2k-menu-tree .d2k-menu-item {
  padding: 0.375rem 0.75rem 0.375rem 1rem !important;
  font-size: 0.875rem;
  margin: 0 0.25rem 0.125rem;
}

.d2k-menu-tree .d2k-menu-icon-item {
  flex-shrink: 0;
}

/* Tree menu: empty state */
.d2k-menu-empty {
  padding-left: 1rem;
}

.d2k-menu-icon {
  font-size: 1.25rem;
  width: 1.5rem;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
  opacity: 0.8;
}

.d2k-menu-item:hover .d2k-menu-icon,
.d2k-menu-item.active .d2k-menu-icon {
  opacity: 1;
  transform: scale(1.1);
}

/* Main Content Area - Sneat Style */
.d2k-main-content {
  min-height: calc(100vh - 60px);
  transition: background 0.3s ease;
  padding: 1rem 1.5rem;
  width: 0;
  min-width: 0;
  flex: 1 1 auto;
  overflow: visible;
  box-sizing: border-box;
}

[data-bs-theme="light"] .d2k-main-content {
  background: #f5f5f9;
}

[data-bs-theme="dark"] .d2k-main-content {
  background: #232333;
}

.d2k-content-card {
  border-radius: 0.5rem;
  transition: all 0.3s ease;
  border: 0;
  width: 100%;
  max-width: 100%;
  overflow: visible;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

[data-bs-theme="light"] .d2k-content-card {
  background: #fff;
  box-shadow: 0 2px 6px 0 rgba(67, 89, 113, 0.12);
}

[data-bs-theme="dark"] .d2k-content-card {
  background: #2b2c40;
  box-shadow: 0 2px 6px 0 rgba(0, 0, 0, 0.3);
}

.d2k-content-card .card-body {
  transition: background-color 0.3s ease;
  padding: 1rem 1.5rem;
  overflow: visible;
  max-width: 100%;
  box-sizing: border-box;
  flex: 1 1 auto;
  min-width: 0;
}

[data-bs-theme="light"] .d2k-content-card .card-body {
  background: #fff;
}

[data-bs-theme="dark"] .d2k-content-card .card-body {
  background: #2b2c40;
}

/* Footer - Sneat Style */
.d2k-footer {
  transition: all 0.3s ease;
  border-top: 1px solid;
}

[data-bs-theme="light"] .d2k-footer {
  background: #fff !important;
  border-top: 1px solid rgba(60, 72, 88, 0.08) !important;
  box-shadow: 0 -1px 0 0 rgba(60, 72, 88, 0.05);
}

[data-bs-theme="dark"] .d2k-footer {
  background: #2b2c40 !important;
  border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
  box-shadow: 0 -1px 0 0 rgba(0, 0, 0, 0.2);
}

.d2k-footer-content {
  transition: color 0.3s ease;
}

[data-bs-theme="light"] .d2k-footer-content {
  color: #697a8d !important;
}

[data-bs-theme="dark"] .d2k-footer-content {
  color: #a1acb8 !important;
}

/* ============================================================================
   LOV Minimal Layout (no nav/header/footer)
   ============================================================================ */

.d2k-lov-body {
  margin: 0;
  padding: 0;
  transition: background 0.3s ease;
}

[data-bs-theme="light"] .d2k-lov-body {
  background: #f5f5f9;
}

[data-bs-theme="dark"] .d2k-lov-body {
  background: #232333;
}

/* LOV Content - Full width, compact design */
.d2k-lov-body > section {
  width: 100%;
  max-width: 100%;
  padding: 1.5rem;
  transition: all 0.3s ease;
}

[data-bs-theme="light"] .d2k-lov-body > section {
  background: transparent;
}

[data-bs-theme="dark"] .d2k-lov-body > section {
  background: transparent;
}

/* ============================================================================
   Sneat-Inspired Cards & Forms
   ============================================================================ */

.card {
  border-radius: 0.5rem;
  transition: all 0.3s ease;
  overflow: hidden;
  border: 0;
}

[data-bs-theme="light"] .card {
  background: #fff;
  box-shadow: 0 2px 6px 0 rgba(67, 89, 113, 0.12);
}

[data-bs-theme="dark"] .card {
  background: #2b2c40;
  box-shadow: 0 2px 6px 0 rgba(0, 0, 0, 0.3);
}

.card:hover {
  box-shadow: 0 4px 12px 0 rgba(67, 89, 113, 0.15);
}

[data-bs-theme="dark"] .card:hover {
  box-shadow: 0 4px 12px 0 rgba(0, 0, 0, 0.4);
}

.card-header {
  font-weight: 600;
  transition: all 0.3s ease;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid;
}

[data-bs-theme="light"] .card-header {
  background: #fff;
  border-bottom-color: rgba(60, 72, 88, 0.08);
  color: #566a7f;
}

[data-bs-theme="dark"] .card-header {
  background: var(--d2k-surface);
  border-bottom-color: var(--d2k-border-dark);
  color: var(--d2k-text-muted-dark);
}

/* Form Controls - Sneat Style (height aligned with buttons) */
.form-control,
.form-select {
  border-radius: 0.375rem;
  transition: all 0.2s ease;
  font-size: 0.9375rem;
  line-height: 1.25;
  min-height: 2.25rem;       /* same visual height as primary buttons */
}

.form-control {
  padding: 0.5rem 0.875rem; /* match vertical padding of .btn */
}

/* Keep Bootstrap-compatible select spacing so indicator/caret renders correctly. */
.form-select {
  padding: 0.5rem 2.25rem 0.5rem 0.875rem;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

.form-select.form-select-sm {
  padding-right: 2rem;
}

.form-select.form-select-lg {
  padding-right: 2.5rem;
}


/* Allow multi-line textareas to grow while keeping baseline height consistent */
textarea.form-control {
  min-height: 2.5rem;
}

.form-control::placeholder {
  color: var(--d2k-placeholder-color);
  opacity: 1;
}

.form-select:has(option[value=""]:checked) {
  color: var(--d2k-placeholder-color);
}

.form-select option {
  color: #566a7f;
}

[data-bs-theme="light"] .form-control,
[data-bs-theme="light"] .form-select {
  border: 1px solid #d9dee3;
  background-color: #fff;
  color: #566a7f;
}


[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
  border: 1px solid rgba(255, 255, 255, 0.1);
  background-color: #323249;
  color: #a1acb8;
}

[data-bs-theme="dark"] .form-select option {
  color: #a1acb8;
  background-color: #323249;
}

/* Preserve Bootstrap disabled/readonly cues after theme-level form overrides. */
.form-control:disabled,
.form-control[readonly],
.form-control.disabled,
.form-select:disabled,
.form-select.disabled,
.input-group .btn.disabled,
.input-group .btn[aria-disabled="true"] {
  background-color: var(--bs-secondary-bg);
  border-color: var(--bs-border-color);
  color: var(--bs-secondary-color);
  opacity: 1;
  cursor: not-allowed;
  box-shadow: none;
}

.form-control[readonly]:not(:disabled) {
  cursor: default;
}

.form-check-input:disabled,
.form-check-input.disabled,
.form-check-input[aria-disabled="true"] {
  background-color: var(--bs-secondary-bg);
  border-color: var(--bs-border-color);
  opacity: 1;
  cursor: not-allowed;
}

.form-check-input:disabled ~ .form-check-label,
.form-check-input:disabled ~ .d2k-bool-text,
.form-check-input.disabled ~ .form-check-label,
.form-check-input.disabled ~ .d2k-bool-text,
.form-check-input[aria-disabled="true"] ~ .form-check-label,
.form-check-input[aria-disabled="true"] ~ .d2k-bool-text,
.form-check:has(.form-check-input:disabled),
.form-check:has(.form-check-input.disabled),
.form-check:has(.form-check-input[aria-disabled="true"]) {
  color: var(--bs-secondary-color);
  cursor: not-allowed;
}

[data-bs-theme="dark"] .form-control:disabled,
[data-bs-theme="dark"] .form-control[readonly],
[data-bs-theme="dark"] .form-control.disabled,
[data-bs-theme="dark"] .form-select:disabled,
[data-bs-theme="dark"] .form-select.disabled,
[data-bs-theme="dark"] .input-group .btn.disabled,
[data-bs-theme="dark"] .input-group .btn[aria-disabled="true"] {
  background-color: #2b2c40;
  border-color: rgba(255, 255, 255, 0.08);
  color: #7f8a99;
}

[data-bs-theme="dark"] .form-check-input:disabled,
[data-bs-theme="dark"] .form-check-input.disabled,
[data-bs-theme="dark"] .form-check-input[aria-disabled="true"] {
  background-color: #2b2c40;
  border-color: rgba(255, 255, 255, 0.12);
}


.form-control:focus,
.form-select:focus {
  border-color: var(--d2k-focus-ring);
  box-shadow: 0 0 0 0.2rem var(--d2k-primary-muted);
  outline: none;
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
  background-color: #3a3b52;
  border-color: var(--d2k-primary-hover);
  box-shadow: 0 0 0 0.2rem var(--d2k-primary-muted);
}

/* Consistent button sizing across the app */
.btn {
  border-radius: 0.375rem;
  font-weight: 500;
  transition: all 0.2s ease;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  line-height: 1.25;
  min-height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.8125rem;
  min-height: 1.875rem;
}

/* Toolbar and filter button groups - same size */
.d2k-btn-toolbar .btn,
.d2k-action-btn {
  min-height: 2.25rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.d2k-btn-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary {
  background: var(--d2k-btn-primary-bg);
  border-color: var(--d2k-btn-primary-border);
  color: #fff;
  box-shadow: 0 0.125rem 0.375rem var(--d2k-primary-muted), 
              0 0.0625rem 0.125rem var(--d2k-primary-muted);
  position: relative;
  overflow: hidden;
}

.btn-primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s ease;
}

.btn-primary:hover::before {
  left: 100%;
}

.btn-primary:hover {
  background: var(--d2k-btn-primary-hover);
  border-color: var(--d2k-btn-primary-hover-border);
  color: #fff;
  box-shadow: 0 0.375rem 0.75rem var(--d2k-primary-muted), 
              0 0.125rem 0.25rem var(--d2k-primary-muted-hover);
  transform: translateY(-2px);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 0.125rem 0.375rem rgba(105, 108, 255, 0.4);
}

[data-bs-theme="dark"] .btn-primary {
  background: var(--d2k-btn-primary-hover);
  box-shadow: 0 0.125rem 0.375rem var(--d2k-primary-muted), 
              0 0.0625rem 0.125rem var(--d2k-primary-muted-hover);
}

[data-bs-theme="dark"] .btn-primary:hover {
  background: var(--d2k-btn-primary-hover);
  border-color: var(--d2k-btn-primary-hover-border);
  box-shadow: 0 0.5rem 1rem var(--d2k-primary-muted-hover), 
              0 0.125rem 0.25rem var(--d2k-primary-muted);
}

.btn-outline-primary {
  border: 1px solid var(--d2k-primary);
  color: var(--d2k-primary);
  background: transparent;
  transition: all 0.2s ease;
}

.btn-outline-primary:hover {
  background: var(--d2k-primary);
  border-color: var(--d2k-primary);
  color: #fff;
  box-shadow: 0 0.25rem 0.5rem var(--d2k-primary-muted);
}

.btn-outline-secondary {
  border: 1px solid #d9dee3;
  color: #697a8d;
  background: transparent;
}

[data-bs-theme="dark"] .btn-outline-secondary {
  border-color: rgba(255, 255, 255, 0.1);
  color: #a1acb8;
}

.btn-outline-secondary:hover {
  background: #f5f5f9;
  border-color: #d9dee3;
  color: #566a7f;
}

[data-bs-theme="dark"] .btn-outline-secondary:hover {
  background: #323249;
  border-color: rgba(255, 255, 255, 0.15);
  color: #fff;
}

/* Tables - Bootstrap Default with Sticky Action Column */
.d2k-table-wrapper {
  position: relative;
  width: 100%;
  /* Let Bootstrap's table-responsive handle scrolling */
}

/* Main container - use flexbox for proper width distribution */
.d2k-main-container {
  width: 100%;
  min-width: 0;
  overflow: visible;
  flex: 1 1 auto;
}



/* Use Bootstrap default table styling */
.d2k-table-wrapper .table {
  margin-bottom: 0;
}

/* Sticky Action Column - keeps Edit/Delete buttons visible during horizontal scroll */
.d2k-action-col-sticky {
  position: sticky;
  right: 0;
  z-index: 11;
  min-width: 120px;
  width: 1%;
  white-space: nowrap;
  background: inherit;
  padding-left: 0.75rem;
  padding-right: 0.75rem;
  vertical-align: middle;
  /* Prevent adjacent cell content from overlapping when row is hovered/selected */
  isolation: isolate;
  box-shadow: -6px 0 8px -2px rgba(0, 0, 0, 0.06);
}

[data-bs-theme="dark"] .d2k-action-col-sticky {
  box-shadow: -6px 0 8px -2px rgba(0, 0, 0, 0.35);
}

.d2k-action-col-sticky .d-flex {
  gap: 0.5rem;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: nowrap;
}

/* Align form (Delete) with anchor (Edit) - form uses inline-flex so it matches flex row alignment */
.d2k-action-col-sticky form.d-inline-flex {
  display: inline-flex;
  align-items: center;
  margin: 0;
  vertical-align: middle;
}

.d2k-action-col-sticky .btn-sm {
  min-width: 4rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.8125rem;
}

/* Ensure proper background for sticky column in light mode */
[data-bs-theme="light"] .d2k-action-col-sticky {
  background: #fff;
  box-shadow: -4px 0 8px rgba(0, 0, 0, 0.08);
}

[data-bs-theme="light"] .table tbody .d2k-action-col-sticky {
  background: #fff;
}

[data-bs-theme="light"] .table tbody tr:hover .d2k-action-col-sticky {
  background: #f5f4ff;
}

[data-bs-theme="light"] .table tbody tr:nth-child(even) .d2k-action-col-sticky {
  background: #f8f9fa;
}

[data-bs-theme="light"] .table tbody tr:nth-child(even):hover .d2k-action-col-sticky {
  background: #f5f4ff;
}

/* Ensure proper background for sticky column in dark mode */
[data-bs-theme="dark"] .d2k-action-col-sticky {
  background: #2b2c40;
  box-shadow: -4px 0 8px rgba(0, 0, 0, 0.4);
}

[data-bs-theme="dark"] .table tbody .d2k-action-col-sticky {
  background: #2b2c40;
}

[data-bs-theme="dark"] .table tbody tr:hover .d2k-action-col-sticky {
  background: #323249;
}

[data-bs-theme="dark"] .table tbody tr:nth-child(even) .d2k-action-col-sticky {
  background: #323249;
}

[data-bs-theme="dark"] .table tbody tr:nth-child(even):hover .d2k-action-col-sticky {
  background: #3a3b52;
}

/* Sticky header for action column */
.d2k-table-wrapper .table thead .d2k-action-col-sticky {
  background: inherit;
  z-index: 21;
}

[data-bs-theme="light"] .d2k-table-wrapper .table thead .d2k-action-col-sticky {
  background: #f5f5f9;
  box-shadow: -4px 0 8px rgba(0, 0, 0, 0.08);
}

[data-bs-theme="dark"] .d2k-table-wrapper .table thead .d2k-action-col-sticky {
  background: #323249;
  box-shadow: -4px 0 8px rgba(0, 0, 0, 0.4);
}

/* Clip data cells so content never overlaps the sticky action column */
.d2k-table-wrapper .table tbody td:not(.d2k-action-col-sticky) {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Selected/active row - sticky column opaque to match row */
[data-bs-theme="light"] .table tbody tr.table-active .d2k-action-col-sticky {
  background: #ebeafe !important;
}

[data-bs-theme="dark"] .table tbody tr.table-active .d2k-action-col-sticky {
  background: #3d3e58 !important;
}

[data-bs-theme="light"] .table {
  background: #fff;
}

[data-bs-theme="dark"] .table {
  background: #2b2c40;
}

/* Table header sticky positioning - moved to .d2k-table-wrapper .table thead above */

[data-bs-theme="light"] .d2k-table-wrapper .table thead {
  background: #f5f5f9;
}

[data-bs-theme="dark"] .d2k-table-wrapper .table thead {
  background: #323249;
}

/* Ensure header cells have proper background for sticky */
[data-bs-theme="light"] .d2k-table-wrapper .table thead th {
  background: #f5f5f9;
}

[data-bs-theme="dark"] .d2k-table-wrapper .table thead th {
  background: #323249;
}

.table thead th {
  border-bottom: 1px solid;
  font-weight: 600;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 1rem 1.25rem;
  white-space: nowrap;
  color: #a1acb8;
}

[data-bs-theme="light"] .table thead th {
  border-bottom-color: rgba(60, 72, 88, 0.08);
  color: #697a8d;
}

[data-bs-theme="dark"] .table thead th {
  border-bottom-color: rgba(255, 255, 255, 0.08);
  color: #a1acb8;
}

.table tbody tr {
  transition: all 0.2s ease;
  border-bottom: 1px solid;
}

[data-bs-theme="light"] .table tbody tr {
  border-bottom-color: rgba(60, 72, 88, 0.05);
}

[data-bs-theme="dark"] .table tbody tr {
  border-bottom-color: rgba(255, 255, 255, 0.05);
}

.table tbody tr:hover {
  background: rgba(105, 108, 255, 0.04);
}

[data-bs-theme="dark"] .table tbody tr:hover {
  background: rgba(105, 108, 255, 0.08);
}

.table tbody td {
  padding: 1rem 1.25rem;
  vertical-align: middle;
  font-size: 0.9375rem;
}

[data-bs-theme="light"] .table tbody td {
  color: #566a7f;
}

[data-bs-theme="dark"] .table tbody td {
  color: #a1acb8;
}

/* ============================================================================
   Page Titles & Toolbars - Sneat Style
   ============================================================================ */

.d2k-toolbar-border {
  border-bottom: 1px solid;
  position: relative;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
}

[data-bs-theme="light"] .d2k-toolbar-border {
  border-bottom-color: rgba(60, 72, 88, 0.08);
}

[data-bs-theme="dark"] .d2k-toolbar-border {
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

.d2k-page-title {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.5px;
  margin-bottom: 0.125rem;
}

[data-bs-theme="light"] .d2k-page-title {
  color: #566a7f;
}

[data-bs-theme="dark"] .d2k-page-title {
  color: #a1acb8;
}

.d2k-page-subtitle {
  font-size: 0.8125rem;
  font-weight: 400;
  margin: 0;
}

[data-bs-theme="light"] .d2k-page-subtitle {
  color: #a1acb8;
}

[data-bs-theme="dark"] .d2k-page-subtitle {
  color: #677788;
}

.d2k-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  font-weight: 500;
  position: relative;
}

.d2k-btn-icon {
  font-size: 1.125rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  font-weight: 600;
  transition: all 0.2s ease;
  position: relative;
}

/* Enhanced Plus Icon Design - CSS-based */
.d2k-icon-plus {
  font-size: 0;
  width: 1.125rem;
  height: 1.125rem;
}

.d2k-icon-plus::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 2.5px;
  background: currentColor;
  border-radius: 2px;
  transition: all 0.2s ease;
  box-shadow: 0 0 0 0 currentColor;
}

.d2k-icon-plus::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2.5px;
  height: 100%;
  background: currentColor;
  border-radius: 2px;
  transition: all 0.2s ease;
  box-shadow: 0 0 0 0 currentColor;
}

/* Better icon styling for primary buttons */
.btn-primary .d2k-btn-icon {
  color: #fff;
}

.btn-primary .d2k-icon-plus::before,
.btn-primary .d2k-icon-plus::after {
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.btn-primary:hover .d2k-icon-plus::before {
  transform: translate(-50%, -50%) rotate(90deg);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.btn-primary:hover .d2k-icon-plus::after {
  transform: translate(-50%, -50%) rotate(90deg);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

[data-bs-theme="dark"] .btn-primary .d2k-icon-plus::before,
[data-bs-theme="dark"] .btn-primary .d2k-icon-plus::after {
  background: #fff;
  box-shadow: 0 1px 2px rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .btn-primary:hover .d2k-icon-plus::before,
[data-bs-theme="dark"] .btn-primary:hover .d2k-icon-plus::after {
  box-shadow: 0 2px 4px rgba(255, 255, 255, 0.2);
}

/* Icon styling for outline buttons */
.btn-outline-primary .d2k-btn-icon {
  color: #696cff;
  transition: all 0.2s ease;
}

.btn-outline-primary:hover .d2k-btn-icon {
  color: #fff;
  transform: scale(1.1);
}

[data-bs-theme="dark"] .btn-outline-primary .d2k-btn-icon {
  color: #8b8dff;
}

[data-bs-theme="dark"] .btn-outline-primary:hover .d2k-btn-icon {
  color: #fff;
}

/* ============================================================================
   Form Labels & Inputs - Sneat Style
   ============================================================================ */

.form-label {
  font-weight: 500;
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
  letter-spacing: 0;
}

[data-bs-theme="light"] .form-label {
  color: #566a7f;
}

[data-bs-theme="dark"] .form-label {
  color: #a1acb8;
}

.form-label .text-danger {
  font-weight: 600;
  margin-left: 0.25rem;
}

/* Badges - Sneat Style */
.badge {
  font-weight: 500;
  padding: 0.35rem 0.65rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  letter-spacing: 0;
}

[data-bs-theme="light"] .badge {
  box-shadow: 0 0.125rem 0.25rem rgba(67, 89, 113, 0.08);
}

[data-bs-theme="dark"] .badge {
  box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.2);
}

/* Empty States */
.text-muted {
  font-style: normal;
}

[data-bs-theme="light"] .text-muted {
  color: #a1acb8 !important;
}

[data-bs-theme="dark"] .text-muted {
  color: #677788 !important;
}

/* Pagination - Sneat Style */
.pagination {
  gap: 0.25rem;
}

.page-link {
  border-radius: 0.375rem;
  border: 1px solid;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  transition: all 0.2s ease;
  font-size: 0.9375rem;
}

[data-bs-theme="light"] .page-link {
  border-color: #d9dee3;
  color: #697a8d;
  background: #fff;
}

[data-bs-theme="dark"] .page-link {
  border-color: rgba(255, 255, 255, 0.1);
  color: #a1acb8;
  background: #2b2c40;
}

.page-link:hover {
  background: rgba(105, 108, 255, 0.08);
  border-color: #696cff;
  color: #696cff;
}

[data-bs-theme="dark"] .page-link:hover {
  background: rgba(105, 108, 255, 0.15);
  border-color: #8b8dff;
  color: #8b8dff;
}

.page-item.active .page-link {
  font-weight: 600;
  background: #696cff;
  border-color: #696cff;
  color: #fff;
  box-shadow: 0 0.125rem 0.25rem rgba(105, 108, 255, 0.4);
}

[data-bs-theme="dark"] .page-item.active .page-link {
  background: #8b8dff;
  border-color: #8b8dff;
}

/* Alerts - Sneat Style */
.alert {
  border-radius: 0.5rem;
  border-left: 4px solid;
  box-shadow: 0 0.125rem 0.25rem rgba(67, 89, 113, 0.08);
  padding: 1rem 1.25rem;
  font-weight: 400;
}

.alert-success {
  border-left-color: #71dd37;
  background: rgba(113, 221, 55, 0.1);
  color: #56ca00;
}

[data-bs-theme="dark"] .alert-success {
  background: rgba(113, 221, 55, 0.15);
  color: #85e248;
  border-left-color: #85e248;
}

.alert-danger {
  border-left-color: #ff3e1d;
  background: rgba(255, 62, 29, 0.1);
  color: #ff3e1d;
}

[data-bs-theme="dark"] .alert-danger {
  background: rgba(255, 62, 29, 0.15);
  color: #ff6b4d;
  border-left-color: #ff6b4d;
}

/* ============================================================================
   Existing D2K Helpers
   ============================================================================ */

/* Zero-JS live label swap for boolean-ish inputs (switch/yn/int01/checkbox). */
.d2k-bool-text .d2k-on { display: none; }
.d2k-bool-input:checked ~ .d2k-bool-text .d2k-on { display: inline; }
.d2k-bool-input:checked ~ .d2k-bool-text .d2k-off { display: none; }

.d2k-clickable { cursor: pointer; user-select: none; }

/* layout.inputGroup fields need a real wrapper for field-rule hooks without breaking Bootstrap sizing */
.input-group > .d2k-input-group-field {
  position: relative;
  flex: 1 1 auto;
  width: 1%;
  min-width: 0;
}
.input-group > .d2k-input-group-field > .form-control,
.input-group > .d2k-input-group-field > .form-select,
.input-group > .d2k-input-group-field > .input-group,
.input-group > .d2k-input-group-field > .d2k-date-dropdown {
  width: 100%;
  min-width: 0;
}
.input-group > .d2k-input-group-field:not(:first-child) > .form-control,
.input-group > .d2k-input-group-field:not(:first-child) > .form-select {
  margin-left: calc(var(--bs-border-width) * -1);
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}
.input-group > .d2k-input-group-field:not(:last-child) > .form-control,
.input-group > .d2k-input-group-field:not(:last-child) > .form-select {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

/* Date dropdown: ensure Day/Month/Year selects are usable (Bootstrap input-group can squash them) */
.d2k-date-dropdown {
  display: flex;
  flex-wrap: nowrap;
}
.d2k-date-dropdown .d2k-date-day { min-width: 4rem; flex: 0 0 auto; }
.d2k-date-dropdown .d2k-date-month { min-width: 7rem; flex: 1 1 auto; }  /* Month names need more space */
.d2k-date-dropdown .d2k-date-year { min-width: 5rem; flex: 0 0 auto; }
.d2k-date-dropdown.is-invalid .form-select { border-color: var(--bs-form-invalid-border-color, #dc3545); }
.d2k-field-invalid .form-control,
.d2k-field-invalid .form-select {
  border-color: var(--bs-form-invalid-border-color, #dc3545);
}

/* Grid helpers */
.d2k-errors-col { width: 30%; }
.d2k-col-action { width: 1%; white-space: nowrap; }
.d2k-phone-cc {
  min-width: 180px;
  max-width: 240px;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

/* Layout helpers */
.d2k-login-container { max-width: 520px; }

/* Autocomplete LOV (d2k.js) */
.d2k-ac { position: relative; }
.d2k-ac-results {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  z-index: 1050;
  background: #fff;
  border: 1px solid rgba(60, 72, 88, 0.08);
  border-radius: 0.375rem;
  max-height: 280px;
  overflow: auto;
  display: none;
  box-shadow: 0 0.5rem 1rem rgba(67, 89, 113, 0.15);
}

[data-bs-theme="dark"] .d2k-ac-results {
  background: #2b2c40;
  border-color: rgba(255, 255, 255, 0.08);
}

.d2k-ac-results .d2k-ac-item {
  padding: 0.625rem 0.875rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(60, 72, 88, 0.05);
  transition: background-color 0.15s ease;
}

[data-bs-theme="dark"] .d2k-ac-results .d2k-ac-item {
  border-bottom-color: rgba(255, 255, 255, 0.05);
}

.d2k-ac-results .d2k-ac-item:last-child { border-bottom: 0; }
.d2k-ac-results .d2k-ac-item:hover { 
  background: rgba(105, 108, 255, 0.08);
}

[data-bs-theme="dark"] .d2k-ac-results .d2k-ac-item:hover {
  background: rgba(105, 108, 255, 0.12);
}

.d2k-ac-results .d2k-ac-muted { color: #a1acb8; }

.d2k-ac-chips { margin-top: 0.5rem; display: flex; flex-wrap: wrap; gap: 0.375rem; }
.d2k-ac-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #f5f5f9;
  border: 1px solid rgba(60, 72, 88, 0.08);
  border-radius: 999px;
  padding: 0.25rem 0.625rem;
  font-size: 0.875rem;
}

[data-bs-theme="dark"] .d2k-ac-chip {
  background: #323249;
  border-color: rgba(255, 255, 255, 0.1);
}

.d2k-ac-chip button {
  border: 0;
  background: transparent;
  padding: 0;
  line-height: 1;
  font-size: 1rem;
  cursor: pointer;
  color: #697a8d;
}

[data-bs-theme="dark"] .d2k-ac-chip button {
  color: #a1acb8;
}

.d2k-ac-chip button:hover { color: #566a7f; }

[data-bs-theme="dark"] .d2k-ac-chip button:hover { color: #fff; }

/* ============================================================================
   LOV multi-select (checklist / dualList)
   ============================================================================ */
.d2k-lov-multiui .d2k-lov-body {
  border: 1px solid var(--d2k-border);
  border-radius: 0.5rem;
  padding: 0.5rem;
  max-height: 22rem;
  overflow: auto;
  background: var(--bs-body-bg);
}

[data-bs-theme="dark"] .d2k-lov-multiui .d2k-lov-body {
  border-color: var(--d2k-border-dark);
}

.d2k-lov-check-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.25rem;
  border-radius: 0.375rem;
  cursor: pointer;
  user-select: none;
  margin: 0;
}

.d2k-lov-check-item:hover {
  background: var(--d2k-primary-muted);
}

.d2k-lov-check-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.d2k-lov-dual-wrap {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.75rem;
  align-items: start;
}

.d2k-lov-dual-controls {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-top: 1.4rem;
}

.d2k-lov-dual-col select {
  width: 100%;
}

/* LOV Icon – CSS “list picker” (list + chevron), elegant in both themes */
.d2k-lov-icon,
.d2k-lov-icon-small {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  color: inherit;
  flex-shrink: 0;
}

.d2k-lov-icon {
  width: 1.5rem;
  height: 1.5rem;
}

.d2k-lov-icon-small {
  width: 1.125rem;
  height: 1.125rem;
}

/* Three horizontal bars (list) + chevron down (pick) */
.d2k-lov-icon::before,
.d2k-lov-icon-small::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0.35em;
  height: 0.12em;
  background: currentColor;
  border-radius: 1px;
  box-shadow:
    0 0.35em 0 currentColor,
    0 0.7em 0 currentColor;
  opacity: 0.9;
}

.d2k-lov-icon-small::before {
  height: 0.1em;
  right: 0.28em;
  box-shadow:
    0 0.28em 0 currentColor,
    0 0.56em 0 currentColor;
}

/* Chevron down (picker) */
.d2k-lov-icon::after,
.d2k-lov-icon-small::after {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 0.28em solid transparent;
  border-right: 0.28em solid transparent;
  border-top: 0.32em solid currentColor;
  opacity: 0.95;
}

.d2k-lov-icon-small::after {
  border-left-width: 0.2em;
  border-right-width: 0.2em;
  border-top-width: 0.24em;
}

/* Light mode: subtle contrast */
[data-bs-theme="light"] .d2k-lov-icon::before,
[data-bs-theme="light"] .d2k-lov-icon::after,
[data-bs-theme="light"] .d2k-lov-icon-small::before,
[data-bs-theme="light"] .d2k-lov-icon-small::after {
  color: #566a7f;
}

.d2k-lov-btn:hover .d2k-lov-icon-small::before,
.d2k-lov-btn:hover .d2k-lov-icon-small::after,
.d2k-lov-btn:focus .d2k-lov-icon-small::before,
.d2k-lov-btn:focus .d2k-lov-icon-small::after {
  color: inherit;
}

[data-bs-theme="dark"] .d2k-lov-icon::before,
[data-bs-theme="dark"] .d2k-lov-icon::after,
[data-bs-theme="dark"] .d2k-lov-icon-small::before,
[data-bs-theme="dark"] .d2k-lov-icon-small::after {
  color: #a1acb8;
}

[data-bs-theme="dark"] .d2k-lov-body .d2k-lov-icon::before,
[data-bs-theme="dark"] .d2k-lov-body .d2k-lov-icon::after {
  color: #8b8dff;
}

.d2k-lov-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  padding: 0.5rem;
}

/* LOV Table - Compact */
.d2k-lov-table {
  margin-bottom: 1rem;
}

/* Prevent body/html horizontal scroll for wide tables */
body.d2k-app-body {
  overflow-x: hidden;
  max-width: 100vw;
}

html {
  overflow-x: hidden;
  max-width: 100%;
}

/* ============================================================================
   Mobile: icon-only action buttons and layout fixes
   ============================================================================ */

/* Desktop: show label, hide icon */
.d2k-btn-action .d2k-action-icon {
  display: none;
}

.d2k-btn-action .d2k-action-label {
  display: inline;
}

/* Mobile: show icon only, hide label to save space */
@media (max-width: 768px) {
  .d2k-lov-body > section {
    padding: 1rem;
  }
  
  .d2k-main-content {
    padding: 0.1rem !important;
  }
  
  .d2k-content-card .card-body {
    padding: 0.25rem !important;
  }
  
  .d2k-table-wrapper {
    -webkit-overflow-scrolling: touch;
  }
  
  /* Icon-only row actions: 44px touch target (UI best practice), 16px icon */
  .d2k-row-actions .d2k-btn-action .d2k-action-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem; /* 16px icon */
    line-height: 1;
  }
  
  .d2k-row-actions .d2k-btn-action .d2k-action-label {
    display: none;
  }
  
  /* Touch-friendly: min 44x44px click area; icon stays 16px so it looks compact */
  .d2k-row-actions .d2k-btn-action {
    min-width: 2.75rem;  /* 44px */
    min-height: 2.75rem;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* Fully opaque so no text shows through */
    background-color: #fff !important;
    border: 1px solid #d9dee3;
  }
  
  .d2k-row-actions .d2k-btn-action.btn-outline-danger {
    background-color: #fff !important;
    border-color: #ff3e1d;
  }
  
  .d2k-row-actions .d2k-btn-action:hover {
    background-color: #f5f5f9 !important;
  }
  
  .d2k-row-actions .d2k-btn-action.btn-outline-danger:hover {
    background-color: #fff5f3 !important;
  }
  
  [data-bs-theme="dark"] .d2k-row-actions .d2k-btn-action {
    background-color: #2b2c40 !important;
    border-color: rgba(255, 255, 255, 0.15);
  }
  
  [data-bs-theme="dark"] .d2k-row-actions .d2k-btn-action.btn-outline-danger {
    background-color: #2b2c40 !important;
    border-color: #ff3e1d;
  }
  
  [data-bs-theme="dark"] .d2k-row-actions .d2k-btn-action:hover {
    background-color: #323249 !important;
  }
  
  [data-bs-theme="dark"] .d2k-row-actions .d2k-btn-action.btn-outline-danger:hover {
    background-color: #3d2020 !important;
  }
  
  .d2k-action-col-sticky {
    min-width: 6.25rem; /* 2×44px + gap */
    width: 6.25rem;
    padding-left: 0.25rem;
    padding-right: 0.25rem;
    z-index: 12;
  }
  
  .d2k-row-actions {
    gap: 0.25rem;
  }
  
  /* Table: truncation and strict clip so no overlap with action column */
  .d2k-table-wrapper .table thead th:not(.d2k-action-col-sticky) {
    max-width: 6em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  
  .d2k-table-wrapper .table tbody td:not(.d2k-action-col-sticky) {
    max-width: 8em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  
  /* Fully opaque backgrounds only (no rgba) so no transparency/bleed-through */
  [data-bs-theme="light"] .d2k-table-wrapper .table tbody .d2k-action-col-sticky {
    background: #fff !important;
  }
  [data-bs-theme="light"] .d2k-table-wrapper .table tbody tr:hover .d2k-action-col-sticky {
    background: #f5f4ff !important;
  }
  [data-bs-theme="light"] .d2k-table-wrapper .table tbody tr:nth-child(even) .d2k-action-col-sticky {
    background: #f8f9fa !important;
  }
  [data-bs-theme="light"] .d2k-table-wrapper .table tbody tr:nth-child(even):hover .d2k-action-col-sticky {
    background: #f5f4ff !important;
  }
  [data-bs-theme="light"] .d2k-table-wrapper .table tbody tr.table-active .d2k-action-col-sticky {
    background: #ebeafe !important;
  }
  [data-bs-theme="dark"] .d2k-table-wrapper .table tbody .d2k-action-col-sticky {
    background: #2b2c40 !important;
  }
  [data-bs-theme="dark"] .d2k-table-wrapper .table tbody tr:hover .d2k-action-col-sticky {
    background: #323249 !important;
  }
  [data-bs-theme="dark"] .d2k-table-wrapper .table tbody tr:nth-child(even) .d2k-action-col-sticky {
    background: #323249 !important;
  }
  [data-bs-theme="dark"] .d2k-table-wrapper .table tbody tr:nth-child(even):hover .d2k-action-col-sticky {
    background: #3a3b52 !important;
  }
  [data-bs-theme="dark"] .d2k-table-wrapper .table tbody tr.table-active .d2k-action-col-sticky {
    background: #3d3e58 !important;
  }
  
  /* Toolbar: stack or shorten on mobile */
  .d2k-toolbar-border {
    flex-wrap: wrap;
    gap: 0.75rem;
  }
  
  .d2k-action-btn .d2k-btn-icon {
    margin-right: 0.25rem;
  }
  
  .d2k-filters-card {
    padding: 0.75rem 1rem !important;
  }
  
  .d2k-filters-card .row.g-2 {
    margin-bottom: 0;
  }
}

/* Very small screens - compact title and toolbar */
@media (max-width: 576px) {
  .d2k-page-title {
    font-size: 1.25rem;
  }
  
  .d2k-toolbar-border .d-flex.gap-2 {
    width: 100%;
    justify-content: flex-start;
  }
}

.d2k-html-editor-wrap .wysi-wrapper {
  width: 100%;
}

.d2k-html-editor-wrap .wysi-editor {
  min-height: 260px;
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
}

.d2k-html-editor-wrap .wysi-editor table {
  width: 100%;
  border-collapse: collapse;
}

.d2k-html-editor-wrap .wysi-editor td,
.d2k-html-editor-wrap .wysi-editor th {
  min-width: 4rem;
  padding: 0.5rem;
  border: 1px solid var(--bs-border-color);
}

.d2k-html-editor-readonly .wysi-toolbar {
  display: none;
}

.d2k-html-editor-readonly .wysi-editor {
  min-height: 0;
  padding: 0.875rem 1rem;
  border-top: 1px solid var(--bs-border-color);
  background: var(--bs-secondary-bg);
}

/* ============================================================================
   MDMS manager toolbars
   ============================================================================ */
.d2k-mdms-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
}

.d2k-mdms-toolbar-query {
  flex: 1 1 34rem;
  margin: 0;
}

.d2k-mdms-toolbar-danger {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  flex: 0 0 auto;
  margin: 0;
}

.d2k-mdms-clear-btn {
  white-space: nowrap;
}

.d2k-mdms-toolbar-col--submit {
  display: flex;
  align-items: flex-end;
}

.d2k-mdms-tabs {
  gap: 0.125rem;
}

/* ============================================================================
   Master screen help
   ============================================================================ */
.d2k-help-panel {
  border-left: 0.25rem solid var(--bs-info);
}

.d2k-help-panel-info {
  border-left-color: var(--bs-info);
}

.d2k-help-panel-warning {
  border-left-color: var(--bs-warning);
}

.d2k-help-panel-success {
  border-left-color: var(--bs-success);
}

.d2k-help-panel-neutral {
  border-left-color: var(--bs-secondary);
}

.d2k-help-content > :last-child {
  margin-bottom: 0;
}

.d2k-help-content ul,
.d2k-help-content ol {
  padding-left: 1.25rem;
}

@media (max-width: 767.98px) {
  .d2k-mdms-toolbar-query,
  .d2k-mdms-toolbar-danger {
    flex: 1 1 100%;
  }

  .d2k-mdms-toolbar-danger,
  .d2k-mdms-clear-btn {
    width: 100%;
  }
}
