/* 
 * Mobile Responsive Styles for SOLIBRA Portal
 * Enhances mobile usability without affecting desktop experience
 */

/* Base mobile optimizations */
@media (max-width: 991.98px) {
    
    /* ==== NAVIGATION FIXES ==== */
    
    /* Hide horizontal navigation menu on mobile */
    .horizontal-menu .bottom-navbar {
        display: none;
    }
    
    /* Mobile navigation toggle */
    .navbar-toggler {
        display: block !important;
        background: transparent;
        border: 1px solid rgba(0,0,0,.1);
        border-radius: .25rem;
        padding: .25rem .5rem;
    }
    
    /* Mobile menu dropdown */
    .horizontal-menu-mobile {
        display: block;
        background: #fff;
        box-shadow: 0 2px 4px rgba(0,0,0,.1);
        border-top: 1px solid #eee;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        z-index: 1000;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease-in-out;
    }
    
    .horizontal-menu-mobile.show {
        max-height: 500px;
    }
    
    .horizontal-menu-mobile .nav-item {
        border-bottom: 1px solid #eee;
    }
    
    .horizontal-menu-mobile .nav-link {
        padding: 15px 20px;
        color: #333;
        display: block;
        text-decoration: none;
    }
    
    .horizontal-menu-mobile .nav-link:hover {
        background-color: #9d3a3d;
        color: white;
    }
    
    /* ==== LAYOUT FIXES ==== */
    
    /* Page title responsive */
    .page-title h6 {
        font-size: 1.5rem;
        margin-bottom: 1rem;
    }
    
    /* Content wrapper padding */
    .content-wrapper {
        padding: 1rem;
    }
    
    /* ==== CARD FIXES ==== */
    
    /* Dashboard cards mobile stacking */
    .grid-margin {
        margin-bottom: 1.5rem;
    }
    
    .stretch-card .card {
        height: auto;
        min-height: 120px;
    }
    
    .stretch-card .card-body {
        padding: 1rem;
    }
    
    .stretch-card .card-body h2 {
        font-size: 1.5rem;
        margin-bottom: 0.5rem;
    }
    
    .stretch-card .card-body .card-title {
        font-size: 0.9rem;
        line-height: 1.2;
    }
    
    /* Icon adjustments for mobile */
    .icon-lg {
        font-size: 2rem !important;
        margin-right: 1rem !important;
        margin-bottom: 0.5rem !important;
    }
    
    /* ==== TABLE FIXES ==== */
    
    /* Horizontal scroll for tables */
    .table-responsive {
        border: 1px solid #dee2e6;
        border-radius: 0.375rem;
    }
    
    .table-responsive table {
        margin-bottom: 0;
    }
    
    /* Table action buttons */
    .table .btn-sm {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
        margin: 0.1rem;
        min-width: 44px;
        min-height: 34px;
    }
    
    /* MVC Grid mobile optimization */
    .mvc-grid {
        overflow-x: auto;
    }
    
    .mvc-grid table {
        min-width: 700px;
    }
    
    /* ==== FORM FIXES ==== */
    
    /* Form groups mobile stacking */
    .form-group.row > .col {
        margin-bottom: 1rem;
    }
    
    /* Form controls touch friendly */
    .form-control {
        min-height: 44px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .btn:not(.btn-sm):not(.btn-lg) {
        min-height: 44px;
        padding: 0.5rem 1rem;
        font-size: 16px;
    }
    
    /* Select2 mobile optimization */
    .select2-container .select2-selection--single {
        height: 44px;
        line-height: 42px;
    }
    
    .select2-container--default .select2-selection--single .select2-selection__rendered {
        line-height: 42px;
    }
    
    /* ==== BUTTON FIXES ==== */
    
    /* Make small buttons touch-friendly */
    .btn-sm {
        min-height: 40px !important;
        min-width: 40px !important;
        font-size: 0.85rem !important;
        padding: 0.4rem 0.8rem !important;
    }
    
    /* Icon buttons */
    .btn i.mdi:only-child {
        font-size: 1.2rem;
    }
    
    /* Button groups mobile spacing */
    .btn-group-vertical .btn {
        margin-bottom: 0.5rem;
    }
    
    /* ==== MODAL FIXES ==== */
    
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    .modal-header {
        padding: 1rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .modal-footer {
        padding: 0.75rem 1rem;
        flex-wrap: wrap;
    }
    
    .modal-footer .btn {
        flex: 1;
        margin: 0.25rem 0.25rem 0 0;
    }
    
    /* ==== ALERT FIXES ==== */
    
    .custom-alert {
        margin: 0.5rem;
        border-radius: 0.375rem;
        font-size: 0.9rem;
    }
    
    .custom-alert .btn-close {
        padding: 1rem;
        font-size: 1.2rem;
    }
    
    /* ==== FOOTER FIXES ==== */
    
    .footer {
        padding: 1rem;
        text-align: center;
    }
    
    .footer .clearfix span {
        display: block;
        margin-bottom: 0.5rem;
    }
    
    /* ==== UTILITY CLASSES ==== */
    
    /* Mobile-specific display utilities */
    .mobile-hidden {
        display: none;
    }
    
    .mobile-visible {
        display: block;
    }
    
    /* Mobile text sizes */
    .mobile-text-sm {
        font-size: 0.8rem;
    }
    
    .mobile-text-lg {
        font-size: 1.2rem;
    }
    
    /* Mobile spacing */
    .mobile-p-1 { padding: 0.5rem; }
    .mobile-p-2 { padding: 1rem; }
    .mobile-m-1 { margin: 0.5rem; }
    .mobile-m-2 { margin: 1rem; }
    
    /* Mobile flex utilities */
    .mobile-flex-column {
        flex-direction: column;
    }
    
    .mobile-text-center {
        text-align: center;
    }
}

/* Tablet optimizations */
@media (max-width: 1199.98px) and (min-width: 992px) {
    
    /* Adjust card layout for tablets */
    .stretch-card .card-body .card-title {
        font-size: 0.95rem;
    }
    
    /* Table responsive for tablets */
    .table-responsive {
        font-size: 0.9rem;
    }
    
    /* Button adjustments for tablets */
    .btn-group .btn {
        font-size: 0.9rem;
    }
}

/* Extra small mobile devices */
@media (max-width: 575.98px) {
    
    /* Further reduce padding on very small screens */
    .content-wrapper {
        padding: 0.5rem;
    }
    
    .card-body {
        padding: 0.75rem;
    }
    
    /* Smaller text for very small screens */
    .card-title {
        font-size: 0.8rem;
    }
    
    .page-title h6 {
        font-size: 1.25rem;
    }
    
    /* Stack form elements more aggressively */
    .form-group.row {
        margin-bottom: 1rem;
    }
    
    /* Make modals full screen on very small devices */
    .modal-dialog {
        height: 100vh;
        margin: 0;
        max-width: 100%;
        max-height: 100%;
    }
    
    .modal-content {
        height: 100%;
        border-radius: 0;
    }
}

/* Landscape orientation adjustments */
@media screen and (orientation: landscape) and (max-height: 600px) {
    
    /* Reduce vertical padding in landscape */
    .content-wrapper {
        padding: 0.5rem 1rem;
    }
    
    .modal-dialog {
        margin: 0.25rem;
    }
    
    .card-body {
        padding: 0.75rem;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    
    /* Larger touch targets */
    .btn, .form-control, .nav-link, .dropdown-item {
        min-height: 44px;
    }
    
    /* Remove hover effects on touch devices */
    .btn:hover {
        transform: none;
    }
    
    /* Better spacing for touch */
    .nav-link {
        padding: 0.75rem 1rem;
    }
    
    .dropdown-item {
        padding: 0.75rem 1.5rem;
    }
}