/* ========== Amazon-like Performance, Smooth Loading & Mobile Responsive CSS ========== */

/* Instant page paint */
html {
    -webkit-text-size-adjust: 100%;
    text-rendering: optimizeSpeed;
    -webkit-tap-highlight-color: transparent;
    scroll-behavior: smooth;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    opacity: 0;
    animation: pageIn 0.3s ease-out 0.05s forwards;
}

@keyframes pageIn {
    to { opacity: 1; }
}

/* GPU acceleration for animated elements */
.pro, .fe-box, .banner-box, #hero, #header {
    will-change: transform;
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

/* ========== Skeleton Loading Shimmer ========== */
@keyframes shimmer {
    0% { background-position: -400px 0; }
    100% { background-position: 400px 0; }
}

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 800px 100%;
    animation: shimmer 1.2s infinite ease-in-out;
    border-radius: 6px;
}

.skeleton-card {
    display: flex;
    flex-direction: column;
    border: 1px solid #e8e8e8;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    padding: 10px;
}

.skeleton-img { width: 100%; height: 180px; border-radius: 8px; }
.skeleton-text { height: 14px; margin-top: 10px; width: 80%; }
.skeleton-text-sm { height: 12px; margin-top: 8px; width: 50%; }
.skeleton-price { height: 18px; margin-top: 12px; width: 40%; }

.skeleton-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 15px;
    width: 100%;
}

/* ========== Smooth Animations ========== */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}
@keyframes toastSlideIn {
    from { transform: translateX(40px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

.fade-in { animation: fadeIn 0.25s ease-out; }
.fade-in-up { animation: fadeInUp 0.3s ease-out; }
.scale-in { animation: scaleIn 0.25s ease-out; }

/* Staggered card animations */
.pro-container .pro {
    opacity: 0;
    animation: fadeInUp 0.35s ease-out forwards;
}
.pro-container .pro:nth-child(1) { animation-delay: 0.02s; }
.pro-container .pro:nth-child(2) { animation-delay: 0.05s; }
.pro-container .pro:nth-child(3) { animation-delay: 0.08s; }
.pro-container .pro:nth-child(4) { animation-delay: 0.11s; }
.pro-container .pro:nth-child(5) { animation-delay: 0.14s; }
.pro-container .pro:nth-child(6) { animation-delay: 0.17s; }
.pro-container .pro:nth-child(7) { animation-delay: 0.20s; }
.pro-container .pro:nth-child(8) { animation-delay: 0.23s; }

/* ========== Smooth Product Card Hover ========== */
.pro {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}
.pro:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
}
.pro img { transition: transform 0.3s ease; }
.pro:hover img { transform: scale(1.03); }

/* Feature Box */
.fe-box { transition: transform 0.2s ease, box-shadow 0.2s ease; }
.fe-box:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}

/* ========== Button Interactions ========== */
button, .normal, .white { transition: all 0.2s ease !important; }
button:active, .normal:active, .white:active { transform: scale(0.97); }

/* ========== Lazy Load Image ========== */
img[loading="lazy"] { opacity: 0; transition: opacity 0.3s ease-in; }
img[loading="lazy"].loaded, img.loaded { opacity: 1; }

/* ========== Smooth Section Transitions ========== */
.section-p1, .section-m1, #hero, #banner, #sm-banner, #banner3, footer {
    animation: fadeIn 0.25s ease-out;
}

/* Off-screen content visibility for better scroll performance */
#feature, #product1, #banner, #sm-banner, #banner3, #newsletter, footer {
    content-visibility: auto;
    contain-intrinsic-size: auto 500px;
}

/* Smooth link transitions */
a {
    transition: color 0.15s ease, opacity 0.15s ease;
}

/* Smooth image loading */
img {
    transition: opacity 0.3s ease;
}

/* ========== Toast ========== */
#simple-toast {
    animation: toastSlideIn 0.25s ease-out;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    font-weight: 500;
}

/* ========== Search Results ========== */
#search-results { transition: opacity 0.15s ease; }
#search-results.active { animation: fadeIn 0.15s ease-out; }

/* ========== Loading Progress Bar ========== */
#page-loader {
    position: fixed;
    top: 0; left: 0;
    width: 0; height: 3px;
    background: linear-gradient(90deg, #088178, #06d6a0, #088178);
    z-index: 99999;
    transition: width 0.3s ease;
    box-shadow: 0 0 8px rgba(8, 129, 120, 0.6);
}
#page-loader.active { width: 70%; transition: width 1.5s ease-out; }
#page-loader.done {
    width: 100%;
    opacity: 0;
    transition: width 0.2s ease-out, opacity 0.3s ease 0.15s;
}

/* ========== Smooth Scrollbar ========== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #c0c0c0; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a0a0a0; }

/* ========== Content Loading Spinner ========== */
.loading-state { position: relative; min-height: 200px; }
.loading-state::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 28px; height: 28px;
    margin: -14px 0 0 -14px;
    border: 3px solid #e0e0e0;
    border-top-color: #088178;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* ========== Image Placeholder ========== */
.img-placeholder {
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ccc;
    font-size: 24px;
}


/* ==========================================================================
   MOBILE RESPONSIVE FIXES — All Frontend Pages
   ========================================================================== */

/* ===== 1024px: Tablets Landscape ===== */
@media (max-width: 1024px) {
    .section-p1 { padding: 30px 40px; }
    #header { padding: 15px 30px; }
    #hero { padding: 0 40px; height: 60vh; }
    #sm-banner .banner-box { min-width: 100%; height: 35vh; margin-bottom: 10px; }
    #banner3 { padding: 0 40px; }
    #banner3 .banner-box { min-width: 48%; }
    #newsletter .form { width: 55%; }
    #blog { padding: 80px 40px 20px 40px; }
    #form-details { padding: 40px; margin: 20px; }
}

/* ===== 799px: Tablets Portrait ===== */
@media (max-width: 799px) {
    /* Header & Nav */
    #header {
        padding: 12px 15px;
        flex-wrap: wrap;
        gap: 8px;
    }
    #header .logo { height: 28px; }
    #search-bar {
        display: flex !important;
        order: 10;
        width: 100%;
        max-width: 100%;
        margin: 0;
        flex: none;
    }
    #mobile { display: flex; align-items: center; gap: 10px; }
    #mobile i { font-size: 22px; padding-left: 12px; }

    /* Hide duplicate mobile search */
    #mobile-search { display: none !important; }

    /* Mobile Nav slide-in */
    #navbar {
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: flex-start;
        position: fixed;
        top: 0; right: -280px;
        width: 280px; height: 100vh;
        background: #E3E6F3;
        box-shadow: -5px 0 30px rgba(0,0,0,0.15);
        transition: right 0.3s ease;
        padding: 70px 0 0 15px;
        z-index: 1001;
        overflow-y: auto;
    }
    #navbar.active { right: 0; }
    #navbar li { margin-bottom: 20px; width: 100%; }
    #navbar li a { font-size: 15px; }
    #close {
        display: block;
        font-size: 22px;
        position: absolute;
        top: 20px; left: 20px;
        color: #222;
        cursor: pointer;
    }
    #lg-bag { display: none; }
    #bar { display: block; cursor: pointer; }

    /* Hero */
    #hero {
        padding: 0 20px;
        height: 50vh;
        background-position: 55% center;
    }
    #hero h1 { font-size: 28px; line-height: 36px; }
    #hero h2 { font-size: 24px; line-height: 30px; }
    #hero h4 { font-size: 14px; }
    #hero p { font-size: 13px; }
    #hero button { padding: 12px 50px 12px 40px; font-size: 13px; }

    /* Sections */
    .section-p1 { padding: 25px 15px; }
    .section-m1 { margin: 20px 0; }

    /* Feature boxes — 3 per row on tablet */
    #feature { justify-content: center; gap: 10px; }
    #feature .fe-box {
        width: calc(33.33% - 10px);
        min-width: 100px;
        margin: 5px 0;
        padding: 15px 10px;
    }
    #feature .fe-box img { width: 80%; margin-bottom: 6px; }
    #feature .fe-box h6 { font-size: 10px; padding: 6px; }

    /* Products — 2 per row */
    #product1 .pro-container, #product2 .pro-container {
        justify-content: space-between;
        gap: 10px;
    }
    #product1 .pro, #product2 .pro {
        width: calc(50% - 8px);
        min-width: 0;
        margin: 5px 0;
        padding: 8px;
        border-radius: 15px;
    }
    #product1 .pro img, #product2 .pro img { border-radius: 12px; }
    .pro .des h5 { font-size: 12px; }
    .pro .des h4 { font-size: 13px; }
    .pro .des span { font-size: 10px; }
    .pro .cart {
        width: 34px; height: 34px; line-height: 34px;
        bottom: 15px; right: 8px;
        font-size: 14px;
    }

    /* Banner */
    #banner { height: 25vh; }
    #banner h2 { font-size: 20px; }
    #banner h4 { font-size: 13px; }

    /* Small banner — stack */
    #sm-banner .banner-box {
        min-width: 100%;
        height: 28vh;
        padding: 20px;
    }
    #sm-banner h2 { font-size: 22px; }
    #sm-banner h4 { font-size: 16px; }

    /* Banner 3 */
    #banner3 { padding: 0 15px; }
    #banner3 .banner-box { min-width: 48%; height: 20vh; }
    #banner3 h2 { font-size: 16px; }
    #banner3 h3 { font-size: 12px; }

    /* Newsletter */
    #newsletter { padding: 30px 15px; flex-direction: column; text-align: center; }
    #newsletter .form { width: 100%; margin-top: 15px; }
    #newsletter h4 { font-size: 18px; }
    #newsletter p { font-size: 12px; }

    /* Footer */
    footer { padding: 30px 15px !important; flex-direction: column; }
    footer .col { width: 100%; margin-bottom: 20px; }
    footer .install .row { display: flex; gap: 8px; }
    footer .install .row img { width: 100px; }
    footer .copyright { text-align: center; }

    /* Shop page */
    #page-header { height: 25vh; }
    #page-header h2 { font-size: 24px; }
    #pagination a { padding: 10px 15px; font-size: 13px; }

    /* Blog */
    #blog { padding: 60px 15px 20px; }
    #blog .blog-box { flex-direction: column; padding-bottom: 40px; }
    #blog .blog-img { width: 100%; margin-right: 0; margin-bottom: 15px; }
    #blog .blog-details { width: 100%; }
    #blog img { height: 200px; }

    /* About */
    #about-head { flex-direction: column; }
    #about-head img { width: 100%; }
    #about-head div { padding-left: 0; padding-top: 15px; }
    #about-app .video { width: 100%; }

    /* Contact */
    #contact-details { flex-wrap: wrap; }
    #contact-details .details { width: 100%; padding-bottom: 20px; }
    #contact-details .map { width: 100%; height: 250px; }
    #form-details { flex-wrap: wrap; margin: 10px; padding: 20px; }
    #form-details form { width: 100%; }
    #form-details .people { width: 100%; }

    /* Cart */
    #cart table { font-size: 12px; table-layout: auto; }
    #cart table td { padding: 8px 5px; }
    #cart table img { width: 50px; }
    #cart-add { flex-direction: column; }
    #cuopon, #subtotal { width: 100%; }
    #cuopon input { width: 55%; }
    #subtotal { padding: 15px; }

    /* Single Product */
    #prodetails { grid-template-columns: 1fr; gap: 18px; padding: 15px !important; }
    .product-gallery-shell { grid-template-columns: 50px minmax(0, 1fr); gap: 10px; }
    .product-main-stage { min-height: 300px; padding: 12px; }
    #prodetails .single-pro-details h1 { font-size: 18px; }
    #prodetails .single-pro-details h2 { font-size: 24px; }
    .product-highlight-cards, .product-trust-strip { grid-template-columns: 1fr 1fr; }
    .single-pro-purchase { position: static; }
    .purchase-card { padding: 15px; }

    /* Skeleton */
    .skeleton-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .skeleton-img { height: 140px; }

    /* Disable hover transforms on touch */
    .pro:hover { transform: none; box-shadow: 20px 20px 30px rgba(0,0,0,0.06); }
    .pro:hover img { transform: none; }
    .fe-box:hover { transform: none; }

    /* Card animation speed */
    .pro-container .pro { animation-delay: 0s !important; animation-duration: 0.2s; }

    /* Auth pages */
    .signin-container, .signup-container, .profile-container {
        width: 90% !important;
        max-width: 100% !important;
        margin: 20px auto !important;
        padding: 20px !important;
    }
}

/* ===== 480px: Small Phones ===== */
@media (max-width: 480px) {
    body { font-size: 14px; }
    h1 { font-size: 26px; line-height: 32px; }
    h2 { font-size: 22px; line-height: 28px; }
    h4 { font-size: 16px; }
    p { font-size: 13px; margin: 8px 0 12px; }

    #header { padding: 8px 10px; }
    #header .logo { height: 24px; }
    #mobile i { font-size: 20px; padding-left: 8px; }

    #search-bar { height: 36px; }
    #search-bar select { font-size: 11px; padding: 0 20px 0 6px; background-position: right 5px center; }
    #search-bar input { font-size: 13px; padding: 0 8px; }
    #search-bar button { width: 38px; font-size: 15px; }

    #navbar { width: 250px; right: -250px; padding: 60px 0 0 15px; }
    #navbar li a { font-size: 14px; }

    #hero { height: 40vh; padding: 0 15px; }
    #hero h1 { font-size: 22px; line-height: 28px; }
    #hero h2 { font-size: 20px; }
    #hero h4 { font-size: 12px; }
    #hero p { font-size: 11px; }
    #hero button { padding: 10px 40px 10px 30px; font-size: 12px; }

    .section-p1 { padding: 15px 10px; }

    /* Feature boxes — 3 per row small */
    #feature .fe-box {
        width: calc(33.33% - 8px);
        min-width: 0;
        padding: 12px 6px;
    }
    #feature .fe-box h6 { font-size: 9px; padding: 5px 4px; }

    /* Products — 2 per row compact */
    #product1 .pro, #product2 .pro {
        width: calc(50% - 5px);
        padding: 6px;
        border-radius: 12px;
    }
    #product1 .pro img, #product2 .pro img {
        height: 140px !important;
        border-radius: 10px;
    }
    .pro .des { padding: 6px 0; }
    .pro .des h5 { font-size: 11px; padding-top: 4px; }
    .pro .des h4 { font-size: 12px; padding-top: 4px; }
    .pro .des span { font-size: 9px; }
    .pro .des i { font-size: 10px; }
    .pro .cart { width: 30px; height: 30px; line-height: 30px; bottom: 12px; right: 6px; font-size: 12px; }

    /* Banner */
    #banner { height: 20vh; }
    #banner h2 { font-size: 16px; }

    #sm-banner .banner-box { height: 25vh; padding: 15px; }
    #sm-banner h2 { font-size: 18px; }
    #sm-banner h4 { font-size: 14px; }
    #sm-banner span { font-size: 11px; }
    button.white { padding: 8px 12px; font-size: 11px; }

    #banner3 { padding: 0 10px; }
    #banner3 .banner-box { min-width: 100%; height: 18vh; margin-bottom: 10px; }
    #banner3 h2 { font-size: 14px; }
    #banner3 h3 { font-size: 11px; }

    /* Newsletter */
    #newsletter { padding: 20px 10px; }
    #newsletter h4 { font-size: 16px; }
    #newsletter input { height: 2.5rem; font-size: 12px; }
    button.normal { font-size: 12px; padding: 10px 18px; }

    /* Footer */
    footer { padding: 20px 10px !important; }
    footer h4 { font-size: 13px; }
    footer p, footer a { font-size: 11px; }
    footer .install .row img { width: 80px; }

    /* Page header */
    #page-header { height: 20vh; }
    #page-header h2 { font-size: 20px; }
    #page-header p { font-size: 12px; }
    #pagination a { padding: 8px 12px; font-size: 12px; }

    /* Blog */
    #blog { padding: 50px 10px 15px; }
    #blog .blog-box h1 { font-size: 40px; top: -20px; }
    #blog img { height: 160px; }

    /* Contact */
    #contact-details .map { height: 200px; }
    #form-details { padding: 15px 10px; margin: 5px; }
    #form-details .people img { width: 50px; height: 50px; }

    /* Cart */
    #cart table { font-size: 11px; }
    #cart table img { width: 40px; }
    #cart table td { padding: 6px 3px; }
    #cart table td:nth-child(5) input { width: 50px; padding: 6px; }
    #cuopon input { width: 50%; font-size: 12px; }
    #cuopon button, #subtotal button { padding: 10px 14px; font-size: 12px; }
    #subtotal table td { font-size: 12px; padding: 8px; }

    /* Single Product */
    .product-gallery-shell { grid-template-columns: 1fr; }
    .small-img-group { flex-direction: row; flex-wrap: wrap; gap: 6px; }
    .small-img-col { width: calc(25% - 6px); }
    .product-main-stage { min-height: 250px; padding: 10px; }
    #prodetails .single-pro-details h1 { font-size: 16px; line-height: 1.3; }
    #prodetails .single-pro-details h2, .purchase-card-price { font-size: 22px; }
    .product-highlight-cards, .product-trust-strip { grid-template-columns: 1fr; }
    .product-highlight-card { padding: 10px; }
    .purchase-primary, .purchase-secondary, .purchase-link-btn { padding: 10px 14px; font-size: 13px; }
    .purchase-card { padding: 12px; }

    /* Skeleton */
    .skeleton-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .skeleton-img { height: 120px; }
    .skeleton-card { padding: 6px; }

    /* Cart badge */
    .cart-badge { width: 16px; height: 16px; font-size: 9px; top: -6px; right: -8px; }

    /* Auth */
    .signin-container, .signup-container, .profile-container {
        width: 95% !important;
        padding: 15px !important;
    }
}

/* ===== 360px: Very small phones ===== */
@media (max-width: 360px) {
    h1 { font-size: 22px; }
    h2 { font-size: 18px; }
    #hero { height: 35vh; }
    #hero h1 { font-size: 18px; }
    #hero h2 { font-size: 16px; }

    #search-bar select { display: none; }
    #search-bar input { border-radius: 6px 0 0 6px; }

    #feature .fe-box { width: calc(50% - 8px); }

    #product1 .pro img, #product2 .pro img { height: 110px !important; }
    .pro .des h5 { font-size: 10px; }
    .pro .des h4 { font-size: 11px; }

    #navbar { width: 220px; right: -220px; }
}

/* ===== Touch-friendly taps ===== */
@media (hover: none) and (pointer: coarse) {
    .pro:active { transform: scale(0.98); }
    .fe-box:active { transform: scale(0.97); }
    button:active, .normal:active, .white:active { transform: scale(0.96); }
    a, button, .pro, .fe-box { -webkit-tap-highlight-color: rgba(8, 129, 120, 0.1); }
    
    /* Larger touch targets */
    #navbar li a { padding: 12px 0; display: block; }
    #pagination a { padding: 12px 18px; }
    .search-item { padding: 12px 15px; }
}
