/**
 * Custom Select Dropdown - Full Replacement
 * Beautiful, intentional dropdown with custom menu
 */

/* Wrapper for custom select */
.custom-select-wrapper {
  position: relative;
  display: inline-block;
  width: 100%;
}

/* Hide the original select completely */
.custom-select-wrapper select {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

/* Custom select display button */
.custom-select-display {
  position: relative;
  width: 100%;
  padding: 0.75rem 1rem;
  padding-right: 2.5rem; /* Extra space for arrow */
  font-size: 1rem;
  font-family: inherit;
  color: #333;
  background: white;
  border: 2px solid #ddd;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  outline: none;
  line-height: 1.5;
  text-align: left;
  user-select: none;
  box-sizing: border-box;
  min-height: 48px; /* Match text input height */
}

/* Custom dropdown arrow */
.custom-select-display::after {
  content: '\f078'; /* FontAwesome chevron-down */
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  position: absolute;
  top: 50%;
  right: 1rem;
  transform: translateY(-50%);
  color: #c9a961;
  transition: all 0.3s ease;
  font-size: 0.875rem;
}

/* Hover state */
.custom-select-display:hover {
  border-color: #c9a961;
  box-shadow: 0 2px 8px rgba(201, 169, 97, 0.15);
}

.custom-select-display:hover::after {
  color: #d4af37;
}

/* Open state */
.custom-select-wrapper.open .custom-select-display {
  border-color: #c9a961;
  box-shadow: 0 0 0 3px rgba(201, 169, 97, 0.1);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.custom-select-wrapper.open .custom-select-display::after {
  color: #d4af37;
  transform: translateY(-50%) rotate(180deg);
}

/* Disabled state */
.custom-select-wrapper.disabled .custom-select-display {
  background: #f5f5f5;
  color: #999;
  cursor: not-allowed;
  border-color: #e0e0e0;
}

.custom-select-wrapper.disabled .custom-select-display::after {
  color: #999;
}

/* Custom dropdown menu */
.custom-select-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 2px solid #c9a961;
  border-top: none;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  max-height: 300px;
  overflow-y: auto;
  z-index: 1000;
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
  transition: all 0.2s ease;
}

.custom-select-wrapper.open .custom-select-dropdown {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

/* Upward opening dropdown */
.custom-select-wrapper.open-upward .custom-select-dropdown {
  top: auto;
  bottom: 100%;
  border-top: 2px solid #c9a961;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  transform: translateY(0);
}

.custom-select-wrapper.open-upward .custom-select-display {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
}

/* Dropdown options */
.custom-select-option {
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: all 0.15s ease;
  color: #333;
  font-size: 1rem;
  border-bottom: 1px solid #f0f0f0;
}

.custom-select-option:last-child {
  border-bottom: none;
}

.custom-select-option:hover {
  background: linear-gradient(135deg, rgba(201, 169, 97, 0.1) 0%, rgba(212, 175, 55, 0.1) 100%);
  color: #1a1a1a;
  padding-left: 1.25rem;
}

.custom-select-option.selected {
  background: linear-gradient(135deg, #c9a961 0%, #d4af37 100%);
  color: white;
  font-weight: 600;
  position: relative;
}

.custom-select-option.selected::before {
  content: '\f00c'; /* FontAwesome check */
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  margin-right: 0.5rem;
  color: white;
}

.custom-select-option:active {
  transform: scale(0.98);
}

/* Scrollbar styling for dropdown */
.custom-select-dropdown::-webkit-scrollbar {
  width: 8px;
}

.custom-select-dropdown::-webkit-scrollbar-track {
  background: #f5f5f5;
  border-radius: 0 0 6px 0;
}

.custom-select-dropdown::-webkit-scrollbar-thumb {
  background: #c9a961;
  border-radius: 4px;
}

.custom-select-dropdown::-webkit-scrollbar-thumb:hover {
  background: #d4af37;
}

/* Small variant */
.custom-select-wrapper.small .custom-select-display {
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  font-size: 0.875rem;
}

.custom-select-wrapper.small .custom-select-display::after {
  font-size: 0.75rem;
  right: 0.75rem;
}

.custom-select-wrapper.small .custom-select-option {
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
}

/* Large variant */
.custom-select-wrapper.large .custom-select-display {
  padding: 1rem 3rem 1rem 1.25rem;
  font-size: 1.125rem;
}

.custom-select-wrapper.large .custom-select-display::after {
  font-size: 1rem;
  right: 1.25rem;
}

.custom-select-wrapper.large .custom-select-option {
  padding: 1rem 1.25rem;
  font-size: 1.125rem;
}

/* Full-width by default in forms */
.form-group .custom-select-wrapper,
.control-wrapper .custom-select-wrapper {
  width: 100%;
}

/* Option styling (limited support) */
.custom-select-wrapper select option {
  padding: 0.5rem;
  color: #333;
  background: white;
}

.custom-select-wrapper select option:checked {
  background: linear-gradient(135deg, #c9a961 0%, #d4af37 100%);
  color: white;
}

.custom-select-wrapper select option:hover {
  background: #f9f9f9;
}

/* Animation on change */
@keyframes selectPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

.custom-select-wrapper.changed select {
  animation: selectPulse 0.3s ease;
  border-color: #c9a961;
}

/* Error state */
.custom-select-wrapper.error select {
  border-color: #e53935;
}

.custom-select-wrapper.error::after {
  color: #e53935;
}

/* Success state */
.custom-select-wrapper.success select {
  border-color: #4CAF50;
}

.custom-select-wrapper.success::after {
  color: #4CAF50;
}

/* Dark variant (for dark backgrounds) */
.custom-select-wrapper.dark select {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(201, 169, 97, 0.3);
  color: white;
}

.custom-select-wrapper.dark::after {
  color: #c9a961;
}

.custom-select-wrapper.dark select:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: #c9a961;
}

.custom-select-wrapper.dark select:focus {
  background: rgba(255, 255, 255, 0.1);
  border-color: #d4af37;
  box-shadow: 0 0 0 3px rgba(201, 169, 97, 0.2);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .custom-select-wrapper select {
    padding: 0.65rem 2.25rem 0.65rem 0.875rem;
    font-size: 1rem; /* iOS requires 16px to prevent zoom */
  }
  
  .custom-select-wrapper::after {
    right: 0.875rem;
  }
}

/* Integration with existing admin styles */
.admin-form .custom-select-wrapper select,
.admin-table .custom-select-wrapper select {
  background: white;
}

/* Ensure proper spacing in form groups */
.form-group .custom-select-wrapper,
label + .custom-select-wrapper {
  margin-top: 0.5rem;
}

.custom-select-wrapper + .form-group,
.custom-select-wrapper + label {
  margin-top: 1rem;
}

