/* ============================================================
   MichPOS - Mobile Responsive CSS v1.0
   ============================================================ 
   Breakpoints:
   - Desktop: > 1024px (default styles)
   - Tablet: 768px - 1024px
   - Mobile: < 768px
   ============================================================ */

/* ============================================================
   GLOBAL MOBILE FIXES
   ============================================================ */

/* Prevent horizontal scroll */
html,
body {
    overflow-x: hidden !important;
    max-width: 100vw !important;
}

/* Ensure proper box sizing */
*,
*::before,
*::after {
    box-sizing: border-box !important;
}

/* Touch-friendly minimum sizes */
.btn,
button,
[type="button"],
[type="submit"] {
    min-height: 44px !important;
    min-width: 44px !important;
}

/* ============================================================
   TABLET BREAKPOINT (≤ 1024px)
   ============================================================ */
@media screen and (max-width: 1024px) {

    /* Reduce padding */
    .content-wrapper {
        padding: 10px !important;
    }

    .box-body {
        padding: 16px !important;
    }

    /* Sidebar width reduction */
    .sidebar-mini .side-bar {
        width: 200px !important;
    }

    /* Tables - horizontal scroll */
    .table-responsive {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .table {
        min-width: 600px !important;
    }
}

/* ============================================================
   MOBILE BREAKPOINT (≤ 768px)
   ============================================================ */
@media screen and (max-width: 768px) {

    /* ========== SIDEBAR ========== */
    .sidebar-mini .side-bar,
    .main-sidebar,
    aside.side-bar {
        position: fixed !important;
        left: -280px !important;
        width: 280px !important;
        height: 100vh !important;
        z-index: 9999 !important;
        transition: left 0.3s ease !important;
        background: white !important;
        box-shadow: 2px 0 15px rgba(0, 0, 0, 0.15) !important;
    }

    .sidebar-mini .side-bar.mobile-open,
    .main-sidebar.mobile-open,
    aside.side-bar.mobile-open {
        left: 0 !important;
    }

    /* Sidebar overlay */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 9998;
    }

    .sidebar-overlay.active {
        display: block;
    }

    /* ========== MAIN CONTENT ========== */
    .content-wrapper,
    .main-content,
    .wrapper {
        margin-left: 0 !important;
        padding: 8px !important;
        width: 100% !important;
    }

    /* ========== HEADER ========== */
    .thetop,
    .main-header,
    header {
        padding: 8px 12px !important;
    }

    .thetop>div:first-child {
        flex-wrap: wrap !important;
    }

    /* Mobile menu toggle button */
    .mobile-menu-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        background: var(--pos-primary-subtle, #EEF2FF) !important;
        border: none !important;
        border-radius: 10px !important;
        cursor: pointer;
        margin-right: 10px;
    }

    .mobile-menu-toggle i {
        font-size: 20px;
        color: var(--pos-primary, #4F46E5);
    }

    /* Hide desktop-only header items */
    .thetop .hidden-mobile,
    .hide-on-mobile {
        display: none !important;
    }

    /* ========== FORMS ========== */
    .form-group {
        margin-bottom: 16px !important;
    }

    .form-control {
        height: 48px !important;
        font-size: 16px !important;
        /* Prevents iOS zoom */
        padding: 0 14px !important;
    }

    select.form-control {
        height: 48px !important;
    }

    textarea.form-control {
        min-height: 100px !important;
    }

    /* Stack form columns */
    .row .col-md-6,
    .row .col-md-4,
    .row .col-md-3,
    .row .col-lg-6,
    .row .col-lg-4,
    .row .col-lg-3 {
        width: 100% !important;
        flex: 0 0 100% !important;
        max-width: 100% !important;
        padding-left: 8px !important;
        padding-right: 8px !important;
    }

    /* ========== BUTTONS ========== */
    .btn {
        padding: 12px 16px !important;
        font-size: 14px !important;
        width: 100% !important;
        margin-bottom: 8px !important;
    }

    .btn-group {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
    }

    .btn-group .btn {
        border-radius: 10px !important;
        margin: 4px 0 !important;
    }

    /* Inline buttons stay inline */
    .btn-inline-group {
        display: flex !important;
        flex-direction: row !important;
        gap: 8px !important;
    }

    .btn-inline-group .btn {
        flex: 1 !important;
        width: auto !important;
    }

    /* ========== TABLES ========== */
    .table-responsive {
        margin: 0 -8px !important;
        padding: 0 8px !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .table {
        font-size: 12px !important;
    }

    .table th,
    .table td {
        padding: 8px 6px !important;
        white-space: nowrap !important;
    }

    /* Hide less important columns on mobile */
    .table .hide-mobile {
        display: none !important;
    }

    /* ========== MODALS ========== */
    .modal-dialog {
        margin: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
        height: 100% !important;
    }

    .modal-content {
        border-radius: 0 !important;
        height: 100% !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .modal-body {
        flex: 1 !important;
        overflow-y: auto !important;
        padding: 16px !important;
    }

    .modal-header,
    .modal-footer {
        padding: 12px 16px !important;
    }

    /* ========== BOXES/CARDS ========== */
    .box {
        border-radius: 12px !important;
        margin-bottom: 16px !important;
    }

    .box-header {
        padding: 12px 16px !important;
    }

    .box-body {
        padding: 12px !important;
    }

    .box-footer {
        padding: 12px 16px !important;
    }

    /* ========== DASHBOARD ========== */
    .info-box {
        margin-bottom: 12px !important;
    }

    .info-box-icon {
        width: 50px !important;
        height: 50px !important;
        line-height: 50px !important;
        font-size: 20px !important;
    }

    .info-box-content {
        margin-left: 60px !important;
    }

    .info-box-number {
        font-size: 18px !important;
    }

    /* ========== SELECT2 ========== */
    .select2-container {
        width: 100% !important;
    }

    .select2-container--default .select2-selection--single {
        height: 48px !important;
        padding-top: 10px !important;
    }

    /* ========== POS SPECIFIC ========== */
    .pos-form-actions {
        flex-wrap: wrap !important;
    }

    .pos-form-actions .btn {
        flex: 1 1 45% !important;
        margin: 4px !important;
    }

    /* Product grid on mobile */
    .pos-product-list {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }

    .pos-product-item {
        padding: 8px !important;
    }

    /* Cart section */
    .pos-cart {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        max-height: 50vh !important;
        z-index: 999 !important;
        background: white !important;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1) !important;
        border-radius: 16px 16px 0 0 !important;
        transition: transform 0.3s ease !important;
    }

    .pos-cart.minimized {
        transform: translateY(calc(100% - 60px)) !important;
    }

    /* ========== DATEPICKER ========== */
    .daterangepicker {
        width: 100% !important;
        left: 0 !important;
        right: 0 !important;
    }

    .daterangepicker .calendar {
        max-width: 100% !important;
    }

    /* ========== UTILITY CLASSES ========== */
    .desktop-only {
        display: none !important;
    }

    .mobile-only {
        display: block !important;
    }

    .text-center-mobile {
        text-align: center !important;
    }

    .full-width-mobile {
        width: 100% !important;
    }
}

/* ============================================================
   SMALL MOBILE (≤ 480px)
   ============================================================ */
@media screen and (max-width: 480px) {

    /* Even smaller text */
    body {
        font-size: 14px !important;
    }

    .box-title {
        font-size: 14px !important;
    }

    /* Single column product grid */
    .pos-product-list {
        grid-template-columns: 1fr !important;
    }

    /* Smaller info boxes */
    .info-box-icon {
        width: 40px !important;
        height: 40px !important;
        line-height: 40px !important;
        font-size: 16px !important;
    }

    .info-box-content {
        margin-left: 50px !important;
    }

    .info-box-number {
        font-size: 16px !important;
    }
}

/* ============================================================
   LANDSCAPE MOBILE
   ============================================================ */
@media screen and (max-width: 896px) and (orientation: landscape) {
    .pos-cart {
        max-height: 40vh !important;
    }

    .modal-dialog {
        max-height: 90vh !important;
    }
}

/* ============================================================
   DESKTOP UTILITY CLASSES
   ============================================================ */
@media screen and (min-width: 769px) {
    .mobile-only {
        display: none !important;
    }

    .mobile-menu-toggle {
        display: none !important;
    }
}

/* ============================================================
   TOUCH IMPROVEMENTS
   ============================================================ */
@media (hover: none) and (pointer: coarse) {

    /* Remove hover effects that don't work on touch */
    .btn:hover {
        transform: none !important;
    }

    /* Make clickable areas larger */
    .dropdown-menu>li>a {
        padding: 12px 16px !important;
    }

    /* Better scrolling */
    .table-responsive,
    .modal-body,
    .box-body {
        -webkit-overflow-scrolling: touch !important;
    }
}