/* Hide navbar */
.hide-navbar .navbar {
    display: none;
  }
  
  .hide-navbar .main-content {
    padding-top: 0;
  }
  
  /* Page-specific styles */
  .stats-card {
    background: #2B2B2B;
  }
  
  .chart-card {
    background: #232323;
  }
  
  /* Print-specific styles */
  @media print {
    /* Hide print-related UI elements */
    .navbar, 
    .sidebar,
    .sidebar-toggle,
    .dropdown,
    .filters-section {
      display: none !important;
    }
    
    /* Basic layout adjustments */
    .main-content {
      margin-left: 0 !important;
      max-width: 100% !important;
      padding: 0 !important;
    }
    
    body {
      background-color: white !important;
      color: black !important;
    }
    
    /* Card styling for print */
    .card {
      border: 1px solid #ddd !important;
      box-shadow: none !important;
      background-color: white !important;
      color: black !important;
      break-inside: avoid;
      margin-bottom: 10px !important; /* Reduced from 20px */
    }
    
    .content-header {
      background: white !important;
      color: black !important;
    }
    
    .content-header h1 {
      color: black !important;
    }
    
    /* Grid layout for print */
    .row {
      display: flex;
      flex-wrap: wrap;
      width: 100%;
      margin-bottom: 10px !important; /* Reduced from 30px */
    }
    
    .col-md-6, .col-6 {
      width: 50%;
      padding: 10px;
      page-break-inside: avoid;
    }
    
    .col-12 {
      width: 100%;
      padding: 10px;
      page-break-inside: avoid;
    }
    
    /* For smaller stat cards */
    .col-sm-6, .col-lg-4, .col-lg-6, .col-xl {
      width: 20%; /* 5 items in a row for print */
      padding: 5px;
      page-break-inside: avoid;
    }
    
    /* Canvas/chart adjustments */
    canvas {
      max-width: 100%;
      height: auto !important;
      max-height: 300px !important;
    }
    
    /* Fix chart container heights */
    .chart-card, 
    .detailed-chart,
    .small-chart {
      height: auto !important;
      min-height: 0 !important;
      max-height: none !important;
    }
    
    /* Specific fixes for pie charts */
    [id$="Chart"] {
      height: auto !important;
      max-height: 250px !important;
    }
    
    /* Target specific chart containers */
    .target-charts-container canvas,
    .damage-charts-container canvas,
    .bc-type-charts-container canvas {
      max-height: 250px !important;
    }
    
    /* Adjust card body padding */
    .card-body {
      padding: 15px !important;
      padding-bottom: 5px !important;
    }
    
    /* Table styling for print */
    .table {
      width: 100%;
      border-collapse: collapse;
      color: black !important;
      page-break-inside: avoid;
      margin-bottom: 10px !important;
    }
    
    .table th, .table td {
      border: 1px solid #ddd !important;
      color: black !important;
    }
    
    .table th {
      background-color: #f2f2f2 !important;
      color: black !important;
    }
    
    /* Remove excessive margins from all elements */
    .main-chart-container, 
    .distribution-charts-container,
    .damage-charts-container,
    .target-charts-container,
    .bc-type-charts-container,
    .top-devices-container,
    .map-container {
      margin-bottom: 10px !important;
    }
    
    /* Page margin */
    @page {
      margin: 0.5cm;
    }
    
    /* Layout-specific styles */
    /* Compact layout - minimize page breaks */
    body[data-print-layout="compact"] .card,
    body[data-print-layout="compact"] .row,
    body[data-print-layout="compact"] .col-6,
    body[data-print-layout="compact"] .col-12 {
      page-break-inside: avoid;
      margin-bottom: 5px !important; /* Even smaller for compact layout */
    }
    
    body[data-print-layout="compact"] .card-body {
      padding: 10px !important;
    }
    
    /* Sections layout - each major section on its own page */
    body[data-print-layout="sections"] .main-chart-container,
    body[data-print-layout="sections"] .distribution-charts-container,
    body[data-print-layout="sections"] .damage-charts-container,
    body[data-print-layout="sections"] .target-charts-container,
    body[data-print-layout="sections"] .bc-type-charts-container,
    body[data-print-layout="sections"] .top-devices-container,
    body[data-print-layout="sections"] .map-container {
      page-break-before: always;
    }
    
    /* Auto layout - more intelligent page breaks */
    body[data-print-layout="auto"] .card,
    body[data-print-layout="auto"] .row {
      page-break-inside: avoid;
    }
    
    body[data-print-layout="auto"] .main-chart-container {
      page-break-before: always;
    }
  }

  /* Efficiency Delivery Stats Inline */

  .table {
    color: #e0e0e0;
    border-color: #444;
    margin-bottom: 0;
  }
  
  .table-dark {
    background-color: #2B2B2B;
  }
  
  .table-dark th,
  .table-dark td {
    border-color: #444;
  }
  
  .table-hover tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.05);
  }
  
  /* Organization name link styles */
  .table td a {
    color: #e0e0e0;
    text-decoration: none;
    transition: color 0.2s ease;
  }
  
  .table td a:hover {
    color: #ffffff;
    text-decoration: underline;
  }
  
  .content-header {
    background: #232323;
    padding: 1.5rem;
    border-radius: 12px 12px 0 0;
    margin: 0 0 1.5rem 0;
  }
  
  .content-header h1 {
    font-size: 1.5rem;
    font-weight: 500;
    color: white;
    margin: 0;
  }
  
  /* Table with sticky first column - alternative approach */
  .table-responsive {
    overflow-x: auto;
    position: relative;
    max-width: 100%;
    margin: 0 auto;
    border: none;
  }
  
  /* Ensure table takes needed width but not more */
  .matrix-table {
    font-size: 0.9rem;
    border-collapse: separate;
    border-spacing: 0;
    margin: 0;
    border: none;
    table-layout: fixed; /* Using fixed layout for better control */
    width: auto; /* Allow natural sizing */
    overflow-x: auto;
  }
  
  /* Cell styling for all cells */
  .matrix-table th,
  .matrix-table td {
    min-width: 80px;
    text-align: center;
    vertical-align: middle;
    border: 1px solid #444;
    padding: 4px 8px;
  }
  
  /* Configure sticky first column */ 
  .matrix-table th:first-child,
  .matrix-table td:first-child {
    position: -webkit-sticky; /* For Safari */
    position: sticky;
    left: 0;
    background-color: #2B2B2B;
    z-index: 10; /* High enough to stay on top */
    width: var(--first-column-width);
    min-width: var(--first-column-width);
    text-align: left;
    box-shadow: 2px 0 3px -1px rgba(0, 0, 0, 0.4);
    border-right: 1px solid #555;
  }
  
  /* Special background for header */
  .matrix-table th:first-child {
    background-color: #232323;
    z-index: 11; /* Even higher for headers */
  }
  
  /* Enhancement when scrolled horizontally */
  .sticky-active {
    box-shadow: 5px 0 10px rgba(0, 0, 0, 0.5) !important;
  }
  
  /* Make header row sticky too */
  .matrix-table thead th {
    position: sticky;
    top: 0;
    z-index: 9;
    background-color: #232323;
  }
  
  /* Double sticky corner cell - both top and left fixed */
  .matrix-table thead th:first-child {
    z-index: 12; /* Highest z-index for the corner cell */
  }
  
  /* Regular cells */
  .matrix-table th:not(:first-child),
  .matrix-table td:not(:first-child) {
    min-width: 100px; /* Ensure cells have consistent width */
  }
  
  .matrix-cell {
    padding: 4px 8px;
  }
  
  .matrix-total {
    font-weight: bold;
    background-color: rgba(255, 255, 255, 0.05);
  }
  
  .matrix-total td {
    border-top: 2px solid #444;
  }
  
  /* Group header styles */
  .group-header {
    background-color: rgba(255, 255, 255, 0.05);
    font-weight: bold;
    border: 1px solid #444;
  }
  
  /* Column header styles */
  .column-header {
    font-size: 0.9em;
    color: #aaa;
    border: 1px solid #444;
    background-color: #2B2B2B;
  }
  
  /* Group separator styles */
  .group-separator {
    border-left: 3px solid #555 !important;
  }
  
  /* Organization level indentation */
  .matrix-table td:first-child[data-level="1"] { padding-left: 30px; }
  .matrix-table td:first-child[data-level="2"] { padding-left: 50px; }
  .matrix-table td:first-child[data-level="3"] { padding-left: 70px; }
  .matrix-table td:first-child[data-level="4"] { padding-left: 90px; }
  .matrix-table td:first-child[data-level="5"] { padding-left: 110px; }
  .matrix-table td:first-child[data-level="6"] { padding-left: 130px; }
  .matrix-table td:first-child[data-level="7"] { padding-left: 150px; }
  .matrix-table td:first-child[data-level="8"] { padding-left: 170px; }
  .matrix-table td:first-child[data-level="9"] { padding-left: 190px; }
  .matrix-table td:first-child[data-level="10"] { padding-left: 210px; }
  
  /* Tree structure styles */
  .tree-cell {
    position: relative;
    padding-left: 0;
    width: 40px;
  }
  
  .tree-indent {
    display: inline-block;
    width: 20px;
    height: 100%;
    position: relative;
  }
  
  .tree-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-left: 1px solid #444;
  }
  
  .tree-line::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 1px;
    background-color: #444;
  }
  
  .tree-line:last-child::before {
    display: none;
  }
  
  .tree-branch {
    position: absolute;
    left: -20px;
    color: #444;
    font-family: monospace;
  }
  
  .tree-branch::before {
    content: '├';
  }
  
  .tree-branch:last-child::before {
    content: '└';
  }
  
  .organization-name {
    padding-left: 5px;
  }
  
  /* Sorting styles */
  .sortable {
    cursor: pointer;
    position: relative;
    padding-right: 20px;
  }
  
  .sortable::after {
    content: '↕';
    position: absolute;
    right: 5px;
    opacity: 0.5;
  }
  
  .sortable.asc::after {
    content: '↑';
    opacity: 1;
  }
  
  .sortable.desc::after {
    content: '↓';
    opacity: 1;
  }
  
  .sortable:hover {
    background-color: rgba(255, 255, 255, 0.05);
  }
  
  /* ABC Analysis Styles */
  .abc-groups {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
  }
  
  .group-container {
    flex: 0 0 auto;
    min-width: 150px;
  }
  
  .group-container label {
    display: block;
    margin-bottom: 5px;
  }
  
  .group-a {
    background-color: rgba(40, 167, 70, 0.63) !important; /* Green */
    color:#fff!important;
  }
  
  .group-b {
    background-color: rgba(255, 198, 26, 0.71) !important; /* Yellow */
    color:#fff!important;
  }
  
  .group-c {
    background-color: rgba(255, 51, 51, 0.87) !important; /* Purple */
    color:#fff!important;
  }
  
  /* Override Bootstrap container width */
  @media (min-width: 1400px) {
    .container,
    .container-lg,
    .container-xl,
    .container-xxl {
      max-width: 1920px;
    }
  }


  /* Application Delivery Stats Inline */

  /* Reuse existing styles from delivery_list.html */
.hide-navbar .navbar {
    display: none;
  }
  
  .hide-navbar .main-content {
    padding-top: 0;
  }
  
  .d-flex {
    display: flex;
    justify-content: flex-start;
    width: 100%;
    padding: 0;
    margin: 0;
  }
  
  .table {
    color: #e0e0e0;
    border-color: #444;
    margin-bottom: 0;
  }
  
  .table-dark {
    background-color: #2B2B2B;
  }
  
  .table-dark th,
  .table-dark td {
    border-color: #444;
  }
  
  .table-hover tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.05);
  }
  
  /* Organization name link styles */
  .table td a {
    color: #e0e0e0;
    text-decoration: none;
    transition: color 0.2s ease;
  }
  
  .table td a:hover {
    color: #ffffff;
    text-decoration: underline;
  }
  
  .content-header {
    background: #232323;
    padding: 1.5rem;
    border-radius: 12px 12px 0 0;
    margin: 0 0 1.5rem 0;
  }
  
  .content-header h1 {
    font-size: 1.5rem;
    font-weight: 500;
    color: white;
    margin: 0;
  }
  
  /* Matrix table styles */
  .matrix-table {
    font-size: 0.9rem;
  }
  
  .matrix-table th,
  .matrix-table td {
    min-width: 100px;
    text-align: center;
  }
  
  .matrix-table th:first-child,
  .matrix-table td:first-child {
    text-align: left;
    min-width: 200px;
  }
  
  .matrix-cell {
    padding: 4px 8px;
  }
  
  .matrix-total {
    font-weight: bold;
    background-color: rgba(255, 255, 255, 0.05);
  }
  
  .matrix-total td {
    border-top: 2px solid #444;
  }
  
  /* Organization level indentation */
  .matrix-table td:first-child[data-level="1"] { padding-left: 30px; }
  .matrix-table td:first-child[data-level="2"] { padding-left: 50px; }
  .matrix-table td:first-child[data-level="3"] { padding-left: 70px; }
  .matrix-table td:first-child[data-level="4"] { padding-left: 90px; }
  .matrix-table td:first-child[data-level="5"] { padding-left: 110px; }
  .matrix-table td:first-child[data-level="6"] { padding-left: 130px; }
  .matrix-table td:first-child[data-level="7"] { padding-left: 150px; }
  .matrix-table td:first-child[data-level="8"] { padding-left: 170px; }
  .matrix-table td:first-child[data-level="9"] { padding-left: 190px; }
  .matrix-table td:first-child[data-level="10"] { padding-left: 210px; }
  
  /* Tree structure styles */
  .tree-cell {
    position: relative;
    padding-left: 0;
    width: 40px;
  }
  
  .tree-indent {
    display: inline-block;
    width: 20px;
    height: 100%;
    position: relative;
  }
  
  .tree-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-left: 1px solid #444;
  }
  
  .tree-line::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 1px;
    background-color: #444;
  }
  
  .tree-line:last-child::before {
    display: none;
  }
  
  .tree-branch {
    position: absolute;
    left: -20px;
    color: #444;
    font-family: monospace;
  }
  
  .tree-branch::before {
    content: '├';
  }
  
  .tree-branch:last-child::before {
    content: '└';
  }
  
  .organization-name {
    padding-left: 5px;
  }
  
  /* Sorting styles */
  .sortable {
    cursor: pointer;
    position: relative;
    padding-right: 20px;
  }
  
  .sortable::after {
    content: '↕';
    position: absolute;
    right: 5px;
    opacity: 0.5;
  }
  
  .sortable.asc::after {
    content: '↑';
    opacity: 1;
  }
  
  .sortable.desc::after {
    content: '↓';
    opacity: 1;
  }
  
  .sortable:hover {
    background-color: rgba(255, 255, 255, 0.05);
  }
  
  /* ABC Analysis Styles */
  .group-a {
    background-color: rgba(40, 167, 70, 0.63) !important; /* Green */
  }
  
  .group-b {
    background-color: rgba(255, 198, 26, 0.71) !important; /* Yellow */
  }
  
  .group-c {
    background-color: rgba(255, 51, 51, 0.87) !important; /* Red */
  }
  
  /* Override Bootstrap container width */
  @media (min-width: 1400px) {
    .container,
    .container-lg,
    .container-xl,
    .container-xxl {
      max-width: 1920px;
    }
  }
  
  /* Loader styles */
  .table-container {
    position: relative;
    min-height: 200px;
  }
  
  .loader-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 999;
    border-radius: 4px;
  }
  
  .loader {
    width: 48px;
    height: 48px;
    border: 5px solid #2B2B2B;
    border-bottom-color: #ffffff;
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
  }
  
  .loader-progress {
    position: absolute;
    bottom: 20%;
    color: white;
    font-size: 1.2rem;
    text-align: center;
    width: 100%;
  }
  
  @keyframes rotation {
    0% {
      transform: rotate(0deg);
    }
    100% {
      transform: rotate(360deg);
    }
  }


  .compact-table {
    margin-bottom: 0;
  }
  .compact-table th,
  .compact-table td {
    padding: 0.3rem 0.75rem;
    vertical-align: middle;
  }
  .compact-table tr {
    line-height: 1;
  }
  .scrollable-table {
    max-height: 150px;
    overflow-y: auto;
  }
  .scrollable-table thead th {
    position: sticky;
    top: 0;
    background-color: #212529;
    z-index: 1;
  }

/* Organization Delivery Stats Inline */

:root {
    --first-column-width: 220px;
  }
  
  /* Reuse existing styles from delivery_list.html */
  .hide-navbar .navbar {
    display: none;
  }
  
  .hide-navbar .main-content {
    padding-top: 0;
  }
  
  .d-flex {
    display: flex;
    justify-content: flex-start;
    width: 100%;
    padding: 0;
    margin: 0;
  }
  
  /* Table with sticky first column */
  .table-responsive {
    overflow-x: auto;
    position: relative;
  }
  
  .table th:first-child,
  .table td:first-child {
    position: -webkit-sticky; /* For Safari */
    position: sticky;
    left: 0;
    z-index: 10; /* High enough to stay on top */
    width: var(--first-column-width);
    min-width: var(--first-column-width);
    background-color: #2B2B2B; /* Match table background */
    box-shadow: 2px 0 3px -1px rgba(0, 0, 0, 0.4);
  }
  
  /* Special background for header */
  .table-dark th:first-child {
    background-color: #232323; /* Match header color */
    z-index: 11; /* Even higher for headers */
  }
  
  /* Handle hover effect for sticky first column */
  .table-hover tbody tr:hover td:first-child {
    background-color: rgba(43, 43, 43, 0.95); /* Slightly transparent to show hover effect */
  }
  
  .table {
    color: #e0e0e0;
    border-color: #444;
    margin-bottom: 0;
  }
  
  .table-dark {
    background-color: #2B2B2B;
  }
  
  .table-dark th,
  .table-dark td {
    border-color: #444;
  }
  
  .table-hover tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.05);
  }
  
  /* Organization name link styles */
  .table td a {
    color: #e0e0e0;
    text-decoration: none;
    transition: color 0.2s ease;
  }
  
  .table td a:hover {
    color: #ffffff;
    text-decoration: underline;
  }
  
  .content-header {
    background: #232323;
    padding: 1.5rem;
    border-radius: 12px 12px 0 0;
    margin: 0 0 1.5rem 0;
  }
  
  .content-header h1 {
    font-size: 1.5rem;
    font-weight: 500;
    color: white;
    margin: 0;
  }
  
  /* Sorting styles */
  .sortable {
    cursor: pointer;
    position: relative;
    padding-right: 20px;
  }
  
  .sortable::after {
    content: '↕';
    position: absolute;
    right: 5px;
    opacity: 0.5;
  }
  
  .sortable.asc::after {
    content: '↑';
    opacity: 1;
  }
  
  .sortable.desc::after {
    content: '↓';
    opacity: 1;
  }
  
  .sortable:hover {
    background-color: rgba(255, 255, 255, 0.05);
  }
  
  /* Override Bootstrap container width */
  @media (min-width: 1400px) {
    .container,
    .container-lg,
    .container-xl,
    .container-xxl {
      max-width: 1920px;
    }
  }

  #paginationNav {
    display: none;
  }