/**
 * Universal E-commerce PWA — Responsive CSS
 * Shein-inspired mobile-first design extending theme.css and components.css.
 *
 * @package UniversalEcommercePWA
 */

/* =========================================================================
   No Horizontal Overflow
   ========================================================================= */
body {
    overflow-x: hidden;
}

*,
*::before,
*::after {
    max-width: 100%;
    box-sizing: border-box;
}

/* =========================================================================
   Homepage Hero
   ========================================================================= */
.uepwa-hero {
    position: relative;
    width: 100%;
    overflow: hidden;
    background-color: var(--color-surface);
}

.uepwa-hero__image {
    width: 100%;
    height: 300px;
    object-fit: cover;
    display: block;
}

@media (min-width: 768px) {
    .uepwa-hero__image {
        height: 420px;
    }
}

@media (min-width: 1024px) {
    .uepwa-hero__image {
        height: 560px;
    }
}

.uepwa-hero__content {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    padding: 24px 20px;
    background: linear-gradient(to left, rgba(0, 0, 0, 0.4), transparent);
}

.uepwa-hero__title {
    font-size: 24px;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 12px;
    line-height: 1.3;
}

@media (min-width: 768px) {
    .uepwa-hero__title {
        font-size: 36px;
    }
}

.uepwa-hero__cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: var(--color-primary);
    color: #ffffff;
    font-family: var(--font-primary);
    font-size: 15px;
    font-weight: 700;
    padding: 12px 28px;
    border-radius: var(--radius-md);
    text-decoration: none;
    transition: background-color var(--transition-fast);
}

.uepwa-hero__cta:hover {
    background-color: var(--color-primary-dark);
    color: #ffffff;
}

/* =========================================================================
   Category Strip (homepage — circle style)
   ========================================================================= */
.uepwa-category-strip {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 12px 16px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    background-color: #ffffff;
    margin-bottom: 16px;
    /* Add spacing below strip */
}

.uepwa-category-strip::-webkit-scrollbar {
    display: none;
}

.uepwa-category-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    text-decoration: none;
    color: var(--color-text);
    min-width: 64px;
    /* Prevent stretching */
}

.uepwa-category-item__image {
    width: 64px !important;
    /* Force size */
    height: 64px !important;
    /* Force size */
    max-width: 64px !important;
    max-height: 64px !important;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--color-border);
    display: block;
}

.uepwa-category-item__name {
    font-size: 11px;
    font-weight: 500;
    text-align: center;
    max-width: 64px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* =========================================================================
   Mobile Category Nav — Pill Style (uepwa-mcat)
   ========================================================================= */
.uepwa-mcat {
    position: sticky;
    top: 60px;
    z-index: 899;
    background-color: #ffffff;
    border-bottom: 1px solid var(--color-border);
}

@media (min-width: 768px) {
    .uepwa-mcat {
        display: none;
    }
}

/* Parent pills row */
.uepwa-mcat__row {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 10px 16px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.uepwa-mcat__row::-webkit-scrollbar {
    display: none;
}

/* Pill button/link */
.uepwa-mcat__pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    font-family: var(--font-primary);
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-muted);
    background-color: var(--color-surface);
    border: 1.5px solid var(--color-border);
    padding: 7px 14px;
    border-radius: 20px;
    text-decoration: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

.uepwa-mcat__pill:active {
    transform: scale(0.96);
}

.uepwa-mcat__pill--active {
    background-color: var(--color-primary);
    color: #ffffff;
    border-color: var(--color-primary);
}

/* Chevron */
.uepwa-mcat__chevron {
    flex-shrink: 0;
    transition: transform var(--transition-fast);
}

.uepwa-mcat__pill--active .uepwa-mcat__chevron {
    transform: rotate(180deg);
}

/* Sub-category row */
.uepwa-mcat__sub {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 8px 16px 10px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    background-color: var(--color-surface);
    border-top: 1px solid var(--color-border);
    animation: uepwa-mcat-slide 0.2s ease-out;
}

.uepwa-mcat__sub::-webkit-scrollbar {
    display: none;
}

@keyframes uepwa-mcat-slide {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.uepwa-mcat__sub[hidden] {
    display: none;
}

/* Sub-pills */
.uepwa-mcat__subpill {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    font-family: var(--font-primary);
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text);
    background-color: #ffffff;
    border: 1px solid var(--color-border);
    padding: 5px 12px;
    border-radius: 16px;
    text-decoration: none;
    transition: all var(--transition-fast);
}

.uepwa-mcat__subpill:active {
    transform: scale(0.96);
}

.uepwa-mcat__subpill--all {
    font-weight: 600;
    color: var(--color-primary);
    border-color: rgba(var(--color-primary-rgb), 0.3);
    background-color: rgba(var(--color-primary-rgb), 0.06);
}

/* =========================================================================
   Product Listing Page
   ========================================================================= */
.uepwa-page-products {
    display: flex;
    gap: 20px;
    padding: 16px;
}

.uepwa-page-products__sidebar {
    display: none;
    /* hidden on mobile */
    width: 240px;
    flex-shrink: 0;
}

.uepwa-page-products__main {
    flex: 1;
    min-width: 0;
}

@media (min-width: 768px) {
    .uepwa-page-products__sidebar {
        display: block;
    }
}

/* =========================================================================
   Filter Bottom Sheet (mobile)
   ========================================================================= */
.uepwa-filter-sheet {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--transition-base);
}

.uepwa-filter-sheet--open {
    pointer-events: auto;
    opacity: 1;
}

.uepwa-filter-sheet__overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
}

.uepwa-filter-sheet__panel {
    position: relative;
    background-color: #ffffff;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 20px;
    padding-bottom: 80px; /* Extra space so content clears the bottom nav bar */
    max-height: 85vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform var(--transition-base);
}

.uepwa-filter-sheet--open .uepwa-filter-sheet__panel {
    transform: translateY(0);
}

.uepwa-filter-sheet__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.uepwa-filter-sheet__title {
    font-size: 18px;
    font-weight: 700;
}

.uepwa-filter-sheet__close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--color-text);
}

/* =========================================================================
   Product Detail Page
   ========================================================================= */
.uepwa-product-detail {
    padding-bottom: 20px;
}

/* Ensure the entire body has padding at the bottom on mobile to avoid overlap with sticky ATC */
@media (max-width: 767px) {
    body.single-product {
        padding-bottom: 90px !important;
    }
}

.uepwa-product-detail__gallery {
    width: 100%;
}

.uepwa-product-detail__info {
    padding: 16px;
}

@media (min-width: 1024px) {
    .uepwa-product-detail {
        display: grid;
        grid-template-columns: 60% 40%;
        gap: 32px;
        padding: 32px;
        padding-bottom: 32px;
        /* no sticky bar needed on desktop */
        max-width: 1200px;
        margin-inline: auto;
    }

    .uepwa-product-detail__gallery {
        position: sticky;
        top: 80px;
        align-self: start;
    }
}

/* =========================================================================
   Image Gallery
   ========================================================================= */
.uepwa-gallery {
    position: relative;
    width: 100%;
    overflow: hidden;
    background-color: var(--color-surface);
}

.uepwa-gallery__track {
    display: flex;
    transition: transform var(--transition-base);
    will-change: transform;
}

.uepwa-gallery__slide {
    min-width: 100%;
    flex-shrink: 0;
}

.uepwa-gallery__slide img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
}

.uepwa-gallery__dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 12px 0;
}

.uepwa-gallery__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--color-border);
    border: none;
    cursor: pointer;
    padding: 0;
    transition: background-color var(--transition-fast), transform var(--transition-fast);
}

.uepwa-gallery__dot--active {
    background-color: var(--color-primary);
    transform: scale(1.3);
}

/* Responsive images with srcset */
.uepwa-product-img {
    width: 100%;
    height: auto;
    display: block;
}

/* =========================================================================
   Checkout Page
   ========================================================================= */
.uepwa-checkout {
    padding: 16px;
    padding-bottom: 100px;
}

.uepwa-checkout__form {
    width: 100%;
}

.uepwa-checkout__summary {
    display: none;
    /* hidden on mobile, shown below form */
}

@media (min-width: 768px) {
    .uepwa-checkout {
        display: grid;
        grid-template-columns: 1fr 380px;
        gap: 32px;
        max-width: 1100px;
        margin-inline: auto;
        padding: 32px;
        padding-bottom: 32px;
    }

    .uepwa-checkout__summary {
        display: block;
    }
}

/* Checkout form inputs */
.uepwa-checkout .uepwa-input {
    height: 52px;
    font-size: 16px;
}

/* =========================================================================
   Form Input Autocomplete Hints
   ========================================================================= */
.uepwa-input[type="tel"] {
    direction: ltr;
    text-align: start;
}

.uepwa-input[type="email"] {
    direction: ltr;
    text-align: start;
}

/* =========================================================================
   Pull-to-Refresh Indicator
   ========================================================================= */
.uepwa-ptr {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translate(-50%, -100%);
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background-color: #ffffff;
    border-radius: 50%;
    box-shadow: var(--shadow-md);
    transition: transform var(--transition-base);
}

.uepwa-ptr--visible {
    transform: translate(-50%, 8px);
}

.uepwa-ptr__spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: uepwa-spin 0.8s linear infinite;
}

@keyframes uepwa-spin {
    to {
        transform: rotate(360deg);
    }
}

/* =========================================================================
   Admin Responsive Additions
   ========================================================================= */

/* Admin table card layout on mobile */
/* Admin Tablet/Mobile Breakpoint (<=1024px) - يرجى استخدام هذا المقاس لجعل أي صفحة متجاوبة */
@media (max-width: 1024px) {
    .uepwa-admin-table--responsive thead {
        display: none;
    }

    .uepwa-admin-table--responsive tr {
        display: block;
        background-color: #ffffff;
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-sm);
        margin-bottom: 12px;
        padding: 12px;
    }

    .uepwa-admin-table--responsive td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 6px 0;
        border: none;
        font-size: 14px;
    }

    .uepwa-admin-table--responsive td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--color-text);
        margin-inline-end: 8px;
    }
}

/* Admin sidebar collapses to bottom tab bar on mobile */
/* Admin Tablet/Mobile Breakpoint (<=1024px) - يرجى استخدام هذا المقاس لجعل أي صفحة متجاوبة */
@media (max-width: 1024px) {
    .uepwa-admin-sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        flex-direction: row;
        height: 60px;
        z-index: 1000;
        background-color: #ffffff;
        border-top: 1px solid var(--color-border);
    }
}

/* All admin action buttons minimum 48px height */
.uepwa-admin-btn {
    min-height: 48px;
}

/* =========================================================================
   Responsive Breakpoint Utilities
   ========================================================================= */

/* Hide on mobile */
.uepwa-hide-mobile {
    display: none;
}

@media (min-width: 768px) {
    .uepwa-hide-mobile {
        display: block;
    }
}

/* Hide on desktop */
.uepwa-hide-desktop {
    display: block;
}

@media (min-width: 768px) {
    .uepwa-hide-desktop {
        display: none;
    }
}

/* =========================================================================
   Spacing for bottom nav on mobile
   ========================================================================= */
.uepwa-page-content {
    padding-bottom: 60px;
    /* space for bottom nav */
}

@media (min-width: 768px) {
    .uepwa-page-content {
        padding-bottom: 0;
    }
}