/* 
 * Mobile-Responsive Design System
 * Ensures consistent mobile-friendly UI across all pages
 */

/* ========================================
   1. RESPONSIVE CARD SYSTEM
   ======================================== */

.card-mobile {
    margin-bottom: 1rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-mobile:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.card-mobile .card-header {
    padding: 0.75rem 1rem;
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.card-mobile .card-body {
    padding: 1rem;
}

.card-mobile .card-footer {
    padding: 0.75rem 1rem;
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
}

/* Mobile optimizations */
@media (max-width: 767.98px) {
    .card-mobile {
        margin-bottom: 0.75rem;
    }

    .card-mobile .card-header,
    .card-mobile .card-body,
    .card-mobile .card-footer {
        padding: 0.75rem;
    }

    .card-mobile .card-title {
        font-size: 1rem;
        margin-bottom: 0.5rem;
    }
}

/* ========================================
   2. RESPONSIVE GRID WRAPPER (Bootstrap 5)
   ======================================== */

.grid-to-cards {
    display: none; /* Hide on mobile, show cards */
}

.cards-view {
    display: block;
}

@media (min-width: 992px) {
    .grid-to-cards {
        display: block; /* Show grid on desktop */
    }

    .cards-view {
        display: none; /* Hide cards on desktop if grid is preferred */
    }

    /* Allow both if you want grid on desktop AND cards on mobile */
    .cards-view.show-on-all {
        display: block;
    }
}

/* ========================================
   3. MOBILE-FRIENDLY BUTTONS
   ======================================== */

@media (max-width: 767.98px) {
    /* Larger tap targets for mobile */
    .btn,
    .e-btn {
        min-height: 44px; /* iOS Human Interface Guidelines */
        padding: 0.5rem 1rem;
        font-size: 1rem;
    }

    .btn-sm,
    .e-btn.e-small {
        min-height: 38px;
        padding: 0.375rem 0.75rem;
        font-size: 0.875rem;
    }

    /* Full-width buttons on mobile */
    .btn-mobile-full {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    /* Stack button groups vertically on mobile */
    .btn-group {
        display: flex;
        flex-direction: column;
        width: 100%;
    }

    .btn-group .btn,
    .btn-group .e-btn {
        width: 100%;
        border-radius: 0.25rem !important;
        margin-bottom: 0.25rem;
    }

    .btn-group .btn:last-child,
    .btn-group .e-btn:last-child {
        margin-bottom: 0;
    }
}

/* ========================================
   4. RESPONSIVE TABLES (Fallback for legacy grids)
   ======================================== */

@media (max-width: 991.98px) {
    /* Make tables scroll horizontally on mobile */
    .table-responsive-mobile {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table-responsive-mobile table {
        min-width: 600px;
    }

    /* Alternate: Stack table rows as cards */
    .table-stacked {
        border: 0;
    }

    .table-stacked thead {
        display: none;
    }

    .table-stacked tbody tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid #dee2e6;
        border-radius: 0.25rem;
    }

    .table-stacked td {
        display: flex;
        justify-content: space-between;
        padding: 0.75rem;
        border: 0;
        border-bottom: 1px solid #dee2e6;
    }

    .table-stacked td:last-child {
        border-bottom: 0;
    }

    .table-stacked td::before {
        content: attr(data-label);
        font-weight: 600;
        margin-right: 1rem;
    }
}

/* ========================================
   5. SYNCFUSION GRID MOBILE OVERRIDES
   ======================================== */

@media (max-width: 767.98px) {
    /* Fix Syncfusion grid overflow issues */
    .e-grid {
        font-size: 0.875rem;
    }

    .e-grid .e-gridheader {
        font-size: 0.75rem;
    }

    .e-grid .e-gridcontent {
        overflow-x: auto;
    }

    /* Make pager more mobile-friendly */
    .e-pager {
        padding: 0.5rem 0.25rem;
    }

    .e-pager .e-pagercontainer {
        flex-wrap: wrap;
    }

    .e-pager .e-numericitem,
    .e-pager .e-prevpagedisabled,
    .e-pager .e-prevpage,
    .e-pager .e-nextpage,
    .e-pager .e-nextpagedisabled {
        min-width: 36px;
        min-height: 36px;
        padding: 0.25rem;
    }
}

/* ========================================
   6. FORM ELEMENTS MOBILE OPTIMIZATION
   ======================================== */

@media (max-width: 767.98px) {
    /* Larger input fields for easier typing */
    .form-control,
    .form-select,
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="date"],
    textarea,
    select {
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 44px;
        padding: 0.5rem 0.75rem;
    }

    /* Stack form labels and inputs */
    .form-group {
        margin-bottom: 1rem;
    }

    .form-label {
        margin-bottom: 0.5rem;
        font-weight: 500;
    }

    /* Full-width form controls on mobile */
    .form-control,
    .form-select {
        width: 100%;
    }
}

/* ========================================
   7. MODAL DIALOGS MOBILE OPTIMIZATION
   ======================================== */

@media (max-width: 767.98px) {
    /* Full-width modals on mobile */
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }

    .modal-content {
        border-radius: 0.25rem;
    }

    .modal-header {
        padding: 1rem;
    }

    .modal-body {
        padding: 1rem;
        max-height: calc(100vh - 200px);
        overflow-y: auto;
    }

    .modal-footer {
        padding: 0.75rem 1rem;
        flex-direction: column;
    }

    .modal-footer .btn {
        width: 100%;
        margin: 0.25rem 0;
    }

    /* Syncfusion Dialog */
    .e-dialog {
        width: calc(100vw - 1rem) !important;
        max-width: calc(100vw - 1rem) !important;
        margin: 0.5rem !important;
    }

    .e-dialog .e-dlg-content {
        max-height: calc(100vh - 200px);
        overflow-y: auto;
    }
}

/* ========================================
   8. NAVIGATION / SIDEBAR MOBILE
   ======================================== */

@media (max-width: 768.99px) {
    /* Ensure sidebar doesn't overlap content on mobile */
    #navigation-sidebar {
        position: fixed;
        z-index: 1000;
    }

    /* Overlay when sidebar is open */
    #overlay.overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }
}

/* ========================================
   9. UTILITY CLASSES
   ======================================== */

/* Responsive text sizes */
.text-responsive-sm {
    font-size: 0.875rem;
}

@media (max-width: 767.98px) {
    .text-responsive-sm {
        font-size: 0.75rem;
    }
}

/* Hide on mobile */
.d-mobile-none {
    display: block;
}

@media (max-width: 767.98px) {
    .d-mobile-none {
        display: none !important;
    }
}

/* Show only on mobile */
.d-mobile-only {
    display: none;
}

@media (max-width: 767.98px) {
    .d-mobile-only {
        display: block !important;
    }
}

/* Responsive spacing */
@media (max-width: 767.98px) {
    .p-mobile-2 {
        padding: 0.5rem !important;
    }

    .px-mobile-2 {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }

    .py-mobile-2 {
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }

    .m-mobile-2 {
        margin: 0.5rem !important;
    }

    .mx-mobile-2 {
        margin-left: 0.5rem !important;
        margin-right: 0.5rem !important;
    }

    .my-mobile-2 {
        margin-top: 0.5rem !important;
        margin-bottom: 0.5rem !important;
    }
}

/* ========================================
   10. RESPONSIVE CONTAINERS
   ======================================== */

.container-mobile {
    width: 100%;
    padding-right: 15px;
    padding-left: 15px;
    margin-right: auto;
    margin-left: auto;
}

@media (min-width: 576px) {
    .container-mobile {
        max-width: 540px;
    }
}

@media (min-width: 768px) {
    .container-mobile {
        max-width: 720px;
    }
}

@media (min-width: 992px) {
    .container-mobile {
        max-width: 960px;
    }
}

@media (min-width: 1200px) {
    .container-mobile {
        max-width: 1140px;
    }
}

/* ========================================
   11. TOUCH-FRIENDLY INTERACTIVE ELEMENTS
   ======================================== */

@media (hover: none) and (pointer: coarse) {
    /* Touch devices */
    .clickable,
    .card:hover,
    a:not(.btn),
    button:not(.btn) {
        cursor: pointer;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }

    /* Remove hover effects on touch devices */
    .card:hover {
        transform: none;
        box-shadow: none;
    }

    /* Add active state for touch feedback */
    .clickable:active,
    .card:active,
    a:active,
    button:active {
        opacity: 0.7;
    }
}

/* ========================================
   12. PRINT STYLES (Bonus)
   ======================================== */

@media print {
    /* Hide navigation, buttons, etc. when printing */
    nav,
    .btn,
    .e-btn,
    .no-print {
        display: none !important;
    }

    /* Expand all cards/grids */
    .card {
        page-break-inside: avoid;
        border: 1px solid #dee2e6;
    }

    /* Remove shadows and transitions */
    * {
        box-shadow: none !important;
        transition: none !important;
    }
}
