/* ============================================================================
   TaskApp - Custom Tailwind Utilities & Animations
   ============================================================================ */

/* ============================================================================
   Color Palette & Theme Variables
   ============================================================================ */

:root {
  --color-primary: #4f46e5; /* Indigo */
  --color-success: #10b981; /* Green */
  --color-danger: #ef4444; /* Red */
  --color-warning: #f59e0b; /* Amber */
  --color-info: #3b82f6; /* Blue */
  --color-gray: #6b7280; /* Gray */
}

/* ============================================================================
   Loading Spinner Animations
   ============================================================================ */

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-0.5rem);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(1rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-1rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-1rem);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(1rem);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

/* ============================================================================
   Utility Classes - Loading States
   ============================================================================ */

.spinner {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(0, 0, 0, 0.1);
  border-radius: 50%;
  border-top-color: var(--color-primary);
  animation: spin 0.8s linear infinite;
}

.spinner-sm {
  width: 0.75rem;
  height: 0.75rem;
  border-width: 1.5px;
}

.spinner-lg {
  width: 1.5rem;
  height: 1.5rem;
  border-width: 2.5px;
}

.spinner-white {
  border-color: rgba(255, 255, 255, 0.2);
  border-top-color: white;
}

.spinner-blue {
  border-color: rgba(59, 130, 246, 0.2);
  border-top-color: #3b82f6;
}

.spinner-green {
  border-color: rgba(16, 185, 129, 0.2);
  border-top-color: #10b981;
}

.pulse-ring {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* ============================================================================
   Status Badge Color Schemes
   ============================================================================ */

.badge-pending {
  @apply inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-sm font-medium bg-gray-100 text-gray-800;
}

.badge-pending::before {
  content: '';
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background-color: #6b7280;
}

.badge-in-progress {
  @apply inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-sm font-medium bg-yellow-100 text-yellow-800;
}

.badge-in-progress::before {
  content: '';
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background-color: #eab308;
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.badge-completed {
  @apply inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-sm font-medium bg-green-100 text-green-800;
}

.badge-completed::before {
  content: '';
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background-color: #10b981;
}

.badge-cancelled {
  @apply inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-sm font-medium bg-red-100 text-red-800;
}

.badge-cancelled::before {
  content: '';
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background-color: #ef4444;
}

.badge-blocked {
  @apply inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-sm font-medium bg-purple-100 text-purple-800;
}

.badge-blocked::before {
  content: '';
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background-color: #a855f7;
}

/* ============================================================================
   Priority Indicator Styles
   ============================================================================ */

.priority-low {
  @apply inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-sm font-medium bg-gray-100 text-gray-800;
}

.priority-low::before {
  content: '↓';
  font-weight: bold;
  font-size: 1.125rem;
}

.priority-medium {
  @apply inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-sm font-medium bg-yellow-100 text-yellow-800;
}

.priority-medium::before {
  content: '→';
  font-weight: bold;
  font-size: 1.125rem;
}

.priority-high {
  @apply inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-sm font-medium bg-red-100 text-red-800;
}

.priority-high::before {
  content: '↑';
  font-weight: bold;
  font-size: 1.125rem;
}

/* ============================================================================
   HTMX Loading & Transition Effects
   ============================================================================ */

/* HTMX loading indicator */
.htmx-request .htmx-indicator {
  display: inline-block;
}

.htmx-indicator {
  display: none;
}

/* Smooth fade transitions for HTMX content swaps */
.htmx-swapping {
  opacity: 0;
  transition: opacity 0.2s ease-out;
}

.htmx-settling {
  opacity: 1;
  transition: opacity 0.2s ease-in;
}

/* Content fade in animation */
.htmx-added {
  animation: fadeIn 0.3s ease-in-out;
}

/* Disable content during request */
.htmx-request .htmx-target {
  opacity: 0.6;
  pointer-events: none;
}

/* ============================================================================
   Interactive Element Hover Effects
   ============================================================================ */

/* Card hover effects */
.card-hover {
  @apply transition-all duration-200 ease-out;
}

.card-hover:hover {
  @apply shadow-md -translate-y-0.5;
}

/* Button hover effects */
.btn-hover {
  @apply transition-all duration-150 ease-out;
}

.btn-hover:hover {
  @apply -translate-y-0.5 shadow-md;
}

.btn-hover:active {
  @apply translate-y-0;
}

/* Link hover effects */
.link-hover {
  @apply transition-colors duration-150;
}

.link-hover:hover {
  @apply text-indigo-600;
}

/* Task item hover effect */
.task-item {
  @apply transition-colors duration-150;
}

.task-item:hover {
  @apply bg-gray-50;
}

.task-item.active {
  @apply bg-indigo-50 border-l-4 border-indigo-600;
}

/* Tag hover effect */
.tag-item {
  @apply transition-all duration-150;
}

.tag-item:hover {
  @apply scale-105;
}

/* ============================================================================
   Custom Tailwind Utilities
   ============================================================================ */

/* Focus ring styles */
.focus-ring {
  @apply focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2;
}

.focus-ring-sm {
  @apply focus:outline-none focus:ring-1 focus:ring-indigo-500;
}

/* Truncate text with ellipsis */
.truncate-1 {
  @apply truncate;
}

.truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.truncate-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
}

/* Scrollbar styling (webkit browsers) */
::-webkit-scrollbar {
  width: 0.5rem;
  height: 0.5rem;
}

::-webkit-scrollbar-track {
  background: #f3f4f6;
}

::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 0.25rem;
}

::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* ============================================================================
   Form Styling
   ============================================================================ */

input[type='text'],
input[type='email'],
input[type='password'],
input[type='number'],
input[type='date'],
input[type='datetime-local'],
input[type='time'],
textarea,
select {
  @apply transition-colors duration-150;
}

input[type='text']:focus,
input[type='email']:focus,
input[type='password']:focus,
input[type='number']:focus,
input[type='date']:focus,
input[type='datetime-local']:focus,
input[type='time']:focus,
textarea:focus,
select:focus {
  @apply border-indigo-500 ring-1 ring-indigo-500;
}

/* Disabled form elements */
input:disabled,
textarea:disabled,
select:disabled {
  @apply cursor-not-allowed opacity-50;
}

/* Date input styling - override browser defaults */
input[type='date'],
input[type='datetime-local'],
input[type='time'] {
  @apply bg-white text-gray-900;
  color-scheme: light;
}

input[type='date']::-webkit-calendar-picker-indicator,
input[type='datetime-local']::-webkit-calendar-picker-indicator,
input[type='time']::-webkit-calendar-picker-indicator {
  @apply cursor-pointer opacity-60;
  filter: invert(0.4);
}

input[type='date']::-webkit-calendar-picker-indicator:hover,
input[type='datetime-local']::-webkit-calendar-picker-indicator:hover,
input[type='time']::-webkit-calendar-picker-indicator:hover {
  @apply opacity-100;
}

input[type='date']::-webkit-datetime-edit-text,
input[type='date']::-webkit-datetime-edit-month-field,
input[type='date']::-webkit-datetime-edit-day-field,
input[type='date']::-webkit-datetime-edit-year-field {
  @apply text-gray-900;
}

/* ============================================================================
   Badge & Status Styling - Enhanced
   ============================================================================ */

/* Size variants */
.badge-xs {
  @apply px-1.5 py-0.25 text-xs;
}

.badge-sm {
  @apply px-2 py-0.5 text-xs;
}

.badge-md {
  @apply px-2.5 py-0.5 text-sm;
}

.badge-lg {
  @apply px-3 py-1 text-base;
}

/* ============================================================================
   Progress Bar Animation
   ============================================================================ */

.progress-bar {
  @apply h-1 w-full bg-gray-200 rounded-full overflow-hidden;
}

.progress-bar-fill {
  @apply h-full bg-indigo-600 rounded-full transition-all duration-500 ease-out;
}

.progress-bar-fill.indeterminate {
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(79, 70, 229, 0.8) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: shimmer 2s infinite;
}

/* ============================================================================
   Disabled Button States
   ============================================================================ */

button:disabled,
button.disabled {
  @apply opacity-50 cursor-not-allowed;
}

button.loading {
  @apply opacity-75 pointer-events-none;
}

button.loading::after {
  content: '';
  display: inline-block;
  margin-left: 0.5rem;
  width: 0.75rem;
  height: 0.75rem;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ============================================================================
   Modal & Overlay Styles
   ============================================================================ */

.modal-overlay {
  @apply fixed inset-0 z-40 bg-black bg-opacity-50 transition-opacity duration-200;
}

.modal-overlay.hidden {
  @apply opacity-0 pointer-events-none;
}

.modal-content {
  @apply fixed left-1/2 top-1/2 z-50 w-full max-w-md -translate-x-1/2 -translate-y-1/2 rounded-lg bg-white shadow-xl transition-all duration-200;
}

.modal-content.hidden {
  @apply -translate-y-1/2 scale-95 opacity-0 pointer-events-none;
}

/* ============================================================================
   Alert Styling
   ============================================================================ */

.alert {
  @apply rounded-lg p-4 transition-all duration-300;
}

.alert-success {
  @apply bg-green-50 text-green-800 border border-green-200;
}

.alert-error {
  @apply bg-red-50 text-red-800 border border-red-200;
}

.alert-warning {
  @apply bg-yellow-50 text-yellow-800 border border-yellow-200;
}

.alert-info {
  @apply bg-blue-50 text-blue-800 border border-blue-200;
}

.alert-close {
  @apply ml-auto cursor-pointer opacity-50 transition-opacity hover:opacity-100;
}

/* ============================================================================
   Responsive Design Utilities
   ============================================================================ */

@media (max-width: 640px) {
  .sm-hide {
    display: none;
  }

  .sm-text-sm {
    @apply text-sm;
  }

  .sm-text-xs {
    @apply text-xs;
  }

  .sm-p-2 {
    @apply p-2;
  }

  .sm-gap-1 {
    @apply gap-1;
  }
}

@media (max-width: 768px) {
  .md-hide {
    display: none;
  }

  .md-text-sm {
    @apply text-sm;
  }

  .md-p-4 {
    @apply p-4;
  }

  .md-grid-cols-1 {
    @apply grid-cols-1;
  }
}

/* ============================================================================
   Accessibility
   ============================================================================ */

/* Focus visible for keyboard navigation */
*:focus-visible {
  @apply outline-2 outline-offset-2 outline-indigo-600;
}

/* High contrast mode support */
@media (prefers-contrast: more) {
  .text-gray-600 {
    @apply text-gray-800;
  }

  .border-gray-200 {
    @apply border-gray-600;
  }
}

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

/* ============================================================================
   Print Styles
   ============================================================================ */

@media print {
  .no-print {
    display: none;
  }

  button,
  .btn {
    display: none;
  }

  .link-hover {
    color: #000;
  }
}
