/* Multi-Select Styles for Client Management */

/* Checkbox styling */
.client-checkbox {
  cursor: pointer;
  transition: all 0.2s ease;
}

.client-checkbox:checked {
  background-color: #4f46e5;
  border-color: #4f46e5;
}

.client-checkbox:focus {
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2);
}

/* Selection toolbar */
#selection-toolbar {
  box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1), 0 -2px 4px -1px rgba(0, 0, 0, 0.06);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Selected row/card highlighting */
tr.selected-row {
  background-color: rgba(79, 70, 229, 0.05) !important;
  box-shadow: inset 0 0 0 1px rgba(79, 70, 229, 0.2);
}

.client-card.selected-card {
  border-color: #4f46e5;
  box-shadow: 0 0 0 1px #4f46e5, 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Bulk action buttons hover effects */
#selection-toolbar button {
  transition: all 0.2s ease;
}

#selection-toolbar button:hover {
  transform: translateY(-1px);
}

/* Progress modal styling */
#bulk-action-progress-modal {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

#bulk-action-progress-bar {
  transition: width 0.5s ease;
}

/* Selection count badge animation */
@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

.count-updated {
  animation: pulse 0.5s ease;
}

/* Mobile responsive adjustments */
@media (max-width: 640px) {
  #selection-toolbar {
    padding: 0.5rem;
  }

  #selection-toolbar button {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
  }

  #selected-count {
    font-size: 0.875rem;
  }
}

/* Selection indication for better accessibility */
input[type="checkbox"].client-checkbox:checked + label,
input[type="checkbox"].client-checkbox:checked ~ div {
  color: #4f46e5;
}

/* Better visible focus states for keyboard navigation */
input[type="checkbox"]:focus-visible {
  outline: 2px solid #4f46e5;
  outline-offset: 2px;
}

/* Improved row selection UI */
tr:has(.client-checkbox:checked) {
  background-color: rgba(79, 70, 229, 0.05) !important;
}

/* Animated selection count */
#selected-count {
  transition: transform 0.2s ease;
}

#selected-count.updating {
  transform: scale(1.1);
}

/* Enhanced Mobile Responsive Styles for Clients Page */

/* General mobile improvements */
@media (max-width: 768px) {
  /* Adjust padding and margins for mobile */
  main.max-w-7xl {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }

  /* Adjust stats cards for mobile */
  .grid.grid-cols-1.md\:grid-cols-3 {
    gap: 0.75rem !important;
  }

  .grid.grid-cols-1.md\:grid-cols-3 .client-card {
    padding: 1rem !important;
  }

  .grid.grid-cols-1.md\:grid-cols-3 .text-3xl {
    font-size: 1.5rem !important;
  }

  /* Adjust search and filter controls for mobile */
  .mb-6.bg-white.p-4 {
    padding: 0.75rem !important;
  }

  .flex.flex-col.md\:flex-row {
    gap: 0.5rem !important;
  }

  /* Make search input take full width on mobile */
  .relative.w-full.md\:w-80 {
    width: 100% !important;
  }

  /* Stack and resize filter controls on mobile */
  .flex.space-x-2.items-center.w-full.md\:w-auto {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 0.5rem !important;
    margin-top: 0.5rem !important;
  }

  .flex.space-x-2.items-center.w-full.md\:w-auto > * {
    margin: 0 !important;
  }

  /* Adjust table for mobile viewing */
  #table-view {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    margin-left: -0.75rem !important;
    margin-right: -0.75rem !important;
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
    width: calc(100% + 1.5rem) !important;
  }

  /* Optimize table columns for mobile */
  .client-table th.email-col,
  .client-table td.email-col,
  .client-table th.phone-col,
  .client-table td.phone-col {
    display: none !important;
  }

  .client-table th.name-col,
  .client-table td.name-col {
    width: 50% !important;
  }

  .client-table th.status-col,
  .client-table td.status-col {
    width: 20% !important;
  }

  .client-table th.actions-col,
  .client-table td.actions-col {
    width: 30% !important;
  }

  /* Make card view more mobile-friendly */
  #card-view {
    padding: 0.5rem !important;
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }

  .client-card {
    margin-bottom: 0 !important;
  }

  /* Adjust client details panel to take full width on mobile */
  #client-details-panel {
    max-width: 100% !important;
  }

  /* Make modals more mobile-friendly */
  #client-modal .max-w-lg,
  #edit-client-modal .max-w-lg,
  #delete-modal .max-w-md {
    width: calc(100% - 2rem) !important;
    margin-left: 1rem !important;
    margin-right: 1rem !important;
  }

  /* Adjust form elements in modals */
  #add-client-form .grid,
  #edit-client-form .grid {
    gap: 0.75rem !important;
  }

  /* Adjust button sizes in client cards */
  .client-card .flex.space-x-2 {
    gap: 0.5rem !important;
  }

  .client-card .flex.space-x-2 button,
  .client-card .flex.space-x-2 a {
    width: 1.5rem !important;
    height: 1.5rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
}

/* Small mobile devices */
@media (max-width: 480px) {
  /* Further refinements for very small screens */
  .page-header h1.text-4xl {
    font-size: 1.5rem !important;
  }

  #add-client-button {
    padding: 0.5rem 0.75rem !important;
    font-size: 0.875rem !important;
  }

  /* Stack action buttons in client details panel */
  #client-details-content .pt-4.flex.flex-wrap {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 0.5rem !important;
  }

  #client-details-content .pt-4.flex.flex-wrap button,
  #client-details-content .pt-4.flex.flex-wrap a {
    width: 100% !important;
    justify-content: center !important;
    padding: 0.5rem !important;
    font-size: 0.75rem !important;
  }

  /* Fix modal buttons on small screens */
  .pt-4.flex.justify-end.space-x-3 {
    gap: 0.5rem !important;
  }

  .pt-4.flex.justify-end.space-x-3 button {
    padding: 0.5rem 0.75rem !important;
    font-size: 0.75rem !important;
  }

  /* Make selection toolbar more compact on small screens */
  #selection-toolbar {
    padding: 0.5rem !important;
  }

  #selection-toolbar .flex.justify-between {
    flex-direction: column !important;
    gap: 0.5rem !important;
  }

  #selection-toolbar .flex.space-x-3 {
    width: 100% !important;
    justify-content: space-between !important;
  }
}

/* Fix for iOS form inputs */
@supports (-webkit-touch-callout: none) {
  input,
  select,
  textarea {
    font-size: 16px !important; /* Prevents iOS zoom on input focus */
  }
}

/* Animation speed improvements for mobile */
@media (prefers-reduced-motion: reduce) {
  .fade-in,
  .client-card,
  .hover-card,
  #selection-toolbar,
  #client-details-panel,
  button {
    transition: none !important;
    animation: none !important;
  }
}

/* Improve touch targets for mobile */
@media (max-width: 768px) {
  .action-button,
  .view-client,
  .edit-client,
  .delete-client,
  button,
  select,
  input[type="checkbox"] {
    min-width: 44px !important;
    min-height: 44px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* Ensure card actions have proper spacing and touch targets */
  .client-card .flex.space-x-2 {
    justify-content: space-between !important;
    width: 100% !important;
  }
}

/* Enhanced Mobile Client CSS 
 * - Consolidates and fixes conflicting mobile styles
 * - Improves table and card view responsiveness
 * - Fixes touch targets and spacing issues
 */

/* Safe area insets for modern mobile browsers */
:root {
  --safe-area-inset-top: env(safe-area-inset-top, 0px);
  --safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
}

/* Global fix for iOS viewport height issues */
.full-height {
  height: 100vh;
  height: calc(var(--vh, 1vh) * 100);
}

/* Improved selections styling */
tr.selected-row {
  background-color: rgba(79, 70, 229, 0.05) !important;
  box-shadow: inset 0 0 0 1px rgba(79, 70, 229, 0.2);
}

.client-card.selected-card {
  border-color: #4f46e5 !important;
  box-shadow: 0 0 0 1px #4f46e5, 0 1px 3px rgba(0, 0, 0, 0.1) !important;
}

/* Fix checkbox styling */
.client-checkbox {
  cursor: pointer;
  transition: all 0.2s ease;
}

.client-checkbox:checked {
  background-color: #4f46e5;
  border-color: #4f46e5;
}

/* Better animation for selection count */
@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

.count-updated {
  animation: pulse 0.5s ease;
}

/* Core responsive rules */
@media (max-width: 768px) {
  /* General viewport fixes */
  html,
  body {
    overflow-x: hidden !important;
    width: 100vw !important;
    position: relative !important;
  }

  .mb-8 {
    margin-bottom: 1.5rem !important;
  }

  /* Fix main heading size */
  h1.text-4xl {
    font-size: 2rem !important;
    line-height: 1.2 !important;
  }

  /* Fix client stats card grid */
  .grid.grid-cols-1.md\:grid-cols-3 {
    gap: 0.75rem !important;
  }

  .grid.grid-cols-1.md\:grid-cols-3 .client-card {
    padding: 1rem !important;
  }

  .grid.grid-cols-1.md\:grid-cols-3 .text-3xl {
    font-size: 1.5rem !important;
  }

  /* Fix search and filter section */
  .mb-6.bg-white.p-4 {
    padding: 0.75rem !important;
  }

  .flex.flex-col.md\:flex-row {
    gap: 0.5rem !important;
  }

  /* Fix search input sizing */
  .relative.w-full.md\:w-80 {
    width: 100% !important;
  }

  .relative.w-full.md\:w-80 input {
    width: 100% !important;
  }

  /* Fix filter controls layout */
  .flex.space-x-2.items-center.w-full.md\:w-auto {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 0.5rem !important;
    margin-top: 0.5rem !important;
  }

  .flex.space-x-2.items-center.w-full.md\:w-auto > * {
    margin: 0 !important; /* Override space-x class */
  }

  /* Hide less important columns on mobile */
  .client-table th.email-col,
  .client-table td.email-col,
  .client-table th.phone-col,
  .client-table td.phone-col {
    display: none !important;
  }

  /* Adjust column widths */
  .client-table th.name-col,
  .client-table td.name-col {
    width: 50% !important;
  }

  .client-table th.status-col,
  .client-table td.status-col {
    width: 20% !important;
  }

  .client-table th.actions-col,
  .client-table td.actions-col {
    width: 30% !important;
  }

  /* Fix table overflow */
  #table-view {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    margin-left: -0.75rem !important;
    margin-right: -0.75rem !important;
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
    width: calc(100% + 1.5rem) !important;
  }

  /* Fix card view layout */
  #card-view {
    padding: 0.75rem !important;
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }

  /* Fix client details panel */
  #client-details-panel {
    max-width: 100% !important;
  }

  #client-details-panel .p-6 {
    padding: 1rem !important;
  }

  /* Fix client modals */
  #client-modal .max-w-lg,
  #edit-client-modal .max-w-lg,
  #delete-modal .max-w-md {
    width: calc(100% - 2rem) !important;
    margin-left: 1rem !important;
    margin-right: 1rem !important;
  }

  /* Adjust modal form padding */
  #add-client-form,
  #edit-client-form {
    padding: 1rem !important;
  }

  /* Fix form grid layout */
  #add-client-form .grid,
  #edit-client-form .grid {
    gap: 0.75rem !important;
  }

  /* Better touch targets for buttons and interactive elements */
  .action-button,
  .view-client,
  .edit-client,
  .delete-client,
  button,
  select,
  input[type="checkbox"] {
    min-width: 44px !important;
    min-height: 44px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* Fix client card action buttons spacing */
  .client-card .flex.space-x-2 {
    gap: 0.75rem !important;
    justify-content: space-between !important;
  }

  /* Make sure action buttons are properly sized & spaced */
  .client-table .action-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
  }

  /* Selection toolbar fixes */
  #selection-toolbar {
    padding: 0.75rem !important;
  }

  #selection-toolbar .flex.justify-between {
    flex-direction: column !important;
    gap: 0.75rem !important;
  }

  #selection-toolbar .flex.space-x-3 {
    width: 100% !important;
    justify-content: space-between !important;
  }

  /* Fix empty state */
  #empty-state {
    padding: 2rem 1rem !important;
  }
}
