/* Compact Real-time Search Form Styles */
.compact-search-form .input-group {
  box-shadow: 0 1px 5px rgba(0,0,0,0.1);
  border-radius: 20px;
  overflow: hidden;
  max-width: 300px;
  margin: 0 auto;
}

.compact-search-form .form-control {
  border: 1px solid #e9ecef;
  font-size: 12px;
  transition: all 0.2s ease;
  padding: 6px 12px;
  border-radius: 20px;
  background-color: #f8f9fa;
}

/* Placeholder text styling */
.compact-search-form .form-control::placeholder {
  color: rgba(108, 117, 125, 0.6);
  text-align: center;
  opacity: 0.6;
}

.compact-search-form .form-control::-webkit-input-placeholder {
  color: rgba(108, 117, 125, 0.6);
  text-align: center;
  opacity: 0.6;
}

.compact-search-form .form-control::-moz-placeholder {
  color: rgba(108, 117, 125, 0.6);
  text-align: center;
  opacity: 0.6;
}

.compact-search-form .form-control:-ms-input-placeholder {
  color: rgba(108, 117, 125, 0.6);
  text-align: center;
  opacity: 0.6;
}

.compact-search-form .form-control:-moz-placeholder {
  color: rgba(108, 117, 125, 0.6);
  text-align: center;
  opacity: 0.6;
}

.compact-search-form .form-control:focus {
  border-color: #007bff;
  box-shadow: 0 0 0 2px rgba(0,123,255,0.25);
  outline: none;
  background-color: white;
}

.compact-search-form .btn {
  display: none; /* Hide search button for real-time search */
}

.compact-search-form .btn-secondary {
  display: none; /* Hide clear button */
}

.compact-search-form .text-muted {
  color: #6c757d !important;
  font-size: 11px;
}

/* Dark mode support */
body.theme-dark .compact-search-form .input-group {
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

body.theme-dark .compact-search-form .form-control {
  background-color: #374151;
  border-color: #4b5563;
  color: #e5e7eb;
}

/* Dark theme placeholder text */
body.theme-dark .compact-search-form .form-control::placeholder {
  color: rgba(156, 163, 175, 0.6);
  text-align: center;
  opacity: 0.6;
}

body.theme-dark .compact-search-form .form-control::-webkit-input-placeholder {
  color: rgba(156, 163, 175, 0.6);
  text-align: center;
  opacity: 0.6;
}

body.theme-dark .compact-search-form .form-control::-moz-placeholder {
  color: rgba(156, 163, 175, 0.6);
  text-align: center;
  opacity: 0.6;
}

body.theme-dark .compact-search-form .form-control:-ms-input-placeholder {
  color: rgba(156, 163, 175, 0.6);
  text-align: center;
  opacity: 0.6;
}

body.theme-dark .compact-search-form .form-control:-moz-placeholder {
  color: rgba(156, 163, 175, 0.6);
  text-align: center;
}

body.theme-dark .compact-search-form .form-control:focus {
  border-color: #60a5fa;
}

body.theme-dark .compact-search-form .text-muted {
  color: #9ca3af !important;
}

/* Search icon - hidden as requested */
.compact-search-form .search-icon {
  display: none;
}

/* Search results styles */
.search-results {
  margin-top: 10px;
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid #e9ecef;
  border-radius: 5px;
  background: white;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.search-results .result-item {
  padding: 8px 12px;
  border-bottom: 1px solid #f8f9fa;
  cursor: pointer;
  transition: background-color 0.2s;
}

.search-results .result-item:hover {
  background-color: #f8f9fa;
}

.search-results .result-item.highlighted {
  background-color: #e9ecef !important;
  border-left: 3px solid #007bff;
}

.search-results .no-results {
  padding: 12px;
  text-align: center;
  color: #6c757d;
  font-style: italic;
}

/* Dark theme search results */
body.theme-dark .search-results {
  border-color: #4b5563;
  background: #374151;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

body.theme-dark .search-results .result-item {
  border-bottom-color: #4b5563;
  color: #e5e7eb;
}

body.theme-dark .search-results .result-item:hover {
  background-color: #4b5563;
}

body.theme-dark .search-results .result-item.highlighted {
  background-color: #4b5563 !important;
  border-left-color: #60a5fa;
}

body.theme-dark .search-results .no-results {
  color: #9ca3af;
}

/* Ensure icons and text elements are visible in dark theme */
body.theme-dark .search-results .result-item strong {
  color: #f3f4f6;
}

body.theme-dark .search-results .result-item small {
  color: #d1d5db;
}

body.theme-dark .search-results .result-item .fa {
  color: #9ca3af;
}

/* Loading state */
.search-results .result-item.loading {
  text-align: center;
  font-style: italic;
}

body.theme-dark .search-results .result-item.loading small {
  color: #9ca3af;
}

/* Clear search button */
.search-clear-btn {
  border-left: none;
  border-radius: 0 20px 20px 0;
  padding: 6px 10px;
  margin-left: -1px;
  transition: all 0.2s;
}

.search-clear-btn:hover {
  background-color: #dc3545;
  border-color: #dc3545;
  color: white;
}

body.theme-dark .search-clear-btn {
  border-color: #4b5563;
  color: #9ca3af;
}

body.theme-dark .search-clear-btn:hover {
  background-color: #dc3545;
  border-color: #dc3545;
  color: white;
}

/* Table layout fixes */
.table-responsive {
  overflow-x: auto;
  width: 100%;
  -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.table-responsive table {
  width: 100%;
  min-width: 650px; /* Minimum width to fit all columns */
  table-layout: fixed; /* Better control over column widths */
  margin-bottom: 0;
}

.table th, .table td {
  white-space: nowrap;
  padding: 8px 12px;
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table th:nth-child(1) { width: 80px; } /* Sr. No */
.table th:nth-child(2) { width: 25%; min-width: 120px; } /* Name */
.table th:nth-child(3) { width: 20%; min-width: 100px; } /* Blood Group */
.table th:nth-child(4) { width: 20%; min-width: 110px; } /* Mobile */
.table th:nth-child(5) { width: 35%; min-width: 150px; } /* Address */

/* Ensure no empty columns appear */
.table-responsive .table {
  border-collapse: collapse;
}

.table-responsive .table th:last-child,
.table-responsive .table td:last-child {
  border-right: 1px solid #dee2e6;
}

/* Mobile responsive table adjustments */
@media (max-width: 768px) {
  .table-responsive table {
    min-width: 600px; /* Slightly smaller for tablets */
    font-size: 14px;
  }

  .table th, .table td {
    padding: 6px 8px;
    font-size: 14px;
  }

  .table th:nth-child(1) { width: 70px; } /* Sr. No */
  .table th:nth-child(2) { width: 25%; min-width: 100px; } /* Name */
  .table th:nth-child(3) { width: 20%; min-width: 80px; } /* Blood Group */
  .table th:nth-child(4) { width: 20%; min-width: 90px; } /* Mobile */
  .table th:nth-child(5) { width: 35%; min-width: 120px; } /* Address */
}

/* Mobile responsive table adjustments */
@media (max-width: 768px) {
  .table-responsive table {
    min-width: 600px; /* Slightly smaller for tablets */
    font-size: 14px;
  }

  .table th, .table td {
    padding: 6px 8px;
    font-size: 14px;
  }

  .table th:nth-child(1) { width: 70px; } /* Sr. No */
  .table th:nth-child(2) { width: 25%; min-width: 100px; } /* Name */
  .table th:nth-child(3) { width: 20%; min-width: 80px; } /* Blood Group */
  .table th:nth-child(4) { width: 20%; min-width: 90px; } /* Mobile */
  .table th:nth-child(5) { width: 35%; min-width: 120px; } /* Address */
}

@media (max-width: 576px) {
  .table-responsive {
    font-size: 12px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
  }

  .table-responsive table {
    min-width: 550px; /* Minimum for very small screens */
  }

  .table th, .table td {
    padding: 4px 6px;
    font-size: 12px;
  }

  .table th:nth-child(1) { width: 60px; } /* Sr. No */
  .table th:nth-child(2) { width: 28%; min-width: 80px; } /* Name */
  .table th:nth-child(3) { width: 18%; min-width: 70px; } /* Blood Group */
  .table th:nth-child(4) { width: 22%; min-width: 80px; } /* Mobile */
  .table th:nth-child(5) { width: 32%; min-width: 100px; } /* Address */

  /* Ensure table header is visible when scrolling */
  .table-responsive table thead th {
    position: sticky;
    top: 0;
    background-color: #f8f9fa;
    z-index: 10;
  }
}

/* Mobile responsive */
@media (max-width: 576px) {
  .compact-search-form .input-group {
    max-width: 100%;
    margin: 0;
  }

  .compact-search-form .form-control {
    font-size: 16px; /* Prevent zoom on iOS */
    padding: 8px 12px;
  }

  .compact-search-form .search-icon {
    right: 12px;
  }

  .search-results {
    max-height: 250px;
  }
}

@media (max-width: 768px) {
  .compact-search-form .input-group {
    max-width: 280px;
  }
}