/* ExerciseSwap Custom Styles */
/* Enhances Tailwind CSS with custom animations and styles */

:root {
    --primary: #ff6b35;    /* Energetic orange */
    --secondary: #2c3e50;  /* Deep charcoal */
    --accent: #27ae60;     /* Success green */
    --warning: #f39c12;    /* Amber warning */
    
    /* Refined grays */
    --gray-50: #fafbfc;
    --gray-100: #f4f6f8;
    --gray-200: #e8ecf0;
    --gray-300: #dce1e6;
    --gray-400: #9eb3c8;
    --gray-500: #6c7b8a;
    --gray-600: #425a72;
    --gray-700: #2d3748;
    --gray-800: #1a202c;
    --gray-900: #171923;
    
    /* Fitness-specific colors */
    --muscle-strength: #e74c3c;
    --muscle-endurance: #3498db;
    --muscle-flexibility: #9b59b6;
    --equipment-free: #27ae60;
    --equipment-gym: #34495e;
}

/* Smooth transitions for all interactive elements */
* {
    transition-property: background-color, border-color, color, fill, stroke, opacity, box-shadow, transform;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

/* Fitness-themed background with gym image */
body {
    position: relative;
    min-height: 100vh;
    background: #1a1a1a;
}

/* Gym background image with overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('https://images.unsplash.com/photo-1534438327276-14e5300c3a48?q=80&w=2070&auto=format&fit=crop');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    z-index: -2;
}

/* Dark overlay for better text readability */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.7) 0%,
        rgba(0, 0, 0, 0.75) 50%,
        rgba(0, 0, 0, 0.7) 100%
    );
    z-index: -1;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--gray-100);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--gray-400);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-500);
}

/* Search input focus animation */
#searchInput {
    position: relative;
    transition: all 0.3s ease;
}

#searchInput:focus {
    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);
}

/* Autocomplete dropdown animations - Google style */
#autocompleteDropdown {
    animation: fadeIn 0.15s ease-out;
    box-shadow: 0 2px 5px 1px rgba(64,60,67,.16);
    border: 1px solid rgba(0,0,0,.05);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-2px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.autocomplete-item {
    transition: background-color 0.1s ease;
    border: none;
}

.autocomplete-item:hover {
    background-color: #f8f9fa;
}

.autocomplete-item.selected,
.autocomplete-item:focus {
    background-color: #f8f9fa;
    outline: none;
}

/* Popular search button hover effect */
.popular-search {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.popular-search::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(37, 99, 235, 0.1);
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

.popular-search:hover::before {
    width: 100%;
    height: 100%;
}

.popular-search:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Results animation */
#resultsSection {
    animation: fadeInUp 0.4s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Alternative cards */
.alternative-card {
    position: relative;
    transition: all 0.3s ease;
    animation: fadeInUp 0.4s ease-out backwards;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
}

/* Alternatives list transitions */
#alternativesList {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Refresh button styles */
#refreshResultsBtn {
    transition: all 0.3s ease;
}

#refreshResultsBtn:hover svg {
    animation: rotate 0.6s ease-in-out;
}

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

.alternative-card:nth-child(1) { animation-delay: 0.1s; }
.alternative-card:nth-child(2) { animation-delay: 0.2s; }
.alternative-card:nth-child(3) { animation-delay: 0.3s; }
.alternative-card:nth-child(4) { animation-delay: 0.4s; }
.alternative-card:nth-child(5) { animation-delay: 0.5s; }

.alternative-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Loading spinner animation */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* Pulse animation for loading states */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

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

/* Error message animation */
#errorMessage {
    animation: shake 0.5s ease-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10% { transform: translateX(-10px); }
    20% { transform: translateX(10px); }
    30% { transform: translateX(-10px); }
    40% { transform: translateX(10px); }
    50% { transform: translateX(-5px); }
    60% { transform: translateX(5px); }
    70% { transform: translateX(-2px); }
    80% { transform: translateX(2px); }
    90% { transform: translateX(-1px); }
}

/* No results animation */
#noResults {
    animation: fadeIn 0.3s ease-out;
}

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

/* Mobile responsive adjustments */
@media (max-width: 640px) {
    #searchInput {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 1rem 1.25rem;
        min-height: 52px; /* Larger touch target */
    }
    
    .alternative-card {
        padding: 1rem;
    }
    
    .alternative-card:hover {
        transform: none;
    }
}

/* Enhanced Mobile Optimizations */

/* iPhone SE, iPhone 6/7/8 */
@media (max-width: 375px) {
    body {
        font-size: 14px;
    }
    
    h1 {
        font-size: 1.5rem !important;
    }
    
    h2 {
        font-size: 1.75rem !important;
        line-height: 1.3;
    }
    
    h3 {
        font-size: 1.25rem !important;
    }
    
    .hero-text {
        font-size: 1rem !important;
    }
    
    /* Larger touch targets for mobile */
    button, .popular-search-link {
        min-height: 44px;
        padding: 12px 16px;
    }
    
    /* Better spacing for mobile */
    main {
        padding: 1rem !important;
    }
}

/* iPhone 6/7/8 Plus, Pixel, Samsung Galaxy */
@media (max-width: 414px) {
    /* Optimize autocomplete for mobile */
    #autocompleteDropdown {
        max-height: 50vh;
        font-size: 16px;
    }
    
    .autocomplete-item {
        padding: 14px 16px;
        min-height: 48px;
        display: flex;
        align-items: center;
    }
    
    /* Mobile-friendly cards */
    .alternative-card {
        margin-bottom: 1rem;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    /* Touch feedback */
    .alternative-card:active {
        background-color: rgba(255, 255, 255, 0.98);
        box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    }
}

/* Tablets and small laptops */
@media (min-width: 641px) and (max-width: 1024px) {
    .alternative-card {
        padding: 1.5rem;
    }
    
    #searchInput {
        font-size: 18px;
        padding: 1.25rem 1.5rem;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects on touch devices */
    .alternative-card:hover {
        transform: none !important;
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1) !important;
    }
    
    /* Add tap highlight */
    button, a, .popular-search-link, .alternative-card {
        -webkit-tap-highlight-color: rgba(255, 107, 53, 0.1);
    }
    
    /* Better scrolling on mobile */
    * {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Larger click areas for mobile */
    .popular-search-link {
        display: inline-block;
        padding: 8px 12px;
        margin: 2px;
    }
}

/* Landscape orientation adjustments */
@media (max-height: 500px) and (orientation: landscape) {
    header {
        padding: 0.5rem 0 !important;
    }
    
    .hero-section {
        padding: 1rem 0 !important;
    }
    
    h2 {
        font-size: 1.5rem !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .alternative-card {
        border: 2px solid currentColor;
    }
    
    button {
        border: 2px solid currentColor;
    }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Demo badge styles */
.demo-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    margin-left: 8px;
    background: linear-gradient(135deg, #f39c12 0%, #ff6b35 100%);
    color: white;
    font-size: 10px;
    font-weight: bold;
    letter-spacing: 0.5px;
    border-radius: 4px;
    text-transform: uppercase;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: relative;
    animation: subtle-pulse 3s ease-in-out infinite;
}

@keyframes subtle-pulse {
    0%, 100% { opacity: 0.9; }
    50% { opacity: 1; }
}

/* Upgrade prompt styles */
.upgrade-prompt {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem;
    border-radius: 12px;
    margin-top: 1rem;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Dark mode support (if needed in future) */
@media (prefers-color-scheme: dark) {
    /* Dark mode styles can be added here */
}

/* Print styles */
@media print {
    header, footer, #popularSearches, .popular-search {
        display: none;
    }
    
    #resultsSection {
        animation: none;
    }
    
    .alternative-card {
        page-break-inside: avoid;
        animation: none;
    }
}

/* Accessibility improvements */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Focus visible for keyboard navigation */
*:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

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

/* Custom utility classes */
.text-primary {
    color: var(--primary);
}

.text-secondary {
    color: var(--secondary);
}

.bg-primary {
    background-color: var(--primary);
}

.bg-secondary {
    background-color: var(--secondary);
}

.border-primary {
    border-color: var(--primary);
}

.border-secondary {
    border-color: var(--secondary);
}

/* Gradient backgrounds */
.gradient-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
}

.gradient-light {
    background: linear-gradient(135deg, var(--gray-50) 0%, var(--gray-100) 100%);
}

/* Text selection */
::selection {
    background-color: rgba(37, 99, 235, 0.2);
    color: var(--gray-900);
}

/* Input placeholder */
::placeholder {
    color: var(--gray-400);
    opacity: 1;
}

/* Badge styles */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 9999px;
}

.badge-primary {
    background-color: rgba(37, 99, 235, 0.1);
    color: var(--primary);
}

.badge-secondary {
    background-color: rgba(249, 115, 22, 0.1);
    color: var(--secondary);
}

/* Card shadows */
.shadow-soft {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

.shadow-medium {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.03);
}

.shadow-large {
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 10px 10px -5px rgba(0, 0, 0, 0.02);
}