/* =============================================================================
   Theme Contrast Optimization
   Comprehensive fix for dropdown menus and form elements visibility
   ============================================================================= */

/* Fix Select Elements Contrast - Override base style.css - EXCLUDE NAVBAR */
select:not(.navbar select):not(.navbar-nav select) {
  background-color: #ffffff !important;
  color: #1f2937 !important;
  border: 1px solid #d1d5db !important;
  padding: 8px 12px !important;
  border-radius: 6px !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  min-height: 40px !important;
  line-height: 1.4 !important;
}

/* Fix Option Elements in Dropdowns - EXCLUDE NAVBAR */
select:not(.navbar select):not(.navbar-nav select) option {
  background-color: #ffffff !important;
  color: #1f2937 !important;
  padding: 8px 12px !important;
  font-weight: 400 !important;
  border: none !important;
}

select:not(.navbar select):not(.navbar-nav select) option:hover,
select:not(.navbar select):not(.navbar-nav select) option:focus {
  background-color: #f3f4f6 !important;
  color: #111827 !important;
}

select:not(.navbar select):not(.navbar-nav select) option:checked,
select:not(.navbar select):not(.navbar-nav select) option:selected {
  background-color: #3b82f6 !important;
  color: #ffffff !important;
}

/* Fix Form Control Elements - EXCLUDE NAVBAR */
.form-control:not(.navbar .form-control):not(.navbar-nav .form-control), 
.form-select:not(.navbar .form-select):not(.navbar-nav .form-select) {
  background-color: #ffffff !important;
  color: #1f2937 !important;
  border: 1px solid #d1d5db !important;
  padding: 12px 16px !important;
  border-radius: 6px !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  min-height: 44px !important;
}

/* Fix Focus States for Better Accessibility - EXCLUDE NAVBAR */
select:not(.navbar select):not(.navbar-nav select):focus,
.form-control:not(.navbar .form-control):not(.navbar-nav .form-control):focus,
.form-select:not(.navbar .form-select):not(.navbar-nav .form-select):focus {
  outline: none !important;
  border-color: #3b82f6 !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15) !important;
  background-color: #ffffff !important;
  color: #1f2937 !important;
}

/* Fix Bootstrap Dropdown Menus - EXCLUDE NAVBAR */
.dropdown-menu:not(.navbar .dropdown-menu):not(.navbar-nav .dropdown-menu) {
  background-color: #ffffff !important;
  border: 1px solid #e5e7eb !important;
  border-radius: 8px !important;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05) !important;
  padding: 8px 0 !important;
}

.dropdown-item:not(.navbar .dropdown-item):not(.navbar-nav .dropdown-item) {
  color: #1f2937 !important;
  padding: 8px 16px !important;
  font-weight: 400 !important;
  border: none !important;
  background-color: transparent !important;
}

.dropdown-item:not(.navbar .dropdown-item):not(.navbar-nav .dropdown-item):hover,
.dropdown-item:not(.navbar .dropdown-item):not(.navbar-nav .dropdown-item):focus {
  background-color: #f3f4f6 !important;
  color: #111827 !important;
}

.dropdown-item:not(.navbar .dropdown-item):not(.navbar-nav .dropdown-item):active,
.dropdown-item:not(.navbar .dropdown-item):not(.navbar-nav .dropdown-item).active {
  background-color: #3b82f6 !important;
  color: #ffffff !important;
}

/* Fix Text Input Elements */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
textarea {
  background-color: #ffffff !important;
  color: #1f2937 !important;
  border: 1px solid #d1d5db !important;
  padding: 12px 16px !important;
  border-radius: 6px !important;
  font-size: 14px !important;
  font-weight: 400 !important;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="search"]:focus,
textarea:focus {
  outline: none !important;
  border-color: #3b82f6 !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15) !important;
  background-color: #ffffff !important;
  color: #1f2937 !important;
}

/* Fix Placeholder Text */
input::placeholder,
textarea::placeholder,
select::placeholder {
  color: #9ca3af !important;
  opacity: 1 !important;
}

/* Fix Multi-select Lists */
select[multiple] {
  background-color: #ffffff !important;
  color: #1f2937 !important;
  border: 1px solid #d1d5db !important;
  padding: 8px !important;
  min-height: 120px !important;
}

select[multiple] option {
  padding: 6px 12px !important;
  margin: 1px 0 !important;
  background-color: transparent !important;
  color: #1f2937 !important;
}

select[multiple] option:hover {
  background-color: #f3f4f6 !important;
}

select[multiple] option:selected {
  background-color: #3b82f6 !important;
  color: #ffffff !important;
}

/* Fix Disabled States */
select:disabled,
.form-control:disabled,
.form-select:disabled,
input:disabled,
textarea:disabled {
  background-color: #f9fafb !important;
  color: #9ca3af !important;
  cursor: not-allowed !important;
  opacity: 0.7 !important;
}

/* Fix Labels for Better Readability */
label {
  color: #374151 !important;
  font-weight: 600 !important;
  font-size: 14px !important;
  margin-bottom: 6px !important;
  display: block !important;
}

/* Fix Form Group Spacing */
.form-group,
.mb-3 {
  margin-bottom: 20px !important;
}

/* Fix Button Contrast */
.btn-primary {
  background-color: #3b82f6 !important;
  border-color: #3b82f6 !important;
  color: #ffffff !important;
  font-weight: 600 !important;
}

.btn-primary:hover {
  background-color: #2563eb !important;
  border-color: #2563eb !important;
  color: #ffffff !important;
}

.btn-secondary {
  background-color: #6b7280 !important;
  border-color: #6b7280 !important;
  color: #ffffff !important;
  font-weight: 600 !important;
}

.btn-secondary:hover {
  background-color: #4b5563 !important;
  border-color: #4b5563 !important;
  color: #ffffff !important;
}

/* Fix Link Colors */
a {
  color: #3b82f6 !important;
  text-decoration: none !important;
}

a:hover {
  color: #1d4ed8 !important;
  text-decoration: underline !important;
}

/* Ensure high contrast for accessibility */
.text-muted {
  color: #6b7280 !important;
}

.text-dark {
  color: #111827 !important;
}

.text-light {
  color: #f9fafb !important;
}

/* Override any remaining low contrast elements */
.bg-light {
  background-color: #f9fafb !important;
  color: #111827 !important;
}

.bg-dark {
  background-color: #111827 !important;
  color: #f9fafb !important;
}

/* Fix Navbar Dropdown Contrast (if applicable) */
.navbar .dropdown-menu {
  background-color: #ffffff !important;
  border: 1px solid #e5e7eb !important;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1) !important;
}

.navbar .dropdown-item {
  color: #1f2937 !important;
}

.navbar .dropdown-item:hover {
  background-color: #f3f4f6 !important;
  color: #111827 !important;
}

/* Mobile Responsiveness for Form Elements - EXCLUDE NAVBAR */
@media (max-width: 768px) {
  select:not(.navbar select):not(.navbar-nav select),
  .form-control:not(.navbar .form-control):not(.navbar-nav .form-control),
  .form-select:not(.navbar .form-select):not(.navbar-nav .form-select) {
    font-size: 16px !important; /* Prevent zoom on iOS */
    min-height: 48px !important;
    padding: 12px 16px !important;
  }
  
  .dropdown-menu:not(.navbar .dropdown-menu):not(.navbar-nav .dropdown-menu) {
    max-width: calc(100vw - 32px) !important;
    margin: 0 16px !important;
  }
}

/* =============================================================================
   RESTORE ORIGINAL NAVBAR STYLING
   Ensure navbar elements keep their original appearance from style.css
   ============================================================================= */

/* Restore original navbar select styling from style.css */
.navbar select,
.navbar-nav select,
nav select {
  min-width: 2em !important;
  padding: 0.5em 1em !important;
  background: transparent !important;
  border: transparent !important;
  color: white !important;
  font: inherit !important;
}

/* Restore original navbar dropdown styling from style.css */
.navbar .dropdown-menu,
.navbar-nav .dropdown-menu,
nav .dropdown-menu {
  background: #495057 !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
}

/* Restore navbar dropdown item styling */
.navbar .dropdown-item,
.navbar-nav .dropdown-item,
nav .dropdown-item {
  color: white !important;
  padding: 8px 16px !important;
  font-weight: normal !important;
  background-color: transparent !important;
}

.navbar .dropdown-item:hover,
.navbar-nav .dropdown-item:hover,
nav .dropdown-item:hover,
.navbar .dropdown-item:focus,
.navbar-nav .dropdown-item:focus,
nav .dropdown-item:focus {
  background-color: rgba(255, 255, 255, 0.1) !important;
  color: white !important;
}

/* Restore navbar search input styling - WHITE BACKGROUND */
.navbar input[type="search"],
.navbar-nav input[type="search"],
nav input[type="search"] {
  background: #ffffff !important;
  border: 1px solid #e5e7eb !important;
  color: #1f2937 !important;
  padding: 0.375rem 0.75rem !important;
  border-radius: 0.25rem !important;
  font-size: inherit !important;
  min-height: auto !important;
}

.navbar input[type="search"]::placeholder,
.navbar-nav input[type="search"]::placeholder,
nav input[type="search"]::placeholder {
  color: #9ca3af !important;
}