/* Mobile Responsiveness Fix - Priority CSS */

/* Prevent horizontal scroll - CRITICAL */
html {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100vw !important;
    position: relative;
}

body {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100vw !important;
    position: relative;
    margin: 0;
    padding: 0;
}

* {
    box-sizing: border-box;
}

/* All direct children of body should not overflow */
body > * {
    max-width: 100vw;
    overflow-x: hidden;
}

/* Header specific overflow fix */
header, .site-header {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

.site-header * {
    max-width: 100%;
}

/* Container fix */
.container {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    padding-left: 15px;
    padding-right: 15px;
}

/* Images responsive */
img {
    max-width: 100%;
    height: auto;
}

/* Tables responsive wrapper */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

.data-table {
    min-width: 600px;
}

/* Mobile specific fixes */
@media (max-width: 768px) {
    /* Global mobile fixes */
    html, body {
        overflow-x: hidden !important;
        max-width: 100vw !important;
        width: 100% !important;
    }
    
    * {
        max-width: 100% !important;
    }
    
    /* Container */
    .container {
        padding: 0 10px !important;
        width: 100% !important;
        max-width: 100vw !important;
    }
    
    /* Checkout progress bar fix */
    .checkout-progress {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .checkout-progress > .container {
        padding: 0 10px !important;
    }
    
    .checkout-progress > .container > div {
        min-width: 100%;
        flex-wrap: nowrap;
    }
    
    .progress-step {
        flex: 1;
        min-width: 60px;
    }
    
    .progress-step div:first-child {
        width: 40px !important;
        height: 40px !important;
        font-size: 16px !important;
    }
    
    .progress-step div:last-child {
        font-size: 11px !important;
    }
    
    .progress-line {
        flex: 0 0 20px !important;
    }
    
    /* Forms fix */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="number"],
    input[type="password"],
    textarea,
    select {
        width: 100% !important;
        max-width: 100% !important;
        font-size: 16px !important; /* Prevents zoom on iOS */
        padding: 12px !important;
    }
    
    /* Buttons */
    .btn,
    button {
        width: 100% !important;
        max-width: 100% !important;
        padding: 12px 20px !important;
        font-size: 14px !important;
    }
    
    .btn-sm {
        padding: 8px 12px !important;
        font-size: 12px !important;
        width: auto !important;
    }
    
    /* Grid layouts */
    div[style*="display: grid"],
    div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }
    
    /* Flex layouts */
    div[style*="display: flex"] {
        flex-wrap: wrap !important;
    }
    
    /* Product detail page */
    .product-detail-wrapper {
        grid-template-columns: 1fr !important;
        padding: 15px !important;
    }
    
    /* Cart items */
    .cart-item {
        flex-direction: column !important;
        align-items: flex-start !important;
    }
    
    .cart-item img {
        width: 100% !important;
        max-height: 200px;
        object-fit: cover;
    }
    
    /* Article content */
    .article-single {
        padding: 20px 15px !important;
    }
    
    .article-single h1 {
        font-size: 24px !important;
        line-height: 1.3 !important;
    }
    
    /* User dashboard */
    .user-dashboard-grid {
        grid-template-columns: 1fr !important;
    }
    
    .dashboard-sidebar {
        order: 2;
        margin-top: 20px;
    }
    
    .dashboard-content {
        order: 1;
    }
    
    /* Stats cards */
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }
    
    /* Footer */
    .footer-grid {
        grid-template-columns: 1fr !important;
    }
    
    .footer-main {
        padding: 40px 0 20px !important;
    }
    
    /* Newsletter widget */
    #newsletterWidget {
        left: 10px !important;
        right: 10px !important;
        bottom: 10px !important;
        max-width: calc(100% - 20px) !important;
        padding: 15px !important;
    }
    
    /* Back to top button */
    .back-to-top {
        bottom: 70px !important;
        right: 15px !important;
        width: 45px !important;
        height: 45px !important;
    }
    
    /* Dark mode toggle */
    .dark-mode-toggle {
        bottom: 15px !important;
        right: 15px !important;
        width: 45px !important;
        height: 45px !important;
    }
    
    /* Hide long text on mobile */
    .hide-mobile {
        display: none !important;
    }
    
    /* Product actions */
    .product-actions {
        flex-direction: column !important;
        gap: 10px !important;
    }
    
    .product-actions button,
    .product-actions a {
        width: 100% !important;
    }
    
    /* Random article boxes */
    .random-article {
        padding: 20px 15px !important;
    }
    
    .random-article h2 {
        font-size: 18px !important;
    }
    
    .random-article p {
        font-size: 14px !important;
    }
}

@media (max-width: 480px) {
    /* Extra small devices */
    .container {
        padding: 0 8px !important;
    }
    
    h1 {
        font-size: 22px !important;
    }
    
    h2 {
        font-size: 20px !important;
    }
    
    h3 {
        font-size: 18px !important;
    }
    
    .section-title {
        font-size: 22px !important;
    }
    
    .hero-title {
        font-size: 28px !important;
    }
    
    .hero-discount {
        font-size: 28px !important;
        padding: 15px 25px !important;
    }
    
    /* Form actions */
    .form-actions {
        flex-direction: column !important;
    }
    
    .form-actions .btn {
        width: 100% !important;
    }
}

/* Prevent text overflow */
p, span, div, a {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Image containers */
.product-image,
.article-image {
    width: 100%;
    overflow: hidden;
}

.product-image img,
.article-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Inline elements that might overflow */
.product-title a,
.article-title a {
    word-wrap: break-word;
    overflow-wrap: break-word;
    display: block;
}

