/* Modern Bootstrap CRM Theme */

/* Softer card and modal corners */
.card, .modal-content, .dropdown-menu {
  border-radius: 1rem !important;
  box-shadow: 0 4px 24px rgba(30, 41, 59, 0.08), 0 1.5px 4px rgba(30, 41, 59, 0.04);
}

/* Table container for shadow and rounded corners */
.table-responsive, .table {
  border-radius: 0.75rem;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(30, 41, 59, 0.06);
}

/* Fix for table column overlap */
.table-responsive {
  overflow-x: auto !important;
  overflow-y: hidden !important;
}

.table {
  width: max-content !important;
  min-width: 100% !important;
  table-layout: auto !important;
}

/* Force table cells to not wrap and expand properly */
.table th,
.table td {
  white-space: nowrap !important;
  min-width: auto !important;
}

/* Ensure table cells have proper padding */
.table td, .table th {
  padding: 0.75rem 0.5rem;
  border-bottom: 1px solid #e5e7eb;
}

/* Improve table responsiveness */
.table-responsive {
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch;
  border-radius: 0.75rem;
}

/* Add horizontal scroll indicator */
.table-responsive::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 20px;
  background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.8));
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.table-responsive:hover::after {
  opacity: 1;
}

/* Modern buttons */
.btn {
  border-radius: 0.5rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: box-shadow 0.2s, background 0.2s;
}
.btn-primary {
  background: linear-gradient(90deg, #2563eb 0%, #1e40af 100%);
  border: none;
  color: #fff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.08);
}
.btn-primary:hover, .btn-primary:focus {
  background: linear-gradient(90deg, #1e40af 0%, #2563eb 100%);
  color: #fff;
}
.btn-outline-secondary {
  border-color: #cbd5e1;
  color: #334155;
}
.btn-outline-secondary:hover, .btn-outline-secondary:focus {
  background: #f1f5f9;
  color: #1e40af;
}

/* Sidebar and header */
.sidebar, .navbar {
  border-radius: 1rem;
  box-shadow: 0 2px 12px rgba(30, 41, 59, 0.06);
  background: #fff;
}

/* Section headers */
.section-title, .card-header {
  background: #f8fafc;
  font-weight: 600;
  color: #2563eb;
  border-bottom: 1px solid #e5e7eb;
  letter-spacing: 0.04em;
}

/* Related records section improvements */
.related-records-section {
  margin-top: 1.5rem;
}

.related-records-section .card {
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
}

.related-records-section .card-header {
  background: #f8fafc;
  border-bottom: 1px solid #e5e7eb;
  padding: 1rem 1.25rem;
}

.related-records-section .card-body {
  padding: 0;
  overflow: hidden;
}

.related-records-section .table {
  margin-bottom: 0;
}

/* Ensure proper spacing in related records */
.related-records-section .btn {
  margin-left: 0.5rem;
}

/* Improve table header alignment in related records */
.related-records-section .table thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #f1f5f9;
}

/* Force related records tables to expand properly */
.related-records-section .table-responsive {
  overflow-x: auto !important;
  overflow-y: hidden !important;
}

.related-records-section .table {
  width: max-content !important;
  min-width: 100% !important;
}

.related-records-section .table th,
.related-records-section .table td {
  white-space: nowrap !important;
  min-width: auto !important;
}

/* Fix for table column overlap in related records */
#example.table {
  table-layout: auto !important;
  width: max-content !important;
  min-width: 100% !important;
}

#example.table th,
#example.table td {
  white-space: nowrap !important;
  min-width: auto !important;
  max-width: none !important;
  overflow: visible !important;
  text-overflow: clip !important;
  padding: 0.75rem 0.5rem !important;
  position: relative !important;
}

/* Ensure table headers don't overlap */
#example.table thead th {
  position: sticky !important;
  top: 0 !important;
  z-index: 10 !important;
  background: #f1f5f9 !important;
  border-bottom: 2px solid #e5e7eb !important;
  font-weight: 600 !important;
  text-transform: uppercase !important;
  font-size: 0.875rem !important;
  color: #64748b !important;
}

/* Fix for specific column widths */
#example.table th:first-child,
#example.table td:first-child {
  min-width: auto !important;
  max-width: none !important;
}

/* Ensure table container allows horizontal scrolling */
.table-responsive {
  overflow-x: auto !important;
  overflow-y: hidden !important;
  -webkit-overflow-scrolling: touch !important;
  border-radius: 0.75rem !important;
}

/* Specific fixes for OrderLineItems table */
.table-responsive:has(#example) {
  overflow-x: auto !important;
  overflow-y: hidden !important;
}

/* Prevent text overlap in table cells */
.table td,
.table th {
  position: relative !important;
  z-index: 1 !important;
}

/* Ensure no absolute positioning conflicts */
.table td *,
.table th * {
  position: relative !important;
  z-index: 2 !important;
}

/* Fix for any floating elements that might cause overlap */
.table td::before,
.table th::before,
.table td::after,
.table th::after {
  display: none !important;
}

/* Additional fix for table cell overlap */
.table td,
.table th {
  border-collapse: separate !important;
  border-spacing: 0 !important;
  box-sizing: border-box !important;
}

/* Ensure table cells don't overlap */
.table {
  border-collapse: separate !important;
  border-spacing: 0 !important;
  table-layout: auto !important;
}

/* Force table to respect cell boundaries */
.table tbody tr,
.table thead tr {
  display: table-row !important;
}

.table tbody td,
.table thead th {
  display: table-cell !important;
  vertical-align: middle !important;
}

/* Report table specific fixes - MINIMAL VERSION */
.report-table {
  width: 100% !important;
  table-layout: auto !important;
}

.report-table th,
.report-table td {
  white-space: nowrap !important;
  min-width: auto !important;
  max-width: none !important;
  overflow: visible !important;
  text-overflow: clip !important;
}

/* Ensure table-responsive works properly */
.table-responsive {
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch !important;
}



/* Table header */
.table thead th {
  background: #f1f5f9;
  color: #64748b;
  font-size: 0.95rem;
  font-weight: 600;
  text-transform: uppercase;
  border-bottom: 2px solid #e5e7eb;
}

/* Allow text wrapping for description fields */
.table tbody td[data-field*="description"],
.table tbody td[data-field*="notes"],
.table tbody td[data-field*="subject"] {
  white-space: normal;
  word-wrap: break-word;
}

/* Ensure report tables don't inherit word-wrap from general table styles */
.report-table td {
  word-wrap: normal !important;
  word-break: normal !important;
  hyphens: none !important;
  white-space: nowrap !important;
  overflow: visible !important;
  text-overflow: clip !important;
}

/* Specific column alignments for common fields */
.table th[data-field="quantity"],
.table td[data-field="quantity"] {
  text-align: center;
}

.table th[data-field*="price"],
.table td[data-field*="price"],
.table th[data-field*="amount"],
.table td[data-field*="amount"] {
  text-align: right;
}

/* Checkbox column styling - only apply when checkboxes are present */
.table thead th:first-child:has(.form-check-input),
.table thead th.checkbox-column {
  width: 50px !important;
  min-width: 50px !important;
  max-width: 50px !important;
  text-align: center !important;
  vertical-align: middle !important;
  padding: 0.75rem 0.5rem !important;
}

.table tbody td:first-child:has(.form-check-input),
.table tbody td.checkbox-column {
  width: 50px !important;
  min-width: 50px !important;
  max-width: 50px !important;
  text-align: center !important;
  vertical-align: middle !important;
  padding: 0.75rem 0.5rem !important;
}

/* Checkbox styling */
.form-check-input {
  width: 1.2rem !important;
  height: 1.2rem !important;
  margin: 0 !important;
  cursor: pointer !important;
  border: 2px solid #cbd5e1 !important;
  border-radius: 0.25rem !important;
  transition: all 0.2s ease !important;
}

.form-check-input:checked {
  background-color: #2563eb !important;
  border-color: #2563eb !important;
  box-shadow: 0 0 0 0.15rem rgba(37, 99, 235, 0.15) !important;
}

.form-check-input:hover {
  border-color: #2563eb !important;
  box-shadow: 0 0 0 0.15rem rgba(37, 99, 235, 0.1) !important;
}

.form-check-input:focus {
  border-color: #2563eb !important;
  box-shadow: 0 0 0 0.15rem rgba(37, 99, 235, 0.25) !important;
}

/* Table rows */
.table tbody tr {
  transition: background 0.15s;
}
.table tbody tr:hover {
  background: #f3f6fa;
}

/* Form controls */
.form-control, .form-select {
  border-radius: 0.5rem;
  border-color: #cbd5e1;
  box-shadow: none;
  transition: border-color 0.2s;
}
.form-control:focus, .form-select:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 0.15rem rgba(37, 99, 235, 0.08);
}

/* Alerts */
.alert {
  border-radius: 0.75rem;
  font-weight: 500;
}

/* Custom badge */
.badge {
  border-radius: 0.5rem;
  font-weight: 500;
  padding: 0.4em 0.8em;
}

/* Subtle shadow for floating elements */
.shadow-soft {
  box-shadow: 0 2px 8px rgba(30, 41, 59, 0.08);
}

/* Right sidebar specific styles */
.right-sidebar {
  position: fixed !important;
  top: 80px !important;
  right: 0 !important;
  height: calc(100vh - 80px) !important;
  z-index: 1050 !important;
  transition: width 0.3s ease !important;
  overflow: hidden !important;
  border: none !important;
  max-width: 320px !important;
}

.right-sidebar .card-body {
  height: calc(100% - 60px) !important;
  overflow-y: auto !important;
}

/* Mobile responsive header improvements */
@media (max-width: 768px) {
  .pagetitle {
    padding: 0.75rem !important;
  }
  
  .pagetitle .btn {
    min-height: 38px;
    font-size: 0.875rem;
    padding: 0.375rem 0.75rem;
  }
  
  .pagetitle .dropdown-toggle {
    font-size: 0.875rem;
    padding: 0.375rem 0.75rem;
  }
  
  .pagetitle .d-flex {
    gap: 0.5rem !important;
  }
  
  /* Ensure buttons don't get too small on mobile */
  .pagetitle .btn-sm {
    min-width: 44px; /* Touch target minimum */
  }
  
  /* Stack buttons vertically on very small screens */
  @media (max-width: 576px) {
    .pagetitle .d-flex {
      flex-direction: column;
      align-items: stretch !important;
    }
    
    .pagetitle .d-flex .btn {
      margin-bottom: 0.25rem;
    }
    
    .pagetitle .dropdown {
      margin-bottom: 0.25rem;
    }
  }
  
  /* Header navigation improvements for mobile */
  .header-nav .nav-icon {
    margin-right: 15px;
    font-size: 20px;
  }
  
  .header-nav ul {
    gap: 10px;
  }
  
  /* Ensure profile photo is properly sized and visible */
  .profile-photo {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    object-fit: cover;
    border-radius: 50%;
  }
  
  .profile-photo-placeholder {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
  }
  
  .header-nav .nav-profile span {
    display: none;
  }
  
  /* Ensure header has enough space */
  .header-nav {
    margin-left: auto;
    padding-right: 10px;
  }
  
  /* Reduce search bar width on mobile */
  .search-bar {
    max-width: 200px;
  }
  
  /* Ensure logo doesn't take too much space */
  .logo img {
    max-height: 35px;
    width: auto;
  }
}

@media (max-width: 576px) {
  .profile-photo {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    object-fit: cover;
    border-radius: 50%;
    margin-left: 3px;
  }
  
  .profile-photo-placeholder {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    margin-left: 3px;
  }
  
  /* Further reduce notification icon spacing on very small screens */
  .header-nav .nav-icon {
    margin-right: 5px;
    font-size: 16px;
  }
  
  /* Hide notification badge on very small screens if it causes overflow */
  .header-nav .badge-number {
    font-size: 8px;
    padding: 1px 3px;
  }
  
  /* Search bar will be toggled on small screens, not hidden */
  
  /* Make logo even smaller */
  .logo img {
    max-height: 25px;
  }
  
  /* Ensure maximum space for profile photo */
  .header-nav {
    padding-right: 0;
  }
  
  .header-nav ul {
    gap: 3px;
  }
}

/* Ensure header navigation doesn't overflow */
.header-nav {
  overflow: visible;
}

.header-nav ul {
  flex-wrap: nowrap;
  align-items: center;
}

/* Ensure proper spacing for button groups */
.gap-2 {
  gap: 0.5rem !important;
}

/* Improve dropdown positioning on mobile */
@media (max-width: 768px) {
  .dropdown-menu-end {
    right: 0 !important;
    left: auto !important;
  }
}

/* Mobile responsive table improvements */
@media (max-width: 768px) {
  /* Make table more compact on mobile */
  .table {
    font-size: 0.875rem;
  }
  
  .table thead th {
    font-size: 0.8rem;
    padding: 0.5rem 0.25rem;
  }
  
  .table tbody td {
    padding: 0.5rem 0.25rem;
  }
  
  /* Ensure action buttons are touch-friendly */
  .table .btn-sm {
    min-width: 32px;
    min-height: 32px;
    padding: 0.25rem 0.5rem;
  }
  
  /* Improve text truncation for mobile */
  .text-truncate {
    max-width: 120px !important;
  }
  
  /* Make table responsive with horizontal scroll */
  .table-responsive {
    border-radius: 0.5rem;
    margin: 0 -0.5rem;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  
  /* Improve dropdown positioning in table */
  .table .dropdown-menu {
    min-width: 120px;
    font-size: 0.875rem;
  }
  
  .table .dropdown-item {
    padding: 0.5rem 0.75rem;
  }
  
  /* Force table to scroll horizontally on mobile */
  #records-table {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: thin;
  }
  
  #records-table::-webkit-scrollbar {
    height: 6px;
  }
  
  #records-table::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
  }
  
  #records-table::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
  }
  
  #records-table::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
  }
}

/* Extra small screens (phones) */
@media (max-width: 576px) {
  .table {
    font-size: 0.8rem;
  }
  
  .table thead th {
    font-size: 0.75rem;
    padding: 0.375rem 0.125rem;
  }
  
  .table tbody td {
    padding: 0.375rem 0.125rem;
  }
  
  /* Further reduce text width on very small screens */
  .text-truncate {
    max-width: 80px !important;
  }
  
  /* Make action buttons more compact */
  .table .btn-sm {
    min-width: 28px;
    min-height: 28px;
    padding: 0.125rem 0.25rem;
  }
  
  /* Improve table container spacing */
  .table-responsive {
    margin: 0 -0.25rem;
  }
  
  /* Ensure minimum table width for scrolling */
  #example {
    min-width: 600px !important;
  }
  
  /* Make table headers sticky for better UX */
  .table thead th {
    position: sticky;
    top: 0;
    background: #f1f5f9;
    z-index: 10;
  }
}

/* Ensure table hover effects work on touch devices */
@media (hover: none) {
  .table-hover tbody tr:hover {
    background: transparent;
  }
  
  .table-hover tbody tr:active {
    background: #f3f6fa;
  }
}

/* Additional mobile table improvements */
@media (max-width: 768px) {
  /* Ensure table doesn't break layout */
  .datatable-container {
    overflow: hidden;
  }
  
  /* Improve table cell content handling */
  .table:not(.report-table) td {
    word-wrap: break-word;
    overflow-wrap: break-word;
  }
  
  /* Ensure report tables don't inherit word-wrap from mobile table styles */
  .report-table td {
    word-wrap: normal !important;
    word-break: normal !important;
    hyphens: none !important;
    white-space: nowrap !important;
    overflow: visible !important;
    text-overflow: clip !important;
    max-width: none !important;
  }
  
  /* Better mobile scrolling indicators */
  .table-responsive::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 20px;
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.8));
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
  }
  
  .table-responsive:hover::after {
    opacity: 1;
  }
}

/* Modern sort indicators */
.sort-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  position: relative;
}

.sort-indicator .sort-up,
.sort-indicator .sort-down {
  font-size: 12px;
  line-height: 1;
  transition: all 0.2s ease;
  opacity: 0.4;
}

.sort-indicator .sort-up {
  margin-bottom: -2px;
}

.sort-indicator .sort-down {
  margin-top: -2px;
}

/* Hover effects for sort indicators */
.datatable-sorter:hover .sort-indicator .sort-up,
.datatable-sorter:hover .sort-indicator .sort-down {
  opacity: 0.7;
  color: #2563eb !important;
}

/* Active sort indicators */
.sort-indicator .sort-up.text-primary,
.sort-indicator .sort-down.text-primary {
  opacity: 1;
  font-weight: 600;
}

/* Ensure sort indicators are properly aligned */
.datatable-sorter {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.5rem 0.75rem;
  transition: background-color 0.2s ease;
}

.datatable-sorter:hover {
  background-color: rgba(37, 99, 235, 0.05);
  border-radius: 0.25rem;
}

/* Mobile responsive sort indicators */
@media (max-width: 768px) {
  .sort-indicator {
    width: 14px;
    height: 14px;
  }
  
  .sort-indicator .sort-up,
  .sort-indicator .sort-down {
    font-size: 10px;
  }
  
  .datatable-sorter {
    padding: 0.375rem 0.5rem;
  }
}

/* Ensure sort indicators work well with table header styling */
.table thead th .datatable-sorter {
  background: transparent;
  border: none;
  color: inherit;
  font-weight: inherit;
  text-decoration: none;
}

.table thead th .datatable-sorter:hover {
  background-color: rgba(37, 99, 235, 0.08);
  color: #2563eb;
}

/* Override old datatable sort arrows to hide them */
.datatable-sorter::before,
.datatable-sorter::after {
  display: none !important;
}

/* Ensure no old arrow styling interferes */
.datatable-ascending .datatable-sorter::after,
.datatable-descending .datatable-sorter::before,
.datatable-ascending .datatable-filter::after,
.datatable-descending .datatable-filter::before {
  display: none !important;
} 

.actions-sticky-col {
  position: sticky;
  right: 0;
  background: #fff;
  z-index: 2;
  box-shadow: -2px 0 4px -2px rgba(0,0,0,0.04);
}

.table-responsive {
  overflow-x: auto;
} 

/* Required Field Styling */
.required-field {
    border-left: 3px solid #dc3545;
}

.required-field:focus {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

/* Form Label Styling */
.form-label .text-danger {
    font-weight: bold;
}

/* Django-Bootstrap5 Required Field Styling */
.form-group.required label::after,
label.required::after {
    content: " *";
    color: #dc3545;
    font-weight: bold;
}

/* Bootstrap5 Required Field Input Styling */
.form-control.required,
.form-select.required {
    border-left: 3px solid #dc3545;
}

.form-control.required:focus,
.form-select.required:focus {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

/* Form Instructions */
.form-instructions {
    background-color: #f8f9fa;
    border-left: 4px solid #17a2b8;
    padding: 0.75rem;
    margin-bottom: 1rem;
    border-radius: 0.25rem;
}

/* Required Field Group */
.required-section {
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 0.375rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.required-section h6 {
    color: #856404;
    margin-bottom: 0.5rem;
}

/* Optional Field Group */
.optional-section {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.optional-section h6 {
    color: #6c757d;
    margin-bottom: 0.5rem;
}

/* Form Validation Styling */
.form-control.is-invalid {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

.form-control.is-valid {
    border-color: #28a745;
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
}

/* Help Text Styling */
.form-text {
    font-size: 0.875rem;
    color: #6c757d;
}

/* Field Group Spacing */
.form-group {
    margin-bottom: 1rem;
}

/* Required Field Indicator Animation */
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

.form-label .text-danger {
    animation: pulse 2s infinite;
}

/* Modal Footer Fix */
.modal-footer {
    display: flex !important;
    align-items: center;
    justify-content: flex-end;
    padding: 1rem;
    border-top: 1px solid #dee2e6;
    background-color: #fff;
    z-index: 1;
}

.modal-footer button,
.modal-footer input[type="submit"] {
    margin-left: 0.5rem;
}

/* Ensure modal content doesn't hide footer */
.modal-content {
    display: flex;
    flex-direction: column;
}

.modal-body {
    flex: 1 1 auto;
    overflow-y: auto;
}

/* Sticky bottom for modal footer */
.modal-footer.sticky-bottom {
    position: sticky;
    bottom: 0;
    background-color: white;
    z-index: 10;
} 

/* Ensure trial banner clock icon doesn't look like a spinner */
.trial-banner .bi-clock-history {
    animation: none !important;
    transform: none !important;
    -webkit-animation: none !important;
    -moz-animation: none !important;
    -o-animation: none !important;
    -ms-animation: none !important;
}

/* Remove any spinner classes from trial banner */
.trial-banner.loading-spinner,
.trial-banner.spinner,
.trial-banner.spinning {
    animation: none !important;
    transform: none !important;
}

/* Hide Select2 loading spinners */
.select2-results__option.loading-results {
    display: none !important;
}

/* Ensure Select2 dropdowns work normally */
.select2-results__options {
    min-height: 0 !important;
}

/* Fix profile dropdown being too wide - OVERRIDE ALL CONFLICTING RULES */
.header-nav .profile {
    width: auto !important;
    max-width: 300px !important;
    min-width: auto !important; /* Changed from 240px to auto */
}

/* Ensure dropdown-menu-right works properly (Bootstrap 4) */
.dropdown-menu.dropdown-menu-right {
    right: 0 !important;
    left: auto !important;
}

/* Fix profile dropdown specific styling with higher specificity */
.header-nav .nav-item.dropdown .dropdown-menu.profile {
    position: absolute !important;
    width: auto !important;
    max-width: 300px !important;
    min-width: 200px !important; /* Reasonable minimum width */
}

/* Additional override for the dropdown menu itself */
.header-nav .dropdown-menu.profile {
    position: absolute !important;
    width: auto !important;
    max-width: 300px !important;
    min-width: 200px !important;
}

/* Ensure profile dropdown doesn't stretch */
@media (min-width: 768px) {
    .header-nav .dropdown-menu.profile {
        width: auto !important;
        max-width: 300px !important;
        min-width: 200px !important;
    }
}

/* Override any inherited width from parent elements */
.header-nav li.nav-item.dropdown {
    width: auto !important;
}

/* Force dropdown to not inherit any width styling */
.header-nav .nav-profile + .dropdown-menu {
    width: auto !important;
    max-width: 300px !important;
    min-width: 200px !important;
}

/* Fix header layout - ensure nav items stay at the right */
.header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 0 20px !important;
}

.header > div:first-child {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.header .search-bar {
    flex: 1 1 auto;
    max-width: 400px;
    margin: 0 20px;
}

.header .header-nav {
    flex-shrink: 0;
    margin-left: auto !important;
}

/* Ensure proper spacing on desktop */
@media (min-width: 1200px) {
    .header .search-bar {
        margin: 0 40px;
        min-width: auto !important;
    }
    
    .header .header-nav {
        padding-right: 0;
    }
    
    /* Remove excessive margin from nav icons */
    .header-nav .nav-icon {
        margin-right: 15px !important;
    }
}

/* Override style.css rule that sets min-width on .header-nav .profile */
.header-nav > ul > li.nav-item.dropdown {
    min-width: unset !important;
}

/* Ensure the dropdown menu is positioned correctly and sized properly */
.header-nav .nav-item.dropdown .dropdown-menu {
    position: absolute !important;
    transform: none !important;
    top: 100% !important;
    right: 0 !important;
    left: auto !important;
    width: auto !important;
    max-width: 300px !important;
    min-width: 200px !important;
    margin: 0 !important;
}

/* Style the profile dropdown toggle */
.header-nav .nav-profile.dropdown-toggle::after {
    margin-left: 0.5rem;
    vertical-align: middle;
}

/* Ensure clicking anywhere on the profile link triggers dropdown */
.header-nav .nav-profile {
    cursor: pointer;
}

.header-nav .nav-profile span {
    pointer-events: none; /* Prevent span from interfering with dropdown */
}

/* Modern Search Bar Styles */
.modern-search .search-input-wrapper {
    position: relative;
    width: 100%;
    background: #f5f6fa;
    border-radius: 50px;
    padding: 8px 16px;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.modern-search .search-input-wrapper:hover,
.modern-search .search-input-wrapper:focus-within {
    background: #ffffff;
    border-color: #667eea;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.1);
}

.modern-search .search-icon {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: #8b95a5;
    font-size: 16px;
    pointer-events: none;
    transition: color 0.3s ease;
}

.modern-search .search-input-wrapper:focus-within .search-icon {
    color: #667eea;
}

.modern-search .modern-search-input {
    border: none !important;
    background: transparent !important;
    padding: 8px 45px 8px 45px !important;
    font-size: 14px;
    color: #2d3748;
    width: 100%;
    outline: none !important;
    box-shadow: none !important;
}

.modern-search .modern-search-input::placeholder {
    color: #a0aec0;
    font-weight: 400;
}

.modern-search .modern-search-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: #667eea;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    transition: all 0.3s ease;
    cursor: pointer;
    opacity: 0;
}

.modern-search .search-input-wrapper:hover .modern-search-btn,
.modern-search .modern-search-input:focus ~ .modern-search-btn,
.modern-search .modern-search-input:not(:placeholder-shown) ~ .modern-search-btn {
    opacity: 1;
}

.modern-search .modern-search-btn:hover {
    background: #5a67d8;
    transform: translateY(-50%) scale(1.1);
}

.modern-search .modern-search-btn i {
    color: #ffffff !important;
    font-size: 14px;
}

/* Override existing search bar styles */
.header .search-bar.modern-search {
    min-width: 300px;
    max-width: 450px;
    flex: 1;
    padding: 0 20px;
}

/* Responsive adjustments for modern search */
@media (max-width: 768px) {
    .header .search-bar.modern-search {
        min-width: unset;
        max-width: 250px;
        padding: 0 10px;
    }
    
    .modern-search .modern-search-input {
        font-size: 13px;
        padding: 6px 40px 6px 40px !important;
    }
    
    .modern-search .search-input-wrapper {
        padding: 6px 12px;
    }
    
    .modern-search .modern-search-btn {
        width: 28px;
        height: 28px;
    }
}

/* Remove the display none for mobile - the toggle functionality will handle visibility */

/* Mobile search bar toggle styles */
@media (max-width: 1199px) {
    .header .search-bar {
        position: fixed;
        top: 50px;
        left: 10px;
        right: 10px;
        width: auto;
        max-width: none;
        min-width: auto;
        padding: 10px;
        background: #fff;
        box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
        border-radius: 8px;
        visibility: hidden;
        opacity: 0;
        transition: all 0.3s ease;
        z-index: 997;
    }
    
    .header .search-bar.search-bar-show {
        top: 60px;
        visibility: visible;
        opacity: 1;
    }
    
    .header .search-bar.modern-search .search-input-wrapper {
        background: #f5f6fa;
    }
}