/**
 * Responsive Full Width Fix - KoreaSewa
 * =====================================
 * 
 * Comprehensive responsive fix ensuring:
 * - All pages use 100% width
 * - No horizontal scroll on any device
 * - Perfect mobile support
 * - Full screen utilization
 * - Professional responsive design
 * 
 * Author: KoreaSewa Development Team
 * Version: 1.0.0
 * Last Updated: 2025-01-27
 */

/* ============================================
   CRITICAL: 100% Width & No Horizontal Scroll
   ============================================ */
html,
body {
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
    position: relative !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

*,
*::before,
*::after {
    box-sizing: border-box !important;
    max-width: 100% !important;
}

/* ============================================
   Main Content - 100% Width
   ============================================ */
.main-content,
.content-wrapper,
#main-content {
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
    position: relative !important;
    margin: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

/* ============================================
   Containers - Responsive & Full Width
   ============================================ */
.container,
.container-fluid,
.container-sm,
.container-md,
.container-lg,
.container-xl,
.container-xxl {
    width: 100% !important;
    max-width: 100% !important;
    padding-left: clamp(0.75rem, 4vw, 1.5rem) !important;
    padding-right: clamp(0.75rem, 4vw, 1.5rem) !important;
    margin-left: auto !important;
    margin-right: auto !important;
    box-sizing: border-box !important;
}

/* Mobile: Reduced padding */
@media (max-width: 575.98px) {
    .container,
    .container-fluid,
    .container-sm,
    .container-md,
    .container-lg,
    .container-xl,
    .container-xxl {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
}

/* ============================================
   Rows & Columns - Responsive
   ============================================ */
.row {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    box-sizing: border-box !important;
}

[class*="col-"],
.col,
.col-auto,
.col-sm,
.col-md,
.col-lg,
.col-xl,
.col-xxl {
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
    box-sizing: border-box !important;
}

/* ============================================
   Responsive Media Elements
   ============================================ */
img,
video,
iframe,
embed,
object,
svg,
canvas {
    max-width: 100% !important;
    height: auto !important;
    display: block !important;
    box-sizing: border-box !important;
}

/* ============================================
   Tables - Responsive
   ============================================ */
table {
    width: 100% !important;
    max-width: 100% !important;
    border-collapse: collapse !important;
    box-sizing: border-box !important;
}

@media (max-width: 767.98px) {
    .table-responsive,
    table {
        display: block !important;
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: thin !important;
    }
    
    .table-responsive table,
    table {
        min-width: 100% !important;
    }
}

/* ============================================
   Forms - Responsive & Mobile-Friendly
   ============================================ */
form,
.form,
.form-group,
.form-control,
.form-select,
.input-group {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="tel"],
input[type="url"],
input[type="number"],
textarea,
select {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    font-size: 16px !important; /* Prevents iOS zoom */
}

/* ============================================
   Buttons - Responsive & Touch-Friendly
   ============================================ */
button,
.btn,
a.btn,
input[type="button"],
input[type="submit"],
input[type="reset"] {
    min-height: 44px !important; /* WCAG 2.1 AA compliant */
    min-width: 44px !important;
    touch-action: manipulation !important;
    box-sizing: border-box !important;
    white-space: normal !important;
}

@media (max-width: 767.98px) {
    button,
    .btn,
    a.btn {
        min-height: 48px !important; /* Comfortable on mobile */
        padding: 0.75rem 1rem !important;
        font-size: 16px !important; /* Prevents iOS zoom */
    }
    
    /* Full-width buttons on mobile for better UX */
    .btn-mobile-full,
    .mobile-full-width {
        width: 100% !important;
        display: block !important;
    }
}

/* ============================================
   Cards & Sections - Responsive
   ============================================ */
.card,
.section,
.section-header,
.section-content {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* ============================================
   Grid Systems - Responsive
   ============================================ */
.grid,
.grid-container,
[class*="grid-"] {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* ============================================
   Navigation - Responsive
   ============================================ */
nav,
.nav,
.navbar,
.navbar-nav,
.nav-menu {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* ============================================
   Sidebar - Responsive
   ============================================ */
@media (max-width: 991.98px) {
    .sidebar,
    .koreasewa-sidebar,
    [class*="sidebar"] {
        width: 100% !important;
        max-width: 100vw !important;
    }
}

/* ============================================
   Modals & Overlays - Responsive
   ============================================ */
.modal,
.modal-dialog,
.modal-content {
    width: 100% !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
}

@media (max-width: 575.98px) {
    .modal-dialog {
        margin: 0 !important;
        max-width: 100% !important;
    }
    
    .modal-content {
        border-radius: 0 !important;
        min-height: 100vh !important;
    }
}

/* ============================================
   Header - Responsive
   ============================================ */
header,
.header,
.koreasewa-header {
    width: 100% !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
}

/* ============================================
   Footer - Responsive
   ============================================ */
footer,
.footer,
.koreasewa-footer {
    width: 100% !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
}

/* ============================================
   Utility Classes - Full Width
   ============================================ */
.w-100,
.full-width,
.full-width-mobile {
    width: 100% !important;
    max-width: 100% !important;
}

@media (max-width: 767.98px) {
    .mobile-full-width,
    .mobile-w-100 {
        width: 100% !important;
        max-width: 100% !important;
        display: block !important;
    }
}

/* ============================================
   Prevent Overflow Issues
   ============================================ */
* {
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
}

/* Long URLs and text */
a,
p,
span,
div,
h1, h2, h3, h4, h5, h6 {
    word-break: break-word !important;
    overflow-wrap: break-word !important;
}

/* ============================================
   Mobile-Specific Fixes
   ============================================ */
@media (max-width: 767.98px) {
    /* Stack flex items on mobile */
    .d-flex,
    .flex-row {
        flex-direction: column !important;
    }
    
    /* Full width on mobile */
    .col-md-6,
    .col-lg-4,
    .col-lg-6,
    .col-xl-4,
    .col-xl-6 {
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
    }
    
    /* Remove negative margins that cause overflow */
    .row {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    /* Fix padding issues */
    [class*="col-"] {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
}

/* ============================================
   Extra Small Devices (0-575px)
   ============================================ */
@media (max-width: 575.98px) {
    /* Even more compact on small devices */
    .container,
    .container-fluid {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }
    
    /* Smaller text on very small screens */
    h1 { font-size: clamp(1.5rem, 5vw, 2rem) !important; }
    h2 { font-size: clamp(1.25rem, 4vw, 1.75rem) !important; }
    h3 { font-size: clamp(1.125rem, 3.5vw, 1.5rem) !important; }
    h4 { font-size: clamp(1rem, 3vw, 1.25rem) !important; }
    h5 { font-size: clamp(0.875rem, 2.5vw, 1.125rem) !important; }
    h6 { font-size: clamp(0.75rem, 2vw, 1rem) !important; }
}

/* ============================================
   Tablet Devices (768px - 991px)
   ============================================ */
@media (min-width: 768px) and (max-width: 991.98px) {
    .container {
        max-width: 100% !important;
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
}

/* ============================================
   Desktop Devices (992px+)
   ============================================ */
@media (min-width: 992px) {
    .container {
        max-width: 1200px !important; /* Standard desktop max-width */
        margin-left: auto !important;
        margin-right: auto !important;
    }
}

/* ============================================
   Large Desktop (1200px+)
   ============================================ */
@media (min-width: 1200px) {
    .container {
        max-width: 1400px !important; /* Larger max-width for big screens */
    }
}

/* ============================================
   Print Styles - Full Width
   ============================================ */
@media print {
    * {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    html,
    body {
        width: 100% !important;
        overflow: visible !important;
    }
}

