/* ==========================================================================
   Global Theme Variables (overridden by inline vars from index.php)
   ========================================================================== */
:root {
  --app-primary:   #A82F2C; /* fallback; index.php injects real value */
  --app-secondary: #263A68; /* fallback; index.php injects real value */

  /* Derived light tones of secondary (used for subtle UI states) */
  --app-sec-05: rgba(128, 0, 0, .05);
  --app-sec-08: rgba(128, 0, 0, .08);
  --app-sec-12: rgba(128, 0, 0, .12);

  --app-bg: #ffffff;
  --app-muted: #6c757d;
  --app-navbar-h: 70px;
}

body {
  background: var(--app-bg);
}

/* ==========================================================================
   Header / Navbar (fixed white with 3px primary top line + 3D bottom)
   ========================================================================== */
.app-navbar {
  background: #fff;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1060;
  min-height: var(--app-navbar-h);

  /* softer edge + gentle depth */
  border-bottom: 1px solid rgba(0,0,0,.04);
  box-shadow:
    0 1px 0 rgba(255,255,255,.55) inset,  /* faint inner highlight */
    0 -1px 0 rgba(0,0,0,.02) inset,       /* faint inner shade    */
    0 6px 12px -12px rgba(0,0,0,.20);     /* very light drop shadow */
}

/* 3px primary brand line across the top */
.app-navbar::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--app-primary);
  z-index: 0;
}

/* ultra-subtle gradient lip to suggest depth */
.app-navbar::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  bottom: -4px;
  height: 4px;
  pointer-events: none;
  border-radius: 0 0 8px 8px;
  background: linear-gradient(180deg, rgba(0,0,0,.08), rgba(0,0,0,0));
  filter: blur(.2px);
  z-index: 0; /* ensure it sits below dropdowns */
}

.app-navbar .navbar-brand {
  color: var(--app-primary);
  font-weight: 600;
}
.app-navbar .nav-link {
  color: var(--app-primary) !important;
  font-weight: 500;
}
.app-navbar .nav-link:hover {
  color: var(--app-secondary) !important;
}

.brand-logo {
  height: 50px;
  width: auto;
}

/* Avatar chip */
.avatar-chip {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--app-secondary);
  color: #fff;
  font-weight: 600;
  text-transform: uppercase;
}
.avatar-lg {
  width: 44px;
  height: 44px;
}

/* ==========================================================================
   Page wrapper: content scrolls under fixed header
   ========================================================================== */
.page-wrapper {
  padding-top: calc(var(--app-navbar-h) + 10px);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   Dropdowns: tinted background, fine separators, subtle animation
   ========================================================================== */
@keyframes appDropIn {
  from { opacity: 0; transform: translateY(6px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.dropdown-menu.app-dropdown {
  /* Keep the nice tint but ensure opacity by layering over a solid base */
  background:
    linear-gradient(180deg, var(--app-sec-05) 0%, rgba(255,255,255,.96) 100%),
    #fff;
  border: 1px solid var(--app-sec-12);
  border-radius: .75rem;
  box-shadow: 0 .75rem 1.5rem rgba(0,0,0,.15);
  padding: .35rem;
  transform-origin: top right;
  animation: appDropIn .18s ease-out both;
  z-index: 1100; /* above .app-navbar */
}

.dropdown-menu.app-dropdown .dropdown-item {
  border-radius: .5rem;
  padding: .55rem .75rem;
  transition: background-color .15s ease, transform .15s ease;
}

.dropdown-menu.app-dropdown .dropdown-item + .dropdown-item {
  /* visible on the now mostly-solid background */
  border-top: 1px solid rgba(0,0,0,.06);
}

.dropdown-menu.app-dropdown .dropdown-item:hover {
  background: var(--app-sec-05);
  transform: translateX(2px);
}

.dropdown-menu.app-dropdown .dropdown-divider {
  border-top: 1px dashed var(--app-sec-12);
  opacity: 1;
}

/* Make sure Popper-positioned menus in a fixed navbar do not get clipped */
.navbar .dropdown-menu[data-bs-popper] {
  margin-top: .5rem; /* avoids touching the lip */
}

/* If any parent introduced a stacking context, this helps */
.navbar .dropdown,
.navbar .dropdown-toggle,
.navbar .dropdown-menu {
  position: relative;
}

.text-secondary-accent {
  color: var(--app-secondary) !important;
}
.dropdown-item i {
  width: 1.1rem;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.app-footer {
  width: 100%;
  background: #fff;
  border-top: 3px solid var(--app-primary);
  margin-top: auto;
}
.app-footer .footer-top {
  padding: 2rem 0;
  border-bottom: 1px solid rgba(0,0,0,.06);
}
.app-footer h6 {
  color: var(--app-primary);
  font-weight: 600;
}
.app-footer .footer-link {
  color: var(--app-muted);
  text-decoration: none;
  display: block;
  margin-bottom: .5rem;
}
.app-footer .footer-link:hover {
  color: var(--app-primary);
}
.app-footer .footer-bottom {
  padding: 1rem 0;
  font-size: .875rem;
  color: var(--app-muted);
  background: #f8f9fa;
}
.footer-about {
  padding-left: 1rem;
}

/* ==========================================================================
   Cards (optional common chrome)
   ========================================================================== */
.card.app-card,
.app-card {
  border: 1px solid rgba(0,0,0,.06);
  border-radius: .75rem;
  box-shadow: 0 .125rem .25rem rgba(0,0,0,.05);
}

/* ==========================================================================
   Requested additions
   ========================================================================== */

/* Fullscreen modal override */
.modal-fullscreen {
  width: 100vw !important;
  max-width: 100vw !important;
  height: 100vh !important;
  margin: 0 !important;
}
.modal-fullscreen .modal-content {
  height: 100vh !important;
  border-radius: 0;
}

/* Modal headers: primary → 50% secondary blend + subtle interaction */
#dynamicModal .modal-header,
#confirmGenericModal .modal-header,
.app-modal-header {
  background-image: linear-gradient(
    135deg,
    var(--app-primary) 0%,
    color-mix(in srgb, var(--app-secondary) 50%, var(--app-primary) 50%) 100%
  );
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.18);
  background-size: 160% 160%;
  transition: background-position .6s ease, box-shadow .2s ease;
}

#dynamicModal .modal-header:hover,
#dynamicModal .modal-header:focus-within,
#confirmGenericModal .modal-header:hover,
#confirmGenericModal .modal-header:focus-within,
.app-modal-header:hover,
.app-modal-header:focus-within {
  background-position: 100% 0;
  box-shadow: inset 0 -1px 0 rgba(255,255,255,.12);
}

/* Title: smaller, stronger weight, tighter line-height */
#dynamicModal .modal-title,
#confirmGenericModal .modal-title,
.app-modal-header .modal-title {
  font-size: .95rem;
  line-height: 1.1;
  font-weight: 600;
  letter-spacing: .2px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: .5rem;
  margin: 0; /* ensure no extra spacing */
}

/* Colorful icon chip that uses your theme gradient */
.modal-title .title-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-image: linear-gradient(135deg, var(--app-primary), var(--app-secondary));
  color: #fff;
  box-shadow:
    0 0 0 2px rgba(255,255,255,.18) inset,  /* inner ring */
    0 1px 2px rgba(0,0,0,.25);              /* slight lift */
  flex: 0 0 28px;
  font-size: .95rem;
}

/* Ensure header controls are readable on dark gradient */
#dynamicModal .modal-header .btn-close,
#confirmGenericModal .modal-header .btn-close {
  filter: invert(1) grayscale(100%) brightness(190%);
  opacity: .85;
}
#dynamicModal .modal-header .btn-close:hover,
#confirmGenericModal .modal-header .btn-close:hover {
  opacity: 1;
}

/* If you keep a header action button, use light outline so it blends */
#dynamicModal .modal-header .btn-outline-light,
#confirmGenericModal .modal-header .btn-outline-light {
  --bs-btn-color: #fff;
  --bs-btn-border-color: rgba(255,255,255,.7);
  --bs-btn-hover-bg: rgba(255,255,255,.15);
  --bs-btn-hover-border-color: rgba(255,255,255,.85);
  --bs-btn-active-bg: rgba(255,255,255,.2);
  --bs-btn-active-border-color: rgba(255,255,255,.9);
}

/* Ensure Bootstrap modals sit above the fixed .app-navbar */
.modal,
.modal.show {
  z-index: 1200;
}
.modal-backdrop,
.modal-backdrop.show {
  z-index: 1190;
}

/* Optionally drop the navbar while a modal is open (extra safety) */
.modal-open .app-navbar {
  z-index: 100; /* below modal/backdrop */
}

/* Centred gradient login page */
body.login-page {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  margin: 0;
  background: linear-gradient(to bottom right, #6a11cb, #2575fc);
}

/* Sticky table header */
.table-responsive thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8f9fa;
}

/* Sortable header accessibility hint */
th[role="button"] {
  cursor: pointer;
}
th[role="button"]:focus {
  outline: 2px solid #86b7fe;
  outline-offset: 2px;
}

/* Ensure .btn-primary derives from your theme colours */
.btn-primary {
  --bs-btn-color: #fff;
  --bs-btn-bg: var(--bs-primary);
  --bs-btn-border-color: var(--bs-primary);
  --bs-btn-hover-bg: color-mix(in srgb, var(--bs-primary) 85%, black);
  --bs-btn-hover-border-color: color-mix(in srgb, var(--bs-primary) 78%, black);
  --bs-btn-active-bg: color-mix(in srgb, var(--bs-primary) 74%, black);
  --bs-btn-active-border-color: color-mix(in srgb, var(--bs-primary) 70%, black);
  --bs-btn-disabled-bg: var(--bs-primary);
  --bs-btn-disabled-border-color: var(--bs-primary);
}

/* Outline variant tuned to your primary */
.btn-outline-primary {
  --bs-btn-color: var(--bs-primary);
  --bs-btn-border-color: var(--bs-primary);
  --bs-btn-hover-bg: var(--bs-primary);
  --bs-btn-hover-border-color: var(--bs-primary);
  --bs-btn-active-bg: color-mix(in srgb, var(--bs-primary) 90%, black);
  --bs-btn-active-border-color: color-mix(in srgb, var(--bs-primary) 90%, black);
}

/* Utility backgrounds (bg-primary) already respect --bs-primary-rgb */


/* Themed table header */
.table thead.table-light th {
  background: var(--app-sec-08); /* or just #f8f9fa for plain light grey */
  color: var(--app-primary);
  font-weight: 600;
  border-bottom: 2px solid var(--app-sec-12);
  text-transform: uppercase;
  letter-spacing: .35px;
  font-size: .8rem;
  padding-top: .75rem;
  padding-bottom: .75rem;
  vertical-align: middle;
  position: sticky;
  top: 0;
  z-index: 5;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.6),
              inset 0 -1px 0 rgba(0,0,0,.02);
  transition: background-color .15s ease, color .15s ease;
}

/* Active sort column highlight */
.table thead th[data-active="1"] {
  background: linear-gradient(135deg, var(--app-primary), var(--app-secondary));
  color: #fff !important;
  box-shadow: inset 0 -2px 0 rgba(255,255,255,.25);
}
.table thead th[data-active="1"] i {
  color: #fff !important;
}


/* Hover effect only for non-active sortable headers */
.table thead th[role="button"]:not([data-active="1"]):hover {
  background: color-mix(in srgb, var(--app-primary) 15%, transparent);
  color: var(--app-primary);
  cursor: pointer;
}

/* Keep active sort column strong even on hover */
.table thead th[data-active="1"]:hover {
  background: linear-gradient(135deg, var(--app-primary), var(--app-secondary));
  color: #fff;
}

/* Focus ring for keyboard navigation */
.table thead th[role="button"]:focus {
  outline: none;
  box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--app-primary) 25%, transparent);
  border-radius: .25rem;
}

/* Sort icons alignment */
.table thead th i {
  font-size: .85rem;
  margin-left: .25rem;
  vertical-align: middle;
}

/* Light themed stripes for table-striped */
.table-striped > tbody > tr:nth-of-type(odd) > * {
  background-color: color-mix(in srgb, var(--app-primary) 4%, white) !important;
}

/* Keep hover distinct */
.table-hover > tbody > tr:hover > * {
  background-color: color-mix(in srgb, var(--app-primary) 12%, white) !important;
}

/* =========================================================
   Themed checkboxes & radios (uses --bs-primary or falls back to --app-primary)
   ========================================================= */
.form-check-input[type="checkbox"],
.form-check-input[type="radio"] {
  /* modern browsers: native control tint */
  accent-color: var(--bs-primary, var(--app-primary));
  border-color: color-mix(in srgb, var(--bs-primary, var(--app-primary)) 55%, #0000);
}

/* hover + focus ring */
.form-check-input:hover {
  border-color: var(--bs-primary, var(--app-primary));
}
.form-check-input:focus {
  border-color: var(--bs-primary, var(--app-primary));
  box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--bs-primary, var(--app-primary)) 28%, transparent);
}

/* checked/indeterminate fill (for engines that still paint background instead of accent-color) */
.form-check-input:checked,
.form-check-input:indeterminate {
  background-color: var(--bs-primary, var(--app-primary));
  border-color: var(--bs-primary, var(--app-primary));
}

/* disabled state keeps theme tint but looks muted */
.form-check-input:disabled {
  opacity: .65;
}
.form-check-input:disabled + .form-check-label {
  color: color-mix(in srgb, var(--app-muted) 90%, #0000);
}

/* make label adopt theme when checked */
.form-check-input:checked + .form-check-label {
  color: var(--app-primary);
}

/* optional: highlight the whole row when checked (modern browsers) */
.form-check:has(.form-check-input:checked) {
  background: color-mix(in srgb, var(--app-secondary) 6%, #fff);
  border-radius: .5rem;
}

/* Bootstrap switches also pick up the theme */
.form-switch .form-check-input {
  accent-color: var(--bs-primary, var(--app-primary));
}
.form-switch .form-check-input:focus {
  box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--bs-primary, var(--app-primary)) 28%, transparent);
}

/* +15% size for checkboxes & radios */
.form-check-input[type="checkbox"],
.form-check-input[type="radio"] {
  width: calc(1em * 1.15);
  height: calc(1em * 1.15);
}

/* optional: slight vertical align tweak */
.form-check .form-check-input {
  margin-top: .08rem;
}


/* Make all tab borders use a soft version of your theme colour */
.nav-tabs {
  border-bottom: 1px solid color-mix(in srgb, var(--app-primary, #52001E) 20%, white);
}

/* Each inactive tab link: light bottom border */
.nav-tabs .nav-link {
  border: 1px solid transparent;
  border-bottom-color: color-mix(in srgb, var(--app-primary, #52001E) 20%, white);
  color: color-mix(in srgb, var(--app-primary, #52001E) 65%, black);
  transition: all 0.2s ease-in-out;
}

/* Active tab highlight */
.nav-tabs .nav-link.active {
  border-color: var(--app-primary, #52001E);
  border-bottom-color: var(--app-primary, #52001E);
  background-color: color-mix(in srgb, var(--app-primary, #52001E) 8%, white);
  color: var(--app-primary, #52001E);
  font-weight: 600;
}

/* Wrap your UL in a soft card strip */
#navTabs {
  padding: .5rem;
  border-radius: .75rem;
   background: color-mix(in srgb, var(--app-primary, #52001E) 4%, white); 
  border-bottom: 1px solid color-mix(in srgb, var(--app-primary, #52001E) 25%, white);
}
#navTabs .nav-link { margin: 0 .125rem; border-radius: .5rem; }

/* Light base */
#navTabs .nav-link {
  position: relative;
  color: color-mix(in srgb, var(--app-primary, #52001E) 65%, black);
  transition: color .15s ease;
  border: none;                    /* remove default borders */
  background: transparent;
}

/* Hover tint */
#navTabs .nav-link:hover {
  background: color-mix(in srgb, var(--app-primary, #52001E) 8%, white);
  color: var(--app-primary, #52001E);
}

/* The animated underline */
#navTabs .nav-link::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 0.25rem;
  height: 3px;
  border-radius: 3px;
  background: transparent;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .25s ease, background-color .25s ease;
}

/* Active state */
#navTabs .nav-link.active {
  color: var(--app-primary, #52001E);
  font-weight: 600;
  background: color-mix(in srgb, var(--app-primary, #52001E) 8%, white);
}
#navTabs .nav-link.active::after {
  background: var(--app-primary, #52001E);
  transform: scaleX(1);
}

/* Make the whole strip lose the default nav bottom border */
#navTabs.nav-tabs { border-bottom: 0; }
/* Shrink height and font a touch */
#navTabs .nav-link {
  padding: .5rem .75rem;
  font-size: .925rem;
  letter-spacing: .2px;
}

.nav-tabs {
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  scrollbar-width: thin; /* Firefox */
}

.nav-tabs .nav-item {
  flex: 0 0 auto;
}


.header-box {
    background: linear-gradient(135deg, var(--app-sec-05, #f8f9fa), rgba(255,255,255,0.9));
    border: none;
    border-left: 5px solid var(--app-primary, #52001E);
    border-radius: .75rem;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 1px 6px rgba(0,0,0,0.05);
    animation: fadeSlideIn 0.5s ease both;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
  }

  .header-box:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  }

  .header-box .icon-wrap {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--app-primary, #52001E);
    color: #fff;
    border-radius: 50%;
    font-size: 1.5rem;
    animation: floatIcon 4s ease-in-out infinite;
  }

  .header-box .content h5 {
    margin: 0;
    font-weight: 500;
    color: var(--app-primary, #52001E);
    font-size: 1.1rem;
  }

  .header-box .content .subtitle {
    font-size: 0.9rem;
    color: var(--bs-secondary-color, #555);
    opacity: 0.9;
  }

  @keyframes fadeSlideIn {
    from {
      opacity: 0;
      transform: translateY(10px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  @keyframes floatIcon {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
  }




  .history-view-table .col-note {
    width: 280px;
    max-width: 280px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .history-view-table .icon-btn {
    padding: .25rem .5rem;
    line-height: 1;
    border-radius: .5rem;
  }
.note-summary {
    background: var(--app-sec-08, rgba(128,0,0,0.08)); /* falls back if var missing */
    border: 1px dashed var(--app-secondary, #800000);
    border-radius: .75rem;
  }