/* Mobile Responsive Styles
 * This file contains generic rules to ensure the web application 
 * adapts to small screens without requiring blade file changes.
 */

@media screen and (max-width: 767px) {
    /* Set universal box-sizing on mobile so 100% width respects paddings */
    *, *:before, *:after {
        box-sizing: border-box !important;
        max-width: 100vw;
    }

    /* 1. Ensure DataTables are horizontally scrollable */
    .table-responsive,
    .dataTables_wrapper,
    table.dataTable {
        display: block !important;
        width: 100% !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Prevent table columns from squishing too much */
    .table td, .table th {
        white-space: nowrap;
    }

    /* 2. Adjust flex containers to wrap contents gracefully */
    .d-flex:not(.flex-nowrap, .align-items-center, .justify-content-between) {
        flex-wrap: wrap !important;
    }

    /* Specific fixes for common toolbars and headers */
    .card-header, 
    .toolbar,
    .page-title-wrapper {
        flex-direction: column !important;
        align-items: stretch !important;
        margin-bottom: 1rem;
    }
    
    .card-header > *, 
    .toolbar > *,
    .page-title-wrapper > * {
        margin-bottom: 0.5rem;
    }

    /* 3. Handle modal widths on mobile */
    .modal-dialog {
        max-width: 95% !important;
        margin: 1.75rem auto;
    }

    /* 4. Ensure inputs and form controls are touch-friendly */
    .form-control, .form-select {
        font-size: 16px !important; /* Prevents auto-zoom on iOS */
        width: 100% !important;
    }

    /* 5. Improve spacing inside cards */
    .card .card-body {
        padding: 1rem !important;
    }

    /* Dashboard specific fixes for statistic cards */
    .row-dashboard-statistics {
        flex-direction: column;
    }
    
    .col-dashboard-statistics {
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
    }
    
    .col-dashboard-statistics .tag {
        min-height: 100px;
        padding: 1.5rem !important;
    }

    /* 6. Fix any overflowing images or SVGs */
    img, svg {
        max-width: 100%;
    }

    /* 7. Adjust sidebar/menu if necessary */
    .theme-sidebar {
        width: 100% !important;
        max-width: 320px !important;
    }
    
    .theme-content {
        padding: 10px !important;
    }

    /* 8. Authentication / Login Page Fixes */
    .authentication-wrapper {
        padding: 0 1rem !important;
        height: auto !important;
        min-height: 100vh !important;
    }
    .authentication-wrapper .col-authentication {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 15px !important;
        flex: 0 0 100% !important;
    }
    .authentication-wrapper .authentication-detail {
        width: 100% !important;
        max-width: 100% !important;
        padding: 1rem !important;
    }
    .authentication-wrapper .authentication-detail .card {
        width: 100% !important;
        padding: 3rem 1.5rem 1.5rem !important;
        margin: 0 auto;
        overflow: visible !important;
    }

    /* 9. Pagination responsive support */
    .pagination, .inq-pagination, ul.pagination {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 5px !important;
        padding-left: 0 !important;
        width: 100% !important;
    }

    /* 10. Master Page Responsive Support */
    .col-master {
        width: 100% !important;
        flex: 0 0 50% !important;
        max-width: 50% !important;
    }
    
    ul.pagination > li, .pagination > li, .inq-pagination > li {
        margin: 0 !important;
        float: none !important;
        display: inline-flex !important;
    }
    
    ul.pagination > li > a, ul.pagination > li > span,
    .pagination > li > a, .pagination > li > span {
        width: 32px !important;
        height: 32px !important;
        line-height: 32px !important;
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-size: 13px !important;
    }
    .alert {
        word-break: break-word;
    }

    /* 10. Utilities */
    .w-100-mobile {
        width: 100% !important;
    }
    .mb-2-mobile {
        margin-bottom: 0.5rem !important;
    }
    
    /* 11. Fix Card Header Toolbar Wrap (Booking Inquiry) */
    .card-header .card-title.d-flex {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px !important;
    }
    .card-header .card-title.d-flex > div.d-flex.justify-content-end {
        width: 100% !important;
        justify-content: flex-start !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
    }
    .card-header .theme-table-search {
        flex-grow: 1;
        min-width: 120px;
    }
    .card-header .theme-table-search input {
        width: 100% !important;
    }
    
    /* Remove padding issues on body */
    body {
        padding: 0 !important;
        overflow-x: hidden !important;
        width: 100vw !important;
        max-width: 100%;
        position: relative;
    }
    
    html {
        overflow-x: hidden !important;
        width: 100vw !important;
        max-width: 100%;
    }
}

@media screen and (max-width: 1216px) {
    /* Mobile Top Header containing Logo and Menu Toggle */
    .mobile-top-header {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        background: #fff;
        z-index: 1030;
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        padding: 10px 15px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    }
    .mobile-top-header .mobile-logo {
        display: flex;
        align-items: center;
        text-decoration: none;
    }
    .mobile-top-header .mobile-logo img {
        width: 35px;
        margin-right: 10px;
    }
    .mobile-top-header .mobile-logo span {
        font-size: 1.25rem;
        font-weight: 700;
        color: #343434;
    }
    
    /* Override existing bottom-left toggle to be part of the header */
    .theme-menu-toggle-res {
        position: static !important;
        bottom: auto !important;
        left: auto !important;
        width: auto !important;
        height: auto !important;
        background-color: transparent !important;
        color: #343434 !important;
        border: none !important;
        padding: 5px !important;
        display: flex !important;
        align-items: center;
        justify-content: center;
    }
    
    .theme-menu-toggle-res svg {
        width: 28px;
        height: 28px;
    }
    
    /* Push the main layout down so header doesn't overlap content */
    .layout-wrapper {
        padding-top: 60px !important;
    }
}

/* For very small devices */
@media screen and (max-width: 480px) {
    h1, .h1 { font-size: 1.5rem !important; }
    h2, .h2 { font-size: 1.25rem !important; }
    h3, .h3 { font-size: 1.1rem !important; }
    
    .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
}
