/* Task Page Visual Enhancements */

/* Garden-themed icons for different task types and actions */
.task-type-seasonal::before {
    content: "🍂";
    margin-right: 4px;
}

.task-type-recurring::before {
    content: "🔄";
    margin-right: 4px;
}

.task-type-scheduled::before {
    content: "📅";
    margin-right: 4px;
}

/* Action-specific icons based on care routine action types */
.task-action-watering::before {
    content: "💧";
    margin-right: 4px;
}

.task-action-feeding::before {
    content: "🍽️";
    margin-right: 4px;
}

.task-action-pruning::before {
    content: "✂️";
    margin-right: 4px;
}

.task-action-harvesting::before {
    content: "🧺";
    margin-right: 4px;
}

.task-action-pest-disease::before {
    content: "🐛";
    margin-right: 4px;
}

.task-action-general::before {
    content: "🔧";
    margin-right: 4px;
}

/* Enhanced task status indicators now compiled via Tailwind build */

/* Enhanced overdue styling with better visual hierarchy - optimized for performance */
.task-overdue {
    position: relative;
    background: linear-gradient(135deg, #fef2f2, #fef7f7);
    border-left: 4px solid #ef4444 !important;
}

.task-overdue::before {
    content: "⚠️";
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    font-size: 0.875rem;
    opacity: 0.7;
    animation: subtle-pulse 3s ease-in-out infinite;
}

/* Optimized pulse animation using opacity only */
@keyframes subtle-pulse {
    0%, 100% {
        opacity: 0.7;
    }
    50% {
        opacity: 1;
    }
}

/* Enhanced plant type badges now compile via Tailwind build */

.plant-type-badge::before {
    content: "🌱";
    margin-right: 3px;
    font-size: 0.75rem;
}

/* Multiple plant types get a different icon */
.plant-type-badge.multiple::before {
    content: "🌿";
}

.plant-type-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Care routine indicator styling now compiled via Tailwind build */

.care-routine-indicator:hover {
    transform: scale(1.1);
}

/* Status-specific visual treatments */
.task-item {
    transition: all 0.2s ease-in-out;
    position: relative;
}

.task-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Priority indicators for overdue tasks */
.task-priority-high::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 8px;
    height: 8px;
    background: #ef4444;
    border-radius: 50%;
    box-shadow: 0 0 0 2px #fff;
}

/* Completion indicator - subtle styling */
.task-completed {
    position: relative;
    opacity: 0.85;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.02), rgba(16, 185, 129, 0.05));
}

/* In-progress task indicators - optimized with pseudo-element */
.task-in-progress {
    position: relative;
    background: rgba(59, 130, 246, 0.02);
}

.task-in-progress::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.1), transparent);
    animation: progress-shimmer 3s ease-in-out infinite;
    pointer-events: none;
}

@keyframes progress-shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(300%);
    }
}

/* Enhanced focus states for accessibility */
.task-item:focus-within {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    border-radius: 0.5rem;
}

/* Mobile Touch Optimizations */
@media (max-width: 768px) {
    /* Enhanced touch targets - minimum 44px as per accessibility guidelines */
    .task-item {
        min-height: 44px;
        padding: 1rem !important;
        margin-bottom: 0.5rem;
        border-radius: 0.75rem;
        position: relative;
    }

    /* Touch feedback for task items */
    .task-item:active {
        background-color: rgba(0, 0, 0, 0.05);
        transform: scale(0.98);
        transition: all 0.1s ease-in-out;
    }

    /* Improved button sizing for touch */
    .task-item button,
    .task-item .care-routine-indicator {
        min-width: 44px;
        min-height: 44px;
        padding: 0.75rem !important;
        border-radius: 0.5rem;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Enhanced touch feedback for buttons */
    .task-item button:active,
    .care-routine-indicator:active {
        background-color: rgba(0, 0, 0, 0.1);
        transform: scale(0.95);
        transition: all 0.1s ease-in-out;
    }

    /* Larger touch targets for badges and indicators */
    /* Plant type badge responsive sizing compiled via Tailwind build */

    .plant-type-badge::before {
        font-size: 0.875rem;
        margin-right: 4px;
    }

    /* Task status badge responsive sizing compiled via Tailwind build */

    /* Improved spacing for touch interaction */
    .task-item .flex.flex-wrap {
        gap: 0.75rem !important;
    }

    /* Enhanced visual feedback for touch */
    .task-item:active::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: radial-gradient(circle at center, rgba(0, 0, 0, 0.1) 0%, transparent 70%);
        border-radius: inherit;
        pointer-events: none;
        animation: touch-ripple 0.3s ease-out;
    }

    @keyframes touch-ripple {
        0% {
            opacity: 0;
            transform: scale(0.8);
        }
        50% {
            opacity: 1;
            transform: scale(1);
        }
        100% {
            opacity: 0;
            transform: scale(1.1);
        }
    }

    /* Disable hover effects on mobile */
    .task-item:hover {
        transform: none;
        box-shadow: none;
    }

    .plant-type-badge:hover,
    .care-routine-indicator:hover {
        transform: none;
    }

    /* Mobile-specific overdue styling */
    .task-overdue::before {
        top: 0.75rem;
        right: 0.75rem;
        font-size: 1rem;
        z-index: 2;
    }

    /* Improved loading states for mobile */
    .task-card-pulse {
        background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.1), transparent);
        background-size: 200% 100%;
        animation: mobile-loading-shimmer 1.5s ease-in-out infinite;
    }

    @keyframes mobile-loading-shimmer {
        0% {
            background-position: -200% 0;
        }
        100% {
            background-position: 200% 0;
        }
    }
}

/* Extra small mobile devices */
@media (max-width: 480px) {
    .task-item {
        padding: 0.875rem !important;
        margin-bottom: 0.375rem;
    }

    /* Stack task content vertically on very small screens */
    .task-item .md\\:flex {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 1rem;
    }

    /* Full-width action buttons on small screens */
    .task-item .md\\:justify-start {
        justify-content: stretch !important;
        width: 100%;
    }

    .task-item .md\\:justify-start > * {
        flex: 1;
        text-align: center;
    }

    /* Larger touch targets for very small screens */
    .task-item button,
    .care-routine-indicator {
        min-height: 48px !important;
        font-size: 0.875rem;
    }

    /* Better spacing for cramped screens */
    /* Compact badge sizing compiled via Tailwind build */
}

/* Touch-specific styles (any touch device) */
@media (hover: none) and (pointer: coarse) {
    /* Enhanced touch feedback */
    .task-item {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
        tap-highlight-color: rgba(0, 0, 0, 0.1);
    }

    /* Touch active state */
    .task-item.touch-active {
        background-color: rgba(0, 0, 0, 0.05);
        transform: scale(0.98);
        transition: all 0.1s ease-out;
    }

    /* Remove hover states entirely on touch devices */
    .task-item:hover,
    .plant-type-badge:hover,
    .care-routine-indicator:hover,
    .task-status-badge:hover {
        transform: none !important;
        box-shadow: none !important;
        background-color: inherit !important;
    }

    /* Focus states for accessibility on touch devices */
    .task-item:focus-within {
        outline: 3px solid #3b82f6;
        outline-offset: 2px;
    }

    /* Mobile filter select touch optimization */
    .mobile-filter-select {
        -webkit-tap-highlight-color: rgba(34, 197, 94, 0.2);
        tap-highlight-color: rgba(34, 197, 94, 0.2);
    }

    .mobile-filter-select:active {
        background-color: rgba(34, 197, 94, 0.05);
        border-color: #22c55e;
        transform: scale(0.99);
        transition: all 0.1s ease-out;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .task-overdue {
        border-left-width: 6px;
        background: #fff5f5 !important;
    }

    .plant-type-badge {
        border: 1px solid currentColor;
    }

    .task-status-badge {
        border: 1px solid currentColor;
        font-weight: 600;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .task-item,
    .plant-type-badge,
    .care-routine-indicator,
    .task-status-badge {
        transition: none;
    }

    .task-overdue {
        animation: none;
    }

    .task-in-progress {
        animation: none;
        background: rgba(59, 130, 246, 0.05);
    }

    .task-item:hover {
        transform: none;
    }
}

/* Alpine.js Animation Effects */

/* Task card entrance animations */
@keyframes task-card-enter {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes task-card-exit {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

.task-card-enter {
    animation: task-card-enter 0.4s ease-out forwards;
}

.task-card-exit {
    animation: task-card-exit 0.2s ease-in forwards;
}

/* Task card hover effects */
.task-card-hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.12);
    transition: all 0.2s ease-out;
}

/* Task card click effects */
.task-card-click {
    transform: scale(0.98);
    transition: transform 0.1s ease-in-out;
}

/* Task card pulse for loading states */
@keyframes task-card-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.task-card-pulse {
    animation: task-card-pulse 1.5s ease-in-out infinite;
}

/* Modal transition effects */
@keyframes modal-enter {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

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

.modal-enter {
    animation: modal-enter 0.3s ease-out forwards;
}

.modal-exit {
    animation: modal-exit 0.2s ease-in forwards;
}

/* Filter transition effects */
.filter-transition {
    position: relative;
}

.filter-transition::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.8), transparent);
    animation: filter-sweep 0.6s ease-in-out;
    pointer-events: none;
}

@keyframes filter-sweep {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

.filter-click-effect {
    transform: scale(0.95);
    transition: transform 0.1s ease-in-out;
}

/* Pagination loading effects */
.pagination-loading {
    position: relative;
    overflow: hidden;
}

.pagination-loading::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    height: 2px;
    background: linear-gradient(90deg, #3b82f6, #60a5fa, #3b82f6);
    animation: pagination-progress 1.5s ease-in-out infinite;
    z-index: 10;
}

@keyframes pagination-progress {
    0% {
        width: 0%;
    }
    50% {
        width: 70%;
    }
    100% {
        width: 100%;
    }
}

/* Tasks list refresh animation */
@keyframes refresh-animation {
    0% {
        opacity: 0.8;
        transform: translateY(5px);
    }
    50% {
        opacity: 0.9;
        transform: translateY(-2px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.refresh-animation {
    animation: refresh-animation 0.6s ease-out;
}

/* Global loading state */
.htmx-loading {
    cursor: progress;
}

.htmx-loading * {
    pointer-events: none;
}

/* Staggered animations for task lists */
.task-item:nth-child(1) { animation-delay: 0ms; }
.task-item:nth-child(2) { animation-delay: 50ms; }
.task-item:nth-child(3) { animation-delay: 100ms; }
.task-item:nth-child(4) { animation-delay: 150ms; }
.task-item:nth-child(5) { animation-delay: 200ms; }
.task-item:nth-child(n+6) { animation-delay: 250ms; }

/* Reduced motion support for animations */
@media (prefers-reduced-motion: reduce) {
    .task-card-enter,
    .task-card-exit,
    .modal-enter,
    .modal-exit,
    .refresh-animation {
        animation: none;
    }

    .task-card-hover,
    .task-card-click,
    .filter-click-effect {
        transform: none;
        transition: none;
    }

    .task-card-pulse {
        animation: none;
        opacity: 0.8;
    }

    .filter-transition::after {
        display: none;
    }
}

/* High performance mode */
.reduce-motion * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
}

/* Print styles */
@media print {
    .task-overdue {
        background: #f9f9f9 !important;
        border-left: 4px solid #000 !important;
    }

    .task-overdue::before,
    .plant-type-badge::before,
    .task-type-seasonal::before,
    .task-type-recurring::before,
    .task-type-scheduled::before {
        content: none;
    }

    /* Hide all animations in print */
    .task-card-enter,
    .task-card-exit,
    .modal-enter,
    .modal-exit,
    .refresh-animation,
    .task-card-pulse {
        animation: none;
    }
}
