/* Custom styles for Guangxi Jinhua website */
/* Optimized for performance and modern browsers */

/* Performance optimizations */
* {
    box-sizing: border-box;
}

/* Smooth scrolling for the entire page */
html {
    scroll-behavior: smooth;
    font-display: swap; /* Optimize font loading */
}

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

/* GPU acceleration for animations */
.gpu-accelerated {
    transform: translateZ(0);
    will-change: transform;
}

/* Image optimization */
img {
    max-width: 100%;
    height: auto;
    loading: lazy; /* Native lazy loading */
}

/* Custom animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

/* Animation classes */
.animate-fade-in {
    animation: fadeIn 0.8s ease-out forwards;
}

.animate-slide-left {
    animation: slideInLeft 0.8s ease-out forwards;
}

.animate-slide-right {
    animation: slideInRight 0.8s ease-out forwards;
}

/* Header styling improvements */
header {
    transition: all 0.3s ease;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

header.scrolled {
    background-color: rgba(255, 255, 255, 0.95);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
}

/* Navigation link hover effects */
.nav-link {
    position: relative;
    transition: color 0.3s ease;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 0;
    height: 2px;
    background-color: #1e3a8a;
    transition: width 0.3s ease;
}

.nav-link:hover::after {
    width: 100%;
}

/* Button hover effects */
.btn-primary {
    @apply bg-blue-600 text-white px-6 py-3 rounded-lg font-semibold transition-all duration-300;
    transform: translateY(0);
}

.btn-primary:hover {
    @apply bg-blue-700;
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(59, 130, 246, 0.3);
}

.btn-secondary {
    @apply border-2 border-blue-600 text-blue-600 px-6 py-3 rounded-lg font-semibold transition-all duration-300;
    transform: translateY(0);
}

.btn-secondary:hover {
    @apply bg-blue-600 text-white;
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(59, 130, 246, 0.3);
}

/* Card hover effects */
.card-hover {
    transition: all 0.3s ease;
    transform: translateY(0);
}

.card-hover:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

/* Hero section enhancements */
.hero-gradient {
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
    position: relative;
    overflow: hidden;
}

.hero-gradient::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="25" cy="25" r="1" fill="%23ffffff" opacity="0.1"/><circle cx="75" cy="75" r="1" fill="%23ffffff" opacity="0.1"/><circle cx="50" cy="10" r="0.5" fill="%23ffffff" opacity="0.1"/><circle cx="10" cy="60" r="0.5" fill="%23ffffff" opacity="0.1"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
    opacity: 0.3;
}

/* Stats animation */
.stats-container {
    position: relative;
}

.stats-item {
    transition: all 0.3s ease;
}

.stats-item:hover {
    transform: scale(1.05);
}

/* Product cards styling */
.product-card {
    @apply rounded-lg shadow-lg overflow-hidden transition-all duration-300;
    transform: translateY(0);
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
}

.product-gradient {
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 70%, #60a5fa 100%);
}

/* Form styling improvements */
.form-input {
    @apply w-full px-4 py-3 border border-gray-300 rounded-lg transition-all duration-300;
}

.form-input:focus {
    @apply ring-2 ring-blue-500 border-transparent;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-input:invalid {
    @apply border-red-400;
}

/* Quality process steps */
.process-step {
    position: relative;
}

.process-step::after {
    content: '';
    position: absolute;
    top: 50%;
    right: -50%;
    width: 100%;
    height: 2px;
    background: linear-gradient(to right, #3b82f6, transparent);
    transform: translateY(-50%);
}

.process-step:last-child::after {
    display: none;
}

/* News cards */
.news-card {
    @apply rounded-lg overflow-hidden transition-all duration-300;
    transform: translateY(0);
}

.news-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

/* Contact section styling */
.contact-info-item {
    @apply flex items-start transition-all duration-300;
}

.contact-info-item:hover {
    transform: translateX(5px);
}

/* Map container */
.map-container {
    @apply h-64 bg-gray-200 rounded-lg overflow-hidden;
    position: relative;
}

.map-placeholder {
    @apply w-full h-full flex items-center justify-center text-gray-600;
    background: linear-gradient(135deg, #e5e7eb 0%, #d1d5db 100%);
}

/* Footer styling */
footer {
    background: linear-gradient(135deg, #374151 0%, #1f2937 100%);
}

/* Mobile responsiveness improvements */
@media (max-width: 768px) {
    .hero-gradient {
        background-attachment: scroll;
        padding: 60px 0 40px 0;
    }
    
    .hero-gradient h1 {
        font-size: 2rem !important;
        line-height: 1.2;
    }
    
    .hero-gradient p {
        font-size: 1.1rem !important;
    }
    
    .mobile-menu-overlay {
        @apply fixed inset-0 bg-black bg-opacity-50 z-40;
    }
    
    .mobile-menu-content {
        @apply fixed top-0 right-0 h-full w-80 bg-white shadow-2xl z-50 transform transition-transform duration-300;
    }
    
    .mobile-menu-content.closed {
        transform: translateX(100%);
    }
    
    /* Mobile navigation improvements */
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Mobile card layouts */
    .product-card, .news-card, .certification-badge {
        margin-bottom: 1.5rem;
    }
    
    /* Mobile form improvements */
    .form-input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Mobile stats layout */
    .stats-container {
        padding: 1rem;
    }
    
    .stats-container .grid {
        gap: 1rem;
    }
}

/* Tablet optimizations */
@media (min-width: 769px) and (max-width: 1024px) {
    .hero-gradient h1 {
        font-size: 3rem;
    }
    
    .grid {
        gap: 1.5rem;
    }
    
    .container {
        padding-left: 2rem;
        padding-right: 2rem;
    }
}

/* Large screen optimizations */
@media (min-width: 1920px) {
    .container {
        max-width: 1600px;
    }
    
    .hero-gradient h1 {
        font-size: 4rem;
    }
    
    section {
        padding: 5rem 0;
    }
}

/* Language selector styling */
.language-selector {
    @apply bg-transparent border border-gray-300 rounded px-3 py-2 text-sm transition-all duration-300;
}

.language-selector:focus {
    @apply ring-2 ring-blue-500 border-transparent;
}

.language-selector:hover {
    @apply border-blue-400;
}

/* Scroll indicators */
.scroll-indicator {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(to right, #1e3a8a, #3b82f6);
    transform-origin: left;
    transform: scaleX(0);
    transition: transform 0.1s ease;
    z-index: 1000;
}

/* Loading animations */
.loading-spinner {
    @apply inline-block w-4 h-4 border-2 border-white border-t-transparent rounded-full;
    animation: spin 1s linear infinite;
}

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

/* Success/Error messages */
.message-success {
    @apply bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded mb-4;
    animation: fadeIn 0.5s ease-out;
}
/* Animation delay utilities (replaces inline styles) */
.anim-delay-400 { animation-delay: 0.4s !important; }
.anim-delay-600 { animation-delay: 0.6s !important; }
.anim-delay-800 { animation-delay: 0.8s !important; }
.anim-delay-1000 { animation-delay: 1s !important; }
.anim-delay-2000 { animation-delay: 2s !important; }

.message-error {
    @apply bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded mb-4;
    animation: fadeIn 0.5s ease-out;
}

/* Certification badges */
.certification-badge {
    @apply rounded-lg p-6 text-center shadow-lg transition-all duration-300;
    transform: translateY(0);
}

.certification-badge:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15);
}

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

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

::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, #1e3a8a, #3b82f6);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(to bottom, #1e40af, #2563eb);
}

/* Print styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.4;
    }
    
    h1, h2, h3 {
        page-break-after: avoid;
    }
    
    .page-break {
        page-break-before: always;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .hero-gradient {
        background: #000;
        color: #fff;
    }
    
    .card-hover {
        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;
    }
    
    html {
        scroll-behavior: auto;
    }
}

/* Dark mode support (future enhancement) */
@media (prefers-color-scheme: dark) {
    .dark-mode-compatible {
        background-color: #1f2937;
        color: #f9fafb;
    }
}

/* Focus indicators for accessibility */
.focus-visible:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Skip link for accessibility */
.skip-link {
    @apply absolute top-0 left-0 bg-blue-600 text-white px-4 py-2 z-50 transform -translate-y-full;
    transition: transform 0.3s ease;
}

.skip-link:focus {
    transform: translateY(0);
}

/* Offline mode styles */
.offline {
    filter: grayscale(20%);
}

.offline .product-card:hover,
.offline .news-card:hover,
.offline .certification-badge:hover {
    transform: none;
    box-shadow: inherit;
}

.offline-banner {
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
    }
    to {
        transform: translateY(0);
    }
}

/* PWA install banner */
.install-banner {
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

/* Performance optimizations */
.hero-gradient,
.product-gradient {
    will-change: transform;
    transform: translateZ(0);
}

.card-hover,
.product-card,
.news-card {
    will-change: transform, box-shadow;
}

/* Lazy loading placeholder */
.lazy-loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

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

/* Critical CSS loading indicator */
.critical-loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, #1e3a8a, #3b82f6, #60a5fa);
    background-size: 200% 100%;
    animation: loadingBar 2s infinite;
    z-index: 9999;
}

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

/* Image optimization */
img {
    max-width: 100%;
    height: auto;
    object-fit: cover;
}

.hero-image,
.product-image {
    image-rendering: optimizeQuality;
    image-rendering: -webkit-optimize-contrast;
}

/* Critical path optimization */
.above-fold {
    contain: layout style paint;
}

.below-fold {
    content-visibility: auto;
    contain-intrinsic-size: 500px;
}

/* Interaction improvements */
@media (hover: hover) {
    .interactive-element:hover {
        transform: translateY(-2px);
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    }
}

@media (hover: none) {
    .interactive-element:active {
        transform: scale(0.98);
    }
}

/* Loading states */
.loading-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton 1.5s infinite;
    border-radius: 4px;
}

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

/* Error states */
.error-message {
    @apply bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded-lg;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Connection status indicator */
.connection-status {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    z-index: 1000;
    transition: all 0.3s ease;
}

.connection-status.online {
    background: #10b981;
    color: white;
}

.connection-status.offline {
    background: #ef4444;
    color: white;
}

.connection-status.slow {
    background: #f59e0b;
    color: white;
}

/* Print optimizations */
@media print {
    .hero-gradient {
        background: #1e3a8a !important;
        color: white !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    .no-print,
    nav,
    .mobile-menu,
    .install-banner,
    .offline-banner {
        display: none !important;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.4;
        color: #000;
    }
    
    .container {
        max-width: none;
        padding: 0;
    }
    
    section {
        page-break-inside: avoid;
        margin: 0 0 20pt 0;
    }
    
    h1, h2, h3 {
        page-break-after: avoid;
        color: #1e3a8a;
    }
    
    .product-card, .news-card {
        page-break-inside: avoid;
        border: 1pt solid #ddd;
        margin-bottom: 10pt;
    }
}
