@import "tailwindcss";
@import "tom-select/dist/css/tom-select.css";

/* Global button cursor styling */
button {
  cursor: pointer !important;
}

/* ==============================================
   A/B Test Component Enhancements
   ============================================== */

/* Payment Prompt Animation - Optimized for 60fps */
@keyframes slide-up-fade-in {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Apply subtle backdrop blur with fallback for older browsers */
@supports (backdrop-filter: blur(4px)) or (-webkit-backdrop-filter: blur(4px)) {
  .backdrop-blur-sm {
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
  }
}

/* Ensure smooth transitions on all interactive elements */
.transition-colors {
  transition-property: color, background-color, border-color;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Button active states - improved touch feedback */
button:active:not(:disabled),
a.block:active {
  transform: scale(0.98);
  transition: transform 0.1s ease-out;
}

/* Focus visible for keyboard navigation (WCAG 2.1) */
button:focus-visible,
a:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* Prevent layout shift from focus rings */
*:focus {
  outline-offset: 2px;
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
  /* Fix for gradient rendering on iOS */
  .bg-gradient-to-br {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
  }

  /* Improve tap highlight */
  button, a {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
  }

  /* Disable momentum scrolling conflicts */
  #payment-prompt {
    -webkit-overflow-scrolling: touch;
  }
}

/* High contrast mode support (Windows High Contrast Mode) */
@media (prefers-contrast: high) {
  button {
    border: 2px solid currentColor;
  }

  .bg-gradient-to-br {
    background: black;
  }
}

/* Reduced motion support (WCAG 2.1) */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  #payment-prompt {
    transition: none !important;
  }
}

/* Print styles - hide interactive prompts */
@media print {
  #payment-prompt {
    display: none !important;
  }
}

/* Links styled as buttons should also have pointer cursor */
a.inline-flex {
  cursor: pointer !important;
}

/* Custom styles for locale picker */
.locale-switcher select {
  display: none !important;
}

.locale-switcher .ts-wrapper {
  width: auto;
  min-width: 80px;
}

.locale-switcher .ts-control {
  background-color: rgb(17 24 39) !important; /* gray-900 */
  color: white !important;
  border: none !important;
  border-radius: 0.375rem !important; /* rounded-md */
  padding: 0.25rem 0.75rem !important; /* py-1 px-3 */
  font-size: 0.875rem !important; /* text-sm */
  font-weight: 500 !important; /* font-medium */
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05) !important; /* shadow-sm */
  min-height: auto !important;
  line-height: 1.5 !important;
  cursor: pointer !important;
  position: relative !important;
  padding-right: 2rem !important; /* Space for arrow */
}

.locale-switcher .ts-control:focus {
  outline: 2px solid transparent !important;
  outline-offset: 2px !important;
  box-shadow: 0 0 0 2px rgb(55 65 81) !important; /* ring-gray-700 */
}

.locale-switcher .ts-control::after {
  content: "▼" !important;
  color: rgba(255, 255, 255, 0.75) !important;
  font-size: 10px !important;
  line-height: 1 !important;
  position: absolute !important;
  right: 8px !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  pointer-events: none !important;
}

.locale-switcher .ts-control .item {
  font-size: 0.875rem !important; /* text-sm */
  font-weight: 500 !important; /* font-medium */
  color: white !important;
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

.locale-switcher .ts-dropdown {
  background-color: white !important;
  border: 1px solid rgb(229 231 235) !important; /* border-gray-200 */
  border-radius: 0.375rem !important; /* rounded-md */
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1) !important; /* shadow-lg */
  margin-top: 0.25rem !important; /* mt-1 */
  z-index: 99999 !important; /* Much higher than navbar to ensure it appears on top */
  position: fixed !important; /* Ensure it breaks out of stacking context */
}

.locale-switcher .ts-dropdown .option {
  padding: 0.5rem 0.75rem !important; /* py-2 px-3 */
  font-size: 0.875rem !important; /* text-sm */
  color: rgb(55 65 81) !important; /* text-gray-700 */
  cursor: pointer !important;
}

.locale-switcher .ts-dropdown .option:hover,
.locale-switcher .ts-dropdown .option.active {
  background-color: rgb(243 244 246) !important; /* bg-gray-100 */
}

.locale-switcher .ts-dropdown .option.selected {
  background-color: rgb(17 24 39) !important; /* bg-gray-900 */
  color: white !important;
}

/* Admin page spacing for fixed locale picker */
.admin-page-container {
  padding-top: 4rem !important; /* pt-16 - provides space for fixed locale picker */
}

/* Madmin-specific overrides */
body.form_templates {
  /* Fix button styles in Madmin */
  .btn {
    display: inline-flex !important;
    align-items: center !important;
    gap: 0.25rem !important;
    padding: 0.5rem 1rem !important;
    border-radius: 0.375rem !important;
    font-size: 0.875rem !important;
    font-weight: 500 !important;
    text-decoration: none !important;
    border: 1px solid transparent !important;
  }
  
  .btn-secondary {
    background-color: white !important;
    color: #374151 !important;
    border-color: #d1d5db !important;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05) !important;
  }
  
  .btn-secondary:hover {
    background-color: #f9fafb !important;
    border-color: #9ca3af !important;
  }
  
  /* Dropdown menu styles */
  .relative [data-dropdown-actions-target="menu"] {
    background: white !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 0.5rem !important;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1) !important;
  }
  
  /* Normalize dropdown menu items (both buttons and links) */
  .relative [data-dropdown-actions-target="menu"] button,
  .relative [data-dropdown-actions-target="menu"] a {
    display: flex !important;
    width: 100% !important;
    align-items: center !important;
    padding: 0.5rem 1rem !important;
    font-size: 0.875rem !important;
    color: #374151 !important;
    text-decoration: none !important;
    border: none !important;
    background: transparent !important;
    text-align: left !important;
    cursor: pointer !important;
  }
  
  .relative [data-dropdown-actions-target="menu"] button:hover,
  .relative [data-dropdown-actions-target="menu"] a:hover {
    background-color: #f3f4f6 !important;
    color: #111827 !important;
  }
}
