/* 
   MOBILE RESPONSIVE DESIGN FIX
   This file specifically targets mobile devices to fix layout issues
   while preserving desktop experience
   Created: 2025-07-25
   Updated: 2025-07-26 - Added article page fixes
*/

/* Only apply these styles on mobile devices */
@media (max-width: 767px) {
    /* Fix navbar toggle button */
    .navbar-toggle-checkbox {
        display: none;
    }
    
    .navbar-toggle-label {
        display: flex !important;
        flex-direction: column;
        justify-content: space-around;
        width: 30px;
        height: 25px;
        position: absolute;
        top: 20px;
        right: 20px;
        z-index: 2;
        cursor: pointer;
    }
    
    .hamburger-icon, 
    .hamburger-icon::before, 
    .hamburger-icon::after {
        display: block;
        background-color: #00ff00;
        position: absolute;
        height: 3px;
        width: 30px;
        border-radius: 2px;
        transition: transform 400ms cubic-bezier(0.23, 1, 0.32, 1);
    }
    
    .hamburger-icon::before {
        content: '';
        margin-top: -8px;
    }
    
    .hamburger-icon::after {
        content: '';
        margin-top: 8px;
    }
    
    /* Toggle navbar visibility */
    .navbar-toggle-checkbox:checked ~ .navbar-collapse {
        display: block !important;
    }
    
    .navbar-toggle-checkbox:checked ~ .navbar-toggle-label .hamburger-icon {
        background: transparent;
    }
    
    .navbar-toggle-checkbox:checked ~ .navbar-toggle-label .hamburger-icon::before {
        margin-top: 0;
        transform: rotate(45deg);
    }
    
    .navbar-toggle-checkbox:checked ~ .navbar-toggle-label .hamburger-icon::after {
        margin-top: 0;
        transform: rotate(-45deg);
    }
    
    /* Navbar collapse styling */
    .navbar-collapse {
        display: none;
        position: absolute;
        top: 70px;
        left: 0;
        width: 100%;
        background-color: #000;
        border: 1px solid #00ff00;
        box-shadow: 0 5px 15px rgba(0, 255, 0, 0.2);
        z-index: 1000;
        padding: 10px;
    }

    /* Reset forced desktop styles */
    html body .navbar-expand-lg .navbar-nav {
        flex-direction: column !important;
    }

    html body .navbar-expand-lg .navbar-collapse {
        display: none !important;
    }

    html body .navbar-expand-lg .navbar-collapse.show {
        display: block !important;
    }

    html body .navbar-expand-lg .navbar-toggler {
        display: block !important;
    }

    /* Fix column layout on mobile - DISABLED TO FIX PRODUCT DISPLAY */
    /* html body .row {
        display: flex !important;
        flex-direction: column !important;
        margin-right: 0 !important;
        margin-left: 0 !important;
    } */

    /* Reset all column widths to full width on mobile */
    html body [class*="col-lg-"] {
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
        padding-right: 10px !important;
        padding-left: 10px !important;
    }

    /* Fix container padding and margins */
    html body .container,
    html body .container-fluid {
        padding: 10px !important;
        margin: 10px auto !important;
        width: calc(100% - 20px) !important;
        max-width: 100% !important;
    }

    /* Fix table overflow */
    html body .table-responsive {
        overflow-x: auto !important;
        display: block !important;
        width: 100% !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    /* Adjust table styles for mobile */
    html body table {
        min-width: 100% !important;
        margin-bottom: 15px !important;
    }
    
    /* Stack table cells on mobile for certain tables */
    html body .mobile-stack-table thead {
        display: none !important;
    }
    
    html body .mobile-stack-table tbody tr {
        display: block !important;
        border: 1px solid rgba(0, 255, 0, 0.3) !important;
        margin-bottom: 15px !important;
        padding: 8px !important;
    }
    
    html body .mobile-stack-table tbody td {
        display: block !important;
        text-align: right !important;
        padding: 8px !important;
        border-bottom: 1px solid rgba(0, 255, 0, 0.1) !important;
    }
    
    html body .mobile-stack-table tbody td:last-child {
        border-bottom: none !important;
    }
    
    html body .mobile-stack-table tbody td:before {
        content: attr(data-label) !important;
        float: left !important;
        font-weight: bold !important;
        color: rgba(0, 255, 0, 0.7) !important;
    }

    /* Ensure text doesn't overflow */
    html body .compact-title,
    html body h1, 
    html body h2, 
    html body h3, 
    html body h4, 
    html body h5, 
    html body h6,
    html body p,
    html body .card-title,
    html body .card-text,
    html body .message-content,
    html body .notification-content,
    html body .forum-post-content,
    html body .product-description,
    html body .comment-text,
    html body .order-details,
    html body .ticket-content,
    html body pre,
    html body code,
    html body blockquote,
    html body .text-content {
        overflow-wrap: break-word !important;
        word-wrap: break-word !important;
        word-break: break-word !important;
        hyphens: auto !important;
        max-width: 100% !important;
        white-space: normal !important;
    }
    
    /* Fix content overflow in messages section */
    .message-content {
        word-wrap: break-word;
        overflow-wrap: break-word;
        max-width: 100%;
        white-space: normal;
    }
    
    /* Article page mobile fixes */
    .art_card {
        margin: 0;
        border-radius: 8px;
        overflow: hidden;
    }
    
    /* Article page mobile/desktop menu visibility */
    /* Desktop sidebar (hide on mobile) */
    @media (max-width: 767px) {
        .desktop-sidebar {
            display: none !important;
        }
        
        /* Show mobile menu container */
        .mobile-menu-container {
            display: block !important;
        }
        
        /* Fix flex container on mobile */
        div[style="display: flex; gap: 20px;"] {
            display: block !important;
        }
        
        /* Make article card full width and fix overflow */
        .art_card, .mobile-article-card {
            width: 100% !important;
            margin: 0 !important;
            box-sizing: border-box !important;
            overflow: hidden !important;
            max-width: 100% !important;
        }
        
        /* Fix content overflow in card body */
        .art_card .card-body, .mobile-card-body {
            padding: 10px !important;
            width: 100% !important;
            max-width: 100% !important;
            box-sizing: border-box !important;
            overflow-wrap: break-word !important;
            word-wrap: break-word !important;
            overflow-x: hidden !important;
        }
        
        /* Fix product header and title */
        .product-header {
            width: 100% !important;
            box-sizing: border-box !important;
            padding: 0 !important;
        }
        
        .product-title {
            font-size: 18px !important;
            line-height: 1.3 !important;
            width: 100% !important;
            overflow-wrap: break-word !important;
            word-break: break-word !important;
        }
    }
    
    /* Mobile menu container (hide on desktop) */
    @media (min-width: 768px) {
        .mobile-menu-container {
            display: none !important;
        }
    }
    
    /* Force all content to fit within containers on mobile */
    @media (max-width: 767px) {
        /* Global mobile overflow fixes */
        * {
            max-width: 100% !important;
            box-sizing: border-box !important;
            overflow-wrap: break-word !important;
        }
        
        /* Ensure all divs contain their content */
        div {
            max-width: 100% !important;
            box-sizing: border-box !important;
            word-break: break-word !important;
        }
        
        /* Ensure all text elements wrap properly */
        p, h1, h2, h3, h4, h5, h6, span, a, label {
            max-width: 100% !important;
            overflow-wrap: break-word !important;
            word-break: break-word !important;
        }
        
        /* Additional mobile fixes for article page content */
        /* Product gallery and images */
        .product-gallery {
            width: 100% !important;
            box-sizing: border-box !important;
            overflow: hidden !important;
            padding: 0 !important;
        }
        
        .product-image-container {
            width: 100% !important;
            max-width: 300px !important;
            margin: 0 auto 15px auto !important;
            height: auto !important;
            min-height: 200px !important;
        }
        
        /* Vendor info section */
        .vendor-info {
            width: 100% !important;
            box-sizing: border-box !important;
            flex-direction: column !important;
            padding: 10px 0 !important;
        }
        
        .unified-meta {
            width: 100% !important;
            box-sizing: border-box !important;
            flex-direction: column !important;
            align-items: flex-start !important;
            margin-bottom: 15px !important;
        }
        
        .vendor-box {
            width: 100% !important;
            margin-right: 0 !important;
            margin-bottom: 10px !important;
            box-sizing: border-box !important;
        }
        
        /* Price section */
        .price-section {
            width: 100% !important;
            box-sizing: border-box !important;
            flex-direction: column !important;
        }
        
        .main-price {
            width: 100% !important;
            box-sizing: border-box !important;
            margin-bottom: 15px !important;
            text-align: center !important;
        }
        
        .crypto-prices {
            width: 100% !important;
            box-sizing: border-box !important;
        }
        
        /* Tables and data display */
        table, .ops-table {
            width: 100% !important;
            box-sizing: border-box !important;
            display: block !important;
            overflow-x: auto !important;
        }
        
        /* Form elements */
        form, .order-form {
            width: 100% !important;
            box-sizing: border-box !important;
        }
        
        input, select, textarea, .ops-input, .ops-select, .ops-textarea {
            width: 100% !important;
            box-sizing: border-box !important;
            max-width: 100% !important;
        }
        
        /* Description content */
        .product-info {
            width: 100% !important;
            box-sizing: border-box !important;
            overflow-wrap: break-word !important;
        }
        
        .description-content {
            width: 100% !important;
            box-sizing: border-box !important;
            overflow-wrap: break-word !important;
            word-break: break-word !important;
            white-space: pre-wrap !important;
        }
    }
    
    /* Fix the sidebar menu - make it full width and non-sticky */
    body div[style="width: 280px; flex-shrink: 0; position: sticky; top: 0; height: calc(100vh - 60px); overflow-y: auto;"] {
        width: 100% !important;
        max-width: 100% !important;
        position: static !important;
        height: auto !important;
        margin-bottom: 15px;
        display: block !important;
        float: none !important;
        overflow: visible !important;
    }
    
    /* Ensure main content div is full width and stacks properly */
    body div[style="flex: 1;"] {
        width: 100% !important;
        display: block !important;
        margin-top: 20px;
        float: none !important;
        clear: both !important;
        position: static !important;
        flex: none !important;
    }
    
    /* Product content layout */
    .product-content {
        display: flex;
        flex-direction: column;
    }
    
    /* Product gallery and image */
    .product-gallery {
        width: 100%;
        margin-bottom: 20px;
    }
    
    .main-image {
        width: 100%;
        display: flex;
        justify-content: center;
    }
    
    .product-image-container {
        width: 100% !important;
        max-width: 300px;
        height: auto !important;
        aspect-ratio: 1/1;
    }
    
    /* Product details section */
    .product-details {
        width: 100%;
    }
    
    /* Vendor info section */
    .vendor-info {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .unified-meta {
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
        gap: 8px;
        margin-bottom: 15px;
    }
    
    .vendor-box {
        width: 100%;
        margin-right: 0;
        margin-bottom: 10px;
    }
    
    .meta-item {
        width: 100%;
        box-sizing: border-box;
    }
    
    .vendor-actions {
        width: 100%;
        margin-top: 10px;
        justify-content: space-between;
    }
    
    .vendor-actions .ops-button {
        flex: 1;
        text-align: center;
        padding: 8px 5px;
        font-size: 14px;
    }
    
    /* Price section */
    .price-section {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .main-price {
        width: 100%;
        margin-bottom: 15px;
    }
    
    .price-usd {
        width: 100%;
        text-align: center;
        margin-bottom: 10px;
    }
    
    .crypto-prices {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 8px;
    }
    
    .crypto-price {
        width: 100%;
        justify-content: center;
    }
    
    /* Stock status and badges */
    .stock-status {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .status-badge,
    .escrow-badge,
    .product-type-badge {
        width: 100%;
        text-align: center;
        padding: 8px 0;
    }
    
    /* Form elements */
    .order-form .form-group {
        margin-bottom: 20px;
    }
    
    .order-form label {
        display: block;
        margin-bottom: 8px;
    }
    
    .order-form .ops-select,
    .order-form .ops-input,
    .order-form .ops-textarea {
        width: 100%;
        box-sizing: border-box;
    }
    
    /* Bulk pricing table */
    .bulk-pricing-section {
        margin: 20px 0;
    }
    
    .bulk-price-table {
        overflow-x: auto;
        margin-bottom: 20px;
    }
    
    .ops-table {
        min-width: 100%;
        width: 100%;
        font-size: 14px;
    }
    
    .ops-table th,
    .ops-table td {
        padding: 8px 5px;
        white-space: nowrap;
    }
    
    /* Total price container */
    .total-price-container {
        flex-direction: column;
        align-items: flex-start;
        padding: 15px 10px;
        margin-bottom: 15px;
    }
    
    .total-price-label,
    .total-price-value {
        width: 100%;
        text-align: center;
        margin-bottom: 5px;
    }
    
    /* Product description */
    .product-info {
        margin-top: 30px;
    }
    
    .info-title {
        font-size: 18px;
        margin-bottom: 15px;
    }
    
    .description-content {
        word-wrap: break-word;
        overflow-wrap: break-word;
        white-space: pre-wrap;
        font-size: 14px;
        line-height: 1.5;
    }
    
    /* Reviews button */
    .reviews-button-container {
        margin-top: 20px;
        text-align: center;
    }
    
    /* Article card body padding */
    .art_card .card-body {
        padding: 10px;
    }
    
    /* Product header */
    .product-header {
        padding: 0;
    }
    
    .product-title {
        font-size: 18px;
        line-height: 1.3;
        margin-bottom: 15px;
        word-break: break-word;
    }
    
    /* Alert messages */
    .cyber-alert {
        padding: 10px;
        font-size: 14px;
    }
    
    /* Purchase button */
    .ops-button.primary.full-width {
        padding: 12px;
        font-size: 16px;
        margin-top: 20px;
    }
    
    /* Fix content containers to prevent overflow */
    html body .content-container,
    html body .main-content,
    html body .card-body,
    html body .cyber-panel-body,
    html body .message-container,
    html body .message-box,
    html body .chat-container,
    html body .forum-post,
    html body .product-card,
    html body .order-card,
    html body .notification-card,
    html body .ticket-card,
    html body .comment-card {
        overflow-x: hidden !important;
        max-width: 100% !important;
        padding: 10px !important;
        box-sizing: border-box !important;
    }
    
    /* Fix message-specific styles */
    html body .message-container {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
    }
    
    html body .message-item {
        width: 100% !important;
        margin-bottom: 15px !important;
        box-sizing: border-box !important;
    }
    
    html body .message-content {
        padding: 10px !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
    }

    /* Fix dropdown menu positioning */
    html body .dropdown-menu {
        position: static !important;
        float: none !important;
        width: 100% !important;
        background-color: rgba(0, 0, 0, 0.8) !important;
        border: 1px solid rgba(0, 255, 0, 0.3) !important;
        margin: 5px 0 !important;
        padding: 10px !important;
    }
    
    /* Make dropdown items more tappable */
    html body .dropdown-item {
        padding: 12px 15px !important;
        color: #00ff00 !important;
        border-bottom: 1px solid rgba(0, 255, 0, 0.1) !important;
    }
    
    html body .dropdown-item:last-child {
        border-bottom: none !important;
    }
    
    /* Show dropdowns on tap for mobile */
    html body .dropdown-toggle:focus + .dropdown-menu,
    html body .dropdown-toggle:active + .dropdown-menu {
        display: block !important;
    }
    
    /* Balance display in dropdown */
    html body .balance-container {
        padding: 5px !important;
    }
    
    html body .balance-details {
        width: 100% !important;
    }
    
    html body .balance-row {
        margin-bottom: 8px !important;
    }

    /* Fix spacing between elements */
    html body .card,
    html body .cyber-panel,
    html body .form-group {
        margin-bottom: 15px !important;
    }
    
    /* Improve form elements on mobile */
    html body input[type="text"],
    html body input[type="email"],
    html body input[type="password"],
    html body input[type="number"],
    html body input[type="search"],
    html body input[type="tel"],
    html body input[type="url"],
    html body textarea,
    html body select {
        width: 100% !important;
        padding: 12px !important;
        font-size: 16px !important; /* Prevents iOS zoom on focus */
        margin-bottom: 10px !important;
        border: 1px solid rgba(0, 255, 0, 0.5) !important;
        background-color: rgba(0, 0, 0, 0.8) !important;
        color: #00ff00 !important;
    }
    
    /* Improve form layout */
    html body form .row {
        margin-bottom: 10px !important;
    }
    
    /* Make checkboxes and radio buttons more tappable */
    html body input[type="checkbox"],
    html body input[type="radio"] {
        width: 20px !important;
        height: 20px !important;
        margin-right: 10px !important;
    }
    
    html body label {
        display: block !important;
        margin-bottom: 5px !important;
        color: rgba(0, 255, 0, 0.8) !important;
    }

    /* Fix button layout */
    html body .btn-group,
    html body .action-buttons {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
    }

    html body .btn-group .btn,
    html body .action-buttons .btn,
    html body .action-buttons .cyber-btn {
        width: 100% !important;
        margin-right: 0 !important;
        margin-bottom: 10px !important;
    }

    /* Fix navbar toggler */
    html body .navbar-toggler {
        display: block !important;
        margin-left: auto !important;
    }

    /* Fix news ticker */
    html body .news-ticker-container {
        height: auto !important;
        padding: 10px 0 !important;
    }

    html body .news-ticker-content {
        white-space: normal !important;
        animation: none !important;
        padding: 5px 10px !important;
        display: block !important;
        text-align: center !important;
    }

    /* Fix forum specific styles */
    html body .forum-icon {
        width: 30px !important;
        height: 30px !important;
        font-size: 1rem !important;
    }

    html body .role-badge {
        display: inline-block !important;
        margin-top: 5px !important;
    }
    
    /* Additional forum fixes */
    html body .forum-container,
    html body .forum-topic,
    html body .forum-post,
    html body .forum-thread {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
        padding: 10px !important;
    }
    
    html body .forum-post-content {
        padding: 10px !important;
        border: 1px solid rgba(0, 255, 0, 0.2) !important;
        background-color: rgba(0, 0, 0, 0.3) !important;
        border-radius: 3px !important;
        margin: 5px 0 !important;
        overflow-x: hidden !important;
    }
    
    html body .forum-post-header {
        display: flex !important;
        flex-direction: column !important;
        margin-bottom: 10px !important;
    }
    
    html body .forum-post-meta {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 5px !important;
        margin-bottom: 5px !important;
    }
    
    html body .forum-post-actions {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 5px !important;
        margin-top: 10px !important;
    }
    
    html body .forum-user-info {
        display: flex !important;
        align-items: center !important;
        flex-wrap: wrap !important;
        gap: 5px !important;
        margin-bottom: 10px !important;
    }
}

    /* Fix media overflow */
    html body img,
    html body video,
    html body iframe,
    html body canvas,
    html body svg,
    html body embed,
    html body object {
        max-width: 100% !important;
        height: auto !important;
        display: block !important;
    }
    
    /* Fix pre and code blocks */
    html body pre,
    html body code {
        white-space: pre-wrap !important;
        max-width: 100% !important;
        overflow-x: auto !important;
        padding: 10px !important;
        background-color: rgba(0, 0, 0, 0.5) !important;
        border: 1px solid rgba(0, 255, 0, 0.2) !important;
        border-radius: 3px !important;
    }
    
    /* Fix long URLs and strings */
    html body a {
        word-break: break-all !important;
        display: inline-block !important;
        max-width: 100% !important;
    }
    
    /* Fix product listings */
    html body .product-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
    }
    
    html body .product-card {
        width: 100% !important;
        margin: 0 !important;
    }
    
    html body .product-image {
        max-width: 100% !important;
        height: auto !important;
    }
    
    html body .product-details {
        padding: 10px !important;
    }
    
    html body .product-price {
        font-size: 1.1rem !important;
        margin: 5px 0 !important;
    }
    
    /* Fix order pages */
    html body .order-details {
        padding: 10px !important;
        overflow-x: hidden !important;
    }
    
    html body .order-item {
        display: flex !important;
        flex-direction: column !important;
        margin-bottom: 15px !important;
        padding-bottom: 15px !important;
        border-bottom: 1px solid rgba(0, 255, 0, 0.2) !important;
    }
    
    html body .order-meta {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 10px !important;
        margin-bottom: 10px !important;
    }
    
    html body .order-actions {
        display: flex !important;
        flex-direction: column !important;
        gap: 10px !important;
        margin-top: 15px !important;
    }
    
    /* Fix horizontal scrolling in all content areas */
    html body .content-area,
    html body main,
    html body section,
    html body article,
    html body aside,
    html body .page-content {
        overflow-x: hidden !important;
        max-width: 100vw !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

/* Small mobile devices */
@media (max-width: 480px) {
    /* Even smaller padding for tiny screens */
    html body .container,
    html body .container-fluid {
        padding: 5px !important;
        margin: 5px auto !important;
        width: calc(100% - 10px) !important;
    }

    /* Reduce font sizes for very small screens */
    html body {
        font-size: 14px !important;
    }

    html body h1 { font-size: 1.8rem !important; }
    html body h2 { font-size: 1.5rem !important; }
    html body h3 { font-size: 1.3rem !important; }
    html body h4 { font-size: 1.1rem !important; }
    html body h5 { font-size: 1rem !important; }
    html body h6 { font-size: 0.9rem !important; }

    /* Adjust spacing */
    html body .card-body {
        padding: 10px !important;
    }

    /* Make buttons more tappable */
    html body .btn,
    html body .cyber-btn,
    html body .nav-link {
        padding: 12px 15px !important;
        margin-bottom: 8px !important;
    }
}
