.wallpaper-grid {
    display: grid;
    gap: 1.5rem;
}

.mobile-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.desktop-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

@media (min-width: 640px) {
    .mobile-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
    
    .desktop-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    }
}

@media (min-width: 768px) {
    .mobile-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    }
    
    .desktop-grid {
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    }
}

@media (min-width: 1024px) {
    .mobile-grid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    }
    
    .desktop-grid {
        grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    }
}

/* Tab Styles */
.tab-button, .tab-link {
    color: #6b7280;
    background-color: transparent;
}

.tab-button.active, .tab-link.active {
    color: #1f2937;
    background-color: #ffffff;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

.tab-button:hover, .tab-link:hover {
    color: #ea7c5c;
}

/* Wallpaper Item Hover Effects */
.wallpaper-item {
    transition: transform 0.2s ease-in-out;
}

.wallpaper-item:hover {
    transform: translateY(-2px);
}

.wallpaper-item img,
.wallpaper-container img,
.wallpaper-image-container img {
    transition: transform 0.3s ease-in-out;
}

/* Only apply hover effects to direct children to avoid affecting all items */
.wallpaper-image-container:hover > img {
    transform: scale(1.05) !important;
}

/* Button Hover Effects */
.preview-btn, .download-btn {
    transition: all 0.2s ease-in-out;
    transform: translateY(10px);
    opacity: 0;
    pointer-events: none;
}

.wallpaper-item:hover .preview-btn,
.wallpaper-item:hover .download-btn,
.wallpaper-container:hover .preview-btn,
.wallpaper-container:hover .download-btn {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* Wallpaper overlay styles */
.wallpaper-overlay {
    transition: all 0.3s ease-in-out;
    opacity: 0;
    background-color: rgba(0, 0, 0, 0);
    pointer-events: none;
}

.wallpaper-item:hover .wallpaper-overlay,
.wallpaper-container:hover .wallpaper-overlay {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.4);
    pointer-events: auto;
}

/* Ensure all child elements in overlay are visible on hover */
.wallpaper-item:hover .wallpaper-overlay > *,
.wallpaper-container:hover .wallpaper-overlay > * {
    opacity: 1;
    pointer-events: auto;
}

/* Force visibility on any absolute positioned overlay on hover */
.wallpaper-item:hover .absolute.inset-0,
.wallpaper-container:hover .absolute.inset-0 {
    opacity: 1 !important;
    background-color: rgba(0, 0, 0, 0.4) !important;
    pointer-events: auto !important;
}

/* Ensure buttons in any overlay are visible on hover */
.wallpaper-item:hover .absolute.inset-0 button,
.wallpaper-container:hover .absolute.inset-0 button {
    opacity: 1 !important;
    transform: translateY(0) !important;
    pointer-events: auto !important;
}

/* Additional fallback for deeply nested structures */
.wallpaper-item:hover [class*="absolute"][class*="inset-0"],
.wallpaper-container:hover [class*="absolute"][class*="inset-0"] {
    opacity: 1 !important;
    background-color: rgba(0, 0, 0, 0.4) !important;
    pointer-events: auto !important;
}

/* Force hover state for JavaScript-triggered hover */
.wallpaper-image-container.force-hover > img {
    transform: scale(1.05) !important;
}

.wallpaper-image-container.force-hover > .wallpaper-buttons {
    opacity: 1 !important;
    transform: translate(-50%, -50%) translateY(0) !important;
    pointer-events: auto !important;
}

.wallpaper-image-container.force-hover .bg-gradient-to-t {
    opacity: 1 !important;
}

.wallpaper-image-container.force-hover .wallpaper-info {
    opacity: 1 !important;
}

/* New wallpaper button styles */
.wallpaper-buttons {
    z-index: 10;
    transform: translate(-50%, -50%) translateY(2rem);
    opacity: 0;
    transition: all 0.3s ease-in-out;
}

.wallpaper-image-container:hover > .wallpaper-buttons {
    transform: translate(-50%, -50%) translateY(0) !important;
    opacity: 1 !important;
}

/* Image hover effects */
.wallpaper-image-container:hover > img {
    transform: scale(1.05) !important;
}

/* Enhanced button hover effects */
.wallpaper-buttons button {
    transition: all 0.2s ease-in-out;
    white-space: nowrap;
}

.wallpaper-buttons button:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* Gradient overlay styles */
.bg-gradient-to-t {
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7) 0%, rgba(0, 0, 0, 0.3) 50%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

/* Show overlay on hover */
.wallpaper-image-container:hover .bg-gradient-to-t {
    opacity: 1;
}

/* Hide wallpaper info by default */
.wallpaper-info {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

/* Show wallpaper info on hover */
.wallpaper-image-container:hover .wallpaper-info {
    opacity: 1;
}

/* Featured badge styles */
.bg-gradient-to-r {
    background: linear-gradient(to right, #ec4899, #8b5cf6);
}

/* Text with opacity support */
.text-white\/80 {
    color: rgba(255, 255, 255, 0.8);
}

/* Enhanced card hover effects */
.wallpaper-item:hover {
    transform: translateY(-4px);
}

/* Line clamp utility */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Mobile preview phone frame styles */
.phone-frame {
    background: linear-gradient(145deg, #2c2c2c, #1a1a1a);
    box-shadow: 
        0 20px 40px rgba(0, 0, 0, 0.3),
        inset 0 2px 4px rgba(255, 255, 255, 0.1);
}

.phone-screen {
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.2);
}

/* Phone notch style */
.phone-frame::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 4px;
    background: #333;
    border-radius: 2px;
    z-index: 20;
}

/* Enhanced backdrop blur for better button visibility */
.backdrop-blur-sm {
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

/* Mobile preview modal animation */
#mobilePreviewModal {
    animation: fadeInModal 0.3s ease-out;
}

@keyframes fadeInModal {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

#mobilePreviewModal .phone-frame {
    animation: slideUpPhone 0.4s ease-out 0.1s both;
}

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

/* Desktop preview modal styles */
#desktopPreviewModal {
    animation: fadeInModal 0.3s ease-out;
}

#desktopPreviewModal .desktop-preview-container {
    animation: slideUpDesktop 0.4s ease-out 0.1s both;
    border: none;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
}

@keyframes slideUpDesktop {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Desktop taskbar styling */
.desktop-preview-container .absolute.bottom-0 {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Desktop preview image styling */
.desktop-preview-container img {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 8px 8px 0 0;
}

/* Responsive desktop preview */
@media (max-width: 768px) {
    #desktopPreviewModal .desktop-preview-container {
        margin: 0 1rem;
    }
    
    #desktopPreviewModal .desktop-preview-container img {
        max-height: 60vh;
    }
}

/* Loading animation styles */
.wallpaper-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 20;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top: 3px solid rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

.loading-dots {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.loading-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.6);
    animation: loadingDots 1.5s infinite ease-in-out;
}

.loading-dot:nth-child(1) { animation-delay: 0s; }
.loading-dot:nth-child(2) { animation-delay: 0.2s; }
.loading-dot:nth-child(3) { animation-delay: 0.4s; }

.loading-text {
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.5px;
}

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

@keyframes loadingDots {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Mobile preview loading */
.phone-screen .wallpaper-loading .loading-spinner {
    width: 40px;
    height: 40px;
    border-width: 2px;
}

.phone-screen .wallpaper-loading .loading-text {
    font-size: 12px;
}

.phone-screen .wallpaper-loading .loading-dot {
    width: 6px;
    height: 6px;
}

/* Desktop preview loading */
.desktop-preview-container .wallpaper-loading {
    background-color: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 32px;
    min-width: 200px;
}

/* Image fade-in animation */
.wallpaper-image-loaded {
    animation: fadeInImage 0.5s ease-out;
}

@keyframes fadeInImage {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Modal Styles */
#wallpaperModal {
    backdrop-filter: blur(4px);
}

#wallpaperModal .bg-white {
    max-width: 90vw;
    max-height: 90vh;
}

#wallpaperModal img {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
}

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

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

/* FAQ Accordion */
.faq-button i {
    transition: transform 0.2s ease-in-out;
}

.faq-button[aria-expanded="true"] i {
    transform: rotate(180deg);
}

/* Language Dropdown */
#languageDropdown {
    transition: all 0.2s ease-in-out;
}

#languageDropdown.hidden {
    transform: translateY(-10px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

#languageDropdown:not(.hidden) {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Mobile Menu */
#mobileMenu {
    transition: all 0.3s ease-in-out;
    max-height: 0;
}

#mobileMenu.show {
    max-height: 400px;
}

/* Hero Section Animation */
.hero-animation {
    animation: fadeInUp 1s ease-out;
}

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

/* Stagger Animation for Grid Items */
.wallpaper-item {
    animation: fadeInScale 0.6s ease-out;
    animation-fill-mode: both;
}

.wallpaper-item:nth-child(1) { animation-delay: 0.1s; }
.wallpaper-item:nth-child(2) { animation-delay: 0.2s; }
.wallpaper-item:nth-child(3) { animation-delay: 0.3s; }
.wallpaper-item:nth-child(4) { animation-delay: 0.4s; }
.wallpaper-item:nth-child(5) { animation-delay: 0.5s; }
.wallpaper-item:nth-child(6) { animation-delay: 0.6s; }

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

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

/* Focus Styles for Accessibility */
.tab-button:focus,
.tab-link:focus,
button:focus,
a:focus {
    outline: 2px solid #ea7c5c;
    outline-offset: 2px;
}

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

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

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Print Styles */
@media print {
    .wallpaper-item {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    
    .no-print {
        display: none !important;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .wallpaper-item {
        border: 2px solid #000;
    }
    
    .tab-button.active,
    .tab-link.active {
        border: 2px solid #000;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .wallpaper-item:hover {
        transform: none;
    }
    
    .wallpaper-item:hover img {
        transform: none;
    }
}

/* Dark Mode Support (Future Enhancement) */
@media (prefers-color-scheme: dark) {
    /* Will be implemented if needed */
}

/* Loading States */
.loading {
    position: relative;
    overflow: hidden;
}

.loading::after {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.6),
        transparent
    );
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* Error States */
.error-state {
    color: #ef4444;
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 0.5rem;
    padding: 1rem;
}

/* Success States */
.success-state {
    color: #10b981;
    background-color: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 0.5rem;
    padding: 1rem;
}

/* Utility Classes */
.aspect-ratio-mobile {
    aspect-ratio: 9/16;
}

.aspect-ratio-desktop {
    aspect-ratio: 16/9;
}

.text-shadow {
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.backdrop-blur {
    backdrop-filter: blur(8px);
}

/* SEO and Performance Optimizations */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s;
}

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