/* FxPOS Mobile Responsive Improvements */

/* Base Mobile Styles */
@media (max-width: 768px) {
    /* Body and Layout */
    body {
        font-size: 14px;
        line-height: 1.4;
    }
    
    /* Sidebar Mobile Improvements */
    .sidenav {
        width: 280px !important;
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
    }
    
    .sidenav.show {
        transform: translateX(0);
    }
    
    /* Mobile Navigation Toggle */
    .mobile-nav-toggle {
        display: block !important;
        position: fixed;
        top: 15px;
        left: 15px;
        z-index: 9999;
        background: #344767;
        color: white;
        border: none;
        padding: 10px;
        border-radius: 8px;
        box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    }
    
    /* Mobile Header Improvements */
    .main-header {
        position: sticky;
        top: 0;
        z-index: 1030;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        border-bottom: 1px solid rgba(0, 0, 0, 0.1);
        padding: 0.5rem 1rem;
        min-height: 60px;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    }
    
    .navbar-brand {
        font-size: 1.1rem;
    }
    
    .navbar-nav .nav-item {
        margin: 0 0.25rem;
    }
    
    .navbar-nav .nav-link {
        padding: 0.5rem;
        border-radius: 6px;
    }
    
    /* Adjust content to account for sticky header */
    .content-wrapper {
        padding-top: 1rem;
    }
    
    /* Dark mode sticky header */
    @media (prefers-color-scheme: dark) {
        .main-header {
            background: rgba(33, 37, 41, 0.95);
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        }
    }
}
    
    /* Main Content Adjustments */
    .main-content {
        margin-left: 0 !important;
        padding: 60px 15px 15px 15px;
        width: 100% !important;
    }
    
    /* Cards and Boxes */
    .card, .box {
        margin-bottom: 15px;
        border-radius: 12px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    }
    
    .card-body, .box-body {
        padding: 15px;
    }
    
    /* Tables Mobile Responsive */
    .table-responsive {
        border: none;
        margin-bottom: 0;
    }
    
    .table {
        font-size: 12px;
    }
    
    .table th, .table td {
        padding: 8px 4px;
        white-space: nowrap;
    }
    
    /* Mobile Table Stack */
    .table-mobile-stack {
        display: block;
    }
    
    .table-mobile-stack thead {
        display: none;
    }
    
    .table-mobile-stack tbody,
    .table-mobile-stack tr,
    .table-mobile-stack td {
        display: block;
        width: 100%;
    }
    
    .table-mobile-stack tr {
        border: 1px solid #ddd;
        margin-bottom: 10px;
        padding: 10px;
        border-radius: 8px;
        background: white;
    }
    
    .table-mobile-stack td {
        text-align: left !important;
        padding: 5px 0;
        border: none;
    }
    
    .table-mobile-stack td:before {
        content: attr(data-label) ": ";
        font-weight: bold;
        display: inline-block;
        width: 100px;
    }
    
    /* Buttons Mobile */
    .btn {
        padding: 8px 16px;
        font-size: 14px;
        margin: 2px;
    }
    
    .btn-group {
        display: flex;
        flex-wrap: wrap;
        gap: 5px;
    }
    
    .btn-group .btn {
        flex: 1;
        min-width: 120px;
    }
    
    /* Forms Mobile */
    .form-group {
        margin-bottom: 15px;
    }
    
    .form-control {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px;
        border-radius: 8px;
    }
    
    .input-group {
        flex-wrap: wrap;
    }
    
    .input-group .form-control {
        min-width: 0;
        flex: 1 1 auto;
    }
    
    /* Modal Mobile */
    .modal-dialog {
        margin: 10px;
        max-width: calc(100% - 20px);
    }
    
    .modal-content {
        border-radius: 12px;
    }
    
    .modal-header {
        padding: 15px;
        border-bottom: 1px solid #dee2e6;
    }
    
    .modal-body {
        padding: 15px;
        max-height: 70vh;
        overflow-y: auto;
    }
    
    .modal-footer {
        padding: 15px;
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .modal-footer .btn {
        flex: 1;
        min-width: 120px;
    }
}

/* POS Layout Mobile Specific */
@media (max-width: 768px) {
    .pos-layout {
        padding: 0;
    }
    
    .pos-layout .main-content {
        padding: 10px;
    }
    
    /* Product Grid Mobile */
    .product_list {
        padding: 5px;
    }
    
    .product_box {
        margin-bottom: 8px;
        padding: 6px;
        min-height: 80px;
    }
    
    .product_box .image-container {
        height: 40px;
        margin-bottom: 5px;
    }
    
    .product_box .text {
        font-size: 11px;
        line-height: 12px;
        max-height: 24px;
        -webkit-line-clamp: 2;
    }
    
    /* POS Cart Mobile */
    .pos-cart {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        border-top: 2px solid #dee2e6;
        z-index: 1000;
        max-height: 50vh;
        overflow-y: auto;
    }
    
    .pos-cart-toggle {
        display: block;
        width: 100%;
        padding: 10px;
        background: #344767;
        color: white;
        border: none;
        font-weight: bold;
    }
    
    .pos-cart-content {
        display: none;
        padding: 15px;
    }
    
    .pos-cart.expanded .pos-cart-content {
        display: block;
    }
    
    /* POS Totals Mobile */
    .pos-total {
        padding: 6px 8px;
        margin: 2px;
        border-radius: 6px;
        background: #f8f9fa;
    }
    
    .pos-total span.number {
        font-size: 18px;
    }
    
    .pos-total span.text {
        width: auto;
        font-size: 12px;
    }
    
    /* POS Form Actions */
    .pos-form-actions {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        padding: 15px;
        border-top: 2px solid #dee2e6;
        z-index: 999;
    }
    
    .pos-form-actions .btn {
        width: 100%;
        margin-bottom: 10px;
        padding: 12px;
        font-size: 16px;
    }
}

/* Small Mobile Devices */
@media (max-width: 480px) {
    /* Extra small adjustments */
    .sidenav {
        width: 260px !important;
    }
    
    .main-content {
        padding: 50px 10px 10px 10px;
    }
    
    .card-body, .box-body {
        padding: 10px;
    }
    
    .table {
        font-size: 11px;
    }
    
    .btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .form-control {
        padding: 10px;
        font-size: 14px;
    }
    
    /* Product grid extra small */
    .product_box {
        padding: 4px;
        min-height: 70px;
    }
    
    .product_box .image-container {
        height: 35px;
    }
    
    .product_box .text {
        font-size: 10px;
        line-height: 11px;
    }
}

/* Landscape Mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .sidenav {
        width: 250px !important;
    }
    
    .main-content {
        padding: 50px 10px 10px 10px;
    }
    
    .pos-cart {
        max-height: 40vh;
    }
    
    .modal-body {
        max-height: 50vh;
    }
}

/* Touch Improvements */
@media (hover: none) and (pointer: coarse) {
    /* Touch-friendly sizing */
    .btn, .form-control, .nav-link {
        min-height: 44px;
    }
    
    .table td, .table th {
        min-height: 40px;
    }
    
    /* Remove hover effects on touch devices */
    .btn:hover, .nav-link:hover {
        transform: none;
        box-shadow: none;
    }
    
    /* Better touch targets */
    .product_box {
        min-height: 60px;
        touch-action: manipulation;
    }
    
    .sidebar-toggle, .mobile-nav-toggle {
        min-width: 44px;
        min-height: 44px;
    }
}

/* Dark Mode Mobile Adjustments */
@media (max-width: 768px) and (prefers-color-scheme: dark) {
    .main-content {
        background-color: #1a1a1a;
        color: #ffffff;
    }
    
    .card, .box {
        background-color: #2d2d2d;
        border-color: #404040;
    }
    
    .table {
        color: #ffffff;
    }
    
    .table th {
        border-color: #404040;
    }
    
    .form-control {
        background-color: #2d2d2d;
        border-color: #404040;
        color: #ffffff;
    }
}

/* Print Styles for Mobile */
@media print {
    .sidenav, .mobile-nav-toggle, .pos-form-actions {
        display: none !important;
    }
    
    .main-content {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }
    
    .table {
        font-size: 10px;
    }
    
    .card, .box {
        box-shadow: none;
        border: 1px solid #000;
    }
}

/* Accessibility Improvements */
@media (max-width: 768px) {
    /* Focus indicators */
    .btn:focus, .form-control:focus, .nav-link:focus {
        outline: 2px solid #007bff;
        outline-offset: 2px;
    }
    
    /* High contrast mode */
    @media (prefers-contrast: high) {
        .btn {
            border: 2px solid currentColor;
        }
        
        .card, .box {
            border: 2px solid #000;
        }
    }
    
    /* Reduced motion */
    @media (prefers-reduced-motion: reduce) {
        .sidenav, .modal, .btn {
            transition: none;
        }
    }
}