body {
    background-color: #f8f9fa;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden; /* Prevent horizontal scrolling */
    -webkit-text-size-adjust: 100%; /* Safari text size adjustment */
}

html {
    width: 100%;
    overflow-x: hidden; /* Prevent horizontal scrolling at the root level */
}

/* IMPORTANT FIX: Force mobile sidebar to top */
@media (max-width: 768px) {
  .modal-sidebar-container {
    display: flex !important;
    flex-flow: column !important;
  }
  
  .modal-sidebar {
    width: 100% !important;
  }
  
  .modal-content-area {
    width: 100% !important;
  }
}
  
.page-container {
max-width: 1400px;
margin: 0 auto;
width: 100%; /* Ensure the container takes full width */
padding-left: env(safe-area-inset-left); /* iOS safe area support */
padding-right: env(safe-area-inset-right); /* iOS safe area support */
}

/* Header styling */
.header-container {
border-radius: 10px;
background: linear-gradient(135deg, #3a8ffe 0%, #1d63c3 100%);
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
color: white;
position: relative;
margin-bottom: 0.75rem;
}

.header-container::before {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 18c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm48 25c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm-43-7c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm63 31c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM34 90c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm56-76c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM12 86c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm28-65c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm23-11c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-6 60c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm29 22c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zM32 63c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm57-13c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-9-21c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM60 91c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM35 41c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM12 60c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2z' fill='%23ffffff' fill-opacity='0.05' fill-rule='evenodd'/%3E%3C/svg%3E");
opacity: 0.7;
}

.account-info {
position: relative;
z-index: 2;
padding: 0.75rem !important;
}

.btn-account {
color: white;
text-decoration: underline;
padding: 0;
background: transparent;
border: none;
transition: all 0.2s ease;
}

.btn-account:hover {
color: rgba(255, 255, 255, 0.8);
text-decoration: none;
}

/* Page title */
.page-title {
font-weight: 700;
text-align: right;
position: relative;
color: #2c3e50;
margin-bottom: 1rem;
margin-top: 0.5rem;
margin-right: 0.5rem;
margin-left: auto;
font-size: 1.5rem;
padding-bottom: 0.5rem;
display: inline-block;
direction: rtl;
}

.page-title::after {
content: "";
position: absolute;
width: 60px;
height: 3px;
bottom: -5px;
right: 0;
border-radius: 3px;
}

.saml-page-title {
    font-size: 1.5rem;
    font-weight: 700;
    text-align: right;
    position: relative;
    margin-left: 6px;
    margin-right: 6px;
    color: white;
}
/* Navigation tabs */
.nav-container {
background: white;
border-radius: 10px;
box-shadow: 0 2px 15px rgba(0, 0, 0, 0.05);
overflow: hidden;
margin-bottom: 1.5rem;
}

.custom-tabs {
display: flex;
border-bottom: none;
padding: 0;
height: 100%;
}

.custom-tabs .nav-item {
margin: 0;
}

.custom-tabs .nav-link {
border: none;
padding: 0.8rem 1rem;
font-weight: 500;
color: #6c757d;
border-radius: 0;
border-bottom: 3px solid transparent;
transition: all 0.3s ease;
}

.custom-tabs .nav-link:hover {
color: #3a8ffe;
border-bottom: 3px solid rgba(58, 143, 254, 0.3);
background-color: rgba(58, 143, 254, 0.03);
}

.custom-tabs .nav-link.active {
color: #3a8ffe;
background-color: transparent;
border-bottom: 3px solid #3a8ffe;
}

/* Enhanced mobile actions buttons */
@media (max-width: 768px) {
  .nav-container {
    padding: 5px;
    margin-bottom: 1rem;
  }
  
  .nav-container .row {
    margin: 0;
    display: flex;
    flex-wrap: nowrap;
  }
  
  .nav-container .col-auto,
  .nav-container .col {
    padding: 0.25rem;
  }
  
  .nav-container .btn-custom {
    padding: 0.3rem 0.5rem !important;
    font-size: 0.8rem !important;
    border-radius: 4px !important;
    margin: 0 0.15rem !important;
    min-height: 30px;
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1) !important;
  }
  
  .nav-container .btn-custom:active {
    transform: translateY(1px) !important;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1) !important;
  }
  
  .nav-container .btn-custom i {
    font-size: 0.9rem;
    margin-right: 4px;
  }
  
  /* No wrapping of action buttons */
  .nav-container .d-flex {
    flex-wrap: nowrap;
    gap: 0;
  }
  
  /* RTL adjustments for mobile buttons */
  [dir="rtl"] .nav-container .btn-custom i {
    margin-right: 0;
    margin-left: 4px;
  }
  
  /* Ensure the button text is scaled properly */
  .nav-container .btn-custom strong {
    font-weight: 600;
    font-size: 0.8rem;
  }
  
  /* Truncate text in action buttons if needed */
  .nav-container .btn-custom {
    max-width: auto;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* Language picker inside header: ensure dropdown is visible above header */
.header-container { overflow: visible; }
.language-picker-wrapper { position: relative; z-index: 2000; }
.language-picker-wrapper .language-dropdown-content { z-index: 3000; }

.btn-custom {
padding: 0.4rem 1rem;
font-weight: 500;
border-radius: 5px !important;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
transition: all 0.3s ease;
}

.btn-primary.btn-custom {
background-color: #3a8ffe;
border-color: #3a8ffe;
}

.btn-primary.btn-custom:hover {
background-color: #1d63c3;
border-color: #1d63c3;
transform: translateY(-1px);
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.btn-outline-primary.btn-custom {
color: #3a8ffe;
border-color: #3a8ffe;
}

.btn-outline-primary.btn-custom:hover {
color: white;
background-color: #3a8ffe;
transform: translateY(-1px);
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Fix focus states */
.btn-custom:focus, 
.btn-custom:active, 
.btn-custom.active {
opacity: 1 !important;
box-shadow: 0 0 0 0.25rem rgba(58, 143, 254, 0.25) !important;
}

.btn-outline-primary.btn-custom:focus {
color: #3a8ffe;
background-color: transparent;
}

.btn-primary.btn-custom:focus {
color: white;
background-color: #3a8ffe;
}

/* Account badge */
.account-badge {
display: inline-block;
padding: 0.25rem 0.5rem;
border-radius: 20px;
font-size: 0.75rem;
font-weight: 600;
}

.account-badge.premium {
background-color: rgba(52, 191, 163, 0.1);
color: #34bfa3;
}

.account-badge.basic {
background-color: rgba(255, 184, 34, 0.1);
color: #ffb822;
}

.account-badge.expired {
background-color: rgba(244, 81, 108, 0.1);
color: #f4516c;
}

/* Card container */
.content-container {
background: white;
border-radius: 10px;
box-shadow: 0 2px 15px rgba(0, 0, 0, 0.05);
min-height: 300px;
margin-top: 0.75rem;
}

/* Loading spinner */
.spinner-container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
min-height: 250px;
padding: 1rem 0;
}

.custom-spinner {
width: 35px;
height: 35px;
border: 3px solid rgba(58, 143, 254, 0.1);
border-radius: 50%;
border-top-color: #3a8ffe;
animation: spin 1s ease-in-out infinite;
margin-bottom: 0.5rem;
}

@keyframes spin {
to { transform: rotate(360deg); }
}

/* Original card styling */
/* Card Styling */
.order-card, .study-card {
border: 1px solid #ccc;
border-radius: 8px;
margin-bottom: 1.5rem;
padding: 0; /* Changed from padding: 12px to use card-header and card-body instead */
background-color: #fff;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
transition: all 0.2s ease;
overflow: visible !important; /* Ensure content like dropdowns can overflow */
}

/* Fixed height cards */
.card-fixed-height {
height: 285px;
}

/* Make card body scrollable if content is too tall */
.content-scrollable {
max-height: 70px;
overflow-y: auto;
scrollbar-width: thin;
}

/* Customize scrollbar */
.content-scrollable::-webkit-scrollbar {
width: 8px;
}

.content-scrollable::-webkit-scrollbar-track {
background: #f1f1f1;
border-radius: 4px;
}

.content-scrollable::-webkit-scrollbar-thumb {
background: #bbb;
border-radius: 4px;
}

.content-scrollable::-webkit-scrollbar-thumb:hover {
background: #999;
}

/* Text truncation for longer text */
.text-truncate {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 100%;
}

.order-card:hover, .study-card:hover {
box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

.order-card .card-body, .study-card .card-body {
padding: 15px;
}

.card-header {
background-color: #f8f9fa;
border-bottom: 1px solid #e9ecef;
padding: 0.75rem 1rem;
}

/* Status indicators */
.status-indicator {
display: inline-block;
width: 12px;
height: 12px;
border-radius: 50%;
margin-right: 5px;
}

/* Button styling */
.btn-action {
padding: 0.5rem 0.75rem;
font-size: 1rem;
border-radius: 4px;
margin: 0.25rem 0;
}

/* Status colors with better contrast */
.status-new { background-color: #28a745; }
.status-open { background-color: #0dcaf0; }
.status-wait { background-color: #ffc107; }
.status-cancelled { background-color: #dc3545; }
.status-completed { background-color: #6c757d; }

.bg-light {
background-color: #f8f9fa !important;
}

.bg-warning {
background-color: #f7b924 !important;
}

.bg-info {
background-color: #0dcaf0 !important;
}

.bg-success {
background-color: #198754 !important;
}

.bg-secondary {
background-color: #6c757d !important;
}

/* Loading Spinner */
.spinner-hidden {
display: none !important;
visibility: hidden !important;
opacity: 0 !important;
height: 0 !important;
width: 0 !important;
position: absolute !important;
z-index: -1 !important;
pointer-events: none !important;
}

/* Dropdown styling */
.dropdown {
position: static !important; /* Allow the dropdown to be positioned relative to nearest positioned ancestor */
text-align: left;
}

.dropdown-menu {
position: absolute;
z-index: 1050 !important; /* Higher z-index to appear above other elements */
min-width: 220px;
max-width: 280px;
padding: 0.5rem 0;
margin: 0.125rem 0 0;
font-size: 1rem;
color: #212529;
text-align: left;
list-style: none;
background-color: #fff;
background-clip: padding-box;
border: 1px solid rgba(0,0,0,.15);
border-radius: 0.25rem;
box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.25);
}

.dropdown-toggle {
font-size: 1rem;
padding: 0.5rem 1rem;
font-weight: 500;
}

.dropdown-toggle::after {
display: inline-block;
margin-left: 0.255em;
vertical-align: 0.255em;
content: "";
border-top: 0.3em solid;
border-right: 0.3em solid transparent;
border-bottom: 0;
border-left: 0.3em solid transparent;
}

.dropdown-item {
display: block;
width: 100%;
padding: 0.5rem 1rem;
clear: both;
font-weight: 400;
color: #212529;
text-align: inherit;
white-space: nowrap;
background-color: transparent;
border: 0;
text-decoration: none;
}

.dropdown-item:hover, .dropdown-item:focus {
color: #16181b;
text-decoration: none;
background-color: #f0f7ff;
}

.dropdown-item.active, .dropdown-item:active {
color: #fff;
text-decoration: none;
background-color: #0d6efd;
}

/* Card content */
.card-title {
font-size: 1.2rem;
font-weight: 600;
margin-bottom: 0.5rem;
}

.card-text {
margin-bottom: 0.5rem;
font-size: 1rem;
line-height: 1.5;
}

/* Status text */
.badge {
font-size: 0.9rem;
padding: 0.35em 0.65em;
}

/* Improved text contrast */
.text-muted {
color: #5a5a5a !important;
}

.small {
font-size: 0.95rem !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
.order-card, .study-card {
    padding: 0; /* Adjusted for card-header and card-body */
}
.card-title {
    font-size: 1rem;
}
.card-text {
    font-size: 0.85rem;
}
.btn-action {
    padding: 0.2rem 0.4rem;
    font-size: 0.8rem;
}
.card-fixed-height {
    height: auto; /* On mobile, let cards have natural height */
    min-height: 300px;
}
}

/* Date filter styling */
.date-filter-container {
border-radius: 6px;
}

.date-filter-container .input-group {
flex-wrap: nowrap;
}

.date-filter-container input[type="date"] {
min-width: 120px;
}

.study-item {
  transition: all 0.2s ease;
  cursor: pointer;
  position: relative;
  overflow: visible;
  padding: 0.5rem;
  border-radius: 0.25rem;
}

.study-item:hover {
  box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
  transform: translateY(-1px);
}

.study-actions {
  position: absolute;
  right: 0;
  top: 0;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 100;
  display: flex;
  gap: 0.25rem;
  padding: 0.25rem;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 0.25rem;
  box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.study-item:hover .study-actions {
  opacity: 1;
}

.study-actions button {
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
  white-space: nowrap;
  border: 1px solid var(--bs-primary);
  background: white;
  color: var(--bs-primary);
}

.study-actions button:hover {
  background-color: var(--bs-primary);
  color: white;
}

.study-item .flex-grow-1 {
  padding-right: 1rem;
  max-width: 100%;
}

.study-details {
  max-height: 100px;
  overflow-y: auto;
}

/* Custom Modal Styles */
.custom-modal {
  display: none;
  position: fixed;
  z-index: 1500;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: rgba(15, 23, 42, 0.6);
  animation: fadeIn 0.3s ease-in-out;
  backdrop-filter: blur(2px);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.custom-modal-content {
  background-color: #fff;
  margin: 5% auto;
  max-width: 800px;
  max-height: 600px; /* Fixed height for modal */
  border-radius: 12px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  animation: slideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
}

@keyframes slideIn {
  from { transform: translateY(-40px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.custom-modal-header {
  padding: 20px 25px;
  border-bottom: 1px solid #e9ecef;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(to right, #f8f9fa, #ffffff);
}

.custom-modal-header h5 {
  margin: 0;
  font-weight: 800;
  color: #3a4a61;
  font-size: 1.35rem;
  position: relative;
  padding-left: 15px;
}

.custom-modal-header h5::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(to bottom, #3a8ffe, #4c6ef5);
  border-radius: 4px;
}

.custom-modal-close {
  color: #94a3b8;
  font-size: 32px;
  font-weight: 300;
  cursor: pointer;
  line-height: 0.8;
  transition: all 0.2s ease;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.custom-modal-close:hover {
  color: #ef4444;
  background-color: rgba(239, 68, 68, 0.1);
  transform: rotate(90deg);
}

.custom-modal-footer {
  padding: 16px 25px; /* Slightly reduced padding */
  border-top: 1px solid #e9ecef;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: linear-gradient(to right, #f8f9fa, #ffffff);
  flex-shrink: 0; /* Prevent footer from shrinking */
  position: sticky; /* Keep footer in place */
  bottom: 0;
  z-index: 10;
  box-shadow: 0 -4px 10px rgba(0,0,0,0.05);
}

.custom-modal-footer .btn {
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.custom-modal-footer .btn-primary {
  background: linear-gradient(to right, #3a8ffe, #4c6ef5);
  border: none;
}

.custom-modal-footer .btn-primary:hover {
  background: linear-gradient(to right, #3482e5, #3a55db);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(74, 108, 239, 0.3);
}

.custom-modal-footer .btn-secondary {
  background: #fff;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

.custom-modal-footer .btn-secondary:hover {
  background: #f8fafc;
  color: #334155;
  border-color: #cbd5e1;
}

/* Modality options layout - convert from grid to scrollable */
.modality-options {
  overflow-y: auto;
  max-height: 220px; /* Match the institution options height */
  margin-bottom: 10px;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 10px;
  background-color: #f8fafc;
}

/* Add scrollbar styling for modality options */
.modality-options::-webkit-scrollbar {
  width: 8px;
}

.modality-options::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.modality-options::-webkit-scrollbar-thumb {
  background: #bbb;
  border-radius: 4px;
}

.modality-options::-webkit-scrollbar-thumb:hover {
  background: #999;
}

/* RTL support for the modal sidebar */
[dir="rtl"] .modal-sidebar {
  border-right: none;
}

[dir="rtl"] .filter-nav-item {
  border-left: none;
  border-right: 4px solid transparent;
  border-radius: 8px 0 0 8px;
  text-align: right;
  margin: 0 0 0 5px;
}

[dir="rtl"] .filter-nav-item i {
  margin-right: 0;
  margin-left: 10px;
}

[dir="rtl"] .filter-nav-item.active {
  border-left: none;
  border-right: 4px solid #3ef6ff;
}

[dir="rtl"] .filter-section-title::after {
  left: auto;
  right: 0;
}

[dir="rtl"] .form-check {
  padding-left: 0;
  padding-right: 32px;
}

[dir="rtl"] .form-check:hover {
  transform: translateX(-3px);
}

[dir="rtl"] .form-check-input {
  margin-left: 0;
  margin-right: -32px;
}

[dir="rtl"] .form-check-label {
  padding-left: 0;
  padding-right: 8px;
}

[dir="rtl"] .custom-modal-header h5 {
  padding-left: 0;
  padding-right: 15px;
}

[dir="rtl"] .custom-modal-header h5::before {
  left: auto;
  right: 0;
}

/* Mobile responsive layout */
@media (max-width: 768px) {
  /* Complete reset of modal container for mobile */
  .custom-modal-body,
  .modal-sidebar-container {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
  }
  
  .modal-sidebar-container {
    flex-direction: column !important;
    overflow: hidden;
    flex: 1;
  }
  
  .modal-sidebar {
    width: 100% !important;
    flex-basis: auto !important;
    max-width: 100% !important;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    overflow-x: auto;
    flex-shrink: 0;
    position: relative;
    z-index: 5;
    height: auto !important;
    min-height: 0 !important;
    display: block !important;
    float: none !important;
  }
  
  .filter-nav {
    flex-direction: row !important;
    overflow-x: auto;
    padding: 8px 10px;
    margin: 0;
    white-space: nowrap;
    justify-content: flex-start;
    scrollbar-width: none;
    -ms-overflow-style: none;
    flex-wrap: nowrap;
    display: flex !important;
  }
  
  .filter-nav::-webkit-scrollbar {
    display: none;
  }
  
  .filter-nav-item {
    border-left: none !important;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
    padding: 10px 16px;
    border-radius: 6px;
    margin: 0 4px;
    flex-shrink: 0;
  }
  
  .filter-nav-item.active {
    border-left: none !important;
    border-bottom: 3px solid #3a8ffe;
    background-color: rgba(58, 143, 254, 0.08);
  }
  
  .modal-content-area {
    padding: 15px;
    overflow-y: auto;
    max-height: calc(80vh - 180px); /* Adjusted to leave more room for the footer */
    flex-grow: 1;
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
  }
  
  .modality-options {
    max-height: 30vh; /* Match the institution options height */
    min-height: 100px;
    overflow-y: auto;
    margin-bottom: 15px; /* Add extra space before footer */
  }
  
  .custom-modal-content {
    width: 95%;
    margin: 2% auto;
    display: flex;
    flex-direction: column;
    max-height: 96vh;
  }

  .custom-modal-body {
    overflow: hidden;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
  }
  
  .custom-modal-footer {
    position: sticky;
    bottom: 0;
    padding: 15px;
    box-shadow: 0 -4px 10px rgba(0,0,0,0.05);
    background: #fff;
    z-index: 50;
  }
  
  /* Make all filter content areas work properly on mobile */
  #dateFilter, #modalityFilter, #institutionFilter {
    display: none;
    min-height: auto;
    max-height: none;
    overflow-y: visible;
  }
  
  .filter-tab-content.active {
    display: block;
  }
  
  /* Institution options specifically for mobile */
  .institution-options {
    max-height: 30vh; /* Further reduced to ensure footer is visible */
    min-height: 100px;
    overflow-y: auto;
    margin-bottom: 15px; /* Add extra space before footer */
  }
  
  [dir="rtl"] .filter-nav-item,
  [dir="rtl"] .filter-nav-item.active {
    border-right: none !important;
    border-bottom: 3px solid transparent;
  }
  
  [dir="rtl"] .filter-nav-item.active {
    border-bottom: 3px solid #3a8ffe;
  }

  /* Better tap targets for mobile */
  .filter-nav-item {
    min-width: auto;
    text-align: center;
  }

  .filter-nav-item i {
    margin-right: 6px;
    font-size: 1.1em;
  }

  .form-check-input {
    width: 24px;
    height: 24px;
  }

  .form-check-label {
    padding-left: 10px;
    font-size: 1rem;
  }
  
  /* Remove any sidebar positioning */
  .modal-sidebar::before {
    display: none !important;
  }
  
  /* Ensure buttons in footer are properly sized and visible */
  .custom-modal-footer .btn {
    padding: 8px 16px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* Filtered cards - properly hidden */
.filtered-out {
  display: none;
}

/* Modal sidebar container */
.modal-sidebar-container {
  display: flex;
  flex-direction: row;
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  flex: 1;
  min-height: 0; /* Important for flex containers */
}

/* Sidebar styles */
.modal-sidebar {
  width: 220px;
  flex-shrink: 0;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
  position: relative;
  overflow: hidden;
  z-index: 2;
  background-color: #f8f9fa; /* Light background instead of gradient */
}

/* Add this to ensure proper structure */
.custom-modal-body {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* Prevent body overflow */
  min-height: 0; /* Important for proper flex behavior */
}

.modal-sidebar::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 18c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm48 25c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm-43-7c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm63 31c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3z' fill='%23ffffff' fill-opacity='0.1' fill-rule='evenodd'/%3E%3C/svg%3E");
  opacity: 0.3;
  z-index: -1;
}

/* Content area */
.modal-content-area {
  flex-grow: 1;
  padding: 20px 25px;
  overflow: hidden; /* Change from overflow-y: auto to hidden */
  background: #ffffff;
  position: relative;
  display: flex;
  flex-direction: column;
  max-height: 400px; /* Fixed height for content area */
}

.modal-content-area::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 6px;
  background: linear-gradient(to right, rgba(0,0,0,0.05), rgba(0,0,0,0));
  pointer-events: none;
}

/* Filter navigation */
.filter-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 15px 0;
  margin-top: 5px;
}

.filter-nav-item {
  padding: 14px 18px;
  border-left: 4px solid transparent;
  cursor: pointer;
  transition: all 0.3s ease;
  color: #415668; /* Changed from white to dark blue-gray */
  font-weight: 600;
  letter-spacing: 0.2px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  margin: 0 5px;
  border-radius: 0 8px 8px 0;
}

.filter-nav-item i {
  margin-right: 10px;
  font-size: 1.2em;
  transition: all 0.3s ease;
  color: #3a8ffe; /* Blue color for icons */
}

.filter-nav-item:hover {
  background-color: rgba(58, 143, 254, 0.08); /* Light blue background */
  color: #3a8ffe; /* Blue text on hover */
}

.filter-nav-item.active {
  background-color: rgba(58, 143, 254, 0.12); /* Slightly darker blue background */
  border-left: 4px solid #3a8ffe; /* Changed from teal to primary blue */
  color: #3a8ffe; /* Blue text when active */
  box-shadow: 0 4px 15px rgba(59, 139, 235, 0.1);
}

.filter-nav-item.active i {
  color: #3a8ffe; /* Blue icon when active */
  transform: scale(1.1);
}

.filter-nav-item::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(to right, rgba(58, 143, 254, 0), rgba(58, 143, 254, 0.03));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.filter-nav-item:hover::after {
  opacity: 1;
}

/* Filter tab content */
.filter-tab-content {
  display: none; /* Simple display none instead of complex positioning */
  padding: 5px 0 15px;
}

.filter-tab-content.active {
  display: block; /* Simple display block */
}

/* Make only the institution filter content scrollable while keeping date and modality filter tabs fully visible */
#dateFilter, #modalityFilter {
  height: auto;
  overflow-y: visible;
}

#institutionFilter {
  height: auto;
  overflow-y: visible;
}

/* Style the institution options container to be scrollable */
.institution-options {
  overflow-y: auto;
  max-height: 220px; /* Fixed height for scrollable content */
  margin-bottom: 10px;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 10px;
  background-color: #f8fafc;
}

/* Add scrollbar styling for institution options */
.institution-options::-webkit-scrollbar {
  width: 8px;
}

.institution-options::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.institution-options::-webkit-scrollbar-thumb {
  background: #bbb;
  border-radius: 4px;
}

.institution-options::-webkit-scrollbar-thumb:hover {
  background: #999;
}

.filter-section-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 20px;
  color: #3a4a61;
  border-bottom: 2px solid #e9ecef;
  padding-bottom: 10px;
  position: relative;
}

.filter-section-title::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 50px;
  height: 2px;
  background: linear-gradient(to right, #3a8ffe, #4c6ef5);
}

/* Restore RTL styling for filter section titles */
[dir="rtl"] .filter-section-title::after {
  left: auto;
  right: 0;
}

/* Form check styling */
.form-check {
  margin-bottom: 12px;
  position: relative;
  padding-left: 32px;
  transition: all 0.2s ease;
  cursor: pointer;
}

.form-check:hover {
  transform: translateX(3px);
}

.form-check-input {
  width: 22px;
  height: 22px;
  margin-top: 0;
  margin-left: -32px;
  border: 2px solid #cbd5e1;
  border-radius: 6px !important;
  cursor: pointer;
  transition: all 0.2s ease;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  position: relative;
  background-color: #fff;
}

.form-check-input:checked {
  background-color: #3a8ffe;
  border-color: #3a8ffe;
  box-shadow: 0 3px 8px rgba(58, 143, 254, 0.3);
}

.form-check-input:checked::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 7px;
  width: 6px;
  height: 12px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.form-check-input:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(58, 143, 254, 0.2);
}

.form-check-label {
  display: inline-block;
  padding-left: 8px;
  cursor: pointer;
  font-size: 1.05rem;
  font-weight: 500;
  color: #415668;
  transition: all 0.2s ease;
}

.form-check:hover .form-check-label {
  color: #3a8ffe;
}

/* Date inputs styling */
.date-range-inputs .form-group {
  margin-bottom: 25px;
  position: relative;
}

.date-range-inputs label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: #3a4a61;
  font-size: 0.95rem;
  transition: all 0.2s ease;
}

.date-range-inputs input[type="date"] {
  padding: 12px 16px;
  border: 2px solid #e1e8ef;
  border-radius: 8px;
  width: 100%;
  font-size: 1rem;
  line-height: 1.5;
  transition: all 0.3s ease;
  background-color: #f8fafc;
  color: #334155;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.03);
}

.date-range-inputs input[type="date"]:focus {
  border-color: #3a8ffe;
  box-shadow: 0 0 0 3px rgba(58, 143, 254, 0.2);
  outline: none;
  background-color: #fff;
}

.date-range-inputs input[type="date"]:focus + label {
  color: #3a8ffe;
}

.date-range-inputs input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.6;
  color: #3a8ffe;
  transition: all 0.2s ease;
}

.date-range-inputs input[type="date"]:hover::-webkit-calendar-picker-indicator,
.date-range-inputs input[type="date"]:focus::-webkit-calendar-picker-indicator {
  opacity: 1;
}

/* Additional RTL adjustments for form checks */
[dir="rtl"] .form-check {
  padding-left: 0;
  padding-right: 32px;
}

[dir="rtl"] .form-check:hover {
  transform: translateX(-3px);
}

[dir="rtl"] .form-check-input {
  margin-left: 0;
  margin-right: -32px;
}

[dir="rtl"] .form-check-label {
  padding-left: 0;
  padding-right: 8px;
}

/* Safari specific fixes */
@supports (-webkit-touch-callout: none) {
  /* CSS specific to iOS devices */
  @media (max-width: 768px) {
    body {
      width: 100vw;
      position: relative;
      overflow-x: hidden;
    }
    
    .page-container {
      max-width: 100%;
      width: 100%;
      box-sizing: border-box;
      left: 0;
      position: relative;
    }
    
    .header-container, 
    .nav-container, 
    .content-container,
    .custom-modal-content {
      width: 100%;
      max-width: 100%;
      box-sizing: border-box;
      left: 0;
      position: relative;
    }
  }
}
/* Hidden by the per-patient tab level (kept separate from .filtered-out, which the institution
   filter clears wholesale) */
.patient-filtered-out {
  display: none !important;
}
