/*
 * Mobile Product Page Responsive Fix
 * Last updated: 2025-09-13
 * Author: Assistant  
 * Summary: Comprehensive mobile responsive fixes for product pages and dialogs
 */

/* Mobile viewport fixes */
@viewport {
    width: device-width;
    zoom: 1.0;
}

/* Ensure proper mobile viewport handling */
@media screen and (max-width: 768px) {
    
    /* Fix viewport and container widths */
    html, body {
        width: 100% !important;
        overflow-x: hidden !important;
        -webkit-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
    }
    
    /* Product page container fixes - consistent padding/borders */
    .centerColumn#productGeneral {
        padding: 15px !important;
        margin: 0 !important;
        width: 100% !important;
        box-sizing: border-box !important;
        border-left: none !important;
        border-right: none !important;
    }
    
    /* Ensure consistent padding across all mobile containers */
    .centerColumn,
    .leftColumn,
    .rightColumn,
    #navBreadCrumb,
    .content {
        padding-left: 15px !important;
        padding-right: 15px !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        box-sizing: border-box !important;
    }
    
    /* Fix main wrapper to prevent inconsistent spacing */
    #mainWrapper,
    .wrapper {
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    /* Ensure body and html have no side margins/padding */
    body {
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    /* Product layout responsive grid */
    .productinfo-container {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
        width: 100% !important;
    }
    
    /* Product images mobile responsive */
    #productMainImage,
    .product-image-container {
        width: 100% !important;
        max-width: 100% !important;
        text-align: center !important;
        margin-bottom: 20px !important;
    }
    
    #productMainImage img {
        max-width: 100% !important;
        height: auto !important;
        width: auto !important;
        max-height: 300px !important;
    }
    
    /* Additional product images */
    #productAdditionalImages {
        width: 100% !important;
        overflow-x: auto !important;
        white-space: nowrap !important;
        padding: 10px 0 !important;
    }
    
    #productAdditionalImages img {
        max-width: 80px !important;
        height: auto !important;
        margin-right: 10px !important;
        display: inline-block !important;
    }
    
    /* Product details section */
    .product-details,
    .product-info {
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    /* Product title mobile responsive */
    .product-overview-title,
    #productName,
    .product_head {
        font-size: 18px !important;
        line-height: 1.3 !important;
        margin: 10px 0 !important;
        padding: 0 !important;
        text-align: center !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }
    
    /* Product description */
    #productDescription {
        font-size: 14px !important;
        line-height: 1.4 !important;
        margin: 15px 0 !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }
    
    /* Product pricing */
    .product-price,
    .productPriceColor {
        font-size: 16px !important;
        text-align: center !important;
        margin: 15px 0 !important;
    }
    
    /* Add to cart button */
    .add-to-cart-container,
    #cartAdd {
        width: 100% !important;
        text-align: center !important;
        margin: 20px 0 !important;
    }
    
    .add-to-cart-container input[type="submit"],
    input[type="button"] {
        width: 100% !important;
        max-width: 280px !important;
        padding: 12px !important;
        font-size: 16px !important;
        margin: 10px auto !important;
        display: block !important;
    }
    
    /* Fix mobile tables */
    table {
        width: 100% !important;
        overflow-x: auto !important;
        display: block !important;
        white-space: nowrap !important;
    }
    
    table tbody, table thead, table tr {
        display: block !important;
    }
    
    table tr {
        border: 1px solid #ddd !important;
        margin-bottom: 10px !important;
        display: block !important;
    }
    
    table td, table th {
        border: none !important;
        display: block !important;
        text-align: left !important;
        padding: 8px !important;
    }
}

/* Mobile Dialog/Modal Fixes */
@media screen and (max-width: 768px) {
    
    /* Colorbox mobile responsive fixes */
    #colorbox, #cboxWrapper {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        z-index: 9999 !important;
    }
    
    #cboxOverlay {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        background: rgba(0,0,0,0.8) !important;
    }
    
    #cboxContent, #cboxLoadedContent {
        position: fixed !important;
        top: 5% !important;
        left: 5% !important;
        right: 5% !important;
        bottom: 5% !important;
        width: 90% !important;
        height: 90% !important;
        max-width: none !important;
        max-height: none !important;
        overflow: auto !important;
        -webkit-overflow-scrolling: touch !important;
        background: white !important;
        border-radius: 8px !important;
        box-shadow: 0 4px 20px rgba(0,0,0,0.3) !important;
    }
    
    #cboxLoadedContent img {
        max-width: 100% !important;
        height: auto !important;
        width: auto !important;
        display: block !important;
        margin: 0 auto !important;
    }
    
    /* Close button mobile friendly */
    #cboxClose {
        position: fixed !important;
        top: 10px !important;
        right: 10px !important;
        width: 40px !important;
        height: 40px !important;
        background: rgba(0,0,0,0.7) !important;
        border-radius: 20px !important;
        color: white !important;
        font-size: 24px !important;
        line-height: 36px !important;
        text-align: center !important;
        z-index: 10000 !important;
    }
    
    #cboxClose:before {
        content: "×" !important;
        font-size: 30px !important;
        color: white !important;
    }
    
    /* Navigation buttons mobile friendly */
    #cboxPrevious, #cboxNext {
        position: fixed !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        width: 50px !important;
        height: 50px !important;
        background: rgba(0,0,0,0.7) !important;
        border-radius: 25px !important;
        z-index: 10000 !important;
    }
    
    #cboxPrevious {
        left: 10px !important;
    }
    
    #cboxNext {
        right: 10px !important;
    }
    
    /* Remove all complex borders and decorations on mobile */
    #cboxTopLeft, #cboxTopCenter, #cboxTopRight,
    #cboxBottomLeft, #cboxBottomCenter, #cboxBottomRight,
    #cboxMiddleLeft, #cboxMiddleRight {
        display: none !important;
    }
    
    /* Title and info positioning */
    #cboxTitle, #cboxCurrent {
        position: fixed !important;
        bottom: 20px !important;
        left: 10px !important;
        right: 10px !important;
        background: rgba(0,0,0,0.8) !important;
        color: white !important;
        padding: 10px !important;
        border-radius: 4px !important;
        text-align: center !important;
        font-size: 14px !important;
    }
    
    #cboxCurrent {
        bottom: 60px !important;
    }
    
    /* Zen Lightbox mobile fixes */
    #lbOverlay {
        position: fixed !important;
        width: 100% !important;
        height: 100% !important;
        top: 0 !important;
        left: 0 !important;
        background-color: rgba(0,0,0,0.8) !important;
    }
    
    #lbCenter {
        position: fixed !important;
        top: 5% !important;
        left: 5% !important;
        right: 5% !important;
        bottom: 15% !important;
        width: 90% !important;
        height: 80% !important;
        background-color: #fff !important;
        border-radius: 8px !important;
        overflow: hidden !important;
    }
    
    #lbImage {
        width: 100% !important;
        height: 100% !important;
        object-fit: contain !important;
        border: none !important;
    }
    
    #lbPrevLink, #lbNextLink {
        width: 50px !important;
        height: 50px !important;
        background: rgba(0,0,0,0.7) !important;
        border-radius: 25px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
    }
    
    #lbPrevLink {
        left: 10px !important;
    }
    
    #lbNextLink {
        right: 10px !important;
    }
    
    #lbBottomContainer {
        position: fixed !important;
        bottom: 5% !important;
        left: 5% !important;
        right: 5% !important;
        width: 90% !important;
        height: auto !important;
        background-color: rgba(0,0,0,0.8) !important;
        color: white !important;
        padding: 15px !important;
        border-radius: 8px !important;
    }
    
    #lbCloseLink {
        position: fixed !important;
        top: 10px !important;
        right: 10px !important;
        width: 40px !important;
        height: 40px !important;
        background: rgba(0,0,0,0.7) !important;
        border-radius: 20px !important;
        color: white !important;
        text-align: center !important;
        line-height: 36px !important;
        font-size: 24px !important;
    }
    
    #lbCloseLink:before {
        content: "×" !important;
        color: white !important;
    }
}

/* Touch-friendly interaction improvements */
@media screen and (max-width: 768px) {
    
    /* Ensure all clickable elements are touch-friendly */
    button, input[type="button"], input[type="submit"], 
    a, .clickable {
        min-height: 44px !important;
        min-width: 44px !important;
        padding: 8px 12px !important;
        margin: 4px !important;
        line-height: 1.4 !important;
    }
    
    /* Prevent zoom on input focus */
    input[type="text"], input[type="number"], 
    input[type="email"], select, textarea {
        font-size: 16px !important;
        -webkit-appearance: none !important;
        border-radius: 4px !important;
    }
    
    /* Improved form spacing on mobile */
    .form-group, .input-group {
        margin-bottom: 15px !important;
    }
    
    /* Product attributes mobile responsive */
    .productOptions, .productAttributes {
        width: 100% !important;
        margin: 15px 0 !important;
    }
    
    .productOptions select, .productAttributes select {
        width: 100% !important;
        padding: 10px !important;
        font-size: 16px !important;
        margin: 5px 0 !important;
    }
    
    /* Breadcrumb mobile responsive */
    .breadcrumb-nav {
        font-size: 12px !important;
        margin: 5px 0 !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }
    
    /* Reviews and tabs mobile responsive */
    .product-tabs, .reviews-section {
        width: 100% !important;
        margin: 20px 0 !important;
    }
    
    .product-tabs ul {
        display: flex !important;
        flex-wrap: wrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    .product-tabs li {
        flex: 1 !important;
        min-width: 120px !important;
        text-align: center !important;
    }
    
    /* Related products mobile responsive */
    .related-products, .also-purchased {
        width: 100% !important;
        margin: 20px 0 !important;
    }
    
    .related-products img, .also-purchased img {
        max-width: 80px !important;
        height: auto !important;
        margin: 5px !important;
    }
}

/* Extra small screens (phones in portrait) */
@media screen and (max-width: 480px) {
    
    .product-overview-title,
    #productName {
        font-size: 16px !important;
    }
    
    #productDescription {
        font-size: 13px !important;
    }
    
    .add-to-cart-container input[type="submit"] {
        font-size: 14px !important;
        padding: 10px !important;
    }
    
    /* Even more compact dialog on very small screens */
    #cboxContent, #cboxLoadedContent {
        top: 2% !important;
        left: 2% !important;
        right: 2% !important;
        bottom: 2% !important;
        width: 96% !important;
        height: 96% !important;
    }
}

/* Landscape orientation fixes */
@media screen and (max-height: 500px) and (orientation: landscape) {
    
    #cboxContent, #cboxLoadedContent,
    #lbCenter {
        top: 1% !important;
        bottom: 1% !important;
        height: 98% !important;
    }
    
    #cboxTitle, #cboxCurrent,
    #lbBottomContainer {
        display: none !important;
    }
}