:root {
    --premium-bg: #f5f5f7;
    --premium-card-bg: #ffffff;
    --premium-text: #1d1d1f;
    --premium-text-secondary: #515154;
    --premium-primary: #0d6efd;
    --premium-border: #d2d2d7;
    --premium-danger: #dc3545;
    --premium-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    --skeleton-color: #e9e9ed;
}

/* --- Base Styles --- */

body#page-index-premium {
    background-color: var(--premium-bg);
    font-family: 'Inter', sans-serif;
    margin: 0;
    padding: 0;
}

.premium-main {
    padding-top: 2rem;
}

.premium-section {
    margin-bottom: 4rem;
}

.section-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--premium-text);
    text-align: center;
    margin-bottom: 2rem;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* ==========================================================================
   Premium Header Styles - COMPLETE REDESIGN
   ========================================================================== */

.premium-header {
    background-color: #ffffff;
    padding: 1rem 0;
    border-bottom: 1px solid var(--premium-border);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

.premium-header .logo {
    flex-shrink: 0;
}

.premium-header .logo img {
    height: 40px;
    display: block;
}

.premium-search-container {
    display: flex;
    align-items: center;
    flex-grow: 1;
    max-width: 600px;
    background-color: var(--premium-bg);
    border-radius: 999px;
    border: 1px solid transparent;
    transition: all 0.2s ease-in-out;
    position: relative;
    /* ✅ ADDED: This is crucial for positioning the dropdown */
}

.premium-search-container:focus-within {
    border-color: var(--premium-primary);
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.2);
}

.premium-search-container .search-icon {
    padding-left: 1.2rem;
    color: var(--premium-text-secondary);
}

.premium-search-container input {
    width: 100%;
    border: none;
    background: transparent;
    outline: none;
    padding: 0.8rem 1.2rem;
    font-size: 1rem;
    font-family: 'Inter', sans-serif;
}

.premium-nav-icons {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.premium-nav-icons .nav-icon {
    position: relative;
    font-size: 1.3rem;
    color: var(--premium-text);
    text-decoration: none;
    transition: color 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.premium-nav-icons .nav-icon:hover {
    color: var(--premium-primary);
}

.nav-icon-label {
    display: none;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--premium-text);
}

.nav-icon[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    bottom: -35px;
    transform: translateX(-50%);
    background-color: var(--premium-text);
    color: #fff;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    pointer-events: none;
}

.nav-icon[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
}

.premium-nav-icons .cart-icon #cartCount {
    position: absolute;
    top: -8px;
    right: -10px;
    background-color: var(--premium-danger);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    border: 2px solid #fff;
}

/* --- Hero Section --- */

.hero-section {
    width: 95%;
    max-width: 1400px;
    margin: 1rem auto;
    height: 400px;
    position: relative;
    overflow: hidden;
    background-color: var(--skeleton-color);
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.hero-carousel-slide {
    width: 100%;
    height: 100%;
    position: absolute;
    opacity: 0;
    transition: opacity 1s ease-in-out;
}

.hero-carousel-slide.active {
    opacity: 1;
}

.hero-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.6) 0%, rgba(0, 0, 0, 0.1) 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    padding: 0 10%;
}

.hero-title {
    font-size: 2.5rem;
    font-weight: 800;
    color: #fff;
    max-width: 500px;
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
}

.hero-subtitle {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.9);
    max-width: 500px;
    margin-top: 0.5rem;
}

/* --- Visual Categories --- */

.visual-category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 2rem;
}

.visual-category-item {
    text-align: center;
    text-decoration: none;
    color: var(--premium-text);
    transition: transform 0.2s ease;
}

.visual-category-item:hover {
    transform: translateY(-5px);
}

.visual-category-image-wrapper {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    overflow: hidden;
    margin: 0 auto 1rem auto;
    background-color: var(--premium-card-bg);
    box-shadow: var(--premium-shadow);
    border: 1px solid var(--premium-border);
}

.visual-category-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.visual-category-name {
    font-weight: 600;
}

/* --- Product Grid & Cards --- */

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
}

.premium-product-card {
    background-color: var(--premium-card-bg);
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none;
    box-shadow: var(--premium-shadow);
    border: 1px solid transparent;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
    display: flex;
    flex-direction: column;
}

.premium-product-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
    border-color: var(--premium-primary);
}

/*  Updated the container to allow the image to fill the space and hide the zoom overflow */
.product-image-container {
    aspect-ratio: 1 / 1;
    background-color: #f9f9f9;
    padding: 0;
    /* Set to 0 so the image fits edge-to-edge */
    position: relative;
    overflow: hidden;
    /* Prevents the zoomed image from leaking outside the card */
}

/*  Set the image to cover the area and add the smooth transition */
.product-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Ensures the image fills the card like your shop CSS */
    transition: transform 0.5s ease;
    /* Smooth zoom duration */
}

/* Trigger the zoom effect when the card is hovered */
.premium-product-card:hover .product-image {
    transform: scale(1.05);
    /* Exact zoom level from your shop logic */
}

.product-info-container {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.product-name {
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--premium-text);
    margin-bottom: 0.5rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-price-container {
    display: flex !important;
    flex-direction: row !important;
    /* Force side-by-side alignment */
    align-items: baseline !important;
    /* Keeps the text bottoms aligned */
    flex-wrap: nowrap !important;
    /* Prevents the old price from dropping to a second line */
    gap: 10px !important;
    /* Adds a clean space between the two prices */
    flex-wrap: wrap;
}

.product-price {
    font-size: 1.0rem !important;
    overflow: hidden !important;
    font-weight: 700;
    color: var(--premium-primary);
    flex-shrink: 0 !important;
}

.product-old-price {
    font-size: 0.7rem !important;
    white-space: nowrap !important;
    /* No line breaks */
    text-overflow: ellipsis !important;
    /* Adds "..." if too long */
    overflow: hidden !important;
    font-weight: 500;
    color: var(--premium-text-secondary);
    text-decoration: line-through;
}

.discount-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background-color: var(--premium-danger);
    color: #fff;
    padding: 3px 5px;
    border-radius: 6px;
    font-size: 0.58rem;
    font-weight: 700;
    z-index: 1;
}

/* --- View More Button --- */

.view-more-container {
    text-align: center;
    margin-top: 2rem;
}

.btn-view-more {
    display: inline-block;
    background-color: var(--premium-primary);
    color: #fff;
    padding: 0.875rem 2.5rem;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.25);
}

.btn-view-more:hover {
    background-color: #0b5ed7;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(13, 110, 253, 0.35);
}

/* --- Local Shop Card --- */

.local-shop-card {
    display: block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px;
    padding: 3rem;
    text-align: center;
    text-decoration: none;
    color: #fff;
    margin-bottom: 3rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
}

.local-shop-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(102, 126, 234, 0.4);
}

.local-shop-card-content h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.local-shop-card-content p {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    opacity: 0.95;
}

.local-shop-card .btn {
    background-color: #fff;
    color: #667eea;
    padding: 0.875rem 2.5rem;
    border-radius: 999px;
    font-weight: 600;
    display: inline-block;
    transition: all 0.3s ease;
}

.local-shop-card .btn:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(255, 255, 255, 0.3);
}

/* --- Footer --- */

footer {
    background-color: var(--premium-text);
    color: #fff;
    padding: 2rem 0;
    text-align: center;
}

footer p {
    margin: 0.5rem 0;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin: 1rem 0;
}

.footer-links a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-links a:hover {
    color: #fff;
}

/* --- Skeleton Loaders --- */

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: .5;
    }
}

.skeleton-hero {
    width: 100%;
    height: 100%;
    background-color: var(--skeleton-color);
    animation: pulse 1.5s infinite;
}

.skeleton-visual-category {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.skeleton-visual-category::before {
    content: '';
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background-color: var(--skeleton-color);
    animation: pulse 1.5s infinite;
    margin-bottom: 1rem;
}

.skeleton-visual-category::after {
    content: '';
    width: 80px;
    height: 20px;
    background-color: var(--skeleton-color);
    animation: pulse 1.5s infinite;
    border-radius: 4px;
}

.skeleton-product-card {
    height: 380px;
    background-color: var(--skeleton-color);
    border-radius: 12px;
    animation: pulse 1.5s infinite;
}

/* --- APP-STYLE PRODUCT BADGES --- */

/* The 'Sold/Trending' Ornament (Top Right) */
.ornament-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 100, 100, 0.95);
    padding: 3px 8px;
    border-radius: 6px;
    z-index: 10;
    pointer-events: none;
}

.ornament-text {
    color: #FFF;
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* The Rating Badge (Bottom Right of Image) */
.rating-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 10px;
    z-index: 10;
}

.rating-text {
    color: #FFF;
    font-size: 11px;
    font-weight: 700;
}

.rating-count {
    color: rgba(255, 255, 255, 0.8);
    font-size: 9px;
    margin-left: 2px;
}

.rating-badge i {
    color: #FFD700;
    font-size: 10px;
}

/* --- Responsive Adjustments --- */

@media (max-width: 992px) {
    .premium-search-container {
        max-width: 400px;
    }

    .premium-nav-icons {
        gap: 1rem;
    }
}

@media (max-width: 768px) {
    .ornament-badge {
        position: absolute !important;
        top: 6px !important;
        /* Slightly tighter for mobile */
        right: 6px !important;
        background: rgba(255, 100, 100, 0.95) !important;
        padding: 2px 6px !important;
        /* Smaller padding for mobile cards */
        border-radius: 5px !important;
        z-index: 10 !important;
    }

    .ornament-text {
        color: #FFF !important;
        font-size: 8px !important;
        /* Smaller text to fit mobile card width */
        font-weight: 800 !important;
        text-transform: uppercase !important;
        letter-spacing: 0.3px !important;
    }

    .rating-badge {
        position: absolute !important;
        bottom: 6px !important;
        /* Tighter positioning */
        right: 6px !important;
        background: rgba(0, 0, 0, 0.65) !important;
        backdrop-filter: blur(4px) !important;
        display: flex !important;
        align-items: center !important;
        gap: 3px !important;
        padding: 2px 6px !important;
        border-radius: 8px !important;
        z-index: 10 !important;
    }

    .rating-text {
        color: #FFF !important;
        font-size: 10px !important;
        /* Compact rating text */
        font-weight: 700 !important;
    }

    .rating-count {
        color: rgba(255, 255, 255, 0.8) !important;
        font-size: 8px !important;
        margin-left: 1px !important;
    }

    .rating-badge i {
        color: #FFD700 !important;
        font-size: 9px !important;
        /* Smaller star icon */
    }

    /* Mobile Header Layout */
    .header-container {
        flex-direction: column;
        gap: 0.75rem;
        /* Space between the top row and the nav icons below */
    }

    /* This is the new rule that styles the logo/search bar row */
    .header-top-row {
        display: flex;
        flex-direction: row;
        /* Aligns items horizontally */
        align-items: center;
        /* Vertically centers the logo and search bar */
        gap: 1rem;
        /* Creates space between logo and search bar */
        width: 100%;
        /* Ensures the row takes up the full width */
    }

    /* This rule prevents the logo from getting squished */
    .premium-header .logo {
        flex-shrink: 0;
        margin: 0;
    }

    /* This rule makes the search bar expand to fill the remaining space */
    .premium-search-container {
        flex-grow: 1;
        margin: 0;
    }

    .premium-nav-icons .nav-icon {
        font-size: 1.2rem;
    }

    .premium-nav-icons {
        width: 100%;
        justify-content: space-around;
        padding-top: 0.5rem;
        gap: 0.5rem;
    }

    #clearSearchBtn {
        display: none;
        /* Hidden by default, JS will show it */
        color: var(--premium-text-secondary);
        font-size: 1rem;
        cursor: pointer;
        padding: 0 1rem;
        /* Creates space around the icon */
        transition: color 0.2s ease;
    }

    #clearSearchBtn:hover {
        color: var(--premium-text);
    }

    /* This class will be added by JS when the input has text */
    .premium-search-container.has-text #clearSearchBtn {
        display: block;
        /* Show the button */
    }

    .nav-icon-label {
        display: block !important;
        font-size: 0.7rem;
        color: var(--premium-text);
    }

    .nav-icon[data-tooltip]::after {
        display: none !important;
    }

    .premium-nav-icons .cart-icon #cartCount {
        top: -20px;
        right: -21px;
        width: 10px;
        height: 15px;
        font-size: 0.7rem;
    }


    .product-price-container {
        display: flex !important;
        flex-direction: row !important;
        /* Forces side-by-side alignment */
        align-items: baseline !important;
        /* Aligns the bottom of the text */
        flex-wrap: nowrap !important;
        /* Prevents wrapping to a second line */
        gap: 8px !important;
        /* Space between the two prices */
        width: 100% !important;
        justify-content: flex-start !important;
        /* Aligns them to the left */
        margin-top: auto !important;
        overflow: hidden !important;
        /* Safety lock */
    }

    .product-price {
        font-size: 0.8em !important;
        /* Smaller size as requested */
        font-weight: 700 !important;
        white-space: nowrap !important;
        /* Keeps GHS and numbers together */
        margin: 0 !important;
        /* Removes individual margins to stay on one line */
        overflow: hidden !important;
        gap: 10px !important;
        /* Adds a clean space between the two prices */
        flex-shrink: 0 !important;
    }

    .product-info-container {
        padding: 10px 12px !important;
        /* Increases inner padding for a premium feel */
    }

    .product-old-price {
        font-size: 0.6em !important;
        /* Secondary smaller size */
        color: #999 !important;
        text-decoration: line-through !important;
        white-space: nowrap !important;
        margin: 0 !important;
        text-overflow: ellipsis !important;
        /* Adds "..." if too long */
        overflow: hidden !important;
        gap: 10px !important;
        /* Adds a clean space between the two prices */
    }

    .section-title {
        font-size: 1.5rem;
    }

    .hero-title {
        font-size: 1.8rem;
    }

    .hero-subtitle {
        font-size: 1rem;
    }

    .visual-category-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }

    .visual-category-image-wrapper {
        width: 80px;
        height: 80px;
    }

    .product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .local-shop-card {
        padding: 2rem 1rem;
    }

    .local-shop-card-content h2 {
        font-size: 1.5rem;
    }

    .local-shop-card-content p {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .premium-nav-icons .nav-icon {
        font-size: 1.1rem;
    }

    .nav-icon-label {
        font-size: 0.65rem;
    }

    .product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
}

@media (min-width: 769px) {

    /*
     * This "dissolves" the .header-top-row wrapper on PC,
     * allowing the main .header-container's flexbox rules
     * to create the perfect three-column layout.
    */
    .product-old-price {
        font-size: 1.0rem;
        font-weight: 500;
        color: var(--premium-text-secondary);
        text-decoration: line-through;
    }

    .premium-product-card .product-name {
        font-size: 1.1rem;
        /* Increase font size from 1rem to 1.1rem */
        line-height: 1.5;
        /* Adjust line height for better spacing */
    }

    #page-index-premium .header-top-row {
        display: contents;
    }
}

/* ======================================================= */
/* ✅ 1. ADDED: PREMIUM PAGE PRELOADER                     */
/* ======================================================= */
.preloader-overlay {
    position: fixed;
    inset: 0;
    background-color: #ffffff;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease-out, visibility 0.5s ease-out;
}

.preloader-overlay .spinner {
    border: 6px solid var(--skeleton-color);
    border-top-color: var(--premium-primary);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    animation: spin 1s ease-in-out infinite;
}

.preloader-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ======================================================= */
/* ✅ 2. ADDED: LIVE SEARCH RESULTS DROPDOWN               */
/* ======================================================= */
.live-search-results {
    display: none;
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--premium-border);
    max-height: 450px;
    overflow-y: auto;
    z-index: 1100;
}

.live-search-results.show {
    display: block;
}

.live-search-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    text-decoration: none;
    border-bottom: 1px solid var(--premium-bg);
    transition: background-color 0.2s ease;
}

.live-search-item:last-child {
    border-bottom: none;
}

.live-search-item:hover {
    background-color: var(--premium-bg);
}

.live-search-item img {
    width: 50px;
    height: 50px;
    object-fit: contain;
    border-radius: 8px;
    background-color: #f9f9f9;
    flex-shrink: 0;
}

.live-search-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.live-search-info .name {
    font-weight: 600;
    color: var(--premium-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.live-search-info .price {
    font-size: 0.9rem;
    color: var(--premium-primary);
}

.search-no-results {
    padding: 1.5rem;
    text-align: center;
    color: var(--premium-text-secondary);
}