/* Enhanced Native Dropdown Styles - replaces David UI styles */

.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  min-width: 12rem;
  top: 100%;
  left: 0;
  z-index: 50 !important;
  transform-origin: top;
  transition: opacity 0.15s ease-in-out, transform 0.15s ease-in-out, visibility 0.15s ease-in-out;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.dropdown-menu.hidden {
  opacity: 0;
  transform: scale(0.95) translateY(-10px);
  pointer-events: none;
  visibility: hidden;
}

.dropdown-menu:not(.hidden) {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
  visibility: visible;
}

.dropdown-menu.dropdown-menu-right {
  left: auto;
  right: 0;
  transform-origin: top right;
}

.dropdown-menu.dropdown-menu-up {
  top: auto;
  bottom: 100%;
  transform-origin: bottom;
}

.dropdown-menu.dropdown-menu-up.hidden {
  transform: scale(0.95) translateY(10px);
}

.dropdown-menu.dropdown-menu-up:not(.hidden) {
  transform: scale(1) translateY(0);
}

.dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
}

.dropdown-toggle:hover {
  opacity: 0.8;
}

.dropdown-toggle:focus {
  outline: 2px solid var(--primary-color, #3b82f6);
  outline-offset: 2px;
}

.dropdown-toggle svg {
  transition: transform 0.2s ease-in-out;
}

.dropdown-toggle[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.navigation-menu {
  transition: max-height 0.3s ease-in-out, opacity 0.3s ease-in-out;
  overflow: hidden;
}

.navigation-menu.hidden {
  max-height: 0;
  opacity: 0;
}

.navigation-menu:not(.hidden) {
  opacity: 1;
}

.navigation-menu.max-h-0 {
  max-height: 0 !important;
}

.navigation-menu.max-h-screen {
  max-height: 100vh;
}

.mobile-menu-button:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.tab-content {
  transition: opacity 0.3s ease-in-out;
}

.tab-content.hidden {
  opacity: 0;
  pointer-events: none;
  display: none;
}

.tab-content:not(.hidden) {
  opacity: 1;
  pointer-events: auto;
  display: block;
}

.tab-link {
  position: relative;
  transition: all 0.3s ease-in-out;
}

.tab-link.active {
  color: var(--primary-color, #3b82f6);
  font-weight: 600;
}

.tab-link.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background-color: var(--primary-color, #3b82f6);
  border-radius: 1px;
}

.modal {
  transition: opacity 0.3s ease-in-out;
  backdrop-filter: blur(4px);
}

.modal.opacity-0 {
  opacity: 0;
  pointer-events: none;
}

.modal.opacity-100 {
  opacity: 1;
  pointer-events: auto;
}

.modal .modal-content {
  transition: transform 0.3s ease-in-out;
}

.modal.opacity-0 .modal-content {
  transform: scale(0.95) translateY(-20px);
}

.modal.opacity-100 .modal-content {
  transform: scale(1) translateY(0);
}

@media (max-width: 768px) {
  .dropdown-menu {
    position: absolute !important;
    left: 0 !important;
    right: auto !important;
    width: auto !important;
    min-width: 12rem !important;
    max-width: calc(100vw - 2rem);
    z-index: 1000 !important;
  }
  
  .dropdown-menu.dropdown-menu-right {
    left: auto !important;
    right: 0 !important;
  }
  
  /* Ensure dropdown doesn't go off screen on mobile */
  .dropdown {
    position: relative;
  }
  
  .navigation-menu {
    width: 100%;
  }
  
  /* Improve mobile dropdown visibility */
  .dropdown-menu {
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  }
  
  /* Ensure mobile dropdowns have proper touch targets */
  .dropdown-menu a,
  .dropdown-menu button {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
}

.dropdown-toggle:focus,
.mobile-menu-button:focus,
.tab-link:focus {
  outline: 2px solid var(--primary-color, #3b82f6);
  outline-offset: 2px;
  outline-style: auto;
}

/* Remove default focus outline and add custom rounded outline */
.dropdown-toggle:focus-visible,
.mobile-menu-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
  border-radius: inherit;
}

/* Special handling for rounded buttons */
.dropdown-toggle.rounded-full:focus-visible,
.mobile-menu-button.rounded-full:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
  border-radius: 9999px;
}

/* Ensure focus styles work with existing button styles */
.dropdown-toggle:focus {
  outline: none;
}

.mobile-menu-button:focus {
  outline: none;
}

@media (prefers-reduced-motion: reduce) {
  .dropdown-menu,
  .navigation-menu,
  .tab-content,
  .modal,
  .modal .modal-content,
  .dropdown-toggle svg {
    transition: none !important;
  }
}

@media (prefers-contrast: high) {
  .dropdown-menu {
    border: 2px solid;
  }
  
  .tab-link.active::after {
    height: 3px;
  }
}

@media print {
  .dropdown-menu,
  .mobile-menu-button,
  .navigation-menu {
    display: none !important;
  }
}
