/* Mobile Responsive Improvements for T-Line BOM App */

/* Mobile-first approach with progressive enhancement */

/* Base mobile styles (up to 767px) */
@media (max-width: 767px) {
    /* Navbar improvements */
    .navbar {
        padding: 0.5rem 1rem;
        height: 56px;
        min-height: 56px;
    }
    
    .navbar-brand {
        font-size: 1.1rem;
    }
    
    .navbar-toggler {
        border: 1px solid rgba(255, 255, 255, 0.3);
        padding: 4px 8px;
    }
    
    /* Content wrapper mobile adjustments */
    .content-wrapper {
        margin-top: 56px;
        flex-direction: column;
    }
    
    /* Main content area */
    .main-content {
        padding: 1rem 0.5rem !important;
        margin-left: 0 !important;
    }
    
    /* Hide sidebar by default on mobile */
    .sidebar {
        position: fixed;
        top: 56px;
        left: 0;
        height: calc(100vh - 56px);
        z-index: 1040;
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
        width: 280px;
        border-right: none;
        box-shadow: none;
    }
    
    /* Show sidebar when active */
    .sidebar.show {
        transform: translateX(0);
        box-shadow: 2px 0 10px rgba(0,0,0,0.3);
    }
    
    /* Mobile overlay */
    .mobile-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1039;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }
    
    .mobile-overlay.show {
        opacity: 1;
        visibility: visible;
    }
    
    /* Cards mobile optimization */
    .card {
        margin-bottom: 1rem;
        border-radius: 12px !important;
    }
    
    .card-body {
        padding: 1rem !important;
    }
    
    /* Button mobile optimization */
    .btn {
        padding: 8px 16px;
        font-size: 0.9rem;
        min-height: 44px; /* Touch-friendly minimum */
    }
    
    .btn-group {
        flex-direction: column;
        width: 100%;
    }
    
    .btn-group .btn {
        border-radius: 6px !important;
        margin-bottom: 0.25rem;
    }
    
    /* Form mobile optimization */
    .form-control, .form-select {
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 44px;
        padding: 8px 12px;
    }
    
    .form-label {
        font-weight: 600;
        margin-bottom: 0.25rem;
    }
    
    /* Table mobile optimization */
    .table-responsive {
        border-radius: 12px;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    }
    
    .table {
        font-size: 0.85rem;
    }
    
    .table th,
    .table td {
        padding: 0.5rem 0.25rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 150px;
    }
    
    /* Stack table actions vertically on mobile */
    .table .btn-group {
        flex-direction: column;
    }
    
    .table .btn-group .btn {
        margin-bottom: 2px;
        font-size: 0.75rem;
        padding: 4px 8px;
        border-radius: 4px !important;
    }
    
    /* Navigation improvements */
    .nav-tabs {
        flex-wrap: wrap;
        border-bottom: none;
    }
    
    .nav-tabs .nav-link {
        font-size: 0.9rem;
        padding: 0.5rem 0.75rem;
        margin-right: 0.25rem;
        margin-bottom: 0.25rem;
    }
    
    /* Footer mobile */
    .footer {
        padding: 1rem;
        text-align: center;
        font-size: 0.85rem;
    }
    
    /* Dashboard cards mobile layout */
    .dashboard-stats .col-lg-3,
    .dashboard-stats .col-md-6 {
        margin-bottom: 1rem;
    }
    
    /* Modal mobile optimization */
    .modal-dialog {
        margin: 1rem 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    .modal-content {
        border-radius: 12px;
    }
    
    /* Dropdown mobile optimization */
    .dropdown-menu {
        font-size: 0.9rem;
        min-width: 200px;
    }
    
    .dropdown-item {
        padding: 0.5rem 1rem;
        white-space: nowrap;
    }
    
    /* Hide some verbose text on mobile */
    .mobile-hide {
        display: none !important;
    }
    
    /* Show mobile-only elements */
    .mobile-show {
        display: block !important;
    }
    
    /* Breadcrumb mobile */
    .breadcrumb {
        font-size: 0.85rem;
        padding: 0.5rem;
        background: rgba(255, 255, 255, 0.1);
        margin-bottom: 1rem;
    }
    
    /* Page headers mobile */
    .page-header h1 {
        font-size: 1.5rem;
        margin-bottom: 0.5rem;
    }
    
    .page-header .btn-toolbar {
        margin-top: 0.5rem;
    }
    
    .page-header .btn-toolbar .btn {
        margin-right: 0.25rem;
        margin-bottom: 0.25rem;
    }
}

/* Tablet styles (768px to 991px) */
@media (min-width: 768px) and (max-width: 991px) {
    .sidebar {
        width: 200px;
    }
    
    .main-content {
        margin-left: 200px;
        padding: 1.5rem;
    }
    
    .table th,
    .table td {
        padding: 0.5rem;
    }
    
    .card-body {
        padding: 1.25rem;
    }
}

/* Large mobile/small tablet (576px to 767px) */
@media (min-width: 576px) and (max-width: 767px) {
    .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .main-content {
        padding: 1rem !important;
    }
    
    .table th,
    .table td {
        max-width: 200px;
        padding: 0.5rem;
    }
}

/* Extra small mobile (up to 575px) */
@media (max-width: 575px) {
    .container-fluid {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    
    .main-content {
        padding: 0.5rem !important;
    }
    
    .card-header {
        padding: 0.75rem;
        font-size: 0.9rem;
    }
    
    .table-responsive {
        font-size: 0.8rem;
    }
    
    .btn {
        font-size: 0.85rem;
        padding: 6px 12px;
    }
    
    .btn-sm {
        font-size: 0.75rem;
        padding: 4px 8px;
    }
}

/* Touch improvements for all mobile devices */
@media (pointer: coarse) {
    .btn, .nav-link, .dropdown-item, .list-group-item {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    .table .btn {
        min-height: 36px;
    }
}

/* Landscape phone adjustments */
@media (max-width: 767px) and (orientation: landscape) {
    .sidebar {
        width: 240px;
    }
    
    .navbar {
        height: 50px;
        min-height: 50px;
    }
    
    .content-wrapper {
        margin-top: 50px;
    }
    
    .sidebar {
        top: 50px;
        height: calc(100vh - 50px);
    }
}

/* High DPI display improvements */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .navbar, .sidebar, .card {
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
    }
}