/**
 * UI/UX Enhancement Styles
 * Responsive design, accessibility, loading states, animations
 */

/* Loading States */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.loading-spinner {
    text-align: center;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color, #2563eb);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    color: #666;
    font-weight: 500;
}

/* Error Messages */
.error-message {
    background: #fee;
    border: 2px solid #fcc;
    border-left: 4px solid #dc2626;
    color: #dc2626;
    padding: 1rem 1.25rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    animation: slideDown 0.3s ease-out;
}

.error-message.error-info {
    background: #eff6ff;
    border-color: #bfdbfe;
    border-left-color: #2563eb;
    color: #1e40af;
}

.success-message {
    background: #f0fdf4;
    border: 2px solid #bbf7d0;
    border-left: 4px solid #22c55e;
    color: #15803d;
    padding: 1rem 1.25rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    animation: slideDown 0.3s ease-out;
}

.error-close, .success-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.error-close:hover, .success-close:hover {
    opacity: 1;
}

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

.animate-slide-down {
    animation: slideDown 0.3s ease-out;
}

/* Skip to Main Content Link */
.skip-to-main {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary-color, #2563eb);
    color: white;
    padding: 0.5rem 1rem;
    text-decoration: none;
    z-index: 10000;
    border-radius: 0 0 0.25rem 0;
}

.skip-to-main:focus {
    top: 0;
}

/* Keyboard Navigation Styles */
.keyboard-navigation *:focus {
    outline: 3px solid var(--primary-color, #2563eb);
    outline-offset: 2px;
}

/* Form Input States */
input.invalid,
textarea.invalid,
select.invalid {
    border-color: #dc2626 !important;
    background-color: #fef2f2;
}

input:focus:valid,
textarea:focus:valid,
select:focus:valid {
    border-color: #22c55e;
}

/* Smooth Animations */
.animate-on-scroll {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.animate-on-scroll.animate-in {
    opacity: 1;
    transform: translateY(0);
}

/* Lazy Load Images */
img[data-src] {
    opacity: 0;
    transition: opacity 0.3s;
}

img[data-src].loaded {
    opacity: 1;
}

/* Responsive Improvements */
@media (max-width: 640px) {
    .loading-spinner {
        transform: scale(0.8);
    }
    
    .error-message,
    .success-message {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }
}

/* Focus Visible for Better Accessibility */
*:focus-visible {
    outline: 3px solid var(--primary-color, #2563eb);
    outline-offset: 2px;
    border-radius: 0.25rem;
}

/* 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;
    }
    
    .animate-on-scroll {
        opacity: 1;
        transform: none;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .error-message {
        border-width: 3px;
    }
    
    .success-message {
        border-width: 3px;
    }
}

/* Print Styles */
@media print {
    .loading-overlay,
    .error-message,
    .success-message,
    .skip-to-main {
        display: none;
    }
}

/* Screen Reader Only */
.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;
}

/* Loading Skeleton */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s ease-in-out infinite;
    border-radius: 0.25rem;
}

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

/* Small Spinner for Buttons */
.spinner-small {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

/* Enhanced Mobile Responsiveness */
@media (max-width: 640px) {
    .product-card,
    .blog-card,
    .usp-card,
    .gallery-item {
        transform: none !important;
    }
    
    .product-card:hover,
    .blog-card:hover,
    .usp-card:hover {
        transform: none !important;
    }
    
    /* Touch-friendly targets */
    button, a, input[type="submit"] {
        min-height: 44px;
        min-width: 44px;
    }
}

/* Focus Visible Improvements */
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 3px solid var(--primary-color, #2563eb);
    outline-offset: 3px;
    border-radius: 0.375rem;
}

/* Loading State for Images */
img[loading="lazy"] {
    opacity: 1;
    transition: opacity 0.3s;
}

img[loading="lazy"].loaded {
    opacity: 1;
}

/* Gallery images should always be visible */
.gallery-item img {
    opacity: 1 !important;
    display: block !important;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 400px;
}

.toast {
    background: white;
    border-radius: 0.5rem;
    padding: 1rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    animation: slideInRight 0.3s ease-out;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.toast.toast-success {
    border-left: 4px solid #22c55e;
}

.toast.toast-error {
    border-left: 4px solid #dc2626;
}

.toast.toast-info {
    border-left: 4px solid #2563eb;
}

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

/* Hero Carousel Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Sticky Navigation Styles */
#main-navigation {
    transition: transform 0.3s ease-in-out, box-shadow 0.3s ease-in-out, background-color 0.3s ease-in-out;
}

#main-navigation.sticky-active {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

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

.animate-fade-in-up {
    animation: fadeInUp 0.8s ease-out forwards;
    opacity: 0;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .toast-container {
        left: 1rem;
        right: 1rem;
        max-width: none;
    }
    
    .toast {
        font-size: 0.875rem;
        padding: 0.75rem;
    }
    
    /* Better spacing on mobile */
    section {
        padding-top: 3rem;
        padding-bottom: 3rem;
    }
    
    /* Stack form fields on mobile */
    .grid.md\\:grid-cols-2 > * {
        grid-column: span 2;
    }
}

/* Tablet Optimizations */
@media (min-width: 641px) and (max-width: 1024px) {
    .grid.lg\\:grid-cols-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Large Screen Optimizations */
@media (min-width: 1920px) {
    .max-w-7xl {
        max-width: 90rem;
    }
}

/* Back to Top Button */
#back-to-top {
    transition: opacity 0.3s, transform 0.3s;
}

#back-to-top:hover {
    transform: translateY(-4px);
}

@media (max-width: 768px) {
    #back-to-top {
        bottom: 1rem;
        right: 1rem;
        padding: 0.75rem;
    }
}

