/**
 * Mobile-Friendly CSS Framework
 * Version: 1.0.0
 * Description: Reusable mobile-responsive styles for all pages
 * Usage: Add <link href="{{ asset('assets/dist/css/mobile-friendly.css') }}" rel="stylesheet"> to your page
 */

/* ========================================
   1. BASE MOBILE OPTIMIZATIONS
   ======================================== */

/* Prevent horizontal scroll */
body {
    overflow-x: hidden;
}

/* Responsive viewport meta should be: 
   <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
*/

/* ========================================
   2. TOUCH-FRIENDLY FORM ELEMENTS
   ======================================== */

/* Form Controls - Touch Optimized */
.mobile-friendly .form-control,
.mobile-friendly .custom-select,
.mobile-friendly select.form-control {
    min-height: 48px;
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 12px 16px;
    border-radius: 6px;
}

/* Form Labels */
.mobile-friendly .form-group label,
.mobile-friendly label {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
}

/* Form Group Spacing */
.mobile-friendly .form-group {
    margin-bottom: 1rem;
}

/* Textarea */
.mobile-friendly textarea.form-control {
    min-height: 100px;
}

/* ========================================
   3. TOUCH-FRIENDLY BUTTONS
   ======================================== */

/* Button Base */
.mobile-friendly .btn {
    min-height: 48px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 6px;
    padding: 12px 24px;
    transition: all 0.3s ease;
}

/* Button Active State - Touch Feedback */
.mobile-friendly .btn:active {
    transform: scale(0.98);
}

/* Button Disabled State */
.mobile-friendly .btn:disabled {
    cursor: not-allowed;
    opacity: 0.65;
}

/* Small Buttons for Mobile */
@media (max-width: 767.98px) {
    .mobile-friendly .btn-sm {
        min-height: 40px;
        font-size: 14px;
        padding: 8px 16px;
    }
}

/* ========================================
   4. RESPONSIVE TABLES
   ======================================== */

/* Table Wrapper for Horizontal Scroll */
.mobile-friendly .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Table Mobile Optimization */
@media (max-width: 767.98px) {
    .mobile-friendly table {
        font-size: 14px;
    }

    .mobile-friendly table th,
    .mobile-friendly table td {
        padding: 8px 4px;
        white-space: nowrap;
    }

    /* Stack table on very small screens */
    .mobile-friendly .table-stack-mobile thead {
        display: none;
    }

    .mobile-friendly .table-stack-mobile tbody tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid #dee2e6;
        border-radius: 6px;
    }

    .mobile-friendly .table-stack-mobile tbody td {
        display: block;
        text-align: right;
        padding: 8px 12px;
        border: none;
        border-bottom: 1px solid #dee2e6;
    }

    .mobile-friendly .table-stack-mobile tbody td:before {
        content: attr(data-label);
        float: left;
        font-weight: 600;
    }

    .mobile-friendly .table-stack-mobile tbody td:last-child {
        border-bottom: none;
    }
}

/* ========================================
   5. RESPONSIVE CARDS
   ======================================== */

/* Card Spacing */
.mobile-friendly .card {
    margin-bottom: 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.mobile-friendly .card-body {
    padding: 1.25rem;
}

@media (max-width: 767.98px) {
    .mobile-friendly .card-body {
        padding: 1rem;
    }
}

/* ========================================
   6. RESPONSIVE MODALS
   ======================================== */

/* Modal Optimization for Mobile */
@media (max-width: 767.98px) {
    .mobile-friendly .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }

    .mobile-friendly .modal-content {
        border-radius: 8px;
    }

    .mobile-friendly .modal-header,
    .mobile-friendly .modal-body,
    .mobile-friendly .modal-footer {
        padding: 1rem;
    }

    .mobile-friendly .modal-title {
        font-size: 1.25rem;
    }
}

/* ========================================
   7. RESPONSIVE NAVIGATION
   ======================================== */

/* Navbar Mobile */
@media (max-width: 991.98px) {
    .mobile-friendly .navbar-collapse {
        max-height: calc(100vh - 60px);
        overflow-y: auto;
    }
}

/* ========================================
   8. FOCUS STATES - ACCESSIBILITY
   ======================================== */

/* Form Focus States */
.mobile-friendly .form-control:focus,
.mobile-friendly .custom-select:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
    outline: none;
}

/* Button Focus States */
.mobile-friendly .btn:focus {
    outline: none;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* ========================================
   9. SELECT2 MOBILE OPTIMIZATION
   ======================================== */

/* Select2 Container */
.mobile-friendly .select2-container {
    width: 100% !important;
}

.mobile-friendly .select2-container .select2-selection--single {
    min-height: 48px !important;
    padding: 10px 16px !important;
    border-radius: 6px !important;
}

.mobile-friendly
    .select2-container--default
    .select2-selection--single
    .select2-selection__rendered {
    line-height: 28px !important;
    font-size: 16px !important;
}

.mobile-friendly
    .select2-container--default
    .select2-selection--single
    .select2-selection__arrow {
    height: 46px !important;
}

/* Select2 Dropdown Mobile */
@media (max-width: 767.98px) {
    .mobile-friendly .select2-dropdown {
        font-size: 16px;
    }

    .mobile-friendly .select2-results__option {
        padding: 12px 16px;
    }
}

/* ========================================
   10. DATATABLE MOBILE OPTIMIZATION
   ======================================== */

/* DataTable Wrapper */
.mobile-friendly .dataTables_wrapper {
    overflow-x: auto;
}

/* DataTable Controls */
@media (max-width: 767.98px) {
    .mobile-friendly .dataTables_length,
    .mobile-friendly .dataTables_filter {
        text-align: left;
        margin-bottom: 1rem;
    }

    .mobile-friendly .dataTables_filter input {
        width: 100%;
        margin-left: 0;
        margin-top: 0.5rem;
    }

    .mobile-friendly .dataTables_info,
    .mobile-friendly .dataTables_paginate {
        text-align: center;
        margin-top: 1rem;
    }
}

/* ========================================
   11. RESPONSIVE GRID UTILITIES
   ======================================== */

/* Mobile Padding Utilities */
@media (max-width: 767.98px) {
    .mobile-friendly .mobile-p-1 {
        padding: 0.5rem !important;
    }
    .mobile-friendly .mobile-p-2 {
        padding: 1rem !important;
    }
    .mobile-friendly .mobile-p-3 {
        padding: 1.5rem !important;
    }

    .mobile-friendly .mobile-px-1 {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }
    .mobile-friendly .mobile-px-2 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    .mobile-friendly .mobile-py-1 {
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }
    .mobile-friendly .mobile-py-2 {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }

    .mobile-friendly .mobile-m-1 {
        margin: 0.5rem !important;
    }
    .mobile-friendly .mobile-m-2 {
        margin: 1rem !important;
    }

    .mobile-friendly .mobile-mt-1 {
        margin-top: 0.5rem !important;
    }
    .mobile-friendly .mobile-mt-2 {
        margin-top: 1rem !important;
    }
    .mobile-friendly .mobile-mt-3 {
        margin-top: 1.5rem !important;
    }

    .mobile-friendly .mobile-mb-1 {
        margin-bottom: 0.5rem !important;
    }
    .mobile-friendly .mobile-mb-2 {
        margin-bottom: 1rem !important;
    }
    .mobile-friendly .mobile-mb-3 {
        margin-bottom: 1.5rem !important;
    }
}

/* ========================================
   12. RESPONSIVE TEXT UTILITIES
   ======================================== */

/* Text Size Adjustments */
@media (max-width: 767.98px) {
    .mobile-friendly h1 {
        font-size: 1.75rem;
    }
    .mobile-friendly h2 {
        font-size: 1.5rem;
    }
    .mobile-friendly h3 {
        font-size: 1.25rem;
    }
    .mobile-friendly h4 {
        font-size: 1.1rem;
    }
    .mobile-friendly h5 {
        font-size: 1rem;
    }
    .mobile-friendly h6 {
        font-size: 0.9rem;
    }

    .mobile-friendly .mobile-text-sm {
        font-size: 0.875rem !important;
    }
    .mobile-friendly .mobile-text-xs {
        font-size: 0.75rem !important;
    }
}

/* ========================================
   13. RESPONSIVE IMAGES
   ======================================== */

/* Responsive Images */
.mobile-friendly img {
    max-width: 100%;
    height: auto;
}

.mobile-friendly .img-responsive {
    width: 100%;
    height: auto;
}

/* ========================================
   14. SCROLLBAR CUSTOMIZATION
   ======================================== */

/* Custom Scrollbar for Better Mobile Experience */
.mobile-friendly .custom-scrollbar::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.mobile-friendly .custom-scrollbar::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.mobile-friendly .custom-scrollbar::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

.mobile-friendly .custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ========================================
   15. MOBILE-SPECIFIC UTILITIES
   ======================================== */

/* Hide on Mobile */
@media (max-width: 767.98px) {
    .mobile-friendly .hide-mobile {
        display: none !important;
    }
}

/* Show only on Mobile */
.mobile-friendly .show-mobile {
    display: none !important;
}

@media (max-width: 767.98px) {
    .mobile-friendly .show-mobile {
        display: block !important;
    }

    .mobile-friendly .show-mobile-inline {
        display: inline !important;
    }

    .mobile-friendly .show-mobile-flex {
        display: flex !important;
    }
}

/* Full Width on Mobile */
@media (max-width: 767.98px) {
    .mobile-friendly .mobile-full-width {
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* ========================================
   16. LANDSCAPE MOBILE OPTIMIZATION
   ======================================== */

@media (max-height: 600px) and (orientation: landscape) {
    .mobile-friendly .form-group {
        margin-bottom: 0.5rem;
    }

    .mobile-friendly .card-body {
        padding: 0.75rem;
    }

    .mobile-friendly h1 {
        font-size: 1.5rem;
    }
    .mobile-friendly h2 {
        font-size: 1.25rem;
    }
    .mobile-friendly h3 {
        font-size: 1.1rem;
    }
}

/* ========================================
   17. SMALL MOBILE DEVICES (< 375px)
   ======================================== */

@media (max-width: 374.98px) {
    .mobile-friendly .form-control,
    .mobile-friendly .custom-select,
    .mobile-friendly .btn {
        min-height: 44px;
        font-size: 15px;
    }

    .mobile-friendly .card-body {
        padding: 0.75rem;
    }
}

/* ========================================
   18. TOUCH ACTION OPTIMIZATION
   ======================================== */

/* Improve touch scrolling */
.mobile-friendly .touch-scroll {
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
}

/* Prevent double-tap zoom on buttons */
.mobile-friendly .btn,
.mobile-friendly a,
.mobile-friendly button {
    touch-action: manipulation;
}

/* ========================================
   19. LOADING STATES
   ======================================== */

/* Loading Spinner for Mobile */
.mobile-friendly .mobile-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.mobile-friendly .mobile-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: mobile-spin 1s linear infinite;
}

@keyframes mobile-spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* ========================================
   20. PRINT OPTIMIZATION
   ======================================== */

@media print {
    .mobile-friendly .hide-print {
        display: none !important;
    }

    .mobile-friendly .show-print {
        display: block !important;
    }
}

/* ========================================
   END OF MOBILE-FRIENDLY CSS
   ======================================== */
