body, html {
    height: 100%;
    margin: 0;
    font-family: 'Arial', sans-serif;
    background-color: #f7f8fa;
    overflow-x: hidden;
    overscroll-behavior-x: contain;
}

.wrapper {
    display: flex;
    height: 100vh;
}

/* Sidebar using CSS transforms for smoother animations */
.sidebar {
    background-color: #002d72;
    width: 250px;
    padding-top: 60px;
    color: white;
    position: fixed;
    height: 100%;
    top: 0;
    left: 0;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    will-change: transform;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    -ms-touch-action: pan-y;
    touch-action: pan-y;
    overscroll-behavior: contain;
    overflow-x: hidden;
}

.sidebar.show {
    transform: translateX(0);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -ms-touch-action: pan-y;
    touch-action: pan-y;
}

.sidebar-content a {
    display: block;
    color: white;
    padding: 15px 20px;
    text-decoration: none;
    font-size: 18px;
}

.sidebar-content a:hover {
    background-color: #001a4b;
}

.sidebar-content .category {
    cursor: pointer;
    font-weight: bold;
}

/* New styles for subcategory in sidebar */
.sidebar-content .subcategory {
    cursor: pointer;
    font-weight: 500;
    padding-left: 30px; /* Indent subcategories */
    font-size: 16px;
}

/* Submenu container with CSS transition on max-height */
.sidebar-content .submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -ms-touch-action: pan-y;
    touch-action: pan-y;
}

/* New submenu for subcategories */
.sidebar-content .subcategory-submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding-left: 40px; /* Further indent sections under subcategories */
    overflow-x: hidden;
    overscroll-behavior: contain;
    -ms-touch-action: pan-y;
    touch-action: pan-y;
}

/* When submenu is open, expand it dynamically with scrollbar if needed */
.sidebar-content .submenu.open {
    max-height: calc(100vh - 300px); /* Dynamic height based on viewport */
    overflow-y: auto; /* Enable scrollbar if content overflows */
}

.sidebar-content .subcategory-submenu.open {
    max-height: calc(100vh - 400px); /* Slightly smaller to account for deeper nesting */
    overflow-y: auto;
}

.sidebar-content .submenu a {
    padding-left: 40px;
}

.sidebar-content .subcategory-submenu a {
    padding-left: 50px; /* Even more indentation for sections under subcategories */
}

.sidebar-footer {
    padding: 15px 20px;
    background-color: #001a4b;
    text-align: center;
    font-weight: bold;
    color: white;
}

.sidebar-logo img {
    max-width: 200px;
    padding: 20px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

/* Lowered z-index for toggle-btn so it stays behind modals */
.toggle-btn {
    position: fixed;
    top: 20px;
    left: 10px;
    background-color: #002d72;
    width: 40px;
    height: 40px;
    cursor: pointer;
    z-index: 1040; /* Lowered from 1100 */
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.3s ease, color 0.3s ease;
    color: white;
    font-size: 24px;
}

.toggle-btn:hover {
    background-color: #001a4b;
}

.toggle-btn.active {
    background-color: white;
    color: #002d72;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 900;
    display: none;
}

.overlay.show {
    display: block;
}

.main-content {
    margin-left: 0;
    padding: 20px;
    width: 100%;
    transition: margin-left 0.3s ease, width 0.3s ease;
    overflow-y: auto;
}

.main-content.shifted {
    margin-left: 250px;
    width: calc(100% - 250px);
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.show {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
        width: 100%;
        padding-top: 60px;
    }
    .main-content.shifted {
        margin-left: 0;
        width: 100%;
    }
    .toggle-btn {
        display: flex;
    }
}

@media (min-width: 769px) {
    .sidebar {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 250px;
        width: calc(100% - 250px);
    }
    .toggle-btn {
        display: none;
    }
}

/* Additional styles that remain unchanged */
.table-responsive {
    overflow-x: auto;
}

.form-wrapper {
    max-width: 600px;
    margin: 0 auto;
}

.jumbotron {
    padding: 2rem 1rem;
}

img {
    max-width: 100%;
    height: auto;
}

.logout-link {
    display: block;
    color: white;
    padding: 15px 20px;
    text-decoration: none;
    font-size: 18px;
    background-color: #001a4b;
    text-align: center;
}

.logout-link:hover {
    background-color: #000e26;
}

.show-password {
    margin-top: 5px;
}

.category-card {
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.category-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.btn-primary {
    background-color: #002d72;
    border-color: #002d72;
}

.btn-primary:hover {
    background-color: #001a4b;
    border-color: #001a4b;
}

@media (max-width: 576px) {
    .card-body {
        padding: 1rem;
    }
    .card-title {
        font-size: 1rem;
    }
    .btn {
        font-size: 0.9rem;
        padding: 0.5rem;
    }
}

.select2-container .select2-selection--single {
    height: 38px;
}

.select2-container--bootstrap4 .select2-selection--single .select2-selection__rendered {
    line-height: 38px;
}

.download-link {
    color: #002d72 !important;
    font-weight: 500;
    border-bottom: 2px dotted #002d72;
}

.download-link:hover {
    text-decoration: none;
    color: #001a4b !important;
    border-bottom-style: solid;
}

/* Scrollable modal body */
.modal-dialog-scrollable .modal-body {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.modal-dialog-scrollable .modal-body::-webkit-scrollbar {
    display: none;
}

/* New styles for sub-category headers in sections modal */
.subcategory-header {
    font-size: 1.2rem;
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    color: #002d72;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 0.5rem;
}

/* Updated sections modal to support sub-category grouping */
#sectionsModal .modal-body {
    padding: 20px;
}

/* Adjust table styles for new sub-category column */
#sections_table th, #sections_table td {
    vertical-align: middle;
    padding: 10px;
}
.clsb-logo {
  max-width: 3rem;
  height: auto;
}
.liten-logo {
  max-width: 3rem;
  height: auto;
  display: inline-block;
}
/* Ensure audit URL shows full, wrapping text */
.audit-url { word-break: break-all; white-space: normal; max-width: none; }


/* === Sidebar vertical trail lines (added 2025-09-09) === */
.sidebar-content .submenu,
.sidebar-content .subcategory-submenu {
  position: relative; /* anchor the ::before line */
}

/* show a subtle vertical line when this menu path is active/open */
.sidebar-content .submenu.trail::before {
  content: "";
  position: absolute;
  left: 30px;          /* sits inside the 40px indented links */
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: rgba(255,255,255,0.35);
  border-radius: 1px;
  z-index: 2;
  pointer-events: none;
}

.sidebar-content .subcategory-submenu.trail::before {
  content: "";
  position: absolute;
  left: 40px;          /* sits inside the 50px indented links */
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: rgba(255,255,255,0.35);
  border-radius: 1px;
  z-index: 2;
  pointer-events: none;
}

/* optional: highlight the clicked section without changing brand colors */
.sidebar-content a.active {
  background-color: #001a4b;
}

/* --- Notifications Prompt styles --- */
.notif-banner {
  position: fixed; z-index: 9999; left: 1rem; right: 1rem; bottom: 1rem;
  background: #111; color: #fff; border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.3); padding: .5rem;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}
.notif-inner { display: flex; align-items: center; gap: .75rem; padding: .5rem .75rem; }
.notif-text { flex: 1; line-height: 1.25; }
.notif-text small { display: block; opacity: .8; margin-top: .25rem; }
.notif-btn {
  border: 0; border-radius: 10px; padding: .55rem .9rem; font-weight: 600;
  background: #ffffff; color: #111; cursor: pointer;
}
.notif-btn:disabled { opacity: .6; cursor: not-allowed; }
@media (min-width: 640px) {
  .notif-banner { left: auto; right: 1rem; width: 420px; }
}


/* === Design polish layer appended (2025-09-20) === */

/* ===============================
   Design System & Tokens (added)
   =============================== */
:root{
  --brand-700:#002d72;
  --brand-800:#001a4b;
  --brand-900:#000e26;
  --bg:#f7f8fa;
  --card:#ffffff;
  --text:#1f2937;
  --muted:#6b7280;
  --ring:rgba(0,45,114,.35);
  --shadow:0 10px 30px rgba(0,0,0,.08);
  --shadow-strong:0 14px 44px rgba(0,0,0,.12);
  --radius:14px;
}

/* Better base typography */
html,body{
  color:var(--text);
  background:var(--bg);
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
  text-rendering:optimizeLegibility;
}

/* Cards */
.card{
  border:0 !important;
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  background:var(--card);
}
.card .card-header{
  background:transparent;
  border-bottom:1px solid #eef1f6;
  font-weight:600;
}

/* Buttons */
.btn{
  border-radius:12px;
  font-weight:600;
  transition:transform .12s ease, box-shadow .12s ease, background-color .2s ease, border-color .2s ease, color .2s ease;
}
.btn:active{ transform:translateY(1px); }
.btn-primary{
  background-color:var(--brand-700);
  border-color:var(--brand-700);
  box-shadow:0 4px 16px rgba(0,45,114,.25);
}
.btn-primary:hover{ background-color:var(--brand-800); border-color:var(--brand-800); }
.btn-outline-primary{
  color:var(--brand-700);
  border-color:var(--brand-700);
}
.btn-outline-primary:hover{ background:var(--brand-700); color:#fff; }

/* Focus states */
.form-control, .custom-select, .select2-container--bootstrap4 .select2-selection{
  border-radius:10px;
}
.form-control:focus, .custom-select:focus,
.select2-container--bootstrap4 .select2-selection:focus,
.select2-container--bootstrap4 .select2-selection--single:focus{
  border-color:var(--brand-700) !important;
  box-shadow:0 0 0 4px var(--ring) !important;
  outline:0;
}

/* Tables */
.table{
  background:#fff;
  border-radius:var(--radius);
  overflow:hidden;
}
.table thead th{
  background:#f3f5fa;
  border-bottom:1px solid #e7eaf3;
  font-weight:700;
}
.table td, .table th{ vertical-align:middle; }
.table-responsive{ border-radius:var(--radius); }
.dataTables_wrapper .dataTables_filter input{
  border-radius:10px !important;
}
/* Sticky table header for long lists */
.table-sticky thead th{ position:sticky; top:0; z-index:2; }

/* Sidebar polish */
.sidebar{
  box-shadow: var(--shadow);
}
.sidebar-content a{
  border-radius:8px;
  margin:2px 10px;
}
.sidebar-content a:hover{ transform:translateX(2px); }
.sidebar-logo img{ filter:drop-shadow(0 4px 16px rgba(0,0,0,.15)); }

/* Toggle button improved hit area */
.toggle-btn{
  border-radius:10px;
  box-shadow:var(--shadow);
}

/* Main content spacing */
.main-content{
  padding:24px;
}
@media (max-width: 576px){
  .main-content{ padding:16px; }
}

/* Modals */
.modal-content{
  border:0;
  border-radius:20px;
  box-shadow:var(--shadow-strong);
}
.modal-header{
  border:0;
  padding-bottom:0;
}
.modal-title{ font-weight:700; }
.modal-footer{ border:0; padding-top:0; }

/* Badges & helpers */
.badge-soft{
  background:#eef2ff;
  color:var(--brand-700);
  font-weight:600;
  border-radius:999px;
  padding:.35rem .6rem;
}
.text-muted-2{ color:var(--muted) !important; }
.shadow-soft{ box-shadow:var(--shadow) !important; }

/* Select2 sizing fixes */
.select2-container .select2-selection--single{
  height:42px !important;
}
.select2-container--bootstrap4 .select2-selection--single .select2-selection__rendered{
  line-height:42px !important;
  padding-left:12px !important;
}
.select2-container--bootstrap4 .select2-selection--single .select2-selection__arrow{
  height:42px !important;
}

/* DataTables spacing */
.dataTables_wrapper .dataTables_info{ color:var(--muted); }
.dataTables_wrapper .dataTables_paginate .paginate_button{
  border-radius:10px !important;
  padding:.25rem .6rem !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current{
  background:var(--brand-700) !important;
  color:#fff !important;
}

/* Inputs and file inputs */
.custom-file-input ~ .custom-file-label{
  border-radius:10px;
}

/* Links */
a.download-link{
  text-decoration:none;
  border-bottom:2px dotted var(--brand-700);
}
a.download-link:hover{ border-bottom-style:solid; }

/* Toast-like banners */
.notif-banner{ border:1px solid rgba(255,255,255,.1); }
.notif-btn{ box-shadow:0 6px 20px rgba(255,255,255,.12); }

/* Utility container width for forms */
.form-wrapper{ max-width:760px; }

/* Make jumbotron more modern */
.jumbotron{
  border-radius:20px;
  background:linear-gradient(180deg, #fff, #f3f6fc);
  box-shadow:var(--shadow);
}

/* Smooth transitions for frequently interacted elements */
a, button, .form-control, .custom-select{ transition:all .2s ease; }

/* Ensure modals always above sidebar/toggle */
.modal{ z-index: 1055; }

/* Avatar placeholders */
.avatar{
  width:36px; height:36px; border-radius:50%; display:inline-flex; align-items:center; justify-content:center;
  background:#e9eef7; color:#335; font-weight:700;
}

/* Audit table long URL wrap already present; add subtle code styling */
code{ background:#f3f5fa; padding:.15rem .35rem; border-radius:6px; }

/* === Manage Permissions: make modal scrollbar visible === */
.modal-dialog-scrollable .modal-body{
  max-height: calc(100vh - 200px);
  overflow-y: auto;
  -ms-overflow-style: auto; /* show scrollbars in old Edge/IE */
  scrollbar-width: auto;    /* show in Firefox */
}
.modal-dialog-scrollable .modal-body::-webkit-scrollbar{
  display: initial;         /* show in Chrome/Safari */
}

/* Ensure Select2 dropdowns are visible above Bootstrap modals */
.select2-container .select2-dropdown{
  z-index: 2000;
}


/* ==== Admin Tools Modal: Ensure Sections pane is visible too ==== */
#adminToolsModal #manage-sections {
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
  height: auto !important;
}

/* 3-column layout on extra-wide screens */
@media (min-width: 1400px) {
  #adminToolsModal .tab-content.two-pane {
    grid-template-columns: 1fr 1fr 1fr;
  }
}


/* ==== Admin Tools Modal: Keep Users, Permissions, Sections visible + layout ==== */
#adminToolsModal .tab-content.two-pane {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}
@media (min-width: 992px) {
  #adminToolsModal .tab-content.two-pane {
    grid-template-columns: 1fr 1fr;
  }
}
#adminToolsModal #manage-users,
#adminToolsModal #manage-permissions,
#adminToolsModal #manage-sections {
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
  height: auto !important;
}


/* === PATCH: Desktop-friendly Admin Tools panes — 2025-09-22 08:47:24 === */
/* Keep Manage panes always visible inside the Admin Tools modal */
#adminToolsModal #manage-users,
#adminToolsModal #manage-permissions,
#adminToolsModal #manage-sections {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  height: auto !important;
}

/* Grid layout for wider screens: show panes side-by-side */
#adminToolsModal .panes {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}
@media (min-width: 992px) {
  #adminToolsModal .panes {
    grid-template-columns: 1fr 1fr;
  }
}
@media (min-width: 1400px) {
  #adminToolsModal .panes {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

/* Make each pane look like a card */
#adminToolsModal .pane {
  background: #ffffff;
  border-radius: var(--radius, 14px);
  box-shadow: var(--shadow, 0 10px 30px rgba(0,0,0,.08));
  padding: 1rem;
  min-height: 260px;
}

/* Admin Tools Modal: Quick navigation for management panes */
#adminToolsModal .admin-quick-nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

#adminToolsModal .admin-quick-nav .btn {
  flex: 1 1 auto;
  width: 100%;
  transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

@media (min-width: 576px) {
  #adminToolsModal .admin-quick-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  #adminToolsModal .admin-quick-nav .btn {
    width: auto;
    flex: 1 1 calc(50% - 0.5rem);
    min-width: 10rem;
  }
}

@media (min-width: 992px) {
  #adminToolsModal .admin-quick-nav {
    position: sticky;
    top: 0;
    z-index: 3;
    padding: 0.75rem 0 0.5rem;
    background: #fff;
    border-bottom: 1px solid rgba(0,0,0,0.08);
  }

  #adminToolsModal .admin-quick-nav .btn {
    flex: 1 0 auto;
  }
}

#adminToolsModal .admin-quick-nav .btn.active,
#adminToolsModal .admin-quick-nav .btn:focus,
#adminToolsModal .admin-quick-nav .btn:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

/* Admin Tools Modal: hide legacy tab headers and keep panes visible */
#adminToolsModal .nav-tabs {
  display: none !important;
}

#adminToolsModal .tab-pane {  /* neutralize bootstrap tab-pane hiding */
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
}

/* Ensure nested modals never cover the sidebar toggle and vice versa */
.modal { z-index: 1055; }

/* Better scroll behavior inside modal body for lots of content */
#adminToolsModal .modal-dialog-scrollable .modal-body {
  max-height: calc(100vh - 220px);
  overflow-y: auto;
}

/* Utility in case markup differs */
.force-show { display: block !important; visibility: visible !important; opacity: 1 !important; height: auto !important; }


/* === PATCH 5: Force single-column Admin Control Panel — 2025-09-22 09:06:50 === */
/* Always stack form first, table second (no side-by-side on desktop) */
#adminToolsModal.acp .acp-grid {
  display: block !important;
}
#adminToolsModal.acp .acp-left,
#adminToolsModal.acp .acp-right {
  width: 100% !important;
  max-width: none !important;
}
/* If any previous grid remains, collapse to one column */
#adminToolsModal.acp .acp-grid {
  display: grid !important;
  grid-template-columns: 1fr !important;
  gap: 1rem !important;
}
/* Ensure table comes visually after the form */
#adminToolsModal.acp .acp-right {
  order: 2 !important;
}
#adminToolsModal.acp .acp-left {
  order: 1 !important;
}

/* Keep action bar visible but not overly large */
#adminToolsModal.acp .action-bar {
  position: sticky;
  bottom: 0;
  background: #fff;
  padding: .75rem 0 .5rem;
  box-shadow: 0 -4px 12px rgba(0,0,0,.06);
}

/* Table area height tuned for stacked layout */
#adminToolsModal.acp .table-wrap {
  max-height: calc(100vh - 360px) !important;
  overflow: auto !important;
}

/* Neutralize any old "two-pane" rules */
#adminToolsModal .tab-content.two-pane {
  display: block !important;
}
