/* ==========================================================================
   LS CUSTOM - GLOBAL THEME & UI REDESIGN
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. VARIABLES & CONFIGURATION
   -------------------------------------------------------------------------- */
:root {
  /* Brand Colors */
  --ls-blue: #0056b3;
  --ls-blue-hover: #004494;
  --ls-blue-light: #e6f0ff;
  --ls-yellow: #ffc107;
  --ls-yellow-hover: #e0a800;
  
  /* Override Bootstrap Primary Color with LS Blue */
  --bs-primary: #0056b3;
  --bs-primary-rgb: 0, 86, 179;
  --bs-link-color: #0056b3;
  --bs-link-hover-color: #004494;
  
  /* UI Constants */
  --card-radius: 12px;
  --btn-radius: 8px;
  --input-radius: 8px;
  --nav-radius: 12px;
  
  /* Transitions */
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* --------------------------------------------------------------------------
   2. CUSTOM SCROLLBAR
   -------------------------------------------------------------------------- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 86, 179, 0.2);
  border-radius: 10px;
  transition: var(--transition-fast);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 86, 179, 0.5);
}

/* Dark mode scrollbar */
html.dark-style ::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
}

html.dark-style ::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* --------------------------------------------------------------------------
   3. LIGHT MODE STYLES (Default overrides)
   -------------------------------------------------------------------------- */
html.light-style body {
  background-color: #f4f6f8; /* Softer gray */
}

/* Glassmorphism Navbar */
html.light-style .layout-navbar {
  background-color: rgba(255, 255, 255, 0.85) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.5);
  margin-bottom: 1.5rem !important;
  border-radius: var(--nav-radius) !important;
  width: calc(100% - 3rem) !important;
  margin: 1rem auto !important;
}

/* Cards (Light) */
html.light-style .card {
  border: 1px solid rgba(0, 0, 0, 0.05);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
  border-radius: var(--card-radius);
  transition: var(--transition-normal);
}

html.light-style .card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

/* Sidebar (Light) */
html.light-style .bg-menu-theme {
  background-color: #fff !important;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.03);
}

html.light-style .bg-menu-theme .menu-link {
  border-radius: var(--btn-radius);
  margin: 0 0.75rem;
}

html.light-style .bg-menu-theme .menu-item.active > .menu-link {
  background: linear-gradient(45deg, var(--ls-blue), #3d8bfd);
  box-shadow: 0 4px 12px rgba(0, 86, 179, 0.3);
  color: #fff !important;
}

html.light-style .bg-menu-theme .menu-item.active > .menu-link i {
  color: #fff !important;
}

/* --------------------------------------------------------------------------
   3. DARK MODE STYLES (Complete Overhaul)
   -------------------------------------------------------------------------- */
html.dark-style body {
  background-color: #1a1b2e !important; /* Deep dark blue-grey */
  color: #cdd6f3 !important;
  color-scheme: dark;
}

/* Dark Navbar */
html.dark-style .layout-navbar {
  background-color: rgba(30, 31, 48, 0.85) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  
  /* Centering Fix */
  border-radius: var(--nav-radius) !important;
  width: calc(100% - 3rem) !important;
  margin: 1rem auto !important;
  left: auto !important;
  right: auto !important;
  max-width: 1400px !important;
}

/* Cards (Dark) */
html.dark-style .card {
  background-color: #24253a !important;
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  border-radius: var(--card-radius);
}

html.dark-style .card-header {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
  background-color: transparent !important;
}

html.dark-style .card-body, 
html.dark-style .card-footer {
  color: #cdd6f3;
}

/* Text Colors (Dark) */
html.dark-style h1, html.dark-style h2, html.dark-style h3, 
html.dark-style h4, html.dark-style h5, html.dark-style h6,
html.dark-style .h1, html.dark-style .h2, html.dark-style .h3, 
html.dark-style .h4, html.dark-style .h5, html.dark-style .h6,
html.dark-style strong {
  color: #ffffff !important;
}

html.dark-style .text-muted {
  color: #8da2c9 !important;
}

html.dark-style .text-body {
  color: #cdd6f3 !important;
}

/* Tables (Dark) */
html.dark-style .table {
  color: #cdd6f3 !important;
}

html.dark-style .table:not(.table-dark) th,
html.dark-style .table:not(.table-dark) td {
  background-color: transparent !important;
  color: #cdd6f3 !important;
}

html.dark-style .table-striped > tbody > tr:nth-of-type(odd) > * {
  background-color: rgba(255, 255, 255, 0.03) !important;
  color: #cdd6f3 !important;
  box-shadow: none !important;
}

html.dark-style .table-striped > tbody > tr:nth-of-type(even) > * {
  background-color: transparent !important;
  color: #cdd6f3 !important;
  box-shadow: none !important;
}

/* Adaptative Backgrounds */
html.dark-style .bg-light {
  background-color: #2b2c40 !important;
  color: #cdd6f3 !important;
}

html.dark-style .table-light,
html.dark-style .table-light th,
html.dark-style .table-light td {
  background-color: #2b2c40 !important;
  color: #fff !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
}

/* Code & Pre Blocks */
html.dark-style pre,
html.dark-style code {
  background-color: transparent !important;
  color: #8da2c9 !important;
  border: none !important;
}

html.dark-style .table-warning {
  background-color: rgba(255, 171, 0, 0.15) !important;
  color: #ffab00 !important;
}

html.dark-style .table-warning td {
  background-color: transparent !important;
  color: inherit !important;
}

html.dark-style .table thead th {
  background-color: #2a2b42 !important;
  color: #fff !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
}

html.dark-style .table tbody td {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
}

html.dark-style .table-hover tbody tr:hover > * {
  background-color: rgba(255, 255, 255, 0.07) !important;
  color: #fff !important;
}

/* Forms & Inputs (Dark) */
html.dark-style .form-control, 
html.dark-style .form-select, 
html.dark-style .input-group-text {
  background-color: #1e1f32 !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  color: #fff !important;
  color-scheme: dark;
}

html.dark-style .form-control:focus, 
html.dark-style .form-select:focus {
  border-color: var(--ls-blue) !important;
  background-color: #1e1f32 !important;
  box-shadow: 0 0 0 0.25rem rgba(0, 86, 179, 0.25) !important;
}

/* Sidebar (Dark) */
html.dark-style .bg-menu-theme {
  background-color: #24253a !important;
}

html.dark-style .bg-menu-theme .menu-link {
  color: #cdd6f3 !important;
}

html.dark-style .bg-menu-theme .menu-link:hover {
  background-color: rgba(255, 255, 255, 0.05) !important;
}

html.dark-style .bg-menu-theme .menu-item.active > .menu-link {
  background: linear-gradient(45deg, var(--ls-blue), #3d8bfd) !important;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4) !important;
  color: #fff !important;
}

html.dark-style .bg-menu-theme .menu-header-text {
  color: #8da2c9 !important;
}

/* Dropdowns (Dark) */
html.dark-style .dropdown-menu {
  background-color: #24253a !important;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
}

html.dark-style .dropdown-item {
  color: #cdd6f3 !important;
}

html.dark-style .dropdown-item:hover, 
html.dark-style .dropdown-item:focus {
  background-color: rgba(255, 255, 255, 0.05) !important;
  color: #fff !important;
}

html.dark-style .dropdown-divider {
  border-top-color: rgba(255, 255, 255, 0.1) !important;
}

/* Badges (Dark) */
html.dark-style .bg-label-primary { background-color: rgba(61, 139, 253, 0.2) !important; color: #6ea8fe !important; }
html.dark-style .bg-label-success { background-color: rgba(40, 167, 69, 0.2) !important; color: #75b798 !important; }
html.dark-style .bg-label-warning { background-color: rgba(255, 193, 7, 0.2) !important; color: #ffda6a !important; }
html.dark-style .bg-label-danger { background-color: rgba(220, 53, 69, 0.2) !important; color: #ea868f !important; }
html.dark-style .bg-label-info { background-color: rgba(23, 162, 184, 0.2) !important; color: #6edff6 !important; }

/* Footer (Dark) */
html.dark-style .content-footer,
html.dark-style .bg-footer-theme {
  background-color: #1e1f32 !important;
  color: #8da2c9 !important;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

html.dark-style .footer-link {
  color: #cdd6f3 !important;
}

html.dark-style .footer-link:hover {
  color: #fff !important;
}

/* Custom Options (Checkboxes Cards) (Dark) */
html.dark-style .custom-option {
  background-color: #1e1f32 !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
  color: #cdd6f3 !important;
}

html.dark-style .custom-option.checked {
  border-color: var(--ls-blue) !important;
  background-color: rgba(0, 86, 179, 0.1) !important;
}

html.dark-style .custom-option-header .h6,
html.dark-style .custom-option-header h6 {
  color: #fff !important;
}

html.dark-style .custom-option-body {
  color: #8da2c9 !important;
}

html.dark-style .custom-option:hover {
  border-color: rgba(255, 255, 255, 0.2) !important;
}

/* Checkbox and Radio Inputs (Dark) */
html.dark-style .form-check-input {
  background-color: #24253a !important;
  border-color: rgba(255, 255, 255, 0.2) !important;
}

html.dark-style .form-check-input:checked {
  background-color: var(--ls-blue) !important;
  border-color: var(--ls-blue) !important;
}

/* --------------------------------------------------------------------------
   4. ACCORDION & LS CUSTOM COMPONENTS (Dark)
   -------------------------------------------------------------------------- */
html.dark-style .accordion-item {
  background-color: #24253a !important;
  border: 1px solid rgba(255, 255, 255, 0.05) !important;
}

html.dark-style .accordion-button {
  background-color: #2a2b42 !important;
  color: #fff !important;
}

html.dark-style .accordion-button:not(.collapsed) {
  background-color: #2e2f4a !important;
  color: #fff !important;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.1) !important;
}

html.dark-style .accordion-button::after {
  filter: invert(1) grayscale(1) brightness(2);
}

html.dark-style .accordion-body {
  background-color: #24253a !important;
  color: #cdd6f3 !important;
}

/* --------------------------------------------------------------------------
   5. GLOBAL COMPONENTS (Both Modes)
   -------------------------------------------------------------------------- */
/* Buttons */
.btn {
  border-radius: var(--btn-radius) !important;
  font-weight: 500;
  padding: 0.5rem 1.25rem;
  transition: var(--transition-fast);
}

.btn-primary {
  background-color: var(--ls-blue) !important;
  border-color: var(--ls-blue) !important;
}

.btn-primary:hover {
  background-color: var(--ls-blue-hover) !important;
  border-color: var(--ls-blue-hover) !important;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 86, 179, 0.3) !important;
}

/* LS Yellow Button */
.btn-ls-yellow {
  background-color: var(--ls-yellow) !important;
  border-color: var(--ls-yellow) !important;
  color: #24253a !important;
}

.btn-ls-yellow:hover {
  background-color: var(--ls-yellow-hover) !important;
  border-color: var(--ls-yellow-hover) !important;
  color: #24253a !important;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 193, 7, 0.4) !important;
}

/* Inputs */
.form-control, .form-select {
  border-radius: var(--input-radius) !important;
  padding: 0.6rem 1rem;
}

.form-control:focus, .form-select:focus {
  border-color: var(--ls-blue);
  box-shadow: 0 0 0 0.25rem rgba(0, 86, 179, 0.15);
}

/* Toggle Switch */
.dark-mode-toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  margin: 0;
}
.dark-mode-toggle input { 
  opacity: 0;
  width: 0;
  height: 0;
}
.dark-mode-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #e0e0e0;
  transition: .4s;
  border-radius: 34px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.2);
}
.dark-mode-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
input:checked + .dark-mode-slider {
  background-color: var(--ls-blue);
}
input:checked + .dark-mode-slider:before {
  transform: translateX(20px);
}

/* --------------------------------------------------------------------------
   5. LOGO CENTERING FIX
   -------------------------------------------------------------------------- */
/* Force Logo Container to be Sticky and On Top */
.app-brand.demo {
  height: 120px !important;
  padding: 0 !important;
  overflow: hidden !important;
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  position: sticky !important; /* Makes it stay at top if menu scrolls */
  top: 0 !important;
  z-index: 1000 !important; /* Higher than anything else */
  width: 100% !important;
  flex-shrink: 0 !important; /* Prevents shrinking */
}

/* Explicit Background Colors */
html.light-style .app-brand.demo {
  background-color: #fff !important;
  box-shadow: 0 1px 0 rgba(0,0,0,0.05); /* Separator */
}

html.dark-style .app-brand.demo {
  background-color: #24253a !important;
  box-shadow: 0 1px 0 rgba(255,255,255,0.05); /* Separator */
}

/* Hide the shadow element if it causes conflicts */
.menu-inner-shadow {
  display: none !important;
}

.app-brand-logo.demo {
  width: 100% !important;
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
}

.app-brand-logo.demo img {
  max-width: 140px !important;
  max-height: 100px !important;
  width: auto !important;
  height: auto !important;
  object-fit: contain;
}

/* Fix sidebar trigger hiding logo */
.layout-menu-toggle {
  position: absolute;
  right: 10px;
  top: 10px;
}

/* --------------------------------------------------------------------------
   7. SELECT2 DARK MODE FIXES
   -------------------------------------------------------------------------- */
html.dark-style .select2-container--bootstrap-5 .select2-selection {
  background-color: #1e1f32 !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
  color: #fff !important;
}

html.dark-style .select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
  color: #fff !important;
}

/* Dropdown Menu (Results) */
html.dark-style .select2-container--bootstrap-5 .select2-dropdown {
  background-color: #24253a !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
  color: #fff !important;
}

/* Search Field inside dropdown */
html.dark-style .select2-container--bootstrap-5 .select2-dropdown .select2-search .select2-search__field {
  background-color: #1a1b2e !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
  color: #fff !important;
}

/* Search results items */
html.dark-style .select2-container--bootstrap-5 .select2-results__option {
  color: #cdd6f3 !important;
}

/* Highlighted/Hovered item */
html.dark-style .select2-container--bootstrap-5 .select2-results__option--highlighted[aria-selected] {
  background-color: var(--ls-blue) !important;
  color: #fff !important;
}

/* Selected item */
html.dark-style .select2-container--bootstrap-5 .select2-results__option[aria-selected=true] {
  background-color: rgba(0, 86, 179, 0.2) !important;
  color: #fff !important;
}

/* Placeholder */
html.dark-style .select2-container--bootstrap-5 .select2-selection--single .select2-selection__placeholder {
  color: #8da2c9 !important;
}

/* --------------------------------------------------------------------------
   6. FORM FIXES (Input Groups)
   -------------------------------------------------------------------------- */
/* Fix Border Radius for Input Groups (Override global !important) */
.input-group > .form-control,
.input-group > .form-select,
.input-group > .input-group-text {
  border-radius: 0 !important;
}

.input-group > :first-child {
  border-top-left-radius: var(--input-radius) !important;
  border-bottom-left-radius: var(--input-radius) !important;
}

.input-group > :last-child {
  border-top-right-radius: var(--input-radius) !important;
  border-bottom-right-radius: var(--input-radius) !important;
}

/* Fix Input Group Merge Visuals */
.input-group-merge > .input-group-text {
  border-color: #d9dee3; /* Standard Light Mode Border */
  background-color: #fff; /* White background for seamless merge */
  color: #566a7f; /* Standard text color */
}

/* Dark Mode Specific Merge Styles */
html.dark-style .input-group-merge > .input-group-text {
  border-color: rgba(255, 255, 255, 0.1) !important;
  background-color: #1e1f32 !important; /* Match dark input bg */
  color: #fff !important;
}

/* Remove borders between merged elements */
/* For Left Icon + Input */
.input-group-merge > .input-group-text:first-child {
  border-right: 0 !important;
}
.input-group-merge > .form-control:not(:first-child):not(:last-child) {
  border-left: 0 !important;
  border-right: 0 !important;
}

/* For Input + Right Icon/Text */
.input-group-merge > .form-control:last-child {
  border-left: 0 !important;
}

/* For Icon + Input + Icon (Middle Input) */
.input-group-merge > .form-control:not(:first-child):not(:last-child) {
  border-left: 0 !important;
  border-right: 0 !important;
}

/* Specific fix for the reduction field (Icon + Input + Text) */
/* If the last element is input-group-text (like %) */
.input-group-merge > .input-group-text:last-child {
  border-left: 0 !important;
}

/* Ensure focus ring doesn't look weird */
.input-group-merge .form-control:focus {
  z-index: 3;
}

/* Remove box-shadow (halo) for merged inputs in Dark Mode to avoid broken look */
html.dark-style .input-group-merge .form-control:focus,
html.dark-style .input-group-merge .form-select:focus {
  box-shadow: none !important;
}

/* Highlight icon border when input is focused */
html.dark-style .input-group-merge:focus-within .input-group-text,
html.dark-style .input-group-merge:focus-within .form-control {
  border-color: var(--ls-blue) !important;
}

/* Light mode focus highlight */
html.light-style .input-group-merge:focus-within .input-group-text,
html.light-style .input-group-merge:focus-within .form-control {
  border-color: var(--ls-blue) !important;
}

/* --------------------------------------------------------------------------
   8. CUSTOM NUMBER INPUTS (Themed Native Arrows)
   -------------------------------------------------------------------------- */
/* Style for native number arrows */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
  opacity: 1;
  cursor: pointer;
  height: 24px;
  width: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' style='fill: rgba(0, 86, 179, 1);'%3E%3Cpath d='M7 14l5-5 5 5z'/%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-position: center;
  background-repeat: no-repeat;
  background-color: transparent !important;
  margin-right: 4px;
}

/* Dark mode arrows */
html.dark-style input[type=number]::-webkit-inner-spin-button,
html.dark-style input[type=number]::-webkit-outer-spin-button {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' style='fill: rgba(255, 255, 255, 0.8);'%3E%3Cpath d='M7 14l5-5 5 5z'/%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E") !important;
  filter: none !important;
  background-color: transparent !important;
}

/* --------------------------------------------------------------------------
   9. MODALS (Dark)
   -------------------------------------------------------------------------- */
html.dark-style .modal-content {
  background-color: #24253a !important;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

html.dark-style .modal-header {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
}

html.dark-style .modal-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.05) !important;
}

html.dark-style .modal-title {
  color: #fff !important;
}

html.dark-style .btn-close {
  filter: invert(1) grayscale(1) brightness(2);
}

