/* 
 * ================================================================
 * Elbeclawy Mobile Design Implementation for Artbella
 * ================================================================
 * Based on Flutter app analysis: Header, Search, Ads, Sliders
 * Target: Mobile and Tablet screens (max-width: 768px)
 * ================================================================
 */

@media (max-width: 768px) {

    /* ============================================
     * 1. HEADER / APP BAR STYLING
     * ============================================
     * Design specs from Elbaklawy Flutter app:
     * - Background: Primary color with bottom rounded corners (10px)
     * - Height: Auto based on content
     * - Search bar: Exactly 40px height
     */

    .header-wrapper,
    .site-header,
    header.header,
    .header-mobile {
        background: linear-gradient(135deg, #F11B70 0%, #d01560 100%) !important;
        border-radius: 0 0 10px 10px !important;
        padding: 8px 16px !important;
    }

    /* Logo styling */
    .header-logo img,
    .site-logo img {
        height: 32px !important;
        width: auto !important;
        object-fit: contain !important;
    }

    /* Header icons container */
    .header-icons,
    .header-actions,
    .header-right {
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
    }

    /* Cart icon with badge */
    .cart-icon-wrapper,
    .mini-cart,
    .cart-toggle {
        position: relative !important;
    }

    .cart-badge,
    .cart-count,
    .mini-cart-icon .count {
        position: absolute !important;
        top: 6px !important;
        right: 6px !important;
        background: #000 !important;
        color: #fff !important;
        border-radius: 50% !important;
        min-width: 18px !important;
        min-height: 18px !important;
        padding: 4px !important;
        font-size: 10px !important;
        font-weight: bold !important;
        text-align: center !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        line-height: 1 !important;
    }

    /* RTL support for badges */
    html[dir="rtl"] .cart-badge,
    html[dir="rtl"] .cart-count {
        right: auto !important;
        left: 6px !important;
    }

    /* Notification icon with badge */
    .notification-badge {
        background: #ff0000 !important;
    }

    /* ============================================
     * 2. SEARCH BAR STYLING
     * ============================================
     * Exact specs: 40px height, 8px border-radius
     * Button: 48px width × 40px height, black background
     */

    .search-bar-container,
    .header-search,
    .search-form-wrapper {
        margin-top: 8px !important;
        height: 40px !important;
        background: var(--bb-surface-color, #fff) !important;
        border-radius: 8px !important;
        display: flex !important;
        overflow: hidden !important;
        align-items: center !important;
    }

    .search-input,
    .search-bar input,
    input[type="search"] {
        flex: 1 !important;
        border: none !important;
        padding: 0 10px !important;
        background: transparent !important;
        height: 40px !important;
        font-size: 14px !important;
        outline: none !important;
    }

    .search-button,
    .search-bar button,
    .search-submit {
        width: 48px !important;
        height: 40px !important;
        min-width: 48px !important;
        background: #000 !important;
        border: none !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        border-radius: 0 8px 8px 0 !important;
        padding: 0 !important;
        cursor: pointer !important;
    }

    /* RTL support for search button */
    html[dir="rtl"] .search-button,
    html[dir="rtl"] .search-submit {
        border-radius: 8px 0 0 8px !important;
    }

    .search-button svg,
    .search-button img,
    .search-submit i {
        width: 20px !important;
        height: 20px !important;
        filter: brightness(0) invert(1) !important;
        /* Make icon white */
    }

    /* ============================================
     * 3. ADS SECTION STYLING
     * ============================================
     * Design: Large ad (if odd count) + rows of 96px small ads
     * Spacing: 16px horizontal, 8px vertical padding
     * Gap between ads in row: 4px, between rows: 8px
     */

    .ads-section,
    .banner-section,
    .promotional-banners {
        padding: 8px 16px !important;
    }

    /* Large ad (first ad if odd number of ads) */
    .ad-large,
    .banner-large,
    .full-width-banner {
        width: 100% !important;
        margin-bottom: 8px !important;
        margin-top: 8px !important;
    }

    .ad-large img,
    .banner-large img {
        width: 100% !important;
        height: auto !important;
        object-fit: contain !important;
        display: block !important;
    }

    /* Small ads rows */
    .ads-row,
    .banner-row,
    .small-banners-row {
        display: flex !important;
        gap: 8px !important;
        margin-bottom: 8px !important;
    }

    .ad-small,
    .banner-small,
    .half-width-banner {
        flex: 1 !important;
        height: 96px !important;
        max-height: 96px !important;
        overflow: hidden !important;
        border-radius: 4px !important;
    }

    .ad-small img,
    .banner-small img {
        width: 100% !important;
        height: 96px !important;
        object-fit: cover !important;
        display: block !important;
    }

    /* ============================================
     * 4. SEARCH RESULTS GRID
     * ============================================
     * Design: 2 columns, 16px gap, aspect-ratio 0.64
     */

    .search-results-grid,
    .products-grid,
    .product-list-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 16px !important;
        padding: 10px !important;
    }

    .product-card {
        aspect-ratio: 0.64 !important;
    }

    /* ============================================
     * 5. SECTION HEADERS & SLIDERS
     * ============================================
     * Section title: 18px, bold
     * Horizontal sliders with smooth scrolling
     */

    .section-header,
    .category-header,
    .product-section-title {
        padding: 8px 16px !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
    }

    .section-title,
    h2.section-heading,
    .category-title {
        font-size: 18px !important;
        font-weight: bold !important;
        margin: 0 !important;
    }

    /* Horizontal sliders */
    .horizontal-slider,
    .products-slider,
    .category-slider,
    .product-carousel {
        height: 280px !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        padding: 0 16px !important;
        display: flex !important;
        gap: 12px !important;
        scroll-snap-type: x mandatory !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
        /* Firefox */
    }

    /* Hide scrollbar for Chrome, Safari and Opera */
    .horizontal-slider::-webkit-scrollbar,
    .products-slider::-webkit-scrollbar {
        display: none !important;
    }

    .slider-item,
    .product-carousel-item {
        flex: 0 0 160px !important;
        scroll-snap-align: start !important;
    }

    /* Flash Sale slider - slightly taller */
    .flash-sale-slider,
    .deals-slider {
        height: 295px !important;
    }

    .flash-sale-item {
        flex: 0 0 48% !important;
        /* Approximately half width */
    }

    /* ============================================
     * 6. PRODUCT CARDS STYLING
     * ============================================
     * Consistent with existing Amazon-style but enhanced
     */

    .product-inner,
    .bb-product-item,
    .product-card-inner {
        border: 1px solid #e7e7e7 !important;
        border-radius: 10px !important;
        padding: 10px !important;
        margin-bottom: 20px !important;
        overflow: hidden !important;
        display: flex !important;
        flex-direction: column !important;
        background: #fff !important;
    }

    /* Product images */
    .product-image img,
    .product-thumbnail img {
        width: 100% !important;
        border-radius: 8px 8px 0 0 !important;
        object-fit: cover !important;
    }

    /* ============================================
     * 7. SKELETON/LOADING STATES
     * ============================================
     * For search and product loading states
     */

    .search-skeleton,
    .products-skeleton {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 16px !important;
        padding: 16px !important;
    }

    .skeleton-card {
        background: var(--skeleton-bg, #f0f0f0) !important;
        border-radius: 8px !important;
        overflow: hidden !important;
        aspect-ratio: 0.64 !important;
    }

    .skeleton-image {
        width: 100% !important;
        height: 120px !important;
        background: var(--skeleton-shimmer, #e0e0e0) !important;
        animation: skeleton-loading 1.5s infinite !important;
    }

    @keyframes skeleton-loading {

        0%,
        100% {
            opacity: 1;
        }

        50% {
            opacity: 0.5;
        }
    }

    /* ============================================
     * 8. RTL SUPPORT ENHANCEMENTS
     * ============================================
     * Proper RTL support for Arabic layout
     */

    html[dir="rtl"] .search-input,
    html[dir="rtl"] input[type="search"] {
        text-align: right !important;
        padding: 0 10px !important;
    }

    html[dir="rtl"] .slider-item,
    html[dir="rtl"] .product-carousel-item {
        margin-left: 0 !important;
        margin-right: 12px !important;
    }

    html[dir="rtl"] .slider-item:last-child,
    html[dir="rtl"] .product-carousel-item:last-child {
        margin-right: 0 !important;
    }

    /* ============================================
     * 9. SPACING & LAYOUT IMPROVEMENTS
     * ============================================
     * Consistent spacing matching Elbeclawy app
     */

    .container-padding,
    .page-content {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

    .section-spacing {
        margin-bottom: 16px !important;
    }

    /* Ensure proper spacing between sections */
    .home-section,
    .category-section,
    .product-section {
        margin-bottom: 16px !important;
    }

    /* ============================================
     * 10. TOUCH/INTERACTION IMPROVEMENTS
     * ============================================
     * Better touch targets and smooth interactions
     */

    .touchable,
    button,
    a.button,
    .clickable {
        min-height: 44px !important;
        /* Apple's recommended minimum */
        cursor: pointer !important;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1) !important;
    }

    /* Smooth transitions */
    .transition-smooth,
    .product-card,
    .slider-item {
        transition: transform 0.2s ease, box-shadow 0.2s ease !important;
    }

    .product-card:active,
    .slider-item:active {
        transform: scale(0.98) !important;
    }

    /* ============================================
     * 11. TABLET SPECIFIC (768px)
     * ============================================
     * Adjust for tablet screens
     */

    @media (min-width: 600px) and (max-width: 768px) {

        .search-results-grid,
        .products-grid {
            grid-template-columns: repeat(3, 1fr) !important;
            /* 3 columns on tablet */
        }

        .slider-item {
            flex: 0 0 180px !important;
            /* Slightly larger on tablet */
        }
    }

    /* ============================================
     * 12. MOBILE BOTTOM NAV (if exists)
     * ============================================
     * Match with header styling
     */

    .mobile-bottom-nav,
    .bottom-navigation {
        background: linear-gradient(135deg, #F11B70 0%, #d01560 100%) !important;
        border-radius: 10px 10px 0 0 !important;
        padding: 8px 0 !important;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1) !important;
    }

    /* ============================================
     * 13. DARK MODE SUPPORT (if needed)
     * ============================================
     */

    @media (prefers-color-scheme: dark) {

        .search-bar-container,
        .header-search {
            background: var(--bb-dark-surface, #2a2a2a) !important;
        }

        .product-inner,
        .product-card-inner {
            background: var(--bb-dark-card, #333) !important;
            border-color: #444 !important;
        }

        .skeleton-card {
            background: #2a2a2a !important;
        }

        .skeleton-image {
            background: #3a3a3a !important;
        }
    }
}

/* ============================================
 * MOBILE ONLY (smaller phones)
 * ============================================
 */
@media (max-width: 414px) {

    .header-wrapper,
    .site-header {
        padding: 6px 12px !important;
    }

    .section-header {
        padding: 6px 12px !important;
    }

    .ads-section,
    .banner-section {
        padding: 6px 12px !important;
    }

    .search-results-grid,
    .products-grid {
        padding: 8px !important;
        gap: 12px !important;
    }
}