/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Preloader Styles */
#preloader {
    transition: opacity 0.5s ease-out, visibility 0.5s ease-out;
}

#preloader.fade-out {
    opacity: 0;
    visibility: hidden;
}

.preloader-spinner {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* Header scroll effect with sticky behavior */
.header-scrolled {
    box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.98) !important;
}

#header {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        box-shadow 0.3s ease,
        background-color 0.3s ease;
}

/* Hero Carousel Styles */
.hero-carousel {
    position: relative;
    overflow: hidden;
}

.hero-slide {
    transition: opacity 1s cubic-bezier(0.4, 0, 0.2, 1),
        transform 1.2s cubic-bezier(0.4, 0, 0.2, 1),
        filter 0.8s ease-in-out;
}

.hero-slide:not(.active) {
    filter: blur(0px);
}

.hero-slide.active {
    animation: slideIn 1.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1;
}

@keyframes slideIn {
    0% {
        opacity: 0;
        transform: scale(1.08);
        filter: blur(2px);
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
        transform: scale(1);
        filter: blur(0px);
    }
}

/* Carousel Indicators */
.carousel-indicator {
    cursor: pointer;
    transition: all 0.4s ease;
    position: relative;
    overflow: hidden;
    background-color: rgba(255, 255, 255, 0.4);
}

.carousel-indicator::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0;
    background-color: #4CAF50;
    border-radius: 999px;
}

.carousel-indicator.active {
    opacity: 1;
    width: 2.5rem !important;
    background-color: rgba(255, 255, 255, 0.3);
}

.carousel-indicator.active::before {
    animation: progressFill 4s linear;
}

@keyframes progressFill {
    0% {
        width: 0%;
    }

    100% {
        width: 100%;
    }
}

.carousel-indicator:not(.active) {
    opacity: 0.5;
}

.carousel-indicator:not(.active):hover {
    opacity: 0.75;
    background-color: rgba(255, 255, 255, 0.6);
}

/* Prevent horizontal overflow */
html,
body {
    max-width: 100vw;
    overflow-x: hidden;
}

* {
    box-sizing: border-box;
}

/* Ensure containers don't overflow */
.container {
    max-width: 100%;
}

/* Mobile optimizations for carousel */
@media (max-width: 768px) {
    .hero-slide h1 {
        font-size: 2.5rem;
        line-height: 1.2;
    }

    .hero-slide p {
        font-size: 1.125rem;
    }

    .carousel-prev,
    .carousel-next {
        width: 48px;
        height: 48px;
    }
}

/* Navigation link underline effect */
.nav-link {
    position: relative;
    padding-bottom: 0.25rem;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 2px;
    background: #4CAF50;
    border-radius: 2px;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 100%;
}

/* Mobile navigation active state border */
.mobile-nav-link {
    position: relative;
}

.mobile-nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 70%;
    background: #4CAF50;
    border-radius: 0 4px 4px 0;
}

/* Mobile Menu Sidebar - slide animation */
#mobile-menu {
    right: -100%;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#mobile-menu.open {
    right: 0;
}

/* Mobile menu overlay - fade animation */
.mobile-menu-overlay.open {
    opacity: 1;
    visibility: visible;
}

/* Close button hover effect */
.mobile-menu-close:hover {
    transform: rotate(90deg);
}

/* Modern custom scrollbar */
::-webkit-scrollbar {
    width: 12px;
}

::-webkit-scrollbar-track {
    background: #FFF8E7;
}

::-webkit-scrollbar-thumb {
    background: #4CAF50;
    border-radius: 10px;
    border: 2px solid #FFF8E7;
}

::-webkit-scrollbar-thumb:hover {
    background: #388E3C;
}

/* Loading animation for images */
img {
    transition: opacity 0.3s ease-in-out;
}

img:not([src]) {
    opacity: 0;
}

/* Form focus styles */
input:focus,
textarea:focus,
select:focus {
    outline: none;
}

/* Solid text color */
.gradient-text {
    color: #4CAF50;
}

/* Section spacing */
section {
    position: relative;
}

/* Responsive utilities */
@media (max-width: 768px) {
    .hero-slide h1 {
        font-size: 2.5rem;
        line-height: 1.2;
    }

    .hero-slide p {
        font-size: 1.125rem;
    }
}

/* Print styles for better printing */
@media print {

    header,
    footer,
    #scroll-top {
        display: none;
    }

    section {
        page-break-inside: avoid;
    }
}

/* 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 */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 3px solid #F16A2C;
    outline-offset: 2px;
    border-radius: 4px;
}

/* Prefers reduced motion */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    html {
        scroll-behavior: auto;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    body {
        background: white;
        color: black;
    }

    .bg-primary {
        background-color: #388E3C;
    }

    .text-primary {
        color: #388E3C;
    }
}

/* Loading state */
.loading {
    pointer-events: none;
    opacity: 0.6;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #4CAF50;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Success and error states */
.success {
    color: #059669;
    background-color: #d1fae5;
    padding: 1rem;
    border-radius: 0.5rem;
    border-left: 4px solid #059669;
}

.error {
    color: #dc2626;
    background-color: #fee2e2;
    padding: 1rem;
    border-radius: 0.5rem;
    border-left: 4px solid #dc2626;
}

/* Performance optimizations */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img,
video {
    max-width: 100%;
    height: auto;
}

/* Prevent layout shift */
img,
video,
iframe {
    display: block;
}

/* FAQ Accordion Styles */
.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out, padding 0.3s ease-out;
}

.faq-answer:not(.hidden) {
    max-height: 500px;
    transition: max-height 0.5s ease-in, padding 0.3s ease-in;
}

/* Product Tabs Styles */
.product-tab {
    background-color: white;
    color: #4a5568;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.product-tab:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.product-tab.active {
    background: #4CAF50;
    color: white;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
    transform: translateY(-2px);
}

.product-tab.active:hover {
    box-shadow: 0 6px 16px rgba(76, 175, 80, 0.5);
}

/* Product Panels Animation */
.product-panel {
    animation: fadeIn 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.product-panel.hidden {
    display: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Product Card Enhancements */
.product-panel article {
    transition: box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.3s ease;
}

/* Smooth transitions for product images */
.product-panel img {
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Performance: Reduce animations on low-end devices */
@media (prefers-reduced-motion: reduce) {
    .faq-answer {
        transition: none;
    }
}

/* Improve text rendering */
body {
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Dropdown Menu Styles */
.group:hover .group-hover\:opacity-100 {
    opacity: 1;
}

.group:hover .group-hover\:visible {
    visibility: visible;
}

.group:hover .group-hover\:translate-y-0 {
    transform: translateY(0);
}

/* Desktop Dropdown Arrow */
.group:hover .group-hover\:rotate-180 {
    transform: rotate(180deg);
}

/* Left border on hover for dropdown items */
.border-l-3 {
    border-left-width: 3px;
}

/* Mobile Dropdown Smooth Transition */
.mobile-dropdown-menu {
    transition: all 0.3s ease-in-out;
    max-height: 0;
    overflow: hidden;
}

.mobile-dropdown-menu:not(.hidden) {
    max-height: 500px;
}

/* Dropdown icon rotation */
.dropdown-icon {
    transition: transform 0.3s ease;
}

/* ===== Blog Page Specific Styles ===== */

/* Category tag transitions */
.category-tag {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.category-tag:focus {
    outline: 2px solid #4CAF50;
    outline-offset: 2px;
}

/* Blog card image zoom effect on hover */
.blog-card img {
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Pagination button styles */
.pagination-btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.pagination-number {
    transition: all 0.3s ease;
}

/* Sort select custom styling */
#sort-select {
    background-image: none;
}

/* Screen reader only class */
.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;
}

/* Smooth transitions for blog grid updates */
#blog-grid {
    transition: opacity 0.3s ease-in-out;
}

/* Ensure proper spacing on mobile for filter controls */
@media (max-width: 1023px) {
    #category-filter {
        max-width: 100%;
    }
}

/* Accessibility: Focus visible for better keyboard navigation */
button:focus-visible,
a:focus-visible,
select:focus-visible {
    outline: 2px solid #4CAF50;
    outline-offset: 2px;
}