/*
 * This is a manifest file that'll be compiled into application.tailwind.css, which will include all the files
 * listed below.
 *
 * Any CSS (and SCSS, if configured) file within this directory, lib/assets/stylesheets, or any plugin's
 * vendor/assets/stylesheets directory can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the bottom of the
 * compiled file so the styles you add here take precedence over styles defined in any other CSS
 * files in this directory. Styles in this file should be added after the last require_* statement.
 * It is generally better to create a new file per style scope.
 *
 *= require_tree .
 *= require_self
 */

@import "tailwindcss/base";
@import "tailwindcss/components";
@import "tailwindcss/utilities";

/* Import component stylesheets */
@import "components/type_selector";
 
 /* Dialog styles */
 dialog {
   position: fixed;
   top: 0;
   left: 0;
   right: 0;
   bottom: 0;
   width: 100%;
   height: 100%;
   padding: 0;
   margin: 0;
   border: none;
   background-color: transparent;
   overflow: auto;
   z-index: 50;
 }
 
 dialog::backdrop {
   background-color: rgba(0, 0, 0, 0.5);
 }
 
 /* Button styles */
 .btn {
   @apply inline-flex items-center justify-center px-4 py-2 rounded-md font-medium focus:outline-none focus:ring-2 focus:ring-offset-2 transition-all duration-200;
   text-decoration: none !important;
 }
 
 .btn:hover {
   transform: translateY(-1px);
   box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
 }
 
 .btn-primary {
   @apply bg-primary text-gray-700 hover:bg-primary/85 focus:ring-primary/50;
 }
 
 .btn-secondary {
   @apply bg-gray-500 text-white hover:bg-gray-600 focus:ring-gray-400;
 }
 
 .btn-danger {
   @apply bg-red-600 text-white hover:bg-red-700 focus:ring-red-500;
 }
 
 .btn-sm {
   @apply px-3 py-1 text-sm;
 }
 
 /* Form styles */
 .form-group {
   @apply mb-4;
 }
 
 .form-label {
   @apply block text-sm font-medium text-gray-700 mb-1;
 }
 
 .form-control {
   @apply block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm text-gray-700 focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-primary focus:bg-primary/10;
 }
 
 /* Card styles */
 .card {
   @apply bg-white rounded-lg shadow-md overflow-hidden;
 }
 
 .card-header {
   @apply px-4 py-3 border-b border-gray-200 bg-gray-50 flex justify-between items-center;
 }
 
 .card-body {
   @apply p-4;
 }
 
 /* Table styles */
 .table-container {
   @apply overflow-x-auto rounded-lg shadow-md;
 }
 
 .table {
   @apply min-w-full divide-y divide-gray-200;
 }
 
 .table thead {
   @apply bg-gray-50;
 }
 
 .table th {
   @apply px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider;
 }
 
 .table tbody {
   @apply bg-white divide-y divide-gray-200;
 }
 
 .table td {
   @apply px-6 py-4 whitespace-nowrap text-sm text-gray-500;
 }
 
 /* Badge styles */
 .badge {
   @apply inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium;
 }
 
 .badge-income {
   @apply bg-green-100 text-green-800;
 }
 
 .badge-expense {
   @apply bg-red-100 text-red-800;
 }
 
 .badge-system {
   @apply bg-blue-100 text-blue-800;
 }
 
 .badge-custom {
   @apply bg-green-100 text-green-800;
 }
 
 .badge-global {
   @apply bg-blue-100 text-blue-800;
 }
 
 .badge-personal {
   @apply bg-amber-100 text-amber-800;
 }
 
 .badge-primary {
   @apply bg-indigo-100 text-indigo-800;
 }
 
 .badge-neutral {
   @apply bg-gray-100 text-gray-800;
 }
 
 /* Sidebar styles */
 .sidebar {
   @apply fixed inset-y-0 left-0 w-64 bg-gray-800 text-white transition-all duration-300 ease-in-out z-10;
 }
 
 .sidebar-collapsed {
   @apply w-16;
 }
 
 .sidebar-header {
   @apply p-4 border-b border-gray-700;
 }
 
 .sidebar-user {
   @apply p-4 flex items-center border-b border-gray-700;
 }
 
 .sidebar-nav {
   @apply mt-2;
 }
 
 .sidebar-nav-item {
   @apply flex items-center px-4 py-3 text-gray-300 hover:bg-gray-700 hover:text-white transition-colors;
 }
 
 .sidebar-nav-item.active {
   @apply bg-primary text-gray-700;
 }
 
 /* User dropdown menu styling */
 [data-controller="dropdown"] {
   position: relative;
   z-index: 100;
 }
 
 [data-dropdown-target="menu"] {
   z-index: 100;
   position: absolute;
   transform-origin: top right;
   box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
 }
 
 /* Main content styles */
 .main-content {
   @apply transition-all duration-300 ease-in-out;
 }
 
 .main-content-with-sidebar {
   @apply ml-64;
 }
 
 .main-content-with-sidebar-collapsed {
   @apply ml-16;
 }
 
 /* Improved styling for all buttons with icons */
 a, button {
   text-decoration: none !important;
 }
 
 .inline-flex.items-center {
   display: inline-flex;
   align-items: center;
   text-decoration: none !important;
   transition: all 0.2s ease;
 }
 
 .inline-flex.items-center:hover {
   transform: translateY(-1px);
   box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
 }
 
 /* Icon buttons in tables and lists */
 .text-blue-600, .text-red-600, .text-primary {
   transition: all 0.2s ease;
 }
 
 .text-blue-600:hover, .text-red-600:hover, .text-primary:hover {
   transform: translateY(-1px);
   filter: brightness(0.9);
 }
 
 /* Dialog styles */
 dialog {
   padding: 0;
   border: none;
   border-radius: 0.5rem;
   box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
   max-width: 32rem;
   width: 100%;
 }
 
 dialog::backdrop {
   background-color: rgba(0, 0, 0, 0.5);
   backdrop-filter: blur(2px);
 }
 
 dialog[open] {
   animation: dialog-show 0.3s ease normal;
 }
 
 dialog.closing {
   animation: dialog-hide 0.3s ease normal;
 }
 
 @keyframes dialog-show {
   from {
     opacity: 0;
     transform: translateY(-10px);
   }
   to {
     opacity: 1;
     transform: translateY(0);
   }
 }
 
 @keyframes dialog-hide {
   from {
     opacity: 1;
     transform: translateY(0);
   }
   to {
     opacity: 0;
     transform: translateY(-10px);
   }
 }
 
 body {
   font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
 }
 h1, h2, h3, h4, h5, h6 {
   font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
   font-weight: 700;
 }
 .font-heading {
   font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
 }
 /* Sidebar styling fixes */
 .no-underline, .no-underline:hover, .no-underline:focus {
   text-decoration: none !important;
 }
 nav ul {
   list-style-type: none !important;
   padding: 0 !important;
   margin: 0 !important;
 }
 nav ul li {
   margin: 0 !important;
   padding: 0 !important;
 }
 
 /* Modal dropdown fixes */
 .z-60 {
   z-index: 60 !important;
 }
 
 .z-70 {
   z-index: 70 !important;
 }
 
 .z-80 {
   z-index: 80 !important;
 }
 
 .z-85 {
   z-index: 85 !important;
 }
 
 /* Make sure modal content is interactive */
 #modal select,
 #modal button,
 #modal input[type="submit"] {
   pointer-events: auto !important;
   cursor: pointer !important;
   position: relative !important;
 }
 
 #modal form {
   pointer-events: auto !important;
 }
 
 /* Ensure form elements appear above backdrop */
 [data-modal-backdrop] {
   pointer-events: none !important;
 }
 
 /* Make sure dialogs are above backdrop */
 #modal .inline-block.align-bottom,
 #modal .inline-block.align-bottom.bg-white,
 #modal .bg-white {
   z-index: 9500 !important;
   position: relative !important;
   pointer-events: auto !important;
 }
 
 /* Fix dialog positioning */
 dialog {
   position: fixed !important;
   top: 50% !important;
   transform: translateY(-50%) !important;
   margin: auto !important;
   max-height: 90vh !important;
   max-width: 500px !important;
   width: auto !important;
   border: none !important;
   border-radius: 8px !important;
   box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.08) !important;
   z-index: 9999 !important;
   padding: 0 !important;
 }
 
 /* Add specific sizing for confirmation dialogs */
 dialog.confirm-dialog,
 dialog[id^="delete-transaction-dialog"] {
   max-width: 400px !important;
   width: 95% !important;
 }
 
 dialog::backdrop {
   background-color: rgba(0, 0, 0, 0.5) !important;
 }
 
 /* Ensure dropdown options appear above backdrop */
 select {
   position: relative;
 }
 
 select option {
   position: relative;
   z-index: 70;
 }
 
 /* Ensure sidebar stays behind the modal */
 .sidebar, #mobile-sidebar {
   z-index: 50 !important;
 }
 
 /* Override pointer-events for modal elements */
 #modal.pointer-events-none,
 #modal .pointer-events-none {
   pointer-events: none !important;
 }
 
 #modal.pointer-events-auto,
 #modal .pointer-events-auto,
 #modal button,
 #modal select,
 #modal input,
 #modal form,
 #modal .inline-block,
 #modal .sm\:flex-row-reverse {
   pointer-events: auto !important;
 }
 
 /* Mobile sidebar styles */
 @media (max-width: 767px) {
   .sidebar-mobile-hidden {
     transform: translateX(-100%);
   }
   .sidebar-mobile-visible {
     transform: translateX(0);
   }
   .ml-64 {
     margin-left: 0 !important;
   }
 }
 
 /* Responsive design mode specific styles */
 body.in-responsive-mode #mobile-sidebar {
   display: block !important;
   transform: translateX(-100%);
 }
 
 body.in-responsive-mode #mobile-sidebar.sidebar-mobile-visible {
   transform: translateX(0) !important;
 }
 
 /* Fix for Safari and Firefox */
 @media screen and (max-width: 767px) {
   #mobile-sidebar {
     width: 16rem !important;
     left: 0 !important;
     transform: translateX(-100%) !important;
     transition: transform 0.3s ease-in-out !important;
   }
   
   #mobile-sidebar.sidebar-mobile-visible {
     transform: translateX(0) !important;
   }
   
   .md\:ml-64 {
     margin-left: 0 !important;
   }
 }
 
 /* Fix modal interactions */
 #modal {
   isolation: isolate;
   position: fixed !important;
   z-index: 9999 !important;
 }
 
 /* Ensure backdrop stays below dialog */
 [data-modal-backdrop],
 #modal .fixed.inset-0.bg-gray-500,
 #modal .fixed.inset-0.bg-gray-500.bg-opacity-75 {
   z-index: 9000 !important;
   pointer-events: none !important;
 }

/* Custom components can be added below */
@layer components {
  .btn-primary {
    @apply py-2 px-4 bg-primary text-gray-700 hover:bg-primary/85 focus:ring-primary/50 rounded-md;
  }
  .btn-secondary {
    @apply py-2 px-4 bg-gray-500 text-white hover:bg-gray-600 focus:ring-gray-400 rounded-md;
  }
  .btn-danger {
    @apply py-2 px-4 bg-red-600 text-white hover:bg-red-700 focus:ring-red-500 rounded-md;
  }
}

/* AI Chat Widget Animations */
@keyframes scale-up {
  from {
    opacity: 0;
    transform: scale(0.8) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes scale-down {
  from {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
  to {
    opacity: 0;
    transform: scale(0.8) translateY(20px);
  }
}

@keyframes float {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-5px);
  }
}

.animate-scale-up {
  animation: scale-up 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.animate-scale-down {
  animation: scale-down 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.animate-float {
  animation: float 3s ease-in-out infinite;
}

/* AI Chat Widget Specific Styles */
.ai-widget-minimized {
  transform-origin: bottom right;
}

.ai-widget-expanded {
  transform-origin: bottom right;
}

/* Chat message animations */
@keyframes message-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-enter {
  animation: message-in 0.3s ease-out;
}

/* Token usage progress bar smooth transitions */
.token-progress-bar {
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1), 
              background-color 0.3s ease;
}

/* Typing indicator animation */
@keyframes typing-dot {
  0%, 60%, 100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-10px);
  }
}

.typing-dot {
  animation: typing-dot 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

/* Widget button hover effects */
.ai-widget-minimized button:hover {
  animation: float 3s ease-in-out infinite;
}

/* Toast notification animations */
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toast-out {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

.toast-enter {
  animation: toast-in 0.3s ease-out;
}

.toast-exit {
  animation: toast-out 0.3s ease-in;
}

/* Custom focus ring overrides */
*:focus-visible {
  @apply outline-none ring-2 ring-primary/50 ring-offset-1;
}

input:focus, textarea:focus, select:focus {
  @apply border-primary ring-2 ring-primary/50 outline-none bg-primary/10;
}

/* Form control override to ensure consistent styling */
.form-control:focus {
  @apply border-primary ring-2 ring-primary/50 bg-primary/10;
}

/* Select field styling */
select {
  @apply appearance-none rounded-md border border-gray-300 px-3 py-2 bg-white text-gray-700 shadow-sm focus:border-primary focus:outline-none focus:ring-2 focus:ring-primary/50 focus:bg-primary/10;
}

/* Ensure form inputs in various contexts get the same focus styling */
[type='text']:focus,
[type='email']:focus,
[type='url']:focus,
[type='password']:focus,
[type='number']:focus,
[type='date']:focus,
[type='datetime-local']:focus,
[type='month']:focus,
[type='search']:focus,
[type='tel']:focus,
[type='time']:focus,
[type='week']:focus,
[multiple]:focus,
textarea:focus,
select:focus {
  @apply border-primary ring-2 ring-primary/50 bg-primary/10 text-gray-700;
}

/* Add base styles to override Tailwind Forms plugin defaults */
@layer base {
  [type='text'],
  [type='email'],
  [type='url'],
  [type='password'],
  [type='number'],
  [type='date'],
  [type='datetime-local'],
  [type='month'],
  [type='search'],
  [type='tel'],
  [type='time'],
  [type='week'],
  [multiple],
  textarea,
  select {
    @apply text-gray-700 focus:border-primary focus:ring-primary/50;
  }
  
  [type='checkbox'],
  [type='radio'] {
    @apply border-gray-300 text-primary focus:ring-primary/50;
  }
}

/* Placeholder styling */
::placeholder {
  @apply text-gray-400;
}

/* Input styling */
input, textarea, select {
  @apply text-gray-700;
}

/* Landing page styles */
html {
  overflow-x: hidden;
  max-width: 100%;
}

/* Prose content text color fixes */
.prose {
  color: #111827 !important;
}
.prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 {
  color: #111827 !important;
}
.prose p, .prose ul, .prose ol, .prose li {
  color: #111827 !important;
}
.prose strong {
  color: #111827 !important;
}
.prose a {
  color: #1F30C2 !important;
}

/* Responsive fixes */
@media (max-width: 640px) {
  /* Prevent content overflow on small screens */
  .overflow-x-hidden {
    overflow-x: hidden;
  }
  
  /* Improve image scaling on small screens */
  img {
    max-width: 100%;
    height: auto;
  }
  
  /* Improve button layout on small screens */
  .flex-col {
    row-gap: 0.75rem;
  }
  
  /* Ensure mobile menu doesn't overflow */
  #mobile-menu {
    max-height: 80vh;
    overflow-y: auto;
  }
}

/* Global overflow fixes */
.max-w-7xl {
  max-width: 100%;
  box-sizing: border-box;
}

section {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

.container-fluid {
  width: 100%;
  padding-right: 1rem;
  padding-left: 1rem;
  margin-right: auto;
  margin-left: auto;
  overflow-x: hidden;
}

/* Fix for header dropdown on landing page */
header .dropdown-menu {
  z-index: 100 !important;
}

/* Mobile dropdown menu fixes */
@media (max-width: 767px) {
  [data-controller="dropdown"] {
    position: static;
  }
  
  [data-dropdown-target="menu"] {
    position: absolute;
    top: auto;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    margin-top: 0.5rem;
  }
}

/* Make sure dropdown is always on top regardless of screen size */
#mobile-menu {
  z-index: 200; /* Ensure dropdown opens in front of sidebar and other elements */
}

/* Modern Select2 Styles to match Transaction Form Design */
.select2-container {
  @apply w-full;
}

/* Single Select Styling - Modern Design */
.select2-container--default .select2-selection--single {
  @apply block w-full text-sm border border-gray-300 bg-white transition-all duration-300 ease-in-out;
  height: 48px !important; /* h-12 equivalent */
  border-radius: 12px !important; /* rounded-xl equivalent */
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06) !important;
  line-height: 46px !important;
}

.select2-container--default .select2-selection--single:hover {
  @apply border-gray-400;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
  transform: translateY(-1px);
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
  @apply text-gray-900 px-4 font-normal;
  line-height: 46px !important;
  color: #111827 !important;
}

.select2-container--default .select2-selection--single .select2-selection__placeholder {
  @apply text-gray-500 font-normal;
  color: #6b7280 !important;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
  @apply right-3 top-0 flex items-center justify-center;
  width: 24px !important;
  height: 48px !important;
}

.select2-container--default .select2-selection--single .select2-selection__arrow b {
  border: none !important;
  background: none !important;
  width: 0 !important;
  height: 0 !important;
}

/* Custom arrow icon using CSS */
.select2-container--default .select2-selection--single .select2-selection__arrow::after {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  border: 2px solid #6b7280;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  top: 50%;
  left: 50%;
  margin-top: -8px;
  margin-left: -6px;
}

.select2-container--default.select2-container--open .select2-selection--single {
  @apply border-blue-500;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1), 0 12px 28px rgba(0, 0, 0, 0.12) !important;
  transform: translateY(-2px);
}

.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow::after {
  transform: rotate(-135deg);
  border-color: #3b82f6;
  margin-top: -4px;
}

/* Focus state for better accessibility */
.select2-container--default.select2-container--focus .select2-selection--single {
  @apply border-blue-500;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1) !important;
}

/* Dropdown Styling - Modern Design */
.select2-dropdown {
  @apply border border-gray-200 bg-white mt-2;
  border-radius: 12px !important;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04) !important;
  z-index: 9999 !important;
  overflow: hidden;
}

.select2-container--default .select2-dropdown--above {
  @apply border-gray-200;
  border-radius: 12px !important;
  margin-top: -2px !important;
  margin-bottom: 2px !important;
}

/* Search Field Styling - Modern Design */
.select2-container--default .select2-search--dropdown {
  @apply p-3 border-b border-gray-100 bg-gray-50;
}

.select2-container--default .select2-search--dropdown .select2-search__field {
  @apply block w-full text-sm border border-gray-200 px-3 py-2 bg-white transition-all duration-300;
  border-radius: 8px !important;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05) !important;
}

.select2-container--default .select2-search--dropdown .select2-search__field:focus {
  @apply outline-none border-blue-500;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1), 0 1px 3px 0 rgba(0, 0, 0, 0.1) !important;
}

/* Results Container - Modern Design */
.select2-container--default .select2-results {
  @apply max-h-64 overflow-y-auto;
}

.select2-container--default .select2-results__options {
  @apply py-2;
}

/* Individual Options - Modern Design */
.select2-container--default .select2-results__option {
  @apply text-gray-700 px-4 py-3 text-sm cursor-pointer transition-all duration-200 ease-in-out;
  line-height: 1.4;
}

.select2-container--default .select2-results__option:hover {
  @apply bg-blue-50 text-blue-900;
  background: linear-gradient(135deg, #eff6ff, #dbeafe) !important;
}

.select2-container--default .select2-results__option[aria-selected="true"] {
  @apply bg-blue-100 text-blue-900 font-medium;
  background: linear-gradient(135deg, #dbeafe, #bfdbfe) !important;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
  @apply text-white font-medium;
  background: linear-gradient(135deg, #3b82f6, #2563eb) !important;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4) !important;
}

/* Loading State */
.select2-container--default .select2-results__option.loading-results {
  @apply text-gray-500 italic text-center py-4;
}

/* No Results */
.select2-container--default .select2-results__option[role="alert"] {
  @apply text-gray-500 italic text-center py-4;
}

/* Animation for dropdown appearance */
.select2-dropdown {
  animation: slideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Mobile optimizations */
@media (max-width: 640px) {
  .select2-container--default .select2-selection--single {
    height: 44px !important;
    line-height: 42px !important;
  }
  
  .select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 42px !important;
    font-size: 16px !important; /* Prevent zoom on iOS */
  }
  
  .select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 44px !important;
  }
  
  .select2-dropdown {
    border-radius: 8px !important; /* Slightly smaller radius on mobile */
  }
  
  .select2-container--default .select2-results__option {
    @apply px-4 py-4 text-base; /* Larger touch targets */
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .select2-container--default .select2-selection--single {
    border-width: 2px !important;
  }
  
  .select2-container--default .select2-results__option--highlighted[aria-selected] {
    background: #000000 !important;
    color: #ffffff !important;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .select2-container--default .select2-selection--single,
  .select2-container--default .select2-results__option,
  .select2-dropdown {
    transition: none !important;
    animation: none !important;
  }
  
  .select2-container--default .select2-selection--single:hover,
  .select2-container--default.select2-container--open .select2-selection--single {
    transform: none !important;
  }
}

/* Dark mode support (if implemented later) */
@media (prefers-color-scheme: dark) {
  .select2-container--default .select2-selection--single {
    @apply bg-gray-800 border-gray-600 text-white;
  }
  
  .select2-dropdown {
    @apply bg-gray-800 border-gray-600;
  }
  
  .select2-container--default .select2-results__option {
    @apply text-gray-200;
  }
  
  .select2-container--default .select2-results__option:hover {
    @apply bg-gray-700 text-white;
  }
}

/* Group Headers */
.select2-container--classic .select2-results__group {
  @apply text-gray-700 font-semibold px-3 py-1.5 text-xs uppercase tracking-wider bg-gray-100 border-b border-gray-200;
  margin: 0 !important;
}

/* No Results Message */
.select2-container--classic .select2-results__message {
  @apply text-gray-500 px-3 py-2 text-sm italic;
}

/* Focus states */
.select2-container--classic.select2-container--focus .select2-selection--single {
  @apply ring-2 ring-indigo-500 ring-opacity-50 border-indigo-500 shadow-lg;
}

/* Disabled state */
.select2-container--classic .select2-selection--single.select2-selection--disabled {
  @apply bg-gray-100 border-gray-300 text-gray-500 cursor-not-allowed opacity-60;
}

.select2-container--classic .select2-selection--single.select2-selection--disabled .select2-selection__arrow b {
  @apply border-t-gray-400;
}

/* Multiple select support */
.select2-container--classic .select2-selection--multiple {
  @apply block w-full text-sm border border-gray-300 rounded-md shadow-sm bg-white transition-all duration-200 ease-in-out;
  min-height: 38px !important;
  padding: 3px 6px !important;
}

.select2-container--classic .select2-selection--multiple:hover {
  @apply border-gray-400 shadow-md;
}

.select2-container--classic.select2-container--focus .select2-selection--multiple {
  @apply ring-2 ring-indigo-500 ring-opacity-50 border-indigo-500 shadow-lg;
}

.select2-container--classic .select2-selection--multiple .select2-selection__choice {
  @apply bg-indigo-100 border border-indigo-200 text-indigo-800 rounded px-2 py-0.5 text-xs font-medium mr-1 mb-1 inline-flex items-center shadow-sm;
}

.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove {
  @apply text-indigo-600 hover:text-indigo-800 ml-1 font-bold cursor-pointer transition-colors duration-150;
  font-size: 12px !important;
}

.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove:hover {
  @apply bg-indigo-200 rounded-full;
}

/* Clear button styling */
.select2-container--classic .select2-selection__clear {
  @apply text-gray-400 hover:text-gray-600 cursor-pointer font-bold transition-colors duration-150;
  position: relative;
  line-height: 22px !important;
}

.select2-container--classic .select2-selection__clear:hover {
  @apply text-red-500;
}

/* Loading state */
.select2-container--classic .select2-selection--single .select2-selection__rendered[title*="Searching"] {
  @apply text-gray-500 italic;
}

/* Responsive adjustments */
@media (max-width: 640px) {
  .select2-container--classic .select2-selection--single {
    height: 40px !important;
  }
  
  .select2-container--classic .select2-selection--single .select2-selection__rendered {
    line-height: 25px !important;
  }
  
  .select2-container--classic .select2-results__option {
    @apply py-3;
  }
  
  .select2-container--classic .select2-search--dropdown {
    @apply p-3;
  }
}

/* Animation for dropdown */
.select2-dropdown {
  animation: select2-dropdown-fade-in 0.15s ease-out;
}

@keyframes select2-dropdown-fade-in {
  from {
    opacity: 0;
    transform: translateY(-2px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Custom styling for grouped options */
.select2-option-grouped {
  @apply pl-2;
}

/* Enhanced visual feedback */
.select2-container--classic .select2-results__option:active {
  @apply bg-indigo-700 text-white;
}

/* Mobile header improvements */
@media (max-width: 767px) {
  /* Ensure proper spacing on mobile headers */
  .header-mobile-spacing {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
  }
  
  /* Dashboard title responsive sizing */
  .dashboard-title-mobile {
    font-size: 1.5rem !important;
    line-height: 2rem !important;
  }
  
  /* Action buttons mobile stacking */
  .action-buttons-mobile {
    flex-direction: column !important;
    width: 100% !important;
    gap: 0.5rem !important;
  }
  
  /* Ensure buttons take full width on mobile */
  .btn-mobile-full {
    width: 100% !important;
    justify-content: center !important;
  }
  
  /* Improved mobile header layout */
  .mobile-header {
    padding: 0.75rem 1rem !important;
  }
  
  .mobile-header h1 {
    font-size: 1.125rem !important;
    font-weight: 600 !important;
    line-height: 1.5rem !important;
  }
  
  /* Mobile header text overflow fixes */
  .mobile-header-title {
    max-width: calc(100vw - 120px) !important; /* Account for hamburger + user menu */
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    font-size: 1rem !important;
    line-height: 1.25rem !important;
  }
  
  /* Ensure mobile header never breaks layout */
  .mobile-header-container {
    min-width: 0 !important;
    overflow: hidden !important;
  }
  
  /* Mobile header hamburger button styling */
  .mobile-hamburger {
    flex-shrink: 0 !important;
    width: 2.5rem !important;
    height: 2.5rem !important;
  }
  
  /* Mobile header user menu styling */
  .mobile-user-menu {
    flex-shrink: 0 !important;
  }
  
  /* Better mobile dropdown positioning */
  @supports (-webkit-touch-callout: none) {
    [data-dropdown-target="menu"] {
      position: fixed !important;
      right: 1rem !important;
      left: auto !important;
      width: calc(100vw - 2rem) !important;
      max-width: 16rem !important;
    }
  }
}

/* Fix mobile sidebar interactions */
#mobile-sidebar {
  z-index: 50 !important;
  pointer-events: auto !important;
}

#mobile-sidebar nav,
#mobile-sidebar nav ul,
#mobile-sidebar nav ul li,
#mobile-sidebar nav ul li a,
#mobile-sidebar .flex.items-center {
  pointer-events: auto !important;
  z-index: 51 !important;
  position: relative !important;
}

#mobile-sidebar a {
  pointer-events: auto !important;
  cursor: pointer !important;
  user-select: none !important;
}

/* Ensure sidebar is always interactive on mobile */
@media (max-width: 767px) {
  #mobile-sidebar.sidebar-mobile-visible {
    pointer-events: auto !important;
    z-index: 50 !important;
  }
  
  #mobile-sidebar.sidebar-mobile-visible * {
    pointer-events: auto !important;
  }
}