/* MyTrenkwalder Custom Styles
   Primary Color: #515D82
   ================================ */

:root {
  /* Override Bootstrap/Metronic primary colors */
  --bs-primary: #515D82;
  --bs-primary-rgb: 81, 93, 130;
  --bs-primary-hover: #414b6a;
  --bs-primary-active: #374059;
  --bs-primary-light: #e8eaf0;
  --bs-primary-light-rgb: 232, 234, 240;
  --bs-primary-inverse: #ffffff;
}

/* Primary Button */
.btn-primary {
  background-color: #515D82 !important;
  border-color: #515D82 !important;
}

.btn-primary:hover,
.btn-primary:focus {
  background-color: #414b6a !important;
  border-color: #414b6a !important;
}

.btn-primary:active,
.btn-primary.active {
  background-color: #374059 !important;
  border-color: #374059 !important;
}

/* Primary Text/Links */
.text-primary {
  color: #515D82 !important;
}

a.text-primary:hover {
  color: #414b6a !important;
}

.link-primary {
  color: #515D82 !important;
}

.link-primary:hover {
  color: #414b6a !important;
}

/* Background Primary */
.bg-primary {
  background-color: #515D82 !important;
}

.bg-light-primary {
  background-color: #e8eaf0 !important;
}

/* Border Primary */
.border-primary {
  border-color: #515D82 !important;
}

/* Active menu item */
.menu-state-primary .menu-item .menu-link.active,
.menu-state-primary .menu-item.show > .menu-link {
  color: #515D82 !important;
}

.menu-state-primary .menu-item .menu-link.active .menu-icon i,
.menu-state-primary .menu-item.show > .menu-link .menu-icon i {
  color: #515D82 !important;
}

/* Sidebar active state */
.app-sidebar .menu .menu-item .menu-link.active {
  background-color: #e8eaf0 !important;
}

.app-sidebar .menu .menu-item .menu-link.active .menu-title {
  color: #515D82 !important;
}

.app-sidebar .menu .menu-item .menu-link.active .menu-icon i {
  color: #515D82 !important;
}

/* Form elements focus */
.form-control:focus,
.form-select:focus {
  border-color: #515D82 !important;
  box-shadow: 0 0 0 0.25rem rgba(81, 93, 130, 0.25) !important;
}

/* Checkbox/Radio */
.form-check-input:checked {
  background-color: #515D82 !important;
  border-color: #515D82 !important;
}

/* SVG icons in primary context */
.svg-icon-primary svg [fill]:not(.permanent):not(g) {
  fill: #515D82 !important;
}

/* ================================
   Global Search Modal (Ctrl+K)
   ================================ */
#globalSearchModal .modal-content {
  border: 0;
  box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.175);
}

#globalSearchModal .modal-body::-webkit-scrollbar {
  width: 5px;
}

#globalSearchModal .modal-body::-webkit-scrollbar-thumb {
  background: #dbdfe9;
  border-radius: 5px;
}

/* Search result items */
.search-result-item {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 0.475rem;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.search-result-item:hover,
.search-result-item.active {
  background-color: #f1f1f4;
}

.search-result-item .symbol {
  flex-shrink: 0;
}

.search-result-item.active .symbol .symbol-label {
  background-color: #515D82 !important;
  color: #fff !important;
}

/* ================================
   Dark Mode Overrides
   ================================ */
[data-bs-theme=dark] {
  --bs-primary: #7B89B3;
  --bs-primary-rgb: 123, 137, 179;
  --bs-primary-hover: #8e9ac2;
  --bs-primary-active: #6b78a3;
  --bs-primary-light: #2a2e3d;
  --bs-primary-light-rgb: 42, 46, 61;
  --bs-primary-inverse: #ffffff;
}

/* Dark mode buttons */
[data-bs-theme=dark] .btn-primary {
  background-color: #7B89B3 !important;
  border-color: #7B89B3 !important;
}

[data-bs-theme=dark] .btn-primary:hover,
[data-bs-theme=dark] .btn-primary:focus {
  background-color: #8e9ac2 !important;
  border-color: #8e9ac2 !important;
}

[data-bs-theme=dark] .btn-primary:active,
[data-bs-theme=dark] .btn-primary.active {
  background-color: #6b78a3 !important;
  border-color: #6b78a3 !important;
}

/* Dark mode text/links */
[data-bs-theme=dark] .text-primary {
  color: #7B89B3 !important;
}

[data-bs-theme=dark] a.text-primary:hover {
  color: #8e9ac2 !important;
}

[data-bs-theme=dark] .link-primary {
  color: #7B89B3 !important;
}

[data-bs-theme=dark] .link-primary:hover {
  color: #8e9ac2 !important;
}

/* Dark mode backgrounds */
[data-bs-theme=dark] .bg-primary {
  background-color: #7B89B3 !important;
}

[data-bs-theme=dark] .bg-light-primary {
  background-color: #2a2e3d !important;
}

/* Dark mode border */
[data-bs-theme=dark] .border-primary {
  border-color: #7B89B3 !important;
}

/* Dark mode sidebar */
[data-bs-theme=dark] .app-sidebar {
  background-color: #1e1e2d !important;
  border-right: 1px solid #2d2d3f;
}

[data-bs-theme=dark] .app-sidebar .menu .menu-item .menu-link.active {
  background-color: #2a2e3d !important;
}

[data-bs-theme=dark] .app-sidebar .menu .menu-item .menu-link.active .menu-title {
  color: #7B89B3 !important;
}

[data-bs-theme=dark] .app-sidebar .menu .menu-item .menu-link.active .menu-icon i {
  color: #7B89B3 !important;
}

[data-bs-theme=dark] .app-sidebar .menu .menu-item .menu-link .menu-title {
  color: #9899ac !important;
}

[data-bs-theme=dark] .app-sidebar .menu .menu-item .menu-link .menu-icon i {
  color: #6c6d80 !important;
}

[data-bs-theme=dark] .app-sidebar .menu .menu-item .menu-link:hover .menu-title {
  color: #ffffff !important;
}

[data-bs-theme=dark] .app-sidebar .menu .menu-item .menu-link:hover .menu-icon i {
  color: #7B89B3 !important;
}

/* Dark mode sidebar logo - invert for dark bg */
[data-bs-theme=dark] .app-sidebar-logo-default {
  filter: brightness(0) invert(1);
}

/* Dark mode sidebar footer sign-out button */
[data-bs-theme=dark] .app-sidebar-footer .btn-sign-out {
  background-color: #2a2e3d !important;
  border-color: #2a2e3d !important;
}

[data-bs-theme=dark] .app-sidebar-footer .btn-sign-out:hover {
  background-color: #7B89B3 !important;
  border-color: #7B89B3 !important;
}

/* Dark mode sidebar toggle button */
[data-bs-theme=dark] .app-sidebar-toggle {
  background-color: #2a2e3d !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3) !important;
}

/* Dark mode form elements */
[data-bs-theme=dark] .form-control:focus,
[data-bs-theme=dark] .form-select:focus {
  border-color: #7B89B3 !important;
  box-shadow: 0 0 0 0.25rem rgba(123, 137, 179, 0.25) !important;
}

[data-bs-theme=dark] .form-check-input:checked {
  background-color: #7B89B3 !important;
  border-color: #7B89B3 !important;
}

/* Dark mode search modal */
[data-bs-theme=dark] #globalSearchModal .modal-content {
  box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.5);
}

[data-bs-theme=dark] #globalSearchModal .modal-body::-webkit-scrollbar-thumb {
  background: #3f4254;
}

[data-bs-theme=dark] .search-result-item:hover,
[data-bs-theme=dark] .search-result-item.active {
  background-color: #2a2e3d;
}

[data-bs-theme=dark] .search-result-item.active .symbol .symbol-label {
  background-color: #7B89B3 !important;
  color: #fff !important;
}

/* Dark mode scrollbar */
[data-bs-theme=dark] ::-webkit-scrollbar {
  width: 6px;
}

[data-bs-theme=dark] ::-webkit-scrollbar-track {
  background: #1b1b29;
}

[data-bs-theme=dark] ::-webkit-scrollbar-thumb {
  background: #3f4254;
  border-radius: 3px;
}

[data-bs-theme=dark] ::-webkit-scrollbar-thumb:hover {
  background: #565674;
}

/* Dark mode SVG icons */
[data-bs-theme=dark] .svg-icon-primary svg [fill]:not(.permanent):not(g) {
  fill: #7B89B3 !important;
}

/* Theme toggle icon visibility */
[data-bs-theme=dark] .theme-light-show {
  display: none !important;
}

[data-bs-theme=light] .theme-dark-show,
:root .theme-dark-show {
  display: none !important;
}

[data-bs-theme=dark] .theme-dark-show {
  display: inline-flex !important;
}

/* Dark mode page heading */
[data-bs-theme=dark] .page-heading {
  color: #cdcde4 !important;
}

/* ================================
   Mobile Bottom Navigation
   ================================ */
.app-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  background-color: #ffffff;
  border-top: 1px solid #e4e6ef;
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.06);
}

.app-bottom-nav .bottom-nav-item {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 4px;
  color: #7e8299;
  text-decoration: none;
  background: transparent;
  border: 0;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.2;
  min-height: 56px;
  transition: color 0.15s ease;
  cursor: pointer;
}

.app-bottom-nav .bottom-nav-item:hover,
.app-bottom-nav .bottom-nav-item:focus {
  color: #515D82;
  outline: none;
}

.app-bottom-nav .bottom-nav-item.active {
  color: #515D82;
}

.app-bottom-nav .bottom-nav-item .ki-duotone {
  font-size: 1.5rem;
  line-height: 1;
}

.app-bottom-nav .bottom-nav-item.active .ki-duotone {
  color: #515D82;
}

.app-bottom-nav .bottom-nav-label {
  display: block;
  white-space: nowrap;
}

.app-bottom-nav .bottom-nav-icon-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.app-bottom-nav .bottom-nav-badge {
  position: absolute;
  top: -4px;
  right: -8px;
  font-size: 9px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
}

/* Content padding so bottom nav doesn't cover content (mobile only) */
@media (max-width: 991.98px) {
  #kt_app_main {
    padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px));
  }
}

/* Dark mode bottom nav */
[data-bs-theme=dark] .app-bottom-nav {
  background-color: #1e1e2d;
  border-top-color: #2d2d3f;
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.3);
}

[data-bs-theme=dark] .app-bottom-nav .bottom-nav-item {
  color: #9899ac;
}

[data-bs-theme=dark] .app-bottom-nav .bottom-nav-item:hover,
[data-bs-theme=dark] .app-bottom-nav .bottom-nav-item:focus,
[data-bs-theme=dark] .app-bottom-nav .bottom-nav-item.active {
  color: #7B89B3;
}

[data-bs-theme=dark] .app-bottom-nav .bottom-nav-item.active .ki-duotone {
  color: #7B89B3;
}

/* ================================
   Mobile Menu Sheet
   ================================ */
.mobile-menu-sheet {
  position: fixed;
  inset: 0;
  z-index: 1060;
  visibility: hidden;
  transition: visibility 0s linear 0.3s;
}

.mobile-menu-sheet.show {
  visibility: visible;
  transition: visibility 0s;
}

.mobile-menu-backdrop {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.mobile-menu-sheet.show .mobile-menu-backdrop {
  opacity: 1;
}

.mobile-menu-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 92vh;
  background-color: #ffffff;
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.18);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.mobile-menu-sheet.show .mobile-menu-panel {
  transform: translateY(0);
}

.mobile-menu-panel.dragging {
  transition: none;
}

.mobile-menu-drag-area {
  flex-shrink: 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.mobile-menu-drag-handle {
  display: flex;
  justify-content: center;
  padding: 8px 0 6px;
}

.mobile-menu-drag-handle::before {
  content: '';
  display: block;
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background-color: #d6d6e0;
  transition: background-color 0.15s ease, width 0.15s ease;
}

.mobile-menu-panel.dragging .mobile-menu-drag-handle::before {
  background-color: #a1a5b7;
  width: 50px;
}

.mobile-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1.25rem 0.875rem;
  border-bottom: 1px solid #eff2f5;
  flex-shrink: 0;
}

.mobile-menu-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: #181c32;
}

.mobile-menu-close {
  background: transparent;
  border: 0;
  padding: 0.4rem;
  color: #7e8299;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: background-color 0.15s ease;
}

.mobile-menu-close:hover,
.mobile-menu-close:focus {
  background-color: #f4f6fa;
  outline: none;
}

.mobile-menu-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding-bottom: 0.5rem;
  -webkit-overflow-scrolling: touch;
}

.mobile-menu-user {
  display: flex;
  align-items: center;
  padding: 1rem 1.25rem;
  background-color: #f9fafb;
}

.mobile-menu-user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.mobile-menu-user-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: #181c32;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-menu-user-email {
  font-size: 0.78rem;
  color: #7e8299;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-menu-section-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: #a1a5b7;
  padding: 1rem 1.25rem 0.4rem;
}

.mobile-menu-item {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.75rem 1.25rem;
  text-decoration: none;
  color: #181c32;
  border-bottom: 1px solid #f4f6fa;
  transition: background-color 0.15s ease;
}

.mobile-menu-item:last-child {
  border-bottom: 0;
}

.mobile-menu-item:hover,
.mobile-menu-item:active,
.mobile-menu-item:focus {
  background-color: #f9fafb;
  color: #181c32;
  outline: none;
}

.mobile-menu-item.active {
  background-color: #eef0f4;
}

.mobile-menu-item.active .mobile-menu-item-label {
  color: #515D82;
  font-weight: 600;
}

.mobile-menu-item-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.mobile-menu-item-icon .ki-duotone {
  line-height: 1;
}

.mobile-menu-item-label {
  flex: 1 1 auto;
  font-weight: 500;
  font-size: 0.95rem;
  min-width: 0;
  word-break: break-word;
}

.mobile-menu-footer {
  padding: 1rem 1.25rem calc(1rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid #eff2f5;
  flex-shrink: 0;
}

body.mobile-menu-open {
  overflow: hidden;
}

/* Dark mode mobile menu sheet */
[data-bs-theme=dark] .mobile-menu-panel {
  background-color: #1e1e2d;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.5);
}

[data-bs-theme=dark] .mobile-menu-header {
  border-bottom-color: #2d2d3f;
}

[data-bs-theme=dark] .mobile-menu-drag-handle::before {
  background-color: #3f4254;
}

[data-bs-theme=dark] .mobile-menu-panel.dragging .mobile-menu-drag-handle::before {
  background-color: #6c6d80;
}

[data-bs-theme=dark] .mobile-menu-title {
  color: #cdcde4;
}

[data-bs-theme=dark] .mobile-menu-close {
  color: #9899ac;
}

[data-bs-theme=dark] .mobile-menu-close:hover,
[data-bs-theme=dark] .mobile-menu-close:focus {
  background-color: #2a2e3d;
}

[data-bs-theme=dark] .mobile-menu-user {
  background-color: #181824;
}

[data-bs-theme=dark] .mobile-menu-user-name {
  color: #cdcde4;
}

[data-bs-theme=dark] .mobile-menu-user-email {
  color: #9899ac;
}

[data-bs-theme=dark] .mobile-menu-section-label {
  color: #6c6d80;
}

[data-bs-theme=dark] .mobile-menu-item {
  color: #cdcde4;
  border-bottom-color: #2a2e3d;
}

[data-bs-theme=dark] .mobile-menu-item:hover,
[data-bs-theme=dark] .mobile-menu-item:active,
[data-bs-theme=dark] .mobile-menu-item:focus {
  background-color: #2a2e3d;
  color: #cdcde4;
}

[data-bs-theme=dark] .mobile-menu-item.active {
  background-color: #2a2e3d;
}

[data-bs-theme=dark] .mobile-menu-item.active .mobile-menu-item-label {
  color: #7B89B3;
}

[data-bs-theme=dark] .mobile-menu-footer {
  border-top-color: #2d2d3f;
}

/* ================================
   Notifications Page Card Layout
   ================================ */
.notif-card .notif-content {
  min-width: 0;
}

.notif-card .notif-title {
  word-break: break-word;
  overflow-wrap: anywhere;
}

.notif-card .notif-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Mobile: tighter card padding, smaller toolbar buttons */
@media (max-width: 575.98px) {
  .notif-card {
    padding: 0.75rem !important;
  }
  .notif-card .symbol.symbol-40px {
    width: 36px;
    height: 36px;
  }
  .notif-card .notif-read-badge {
    font-size: 9px !important;
    padding: 0.2rem 0.4rem;
  }
  .notif-card .notif-actions .btn {
    width: 30px;
    height: 30px;
  }
  /* Card toolbar wraps on mobile (Mark all read / Dismiss all buttons) */
  .card-header .card-toolbar {
    flex-wrap: wrap;
  }
}

/* Hide footer when running as installed PWA */
body.pwa-standalone #kt_app_footer {
  display: none !important;
}
