/* Custom Typography Overrides */

/* Make all text darker/black by default */
body {
  color: #212529 !important;
  background-color: #f8f9fc;
}

/* Headings */
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
  color: #212529 !important;
  font-weight: 600;
}

/* Section headers with better spacing */
.h3 {
  letter-spacing: -0.5px;
}

/* Paragraphs and general text */
p, span, div, td, th, li {
  color: #212529;
}

/* Override SB Admin gray text classes */
.text-gray-800 {
  color: #212529 !important;
}

.text-gray-900 {
  color: #000000 !important;
}

/* Card improvements */
.card {
  border: none;
  transition: all 0.3s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.1) !important;
}

.card-body {
  color: #212529;
}

/* Stats card specific */
.stats-card {
  border-radius: 0.5rem;
  overflow: hidden;
}

.stats-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 0.75rem 2rem rgba(0, 0, 0, 0.12) !important;
}

/* Card header improvements */
.card-header {
  background-color: #fff;
  border-bottom: 1px solid #e3e6f0;
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* Table improvements */
.table {
  color: #212529;
}

.table td, .table th {
  color: #212529;
  vertical-align: middle;
  padding: 1rem 0.75rem;
}

.table thead th {
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6c757d;
  border-bottom: 2px solid #e3e6f0;
}

.table thead th.sortable {
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
}

.table thead th.sortable:hover {
  background-color: #f8f9fc;
  color: #4e73df;
}

.table tbody tr {
  transition: all 0.2s ease;
}

.table tbody tr:hover {
  background-color: #f8f9fc;
  transform: scale(1.01);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Form labels and inputs */
label, .form-label {
  color: #212529 !important;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.form-control {
  color: #212529 !important;
  border: 1px solid #d1d3e2;
  transition: all 0.2s ease;
}

.form-control:focus {
  border-color: #4e73df;
  box-shadow: 0 0 0 0.2rem rgba(78, 115, 223, 0.15);
}

/* Keep muted text slightly gray but readable */
.text-muted {
  color: #6c757d !important;
}

/* Small text */
small, .small {
  color: #6c757d !important;
}

/* Sidebar improvements */
.sidebar {
  box-shadow: 0 0 2rem rgba(0, 0, 0, 0.1);
}

.sidebar * {
  color: #fff !important;
}

.sidebar .nav-link {
  padding: 1rem;
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
  color: rgba(255, 255, 255, 0.8) !important;
}

.sidebar .nav-link:hover {
  background-color: rgba(255, 255, 255, 0.1);
  border-left-color: rgba(255, 255, 255, 0.5);
  color: #fff !important;
}

.sidebar .nav-link.active {
  background-color: rgba(255, 255, 255, 0.15);
  border-left-color: #fff;
  font-weight: 600;
  color: #fff !important;
}

.sidebar .nav-link span,
.sidebar .nav-link i,
.sidebar .sidebar-brand-text,
.sidebar .sidebar-brand-icon,
.sidebar .sidebar-brand,
.sidebar a {
  color: #fff !important;
}

.sidebar .sidebar-divider {
  border-color: rgba(255, 255, 255, 0.15);
}

/* Topbar improvements */
.topbar {
  box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.1);
}

.topbar .nav-link {
  color: #212529 !important;
  transition: all 0.2s ease;
}

.topbar .nav-link:hover {
  color: #4e73df !important;
}

/* Dropdown improvements */
.dropdown-menu {
  border: none;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
  border-radius: 0.5rem;
}

.dropdown-item {
  color: #212529 !important;
  padding: 0.75rem 1.5rem;
  transition: all 0.2s ease;
}

.dropdown-item:hover {
  background-color: #f8f9fc;
  color: #4e73df !important;
}

/* Button improvements */
.btn {
  font-weight: 500;
  transition: all 0.2s ease;
  border-radius: 0.35rem;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.15);
}

.btn:active {
  transform: translateY(0);
}

/* Badge improvements */
.badge {
  font-weight: 500;
  padding: 0.35rem 0.65rem;
  border-radius: 0.25rem;
}

/* Empty state styling */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: #6c757d;
}

.empty-state i {
  font-size: 3rem;
  color: #d1d3e2;
  margin-bottom: 1rem;
}

.empty-state h5 {
  color: #5a5c69;
  margin-bottom: 0.5rem;
}

.empty-state p {
  color: #858796;
  margin-bottom: 1.5rem;
}

/* Chart container improvements */
.chart-container {
  background: linear-gradient(180deg, #ffffff 0%, #f8f9fc 100%);
  border-radius: 0.5rem;
  padding: 1rem;
}

/* Smooth scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
  background: #d1d3e2;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #b7b9cc;
}


/* Sidebar Support Card */
.sidebar-card {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.05) 100%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 0.75rem;
  padding: 1.25rem;
  margin: 0 1rem 1rem 1rem;
  backdrop-filter: blur(10px);
  text-align: center;
}

.sidebar-card .support-btn {
  background: linear-gradient(135deg, #FFD700 0%, #FFC700 100%);
  color: #1a1a1a;
  font-weight: 600;
  border: none;
  transition: all 0.3s;
  padding: 0.5rem 1rem;
  width: 100%;
}

.sidebar-card .support-btn:hover {
  background: linear-gradient(135deg, #FFC700 0%, #FFB700 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 215, 0, 0.4);
  color: #000;
}

/* Sidebar Text - Force White */
.sidebar .nav-link,
.sidebar .nav-link span,
.sidebar .nav-link i,
.sidebar .sidebar-brand-text {
  color: #fff !important;
}

.sidebar .nav-item.active .nav-link {
  background-color: rgba(255, 255, 255, 0.1);
}

.sidebar .nav-link:hover {
  background-color: rgba(255, 255, 255, 0.15);
}

/* Logout Button - Red Filled Style */
.sidebar .logout-link {
  background: linear-gradient(135deg, #dc3545 0%, #c82333 100%) !important;
  border: 1px solid rgba(220, 53, 69, 0.5);
  transition: all 0.3s;
  margin: 0 1rem;
  border-radius: 0.35rem;
  padding: 0.75rem 1rem !important;
  display: block;
  max-width: calc(100% - 2rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar .logout-link:hover {
  background: linear-gradient(135deg, #c82333 0%, #bd2130 100%) !important;
  border-color: #bd2130;
  box-shadow: 0 4px 8px rgba(220, 53, 69, 0.4);
}

.sidebar .logout-link i,
.sidebar .logout-link span {
  color: #fff !important;
}

/* Sidebar Brand */
.sidebar-brand {
  background-color: rgba(0, 0, 0, 0.1);
}

.sidebar-brand-text {
  font-weight: 700;
  letter-spacing: 1px;
}


/* Avatar Circle */
.avatar-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #4e73df 0%, #224abe 100%);
  color: white;
  font-weight: 600;
  border-radius: 50%;
  text-transform: uppercase;
}

/* Topbar Avatar */
.topbar .avatar-circle {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Dropdown Logout Item */
.dropdown-item .text-danger {
  color: #dc3545 !important;
  font-weight: 600;
}

.dropdown-item:hover {
  background-color: #dc3545 !important;
}

.dropdown-item:hover .text-danger,
.dropdown-item:hover i {
  color: #fff !important;
}


/* Search Results Dropdown */
.search-results-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border-radius: 0.5rem;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
  margin-top: 0.5rem;
  max-height: 300px;
  overflow-y: auto;
  z-index: 1000;
}

.search-result-item {
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: all 0.2s;
  border-bottom: 1px solid #f1f1f1;
  display: flex;
  align-items: center;
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover {
  background-color: #f8f9fc;
  padding-left: 1.25rem;
}

.search-result-item i {
  width: 20px;
}

.navbar-search {
  position: relative;
}

.navbar-search .form-control {
  border-radius: 2rem;
  padding-left: 1rem;
}

.navbar-search .input-group-append .btn {
  border-radius: 0 2rem 2rem 0;
}


/* Mobile Sidebar Search */
.sidebar-search {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 0.5rem;
  margin: 0 0.5rem;
}

.sidebar-search .form-control {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
}

.sidebar-search .form-control::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

.search-mobile-item {
  border-radius: 0.25rem;
  transition: all 0.2s;
}

.search-mobile-item:hover {
  background: rgba(255, 255, 255, 0.1);
  text-decoration: none;
}

/* Mobile Responsive Fixes */
@media (max-width: 768px) {
  /* Keep sidebar visible in collapsed state on mobile */
  .sidebar {
    position: fixed !important;
    left: 0 !important;
    z-index: 1050;
    height: 100vh;
    overflow-y: auto;
    width: 6.5rem !important;
    min-width: 6.5rem;
  }
  
  /* Hide text in sidebar on mobile, show only icons */
  .sidebar .sidebar-brand-text {
    display: none;
  }
  
  .sidebar .nav-link span {
    display: none;
  }
  
  .sidebar .sidebar-card {
    display: none !important;
  }
  
  .sidebar .logout-link {
    margin: 0 0.5rem;
    padding: 0.75rem 0 !important;
    text-align: center;
    max-width: calc(100% - 1rem);
  }
  
  .sidebar .logout-link span {
    display: none;
  }
  
  .sidebar .logout-link i {
    margin: 0;
  }
  
  .sidebar .sidebar-search {
    display: none !important;
  }
  
  .sidebar .nav-link {
    text-align: center;
    padding: 0.75rem 0;
    border-left: none;
  }
  
  .sidebar .nav-link i {
    margin-right: 0;
  }
  
  .sidebar .nav-link.active {
    border-left: none;
    border-bottom: 3px solid #fff;
  }
  
  /* Remove overlay - no need for it */
  body.sidebar-toggled::before {
    display: none !important;
  }
  
  /* Adjust content wrapper to account for collapsed sidebar */
  #content-wrapper {
    width: calc(100% - 6.5rem) !important;
    margin-left: 6.5rem !important;
  }
  
  #content {
    padding: 1rem !important;
  }
  
  /* Fix topbar positioning - remove all top spacing */
  .topbar {
    padding: 0.5rem 1rem !important;
    margin: 0 !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 1000 !important;
  }
  
  /* Remove any top margin/padding from main content */
  #page-top {
    padding-top: 0 !important;
    margin-top: 0 !important;
  }
  
  #wrapper {
    padding-top: 0 !important;
    margin-top: 0 !important;
  }
  
  #content-wrapper {
    padding-top: 0 !important;
    margin-top: 0 !important;
  }
  
  #content {
    padding-top: 0 !important;
    margin-top: 0 !important;
  }
  
  /* Sidebar mobile behavior - collapsed by default */
  @media (max-width: 768px) {
    .sidebar {
      position: fixed !important;
      left: -14rem !important;
      transition: left 0.3s ease-in-out !important;
      z-index: 1050 !important;
      height: 100vh !important;
      overflow-y: auto !important;
    }
    
    .sidebar.toggled {
      left: 0 !important;
    }
    
    body.sidebar-toggled .sidebar {
      left: 0 !important;
    }
    
    /* Overlay when sidebar is open on mobile */
    body.sidebar-toggled::before {
      content: '';
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: rgba(0, 0, 0, 0.5);
      z-index: 1040;
    }
    
    /* Content should take full width on mobile */
    #content-wrapper {
      margin-left: 0 !important;
    }
  }
  
  /* Hide desktop search, show mobile search */
  .navbar-search {
    display: none !important;
  }
  
  /* Make topbar items stack better */
  .topbar .navbar-nav {
    flex-direction: row;
  }
  
  /* Adjust avatar size on mobile */
  .topbar .avatar-circle {
    width: 35px !important;
    height: 35px !important;
    font-size: 14px !important;
  }
  
  /* Hide user name on small screens */
  .topbar .d-none.d-lg-inline {
    display: none !important;
  }
  
  /* Better dropdown positioning */
  .topbar .dropdown-menu {
    right: 0 !important;
    left: auto !important;
    min-width: 200px;
  }
  
  /* Make cards stack properly */
  .row > [class*='col-'] {
    margin-bottom: 1rem;
  }
  
  /* Adjust table for mobile */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  /* Better button sizing */
  .btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
  }
  
  /* Adjust page title */
  .h3 {
    font-size: 1.5rem !important;
  }
  
  /* Ensure no body overflow */
  body {
    overflow-x: hidden;
  }
  
  /* Fix container padding */
  .container-fluid {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
}

@media (min-width: 769px) {
  /* Hide mobile search on desktop */
  .sidebar-search {
    display: none !important;
  }
  
  /* Ensure sidebar is visible and positioned correctly on desktop */
  .sidebar {
    position: relative !important;
    left: 0 !important;
    margin-left: 0 !important;
    width: 14rem !important;
  }
  
  /* Ensure content wrapper has proper margin */
  #content-wrapper {
    margin-left: 0;
    width: 100%;
  }
  
  /* Desktop Sidebar Collapse */
  body.sidebar-toggled .sidebar {
    width: 6.5rem !important;
    overflow: visible;
    min-width: 6.5rem;
  }
  
  body.sidebar-toggled .sidebar .sidebar-brand-text {
    display: none;
  }
  
  body.sidebar-toggled .sidebar .nav-link span {
    display: none;
  }
  
  body.sidebar-toggled .sidebar .sidebar-card {
    display: none !important;
  }
  
  body.sidebar-toggled .sidebar .logout-link {
    margin: 0 0.5rem;
    padding: 0.75rem 0 !important;
    text-align: center;
    max-width: calc(100% - 1rem);
  }
  
  body.sidebar-toggled .sidebar .logout-link span {
    display: none;
  }
  
  body.sidebar-toggled .sidebar .logout-link i {
    margin: 0;
  }
  
  body.sidebar-toggled .sidebar .sidebar-search {
    display: none !important;
  }
  
  /* Adjust content when sidebar is collapsed */
  body.sidebar-toggled #content-wrapper {
    margin-left: 0;
    width: calc(100% - 6.5rem);
  }
  
  /* Show tooltips on hover for collapsed items */
  body.sidebar-toggled .sidebar .nav-link {
    text-align: center;
    padding: 0.75rem 0;
    border-left: none;
  }
  
  body.sidebar-toggled .sidebar .nav-link i {
    margin-right: 0;
  }
  
  body.sidebar-toggled .sidebar .nav-link.active {
    border-left: none;
    border-bottom: 3px solid #fff;
  }
}

/* Sidebar toggle animation */
.sidebar {
  transition: left 0.3s ease-in-out;
}

/* Ensure page wrapper uses flexbox properly */
#wrapper {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

#wrapper #content-wrapper {
  overflow-x: hidden;
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
}

#wrapper #content {
  flex: 1;
}


/* Ensure sidebar content doesn't overflow */
.sidebar {
  overflow-x: hidden !important;
}

.sidebar .nav-item {
  overflow: hidden;
}

.sidebar .nav-link {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
