/* Custom styles for PolyScan - Optimized for Performance */

/* Critical CSS - Above the fold */
html {
    scroll-behavior: smooth;
}

body {
    font-display: swap;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========== MOBILE AD OPTIMIZATION ========== */

/* Mobile-first responsive ads */
@media (max-width: 767px) {
    /* Hide sidebar ads on mobile - they don't perform well */
    .manual-ad-home-sidebar,
    .manual-ad-assets-sidebar,
    .manual-ad-asset-detail-sidebar,
    .sidebar-ad,
    .desktop-ad-container {
        display: none !important;
    }
    
    /* Optimize manual ads for mobile */
    .mobile-manual-ad {
        max-width: 300px !important;
        margin: 15px auto !important;
        text-align: center !important;
        overflow: hidden !important;
        padding: 0 !important;
    }
    
    /* Optimize AdSense ads for mobile */
    .mobile-ad-wrapper {
        max-width: 320px !important;
        margin: 15px auto !important;
        text-align: center !important;
        overflow: hidden !important;
        padding: 0 10px !important;
    }
    
    .mobile-ad-wrapper .adsbygoogle {
        max-width: 300px !important;
        margin: 0 auto !important;
        display: block !important;
    }
    
    /* Header ads on mobile */
    .mobile-manual-ad.manual-ad-home-header,
    .mobile-manual-ad.manual-ad-assets-header,
    .mobile-manual-ad.manual-ad-asset-detail-header {
        max-width: 320px !important;
        height: auto !important;
        margin: 10px auto !important;
    }
    
    /* Content ads on mobile */
    .mobile-manual-ad.manual-ad-home-content,
    .mobile-manual-ad.manual-ad-assets-content,
    .mobile-manual-ad.manual-ad-asset-detail-content {
        max-width: 300px !important;
        margin: 20px auto !important;
        padding: 10px !important;
    }
    
    /* Footer ads on mobile */
    .mobile-manual-ad.manual-ad-home-footer,
    .mobile-manual-ad.manual-ad-assets-footer,
    .mobile-manual-ad.manual-ad-asset-detail-footer {
        max-width: 320px !important;
        margin: 15px auto 10px !important;
    }
    
    /* Responsive AdSense improvements */
    .adsbygoogle[data-full-width-responsive="true"] {
        width: 100% !important;
        max-width: 300px !important;
        margin: 0 auto !important;
    }
    
    /* Fix any overflow issues */
    .adsbygoogle {
        overflow: hidden !important;
    }
}

/* Tablet optimization */
@media (min-width: 768px) and (max-width: 1023px) {
    .mobile-manual-ad,
    .mobile-ad-wrapper {
        max-width: 468px !important;
        margin: 20px auto !important;
    }
    
    .mobile-ad-wrapper .adsbygoogle {
        max-width: 468px !important;
    }
}

/* Desktop optimization */
@media (min-width: 1024px) {
    .mobile-manual-ad,
    .mobile-ad-wrapper {
        display: block;
        max-width: none;
        margin: initial;
        text-align: initial;
    }
}

/* Performance optimizations */
* {
    box-sizing: border-box;
}

img {
    max-width: 100%;
    height: auto;
    loading: lazy;
}

/* Line clamp utility */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #374151;
}

::-webkit-scrollbar-thumb {
    background: #4B5563;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #6B7280;
}

/* Lazy loading placeholder */
.lazy {
    opacity: 0;
    transition: opacity 0.3s;
}

.lazy.loaded {
    opacity: 1;
}

/* Custom focus styles */
.focus-ring:focus {
    outline: none;
    ring: 2px;
    ring-color: #3B82F6;
}

/* Loading animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #374151;
    border-radius: 50%;
    border-top-color: #3B82F6;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Pulse animation for upload areas */
.pulse-upload {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* Colorful & Animated Filter Buttons */
.filter-container {
    display: flex;
    gap: 1.25rem; /* More spacing */
    justify-content: flex-start; /* Left-aligned */
    flex-wrap: wrap;
}

.modern-filter-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 2rem;
    min-width: 150px;
    background: rgba(31, 41, 55, 0.7); /* Slightly more transparent */
    backdrop-filter: blur(15px);
    border: 1px solid rgba(75, 85, 99, 0.4);
    border-radius: 1.25rem; /* Larger radius */
    text-decoration: none;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* Glassmorphism Shine Effect */
.modern-filter-btn::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(to bottom right, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0));
    transform: rotate(45deg);
    opacity: 0;
    transition: opacity 0.5s ease, transform 0.5s ease;
}

/* --- Elements inside the button --- */
.filter-icon {
    width: 2.75rem;
    height: 2.75rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 1rem;
    background: rgba(59, 130, 246, 0.1);
    transition: all 0.3s ease;
}
.filter-icon svg {
    width: 1.75rem;
    height: 1.75rem;
    color: #93C5FD; /* light blue */
    transition: all 0.3s ease;
}
.filter-label {
    font-size: 1rem;
    font-weight: 600;
    color: #E5E7EB; /* light gray */
    margin-bottom: 0.25rem;
    transition: color 0.3s ease;
}
.filter-count {
    font-size: 0.8rem;
    font-weight: 500;
    color: #9CA3AF; /* medium gray */
    background: rgba(75, 85, 99, 0.6);
    padding: 0.25rem 0.6rem;
    border-radius: 0.5rem;
    transition: all 0.3s ease;
}

/* --- HOVER STATE --- */
.modern-filter-btn:hover {
    transform: translateY(-6px) scale(1.02);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border-color: rgba(59, 130, 246, 0.4);
    background: rgba(41, 51, 65, 0.8);
}
.modern-filter-btn:hover::before {
    opacity: 1;
    transform: rotate(30deg) translate(20%, 20%);
}
.modern-filter-btn:hover .filter-icon {
    background: rgba(59, 130, 246, 0.2);
    transform: scale(1.1) rotate(-5deg);
}
.modern-filter-btn:hover .filter-icon svg {
    color: #60A5FA; /* medium blue */
}
.modern-filter-btn:hover .filter-label {
    color: #FFFFFF;
}

/* --- ACTIVE STATE --- */
.modern-filter-btn.active {
    background: linear-gradient(135deg, #3B82F6 0%, #1E40AF 100%);
    border-color: #60A5FA;
    transform: translateY(-2px);
    animation: activeGlow 3s ease-in-out infinite alternate;
}
.modern-filter-btn.active .filter-icon {
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
.modern-filter-btn.active .filter-icon svg,
.modern-filter-btn.active .filter-label,
.modern-filter-btn.active .filter-count {
    color: #FFFFFF;
}
.modern-filter-btn.active .filter-count {
    background: rgba(255, 255, 255, 0.25);
    font-weight: 600;
}

/* --- ACTIVE HOVER STATE --- */
.modern-filter-btn.active:hover {
    transform: translateY(-8px) scale(1.03);
    background: linear-gradient(135deg, #2563EB 0%, #1D4ED8 100%);
}

/* --- RESPONSIVE DESIGN --- */
@media (max-width: 768px) {
    .filter-container {
        gap: 1rem;
    }
    .modern-filter-btn {
        padding: 1.25rem 1.5rem;
        min-width: 130px;
    }
}

@media (max-width: 640px) {
    .filter-container {
        justify-content: center; /* Center on small screens */
        gap: 0.75rem;
    }
    .modern-filter-btn {
        flex: 1; /* Allow buttons to grow */
        max-width: 160px;
        padding: 1rem 1.25rem;
    }
}
@media (max-width: 480px) {
    .modern-filter-btn {
        flex-direction: row;
        padding: 0.75rem 1rem;
        min-width: 0;
        max-width: none;
    }
    .modern-filter-btn .filter-icon {
        width: 2rem; height: 2rem;
        margin-bottom: 0; margin-right: 0.75rem;
    }
    .modern-filter-btn .filter-icon svg {
        width: 1.25rem; height: 1.25rem;
    }
    .modern-filter-btn .filter-label {
        font-size: 0.9rem; margin-bottom: 0;
        margin-right: auto; /* Push count to the end */
    }
}

/* Hover effects for cards */
.asset-card {
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.asset-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

/* Custom button styles */
.btn-primary {
    background: linear-gradient(135deg, #3B82F6 0%, #2563EB 100%);
    transition: all 0.2s ease-in-out;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #2563EB 0%, #1D4ED8 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* Sidebar animations */
.sidebar-item {
    transition: all 0.2s ease-in-out;
}

.sidebar-item:hover {
    background: linear-gradient(90deg, #374151 0%, #4B5563 100%);
    transform: translateX(4px);
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .grid {
        gap: 1rem;
    }
    
    .text-4xl {
        font-size: 2rem;
    }
    
    .text-5xl {
        font-size: 2.5rem;
    }
}

/* Print styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .bg-gray-800 {
        background-color: #1F2937 !important;
    }
    
    .text-gray-300 {
        color: #E5E7EB !important;
    }
    
    .border-gray-600 {
        border-color: #4B5563 !important;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Custom utility classes */
.text-gradient {
    background: linear-gradient(135deg, #3B82F6 0%, #8B5CF6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.bg-gradient {
    background: linear-gradient(135deg, #1F2937 0%, #374151 100%);
}

.shadow-glow {
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
}

/* Form styles */
.form-input:focus {
    border-color: #3B82F6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Table styles */
.table-hover tbody tr:hover {
    background-color: #374151;
}

/* Badge styles */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1;
}

.badge-blue {
    background-color: #3B82F6;
    color: white;
}

.badge-gray {
    background-color: #6B7280;
    color: white;
}

.badge-green {
    background-color: #10B981;
    color: white;
}

/* Tooltip styles */
.tooltip {
    position: relative;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #1F2937;
    color: white;
    padding: 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 1000;
}

.tooltip:hover::after {
    opacity: 1;
}

/* Modal styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background-color: #1F2937;
    border-radius: 0.5rem;
    padding: 1.5rem;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
}

/* Notification styles */
.notification {
    position: fixed;
    top: 1rem;
    right: 1rem;
    padding: 1rem;
    border-radius: 0.5rem;
    color: white;
    z-index: 1000;
    animation: slideIn 0.3s ease-out;
}

.notification.success {
    background-color: #10B981;
}

.notification.error {
    background-color: #EF4444;
}

.notification.warning {
    background-color: #F59E0B;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive images */
.img-responsive {
    max-width: 100%;
    height: auto;
}

/* Aspect ratio utilities */
.aspect-square {
    aspect-ratio: 1 / 1;
}

.aspect-video {
    aspect-ratio: 16 / 9;
}

.aspect-photo {
    aspect-ratio: 4 / 3;
}

/* Loading skeleton */
.skeleton {
    background: linear-gradient(90deg, #374151 25%, #4B5563 50%, #374151 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* New Category Filter Buttons */
.category-filter-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: 999px; /* pill shape */
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: #9CA3AF; /* gray-400 */
    cursor: pointer;
    position: relative;
    border: 1px solid transparent;
}

.category-filter-btn .filter-icon {
    margin-bottom: 0.25rem;
    transition: all 0.3s ease;
}

.category-filter-btn .filter-label {
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25rem;
    transition: all 0.3s ease;
}

/* Hover State */
.category-filter-btn:hover {
    color: #F9FAFB; /* gray-50 */
    background-color: rgba(75, 85, 99, 0.5); /* gray-500 with alpha */
}

.category-filter-btn:hover .filter-icon {
    transform: scale(1.1);
}

/* Active State */
.category-filter-btn.active {
    background-color: #3B82F6; /* blue-500 */
    color: #FFFFFF;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.25);
}

.category-filter-btn.active .filter-label {
    font-weight: 600;
}

.category-filter-btn.active:hover {
    background-color: #2563EB; /* blue-600 */
}

/* Focus State */
.category-filter-btn:focus-visible {
    outline: 2px solid #3B82F6;
    outline-offset: 2px;
}

/* Filter Buttons */
.filter-btn {
    display: inline-flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, #374151 0%, #4B5563 100%);
    color: #D1D5DB;
    text-decoration: none;
    border-radius: 0.75rem;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.filter-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.5s ease;
}

.filter-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    background: linear-gradient(135deg, #4B5563 0%, #6B7280 100%);
    color: #F9FAFB;
}

.filter-btn:hover::before {
    left: 100%;
}

.filter-btn.active {
    background: linear-gradient(135deg, #3B82F6 0%, #1D4ED8 100%);
    color: #FFFFFF;
    border-color: #60A5FA;
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.3);
    transform: translateY(-1px);
}

.filter-btn.active:hover {
    background: linear-gradient(135deg, #2563EB 0%, #1E40AF 100%);
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(59, 130, 246, 0.4);
}

.filter-btn svg {
    transition: transform 0.3s ease;
}

.filter-btn:hover svg {
    transform: scale(1.1);
}

.filter-btn.active svg {
    transform: scale(1.05);
}

/* Filter button container */
.filter-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

.filter-btn:active {
    transform: translateY(0) scale(0.98);
}

/* Add subtle animation for filter transitions */
.filter-btn {
    backdrop-filter: blur(10px);
}

.filter-btn.active {
    animation: activeGlow 2s ease-in-out infinite alternate;
}

@keyframes activeGlow {
    0% {
        box-shadow: 0 8px 25px rgba(59, 130, 246, 0.3);
    }
    100% {
        box-shadow: 0 8px 25px rgba(59, 130, 246, 0.5);
    }
}

/* Mobile responsive filter buttons */
@media (max-width: 768px) {
    .filter-btn {
        padding: 0.625rem 1.25rem;
        font-size: 0.8rem;
    }
    
    .filter-btn svg {
        width: 0.875rem;
        height: 0.875rem;
    }
}

@media (max-width: 480px) {
    .filter-btn {
        padding: 0.5rem 1rem;
        font-size: 0.75rem;
        flex: 1;
        justify-content: center;
        min-width: 0;
    }
    
    .filter-btn svg {
        width: 0.75rem;
        height: 0.75rem;
        margin-right: 0.375rem;
    }
    
    /* Stack buttons vertically on very small screens if needed */
    @media (max-width: 360px) {
        .filter-btn {
            flex: none;
            width: 100%;
            margin-bottom: 0.5rem;
        }
    }
}

/* Gradient Filter Buttons */
.gradient-filter-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.65rem 1.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: #E5E7EB; /* light gray */
    background-color: rgba(75, 85, 99, 0.4); /* gray-500 with alpha */
    border: 1px solid rgba(139, 92, 246, 0.3); /* purple border */
    border-radius: 999px; /* pill shape */
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.gradient-filter-btn:hover {
    color: #FFFFFF;
    background-color: rgba(99, 102, 241, 0.5); /* indigo with alpha */
    border-color: rgba(167, 139, 250, 0.7); /* lighter purple */
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.2);
}

/* --- ACTIVE STATE --- */
.gradient-filter-btn.active {
    color: #FFFFFF;
    background: linear-gradient(to right, #4F46E5, #7C3AED); /* from-indigo-600 to-purple-600 */
    border-color: transparent;
    box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3), 0 6px 6px rgba(124, 58, 237, 0.2);
    transform: translateY(-1px) scale(1.02);
}

.gradient-filter-btn.active:hover {
    background: linear-gradient(to right, #4338CA, #6D28D9); /* from-indigo-700 to-purple-700 */
    box-shadow: 0 12px 28px rgba(99, 102, 241, 0.35), 0 8px 10px rgba(124, 58, 237, 0.25);
    transform: translateY(-2px) scale(1.03);
}

/* --- FOCUS STATE --- */
.gradient-filter-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(31, 41, 55, 1), 0 0 0 5px rgba(124, 58, 237, 0.7);
}

/* --- SVG ICONS --- */
.gradient-filter-btn svg {
    transition: transform 0.3s ease;
}

.gradient-filter-btn:hover svg {
    transform: scale(1.1) rotate(-5deg);
}

.gradient-filter-btn.active svg {
    transform: scale(1.05);
}

/* New styles for the integrated filter bar */
.inline-filter-btn {
    display: inline-flex;
    flex-direction: row; /* Horizontal layout */
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem; /* Adjusted padding */
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    text-align: center;
    background-image: linear-gradient(to right, #3b82f6, #6366f1);
    color: white;
    border: 1px solid transparent;
    transition: all 0.3s ease;
    width: 100%; /* Fill grid cell */
    height: 2.5rem; /* 40px */
}

.inline-filter-btn svg {
    margin-bottom: 0; /* Removed */
    /* margin-right is now handled by Tailwind class in HTML */
}

.inline-filter-btn:hover {
    background-image: linear-gradient(to right, #60a5fa, #818cf8);
    box-shadow: 0 0 15px rgba(96, 165, 250, 0.5);
    transform: translateY(-1px);
}

.inline-filter-btn.active {
    background-image: linear-gradient(to right, #8b5cf6, #ec4899);
    color: white;
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.6);
    border-color: #a78bfa;
    transform: scale(1.03);
}

/* Ensure text is always visible and override responsive hiding */
.inline-filter-btn span {
    display: inline !important;
}

/* New responsive grid for the assets page */
.responsive-assets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

/* Blog content links styling */
.prose a {
  color: #3b82f6;
  text-decoration: underline;
  font-weight: 500;
  transition: color 0.2s;
}
.prose a:hover {
  color: #2563eb;
}