/* ZphrMarketplace - Global Styles */

/* Reset & Base */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: #1a1a2e;
    background-color: #f5f6fa;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    margin: 0;
    font-weight: 700;
}

p {
    margin: 0;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
}

img {
    max-width: 100%;
    height: auto;
}

/* Blazor Error Boundary */
.blazor-error-boundary {
    background: #f8d7da;
    padding: 1rem;
    margin-bottom: 1rem;
    border: 1px solid #f5c6cb;
    border-radius: 0.5rem;
    color: #721c24;
}

.blazor-error-boundary::after {
    content: "An error has occurred. Please try refreshing the page.";
}

/* Validation */
.validation-message {
    color: #dc3545;
    font-size: 0.8125rem;
    margin-top: 4px;
}

.valid.modified:not([type=checkbox]) {
    outline: none;
}

.invalid {
    outline: none;
    border-color: #dc3545 !important;
}

/* Loading Spinner */
.loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.loading-indicator::after {
    content: '';
    width: 32px;
    height: 32px;
    border: 3px solid #e8eaed;
    border-top-color: #4f46e5;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Utility Classes */
.text-center { text-align: center; }
.text-right { text-align: right; }

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }

.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }

.p-1 { padding: 4px; }
.p-2 { padding: 8px; }
.p-3 { padding: 16px; }
.p-4 { padding: 24px; }

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }

.fw-bold { font-weight: 700; }
.fw-semibold { font-weight: 600; }

.text-muted { color: #6c757d; }
.text-success { color: #28a745; }
.text-danger { color: #dc3545; }
.text-primary { color: #4f46e5; }

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Focus styles for accessibility */
:focus-visible {
    outline: 2px solid #4f46e5;
    outline-offset: 2px;
}

/* Skip link for accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #4f46e5;
    color: #ffffff;
    padding: 8px 16px;
    z-index: 9999;
    border-radius: 0 0 8px 0;
}

.skip-link:focus {
    top: 0;
}

/*
 * Storefront (Buyer & Seller) pages.
 * On phones they fill the screen edge-to-edge. On tablet/desktop they expand
 * to a comfortable centered content width instead of staying as a narrow
 * phone frame, so the dashboard uses the whole screen.
 */

/* Full-screen shell that hosts the storefront pages (no admin sidebar) */
.storefront-shell {
    min-height: 100vh;
    background: #eef0f4;
}

/* Shared header/back button for buyer sub-pages */
.buyer-home .page-top {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.buyer-home .page-top h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
    color: #1a1a2e;
}

.buyer-home .btn-back {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid #e8eaed;
    background: #ffffff;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1a1a2e;
}

.buyer-home .results-count {
    font-size: 0.85rem;
    color: #6c757d;
    margin: 0 0 16px;
}

/* Category list cards (Categories page) */
.category-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 24px;
}

.category-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: #ffffff;
    border: 1px solid #e8eaed;
    border-radius: 14px;
    cursor: pointer;
    transition: box-shadow 0.2s, transform 0.15s;
}

.category-card:hover {
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.category-card-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: #f0f1f5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    flex-shrink: 0;
}

.category-card-meta {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.category-card-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1a1a2e;
}

.category-card-count {
    font-size: 0.75rem;
    color: #6c757d;
}

.category-card-chevron {
    font-size: 1.4rem;
    color: #adb5bd;
}

.category-item {
    cursor: pointer;
}

@media (min-width: 700px) {
    .category-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
}

@media (min-width: 1000px) {
    .category-cards {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Slim top navigation bar for storefront pages */
.storefront-topbar {
    position: sticky;
    top: 0;
    z-index: 150;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: #ffffff;
    border-bottom: 1px solid #e8eaed;
}

.storefront-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.storefront-brand-icon {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: linear-gradient(135deg, #6366f1, #7c3aed);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.05rem;
}

.storefront-brand-name {
    font-size: 1.15rem;
    font-weight: 700;
    color: #1a1a2e;
}

.storefront-topbar-right {
    display: flex;
    align-items: center;
}

/* In the storefront top bar the user menu stands alone - drop the divider */
.storefront-topbar-right .user-avatar {
    border-left: none;
    padding-left: 0;
}

.storefront-content {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 20px;
    padding: 0 16px;
}

.storefront-main {
    width: 100%;
    max-width: 1100px;
    min-width: 0;
}

/* ---------- Sponsored side ad rails ---------- */
.ad-rail {
    display: none; /* hidden by default; shown on wide screens */
    flex-direction: column;
    gap: 16px;
    width: 190px;
    flex-shrink: 0;
    position: sticky;
    top: 84px;
    padding-top: 20px;
}

.ad-card {
    position: relative;
    border-radius: 16px;
    padding: 18px 16px 16px;
    color: #ffffff;
    overflow: hidden;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}

.ad-card h4 {
    margin: 8px 0 4px;
    font-size: 1rem;
    font-weight: 800;
}

.ad-card p {
    margin: 0 0 12px;
    font-size: 0.78rem;
    opacity: 0.92;
    line-height: 1.4;
}

.ad-emoji {
    font-size: 2rem;
    line-height: 1;
}

.ad-tag {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.25);
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 2px 7px;
    border-radius: 6px;
}

.ad-cta {
    display: inline-block;
    font-size: 0.78rem;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.9);
    color: #1a1a2e;
    padding: 6px 12px;
    border-radius: 8px;
}

.ad-purple { background: linear-gradient(150deg, #6366f1, #7c3aed); }
.ad-green  { background: linear-gradient(150deg, #16a34a, #15803d); }
.ad-amber  { background: linear-gradient(150deg, #f59e0b, #d97706); }
.ad-pink   { background: linear-gradient(150deg, #ec4899, #db2777); }
.ad-blue   { background: linear-gradient(150deg, #0ea5e9, #0284c7); }
.ad-teal   { background: linear-gradient(150deg, #14b8a6, #0d9488); }

/* Show the ad rails only when there is enough room beside the 1100px content.
   1100 (content) + 2*190 (rails) + gaps/padding ~ 1520px */
@media (min-width: 1520px) {
    .ad-rail {
        display: flex;
    }
}

/* Shared selectors for all storefront pages */
.buyer-home,
.product-detail,
.cart-page,
.checkout-page,
.orders-page,
.seller-dashboard,
.seller-products,
.add-product-page,
.seller-orders,
.seller-earnings {
    width: 100%;
    max-width: 100% !important;   /* override the per-page 430px cap */
    margin: 0 auto;
    box-sizing: border-box;
}

/* Tablet & desktop: give a centered, roomy content area */
@media (min-width: 700px) {
    .buyer-home,
    .product-detail,
    .cart-page,
    .checkout-page,
    .orders-page,
    .seller-dashboard,
    .seller-products,
    .add-product-page,
    .seller-orders,
    .seller-earnings {
        max-width: 1100px !important;
        padding-left: 32px;
        padding-right: 32px;
        padding-bottom: 96px; /* room above the bottom nav */
    }

    /* Bottom navigation becomes a full-width bar centered to the content */
    .bottom-nav {
        max-width: 1100px !important;
        border-radius: 16px 16px 0 0;
    }
}

/* Tablet & desktop: convert the horizontal scroll rows into full-width grids
   so the content fills the available space instead of leaving it empty. */
@media (min-width: 700px) {
    .buyer-home .products-scroll {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr);
        gap: 16px;
        overflow: visible !important;
    }

    .buyer-home .product-card {
        min-width: 0 !important;
    }

    .buyer-home .product-image {
        height: 150px !important;
    }

    .buyer-home .categories-grid {
        overflow: visible !important;
        gap: 24px;
    }

    .buyer-home .category-icon {
        width: 68px !important;
        height: 68px !important;
        font-size: 1.9rem !important;
    }

    .buyer-home .sellers-strip {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
        overflow: visible !important;
    }

    .buyer-home .seller-chip {
        min-width: 0 !important;
    }
}

@media (min-width: 1000px) {
    .buyer-home .products-scroll {
        grid-template-columns: repeat(5, 1fr);
    }

    .buyer-home .sellers-strip {
        grid-template-columns: repeat(5, 1fr);
    }
}


/* =========================================================
   Storefront page components (shared by all buyer pages).
   Moved here from Home.razor.css so category / wishlist /
   sellers pages get the same styling (scoped CSS only applied
   to the Home component and left the others unstyled).
   All rules are prefixed with .buyer-home which wraps every
   storefront page.
   ========================================================= */

.buyer-home {
    background: #ffffff;
    min-height: 100vh;
    padding: 20px 16px 90px;
    position: relative;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;   /* clip the horizontal scroll rows to the screen width */
}

/* Horizontal scroll rows must never widen the page: constrain to the container
   and scroll internally instead. */
.buyer-home .products-scroll,
.buyer-home .shops-strip,
.buyer-home .sellers-strip {
    max-width: 100%;
    box-sizing: border-box;
}

.buyer-home .home-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.buyer-home .home-header .greeting h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
    color: #1a1a2e;
}

.buyer-home .home-header .greeting p {
    font-size: 0.875rem;
    color: #6c757d;
    margin: 4px 0 0;
}

.buyer-home .btn-cart {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid #e8eaed;
    background: transparent;
    cursor: pointer;
    font-size: 1.25rem;
}

.buyer-home .search-container {
    position: relative;
    margin-bottom: 16px;
}

.buyer-home .search-input {
    width: 100%;
    padding: 12px 16px 12px 44px;
    border: 1px solid #e8eaed;
    border-radius: 12px;
    font-size: 0.875rem;
    outline: none;
    background: #f8f9fa;
}

.buyer-home .search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
}

.buyer-home .promo-banner {
    background: linear-gradient(135deg, #2d8f6f 0%, #1a6b4f 100%);
    border-radius: 16px;
    padding: 24px;
    color: #ffffff;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
}

.buyer-home .promo-content h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 4px;
}

.buyer-home .promo-content p {
    font-size: 1.5rem;
    font-weight: 800;
    margin: 0 0 12px;
}

.buyer-home .btn-promo {
    padding: 8px 20px;
    background: #ffffff;
    color: #2d8f6f;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

.buyer-home .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.buyer-home .section-header h3 {
    font-size: 1.125rem;
    font-weight: 700;
    margin: 0;
    color: #1a1a2e;
}

.buyer-home .view-all {
    font-size: 0.875rem;
    color: #4f46e5;
    text-decoration: none;
}

.buyer-home .categories-grid {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 16px;
    margin-bottom: 24px;
}

.buyer-home .category-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-width: 64px;
    cursor: pointer;
}

.buyer-home .category-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #f0f1f5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.buyer-home .category-name {
    font-size: 0.75rem;
    color: #1a1a2e;
    text-align: center;
}

.buyer-home .countdown {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: #6c757d;
}

.buyer-home .timer {
    font-weight: 700;
    color: #dc3545;
}

.buyer-home .products-scroll {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 16px;
}

.buyer-home .product-card {
    min-width: 150px;
    width: 150px;
    flex-shrink: 0;
    border-radius: 12px;
    border: 1px solid #e8eaed;
    padding: 12px;
    cursor: pointer;
    position: relative;
    transition: box-shadow 0.2s;
    background: #ffffff;
    display: flex;
    flex-direction: column;
}

.buyer-home .product-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.buyer-home .discount-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: #dc3545;
    color: #ffffff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    z-index: 2;
}

.buyer-home .product-image {
    height: 110px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    background: #f8f9fa;
    border-radius: 8px;
    overflow: hidden;
}

.buyer-home .product-image img {
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
}

.buyer-home .product-info {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.buyer-home .product-info h4 {
    font-size: 0.82rem;
    margin: 0 0 4px;
    color: #1a1a2e;
    line-height: 1.3;
}

.buyer-home .price-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
}

.buyer-home .current-price {
    font-weight: 700;
    color: #1a1a2e;
    font-size: 0.9rem;
}

.buyer-home .original-price {
    text-decoration: line-through;
    color: #adb5bd;
    font-size: 0.75rem;
}

.buyer-home .rating-line {
    font-size: 0.72rem;
    color: #f59e0b;
    font-weight: 600;
    margin-bottom: 4px;
}

.buyer-home .rating-line .reviews {
    color: #adb5bd;
    font-weight: 400;
}

/* Top sellers strip */
.buyer-home .sellers-strip {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 16px;
    margin-bottom: 8px;
}

.buyer-home .seller-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1px solid #e8eaed;
    border-radius: 12px;
    min-width: 200px;
    background: #ffffff;
}

.buyer-home .seller-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #7c3aed);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}

.buyer-home .seller-meta {
    display: flex;
    flex-direction: column;
}

.buyer-home .seller-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #1a1a2e;
}

.buyer-home .seller-rating {
    font-size: 0.7rem;
    color: #6c757d;
}

/* Distinctive "Add to Cart / Wishlist" button on product cards */
.buyer-home .btn-add {
    margin-top: auto;
    width: 100%;
    padding: 8px 10px;
    border: none;
    border-radius: 10px;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: #ffffff;
    background: linear-gradient(135deg, #f97316, #ea580c);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.35);
    transition: transform 0.12s, box-shadow 0.2s, filter 0.2s;
}

.buyer-home .btn-add:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(249, 115, 22, 0.45);
    filter: brightness(1.03);
}

.buyer-home .btn-add:active {
    transform: translateY(0);
}

.buyer-home .btn-add.added {
    background: linear-gradient(135deg, #16a34a, #15803d);
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.35);
}

.buyer-home .btn-add .btn-add-icon {
    font-size: 0.95rem;
    line-height: 1;
}

/* Bottom navigation bar */
.buyer-home .bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 430px;
    background: #ffffff;
    border-top: 1px solid #e8eaed;
    display: flex;
    justify-content: space-around;
    padding: 8px 0 12px;
    z-index: 100;
    box-sizing: border-box;
}

.buyer-home .nav-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-decoration: none;
    color: #adb5bd;
    font-size: 0.7rem;
}

.buyer-home .nav-tab.active {
    color: #4f46e5;
}

.buyer-home .nav-tab span:first-child {
    font-size: 1.25rem;
}

/* Desktop: bottom nav widens to match the centered content */
@media (min-width: 700px) {
    .buyer-home .bottom-nav {
        max-width: 1100px !important;
        border-radius: 16px 16px 0 0;
    }
}


/* =========================================================
   Cart functionality UI (badge, empty state, toast, remove)
   ========================================================= */

/* Cart count badge on the header cart button */
.buyer-home .btn-cart {
    position: relative;
}

.buyer-home .cart-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #ef4444;
    color: #ffffff;
    font-size: 0.65rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    box-sizing: border-box;
}

/* Empty cart state */
.cart-page .cart-empty {
    text-align: center;
    padding: 48px 20px;
}

.cart-page .cart-empty-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

.cart-page .cart-empty h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1a1a2e;
    margin: 0 0 6px;
}

.cart-page .cart-empty p {
    font-size: 0.85rem;
    color: #6c757d;
    margin: 0 0 20px;
}

/* Cart line item actions (quantity + remove) */
.cart-page .item-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.cart-page .btn-remove {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    opacity: 0.7;
    padding: 2px;
}

.cart-page .btn-remove:hover {
    opacity: 1;
}

.cart-page .edit-link {
    background: none;
    border: none;
    color: #ef4444;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

/* "Added to cart" toast on the product detail page */
.product-detail .cart-toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    background: #1a1a2e;
    color: #ffffff;
    padding: 12px 20px;
    border-radius: 30px;
    font-size: 0.85rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    z-index: 500;
    animation: toast-in 0.25s ease;
}

.product-detail .cart-toast a {
    color: #a5b4fc;
    font-weight: 700;
    text-decoration: none;
}

@keyframes toast-in {
    from { opacity: 0; transform: translate(-50%, 10px); }
    to   { opacity: 1; transform: translate(-50%, 0); }
}


/* =========================================================
   Live search (buyer home)
   ========================================================= */

/* Clear (x) button inside the search box */
.buyer-home .search-clear {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 50%;
    background: #e5e7eb;
    color: #6b7280;
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.buyer-home .search-clear:hover {
    background: #d1d5db;
    color: #374151;
}

/* Search results header count */
.buyer-home .results-count {
    font-size: 0.8rem;
    color: #6c757d;
    font-weight: 600;
}

/* No-results state */
.buyer-home .search-empty {
    text-align: center;
    padding: 48px 20px;
}

.buyer-home .search-empty-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

.buyer-home .search-empty h3 {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1a1a2e;
    margin: 0 0 6px;
}

.buyer-home .search-empty p {
    font-size: 0.85rem;
    color: #6c757d;
    margin: 0;
}

/* When searching, let results grid fill width on desktop like other rows */
@media (min-width: 700px) {
    .buyer-home .products-scroll {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 16px;
        overflow: visible;
    }
}

@media (min-width: 1000px) {
    .buyer-home .products-scroll {
        grid-template-columns: repeat(5, 1fr);
    }
}


/* =========================================================
   Shops Near Me (buyer home)
   ========================================================= */

.buyer-home .shop-search-container {
    position: relative;
    margin-bottom: 12px;
}

.buyer-home .shop-clear-btn {
    background: none;
    border: none;
    color: #4f46e5;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.buyer-home .shops-strip {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 12px;
    margin-bottom: 20px;
}

.buyer-home .shop-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1.5px solid #e8eaed;
    border-radius: 14px;
    background: #ffffff;
    cursor: pointer;
    min-width: 190px;
    flex-shrink: 0;
    text-align: left;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.buyer-home .shop-chip:hover {
    border-color: #c7d2fe;
}

.buyer-home .shop-chip.selected {
    border-color: #4f46e5;
    background: #eef2ff;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.buyer-home .shop-chip-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #7c3aed);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
    text-transform: uppercase;
}

.buyer-home .shop-chip-meta {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.buyer-home .shop-chip-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #1a1a2e;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.buyer-home .shop-chip-sub {
    font-size: 0.7rem;
    color: #6c757d;
}

.buyer-home .shop-chip-check {
    color: #4f46e5;
    font-weight: 800;
    font-size: 0.9rem;
}

/* On desktop let the shops wrap into a grid instead of scrolling */
@media (min-width: 700px) {
    .buyer-home .shops-strip {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
        overflow: visible;
    }

    .buyer-home .shop-chip {
        min-width: 0;
    }
}

@media (min-width: 1000px) {
    .buyer-home .shops-strip {
        grid-template-columns: repeat(4, 1fr);
    }
}


/* =========================================================
   User menu dropdown (top bar - storefront & admin)
   ========================================================= */

.user-menu {
    position: relative;
}

.user-menu-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    background: transparent;
    border: 1px solid #e8eaed;
    border-radius: 30px;
    padding: 5px 10px 5px 6px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.user-menu-trigger:hover {
    background: #f5f6fa;
    border-color: #d1d5db;
}

.user-menu-trigger img {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
}

.user-menu-trigger .user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    text-align: left;
}

.user-menu-trigger .user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #1a1a2e;
}

.user-menu-trigger .user-role {
    font-size: 0.7rem;
    color: #6c757d;
}

.user-menu-caret {
    font-size: 0.75rem;
    color: #6c757d;
    margin-left: 2px;
}

/* Invisible backdrop to catch outside clicks */
.user-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 400;
}

.user-menu-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    background: #ffffff;
    border: 1px solid #e8eaed;
    border-radius: 14px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.16);
    padding: 8px;
    z-index: 401;
    animation: user-menu-in 0.15s ease;
}

@keyframes user-menu-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.user-menu-header {
    display: flex;
    flex-direction: column;
    padding: 8px 12px 10px;
    border-bottom: 1px solid #f0f1f5;
    margin-bottom: 6px;
}

.user-menu-name {
    font-size: 0.9rem;
    font-weight: 700;
    color: #1a1a2e;
}

.user-menu-email {
    font-size: 0.72rem;
    color: #6c757d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: 10px;
    font-size: 0.875rem;
    color: #1a1a2e;
    cursor: pointer;
    text-align: left;
    transition: background 0.12s;
}

.user-menu-item:hover {
    background: #f5f6fa;
}

.user-menu-item.danger {
    color: #dc2626;
}

.user-menu-item.danger:hover {
    background: #fef2f2;
}

.user-menu-icon {
    font-size: 1rem;
    width: 20px;
    text-align: center;
}

.user-menu-divider {
    height: 1px;
    background: #f0f1f5;
    margin: 6px 4px;
}

/* On small screens hide the name/role text, keep just the avatar + caret */
@media (max-width: 560px) {
    .user-menu-trigger .user-info {
        display: none;
    }
}

/* =========================================================
   Mobile fit / horizontal-overflow safety net
   ---------------------------------------------------------
   Ensures every page stays within the device width on phones.
   The root cause of "the screen is wider than the phone" is
   almost always a single element overflowing horizontally
   (a fixed width, a flex item that refuses to shrink, or a
   long unbreakable string). These rules contain all of that.
   ========================================================= */

html, body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;   /* clip any accidental horizontal spill */
}

/* Flex/grid children default to min-width:auto and can push a row
   wider than the screen. Let the main shells shrink to fit. */
.storefront-shell,
.storefront-main,
.buyer-home,
.seller-products,
.seller-orders,
.seller-earnings,
.seller-dashboard,
.product-detail,
.checkout-page,
.cart-page,
.admin-page,
.main-content,
.content-area {
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

/* Long words, emails and URLs should wrap instead of stretching a card. */
.buyer-home,
.admin-page,
.auth-form-panel,
.product-detail,
.checkout-page {
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Media never overflows its container on any screen. */
img, video, canvas, svg {
    max-width: 100%;
    height: auto;
}

/* Phone-specific tightening so edge-to-edge content has breathing room
   without spilling past the viewport. */
@media (max-width: 480px) {
    .buyer-home {
        padding-left: 12px;
        padding-right: 12px;
    }

    /* Two-column form rows stack on narrow phones so inputs aren't squeezed. */
    .form-row {
        flex-direction: column;
        gap: 0;
    }

    /* The bottom nav spans the real device width (its 430px cap is a max, not a min). */
    .buyer-home .bottom-nav,
    .bottom-nav {
        left: 0;
        right: 0;
        transform: none;
        margin: 0 auto;
    }
}
