/* ============================================
   PRODUCT PAGE MOBILE FIXES
   Comprehensive mobile responsiveness for product page
   ============================================ */

/* ============================================
   PRODUCT PAGE MOBILE FIXES - HIGH PRIORITY
   These rules override all desktop styles
   ============================================ */

/* Mobile Product Page - 768px and below */
@media (max-width: 768px) {
    /* CRITICAL: Override all desktop grid layouts */
    html body .product-content,
    html body #productContent,
    body .product-content,
    body #productContent {
        display: grid !important;
        grid-template-columns: 1fr !important;
        grid-template-rows: auto auto !important;
        gap: 0 !important;
    }
    /* Product Main Container */
    .product-main {
        padding: 0 !important;
        margin-top: 0 !important;
    }

    /* Product Container */
    .product-container {
        padding: 0 !important;
        margin-top: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .product-main > .container {
        padding: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Breadcrumbs */
    .breadcrumbs {
        margin-top: 96px !important; /* Header (56px) + Nav (40px) */
        padding: 8px 10px !important;
        font-size: 11px;
    }

    .breadcrumbs .container {
        padding: 0 10px;
        flex-wrap: wrap;
        gap: 4px;
    }

    /* Product Content Grid - CRITICAL: Force single column */
    .product-content,
    #productContent,
    .product-main .container .product-content,
    .product-container .product-content {
        display: grid !important;
        grid-template-columns: 1fr !important;
        grid-template-rows: auto auto !important;
        gap: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        min-height: auto !important;
    }

    /* Product Images Wrapper - Force full width and stack */
    html body .product-images-wrapper,
    html body #productContent .product-images-wrapper,
    html body .product-content .product-images-wrapper,
    body .product-images-wrapper,
    body #productContent .product-images-wrapper,
    body .product-content .product-images-wrapper,
    .product-images-wrapper,
    #productContent .product-images-wrapper,
    .product-content .product-images-wrapper,
    .product-container .product-images-wrapper {
        position: relative !important;
        top: 0 !important;
        margin-bottom: 0 !important;
        margin-top: 0 !important;
        padding: 0 !important;
        padding-bottom: 0 !important;
        padding-top: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        border-right: none !important;
        border-bottom: 1px solid #f0f0f0 !important;
        order: 1 !important;
        height: auto !important;
        max-height: none !important;
        align-self: stretch !important;
        grid-column: 1 / -1 !important;
        grid-row: 1 !important;
    }

    /* Product Right Column - Force full width */
    html body .product-right-column,
    html body #productContent .product-right-column,
    html body .product-content .product-right-column,
    body .product-right-column,
    body #productContent .product-right-column,
    body .product-content .product-right-column,
    .product-right-column,
    #productContent .product-right-column,
    .product-content .product-right-column {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        padding-top: 0 !important;
        margin: 0 !important;
        margin-top: 0 !important;
        order: 2 !important;
        grid-column: 1 / -1 !important;
        grid-row: 2 !important;
    }
    
    /* Hide br tags that create spacing */
    html body .product-right-column br,
    body .product-right-column br,
    .product-right-column br {
        display: none !important;
        line-height: 0 !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Product Info Section */
    .product-info {
        padding: 16px 12px !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Product Images Container */
    .product-images {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
        padding: 16px 12px !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Thumbnail Gallery - Horizontal on mobile */
    .thumbnail-gallery-vertical {
        display: flex !important;
        flex-direction: row !important;
        gap: 8px !important;
        margin-top: 0 !important;
        margin-bottom: 12px !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        max-height: none !important;
        padding: 0 !important;
        width: 100% !important;
        -webkit-overflow-scrolling: touch;
    }

    .thumbnail-gallery-vertical::-webkit-scrollbar {
        display: none;
    }

    .thumbnail-item {
        width: 60px !important;
        height: 60px !important;
        min-width: 60px !important;
        min-height: 60px !important;
        flex-shrink: 0 !important;
    }

    /* Main Image Container - Full height on mobile */
    .main-image-container {
        width: 100% !important;
        height: auto !important;
        min-height: auto !important;
        max-height: none !important;
        order: 2 !important;
    }

    .main-product-image,
    .main-image,
    #mainProductImage {
        height: auto !important;
        max-height: none !important;
        max-width: 100% !important;
        width: 100% !important;
        object-fit: contain !important;
        display: block !important;
    }

    .main-image-wrapper {
        width: 100% !important;
        height: auto !important;
        min-height: auto !important;
    }

    /* Product Details Section */
    .product-details-section {
        padding: 16px 12px !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
    }

    /* Product Top Actions */
    .product-top-actions {
        position: static !important;
        margin-bottom: 12px !important;
        padding: 0 !important;
        justify-content: flex-end !important;
    }

    /* Wishlist Button */
    .product-wishlist {
        position: static !important;
        margin-bottom: 12px !important;
    }

    /* Product Title */
    .product-title {
        font-size: 16px !important;
        line-height: 1.4;
        margin-bottom: 8px;
        font-weight: 500;
    }

    /* Rating Section */
    .product-rating {
        margin-bottom: 12px;
        padding: 8px 12px;
        font-size: 13px;
    }

    /* Price Section */
    .price-section {
        margin-bottom: 16px;
    }

    .price-current {
        font-size: 22px !important;
        font-weight: 600;
    }

    .price-original {
        font-size: 16px;
    }

    .discount-badge {
        font-size: 12px;
        padding: 4px 8px;
    }

    /* Purchase Options */
    .purchase-options {
        padding: 16px 12px !important;
        margin-bottom: 16px;
        border-radius: 4px;
    }

    /* Product Actions */
    .product-actions-left {
        flex-direction: column !important;
        gap: 10px !important;
        width: 100%;
        margin-bottom: 0 !important;
        padding-bottom: 0 !important;
    }

    .product-actions-left .btn-add-cart,
    .product-actions-left .btn-buy-now {
        width: 100% !important;
        padding: 12px 16px !important;
        font-size: 14px !important;
        font-weight: 600;
        min-height: 44px; /* Touch-friendly */
    }

    /* Variations Section */
    .variations-section {
        margin-bottom: 16px;
    }

    .variation-attribute {
        margin-bottom: 16px;
    }

    .variation-label {
        font-size: 14px;
        margin-bottom: 8px;
        font-weight: 500;
    }

    .variation-options {
        gap: 8px;
        flex-wrap: wrap;
    }

    /* Color Variations */
    .color-variation-box {
        width: 50px !important;
        height: 50px !important;
        border-width: 2px;
    }

    .color-variation-box .color-variation-image {
        width: 46px !important;
        height: 46px !important;
    }

    /* RAM/Storage Options */
    .variation-option-detail {
        padding: 10px 16px !important;
        font-size: 13px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Warranty Info */
    .warranty-info {
        padding: 12px !important;
        margin-bottom: 16px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .warranty-info .warranty-logo {
        width: 60px;
        height: auto;
    }

    .warranty-info span {
        font-size: 13px;
        line-height: 1.5;
    }

    .warranty-info .detail-link {
        font-size: 13px;
        margin-top: 4px;
    }

    /* Available Offers */
    .offers-section {
        margin-bottom: 16px;
    }

    .offers-title {
        font-size: 14px;
        margin-bottom: 12px;
        font-weight: 600;
    }

    .offers-list {
        font-size: 12px !important;
        line-height: 1.6;
    }

    .offer-item {
        padding: 8px 0;
        font-size: 12px;
    }

    .offer-item .offer-label {
        font-size: 12px;
    }

    .offer-item .offer-title-text {
        font-size: 12px;
    }

    .offer-tc {
        font-size: 11px;
        padding: 2px 6px;
    }

    /* Product Highlights */
    .product-highlights {
        margin-bottom: 16px;
        padding: 12px;
    }

    .highlights-title {
        font-size: 14px;
        margin-bottom: 12px;
    }

    .highlights-list {
        font-size: 13px;
    }

    .highlights-list li {
        margin-bottom: 8px;
        padding-left: 20px;
    }

    /* Specifications */
    .specifications-section {
        margin-bottom: 16px;
    }

    .specifications-title {
        font-size: 16px;
        margin-bottom: 12px;
        font-weight: 600;
    }

    .specification-group {
        margin-bottom: 16px;
    }

    .specification-group-title {
        font-size: 14px;
        margin-bottom: 8px;
    }

    .specification-row {
        padding: 8px 0;
        font-size: 13px;
    }

    .specification-label {
        font-size: 13px;
        width: 40%;
    }

    .specification-value {
        font-size: 13px;
        width: 60%;
    }

    /* Compare Checkbox */
    .compare-checkbox-wrapper {
        margin-bottom: 16px;
        padding: 12px;
        font-size: 13px;
    }

    /* Share Button */
    .share-button {
        padding: 8px 12px;
        font-size: 13px;
    }

    /* Buy Together Section */
    .buy-together-section {
        margin-bottom: 16px;
        padding: 12px;
    }

    .buy-together-title {
        font-size: 16px;
        margin-bottom: 12px;
    }

    .buy-together-products {
        flex-direction: column;
        gap: 12px;
    }

    .buy-together-product-item {
        width: 100%;
        padding: 12px;
    }

    /* Recently Viewed */
    .recently-viewed-section {
        margin-bottom: 16px;
        padding: 12px;
    }

    .recently-viewed-title {
        font-size: 16px;
        margin-bottom: 12px;
    }

    /* Ratings and Reviews */
    .ratings-reviews-section {
        margin-bottom: 16px;
        padding: 12px;
    }

    .ratings-reviews-title {
        font-size: 16px;
        margin-bottom: 12px;
    }

    .ratings-reviews-content {
        grid-template-columns: 1fr !important;
        gap: 16px;
    }

    /* Q&A Section */
    .qa-section {
        margin-bottom: 16px;
        padding: 12px;
    }

    .qa-title {
        font-size: 16px;
        margin-bottom: 12px;
    }

    /* Product Description */
    .product-description-section {
        padding: 16px 12px !important;
        margin-bottom: 16px;
    }

    .product-description-title {
        font-size: 18px !important;
        margin-bottom: 20px !important;
        padding-bottom: 12px !important;
    }

    /* Compare Bar */
    .compare-bar {
        padding: 10px 12px !important;
        bottom: 0;
        z-index: 1000;
    }

    .compare-bar-content {
        flex-direction: column;
        gap: 8px;
    }

    .compare-bar-left {
        width: 100%;
        text-align: center;
    }

    .compare-bar-right {
        width: 100%;
        justify-content: space-between;
        gap: 8px;
    }

    .compare-bar-clear,
    .compare-bar-btn {
        flex: 1;
        padding: 10px 16px;
        font-size: 13px;
        min-height: 44px;
    }
}

/* Small Mobile - 480px and below */
@media (max-width: 480px) {
    .product-container {
        padding: 10px 8px !important;
    }

    .breadcrumbs {
        padding: 6px 8px !important;
        font-size: 10px;
    }

    .breadcrumbs .container {
        padding: 0 8px;
    }

    .product-title {
        font-size: 15px !important;
    }

    .price-current {
        font-size: 20px !important;
    }

    .main-image-container {
        height: auto !important;
        max-height: none !important;
    }

    .main-product-image,
    .main-image,
    #mainProductImage {
        height: auto !important;
        max-height: none !important;
    }

    .thumbnail-item {
        width: 45px !important;
        height: 45px !important;
    }

    .product-actions-left .btn-add-cart,
    .product-actions-left .btn-buy-now {
        padding: 10px 14px !important;
        font-size: 13px !important;
    }

    .color-variation-box {
        width: 45px !important;
        height: 45px !important;
    }

    .color-variation-box .color-variation-image {
        width: 41px !important;
        height: 41px !important;
    }

    .variation-option-detail {
        padding: 8px 12px !important;
        font-size: 12px;
    }

    .offers-list {
        font-size: 11px !important;
    }

    .offer-item {
        font-size: 11px;
    }

    .specification-row {
        flex-direction: column;
        gap: 4px;
    }

    .specification-label {
        width: 100%;
        font-weight: 600;
    }

    .specification-value {
        width: 100%;
    }
}

/* Extra Small Mobile - 360px and below */
@media (max-width: 360px) {
    .product-container {
        padding: 8px 6px !important;
    }

    .product-title {
        font-size: 14px !important;
    }

    .price-current {
        font-size: 18px !important;
    }

    .main-image-container {
        height: auto !important;
        max-height: none !important;
    }
    
    .main-product-image,
    .main-image,
    #mainProductImage {
        height: auto !important;
        max-height: none !important;
    }

    .thumbnail-item {
        width: 40px !important;
        height: 40px !important;
    }

    .color-variation-box {
        width: 40px !important;
        height: 40px !important;
    }

    .color-variation-box .color-variation-image {
        width: 36px !important;
        height: 36px !important;
    }
}

/* Ensure proper spacing on mobile */
@media (max-width: 768px) {
    /* CRITICAL OVERRIDES - Must be at the end to override everything */
    
    /* Force single column layout - override ALL grid definitions */
    .product-content,
    #productContent,
    .product-main .container .product-content,
    .product-container .product-content,
    body .product-content,
    html body .product-content {
        grid-template-columns: 1fr !important;
        grid-template-rows: auto auto !important;
    }

    /* Remove any fixed heights that might cause issues */
    .product-images-wrapper,
    .product-details-section,
    .product-images-wrapper,
    #productContent .product-images-wrapper {
        height: auto !important;
        max-height: none !important;
        position: relative !important;
        top: 0 !important;
    }

    /* Ensure images are responsive */
    .main-product-image,
    .thumbnail-image {
        max-width: 100%;
        height: auto;
    }

    /* Fix any overflow issues */
    .product-content,
    .product-container,
    .product-main {
        overflow-x: hidden !important;
    }

    /* Ensure buttons are touch-friendly */
    .btn,
    button,
    .btn-add-cart,
    .btn-buy-now,
    .variation-option-detail,
    .color-variation-box {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
        user-select: none;
    }

    /* Force product images wrapper to be full width */
    html body .product-images-wrapper,
    html body #productContent .product-images-wrapper,
    body .product-images-wrapper,
    body #productContent .product-images-wrapper,
    .product-images-wrapper {
        grid-column: 1 / -1 !important;
        width: 100% !important;
        max-width: 100% !important;
        position: relative !important;
        top: 0 !important;
    }

    /* Force product right column to be full width */
    html body .product-right-column,
    html body #productContent .product-right-column,
    body .product-right-column,
    body #productContent .product-right-column,
    .product-right-column {
        grid-column: 1 / -1 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* OVERRIDE ALL STICKY POSITIONING RULES FROM product.css */
    html body .product-images-wrapper,
    html body #productContent .product-images-wrapper,
    html body .product-content .product-images-wrapper,
    body .product-images-wrapper,
    body #productContent .product-images-wrapper,
    body .product-content .product-images-wrapper {
        position: relative !important;
        top: 0 !important;
        height: auto !important;
        max-height: none !important;
        align-self: stretch !important;
    }
}

