/**
 * SKJ General Administration - Global Mobile-First UX/UI System
 * Version: 1.0.0
 * Author: Antigravity
 * Target: Smartphones & Tablets (<= 768px) with zero desktop regressions
 */

:root {
    --mobile-nav-height: 62px;
    --mobile-safe-bottom: env(safe-area-inset-bottom, 0px);
    --mobile-primary: #696cff;
    --mobile-primary-rgb: 105, 108, 255;
}

/* ============================================================
   1. GLOBAL MOBILE LAYOUT ADJUSTMENTS
   ============================================================ */
@media (max-width: 768px) {
    /* Safe padding so fixed bottom bar never hides content */
    body.has-bottom-nav {
        padding-bottom: calc(var(--mobile-nav-height) + var(--mobile-safe-bottom) + 16px) !important;
    }

    /* Container Spacing on Mobile */
    .container-xxl, .container-fluid, .container {
        padding-left: 0.85rem !important;
        padding-right: 0.85rem !important;
    }

    .content-wrapper {
        padding-bottom: 0.5rem !important;
    }

    /* Navbar streamline for mobile */
    #layout-navbar {
        margin: 0.5rem 0.85rem 1rem 0.85rem !important;
        border-radius: 14px !important;
        padding: 0.4rem 0.75rem !important;
    }

    /* Typography & Hierarchy */
    h1, .h1 { font-size: 1.5rem !important; }
    h2, .h2 { font-size: 1.35rem !important; }
    h3, .h3 { font-size: 1.2rem !important; }
    h4, .h4 { font-size: 1.05rem !important; }
    h5, .h5 { font-size: 0.95rem !important; }

    /* Compact Cards */
    .card {
        border-radius: 16px !important;
        margin-bottom: 1rem !important;
    }

    .card .card-body {
        padding: 1.15rem 1rem !important;
    }

    .card .card-header {
        padding: 1rem 1rem 0.5rem 1rem !important;
    }
}

/* ============================================================
   2. APP-LIKE BOTTOM NAVIGATION BAR
   ============================================================ */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--mobile-nav-height) + var(--mobile-safe-bottom));
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(18px) saturate(180%);
    -webkit-backdrop-filter: blur(18px) saturate(180%);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 -4px 25px rgba(105, 108, 255, 0.08), 0 -1px 3px rgba(0, 0, 0, 0.03);
    display: flex;
    align-items: flex-start;
    justify-content: space-around;
    padding-top: 6px;
    padding-bottom: var(--mobile-safe-bottom);
    z-index: 1040;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Hide on Desktop and Laptops */
@media (min-width: 769px) {
    .mobile-bottom-nav {
        display: none !important;
    }
}

/* Auto-hide when keyboard is open or modal requires full focus */
.mobile-bottom-nav.hide-nav,
body.keyboard-open .mobile-bottom-nav,
body.modal-open .mobile-bottom-nav {
    transform: translateY(110%);
}

.nav-item-mobile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none !important;
    color: #8592a3;
    font-size: 0.7rem;
    font-weight: 500;
    min-width: 58px;
    padding: 4px 6px;
    border-radius: 12px;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.nav-item-mobile i {
    font-size: 1.45rem;
    margin-bottom: 2px;
    transition: transform 0.2s ease, color 0.2s ease;
}

.nav-item-mobile.active {
    color: var(--mobile-primary) !important;
    font-weight: 700;
}

.nav-item-mobile.active i {
    transform: translateY(-2px) scale(1.1);
    color: var(--mobile-primary);
}

.nav-item-mobile.active::before {
    content: '';
    position: absolute;
    top: -4px;
    width: 20px;
    height: 3px;
    background: var(--mobile-primary);
    border-radius: 4px;
    box-shadow: 0 1px 6px rgba(var(--mobile-primary-rgb), 0.5);
}

.nav-item-mobile:active {
    transform: scale(0.92);
}

/* ============================================================
   3. SMART COMPACT PAGE HEADERS
   ============================================================ */
@media (max-width: 768px) {
    .page-header-premium,
    .page-header {
        border-radius: 16px !important;
        padding: 0 !important;
        margin-bottom: 1.15rem !important;
        box-shadow: 0 4px 18px rgba(0, 0, 0, 0.04) !important;
    }

    .page-header-premium .header-accent {
        width: 6px !important;
    }

    .page-header-premium .header-body {
        padding: 1.1rem 0.9rem !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.85rem !important;
    }

    .header-info {
        gap: 0.85rem !important;
        width: 100% !important;
        align-items: center !important;
    }

    .header-icon-box {
        width: 48px !important;
        height: 48px !important;
        border-radius: 14px !important;
        font-size: 1.5rem !important;
        flex-shrink: 0 !important;
    }

    .header-text h2 {
        font-size: 1.18rem !important;
        margin-bottom: 0.15rem !important;
        line-height: 1.3 !important;
    }

    .header-text p {
        font-size: 0.8rem !important;
        margin-bottom: 0 !important;
        opacity: 0.85;
    }

    .header-actions {
        width: 100% !important;
        text-align: left !important;
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
    }

    .header-actions .btn {
        flex: 1 1 auto !important;
        justify-content: center !important;
        display: inline-flex !important;
        align-items: center !important;
    }
}

/* ============================================================
   4. TOUCH ERGONOMICS & FORM USABILITY
   ============================================================ */
@media (max-width: 768px) {
    /* Minimum 44px touch targets */
    .form-control,
    .form-select,
    .input-group-text,
    .btn:not(.btn-sm):not(.btn-xs) {
        min-height: 46px !important;
        font-size: 16px !important; /* Prevents iOS auto-zoom on focus */
        border-radius: 10px !important;
    }

    /* Smarter small buttons */
    .btn-sm {
        min-height: 38px !important;
        font-size: 0.84rem !important;
        padding: 0.4rem 0.75rem !important;
        border-radius: 8px !important;
    }

    .btn-group {
        display: flex !important;
        width: 100% !important;
    }

    .btn-group .btn {
        flex: 1 !important;
    }

    /* Select2 & Flatpickr Mobile Tuning */
    .select2-container .select2-selection--single {
        height: 46px !important;
        border-radius: 10px !important;
        display: flex !important;
        align-items: center !important;
    }

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

    .flatpickr-calendar {
        max-width: 320px !important;
        margin: 0 auto !important;
        border-radius: 16px !important;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15) !important;
    }
}

/* ============================================================
   5. TOUCH-RESPONSIVE DATATABLES & LIST WRAPPERS
   ============================================================ */
.table-responsive-touch {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
    position: relative;
    margin-bottom: 1rem;
}

.table-responsive-touch::-webkit-scrollbar {
    height: 4px;
}

.table-responsive-touch::-webkit-scrollbar-thumb {
    background: rgba(105, 108, 255, 0.25);
    border-radius: 6px;
}

@media (max-width: 768px) {
    /* Compact Table cells on mobile */
    .table td, .table th {
        padding: 0.65rem 0.75rem !important;
        font-size: 0.84rem !important;
        vertical-align: middle !important;
    }

    /* Action buttons in tables stacked neatly */
    .table td .btn-group,
    .table td .action-btns {
        display: inline-flex !important;
        gap: 0.35rem !important;
        flex-wrap: nowrap !important;
    }

    /* DataTables length and filter on mobile */
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        text-align: left !important;
        margin-bottom: 0.75rem !important;
    }

    .dataTables_wrapper .dataTables_filter input {
        width: 100% !important;
        margin-left: 0 !important;
        min-height: 44px !important;
        font-size: 16px !important;
    }

    .dataTables_wrapper .dataTables_paginate {
        text-align: center !important;
        margin-top: 0.75rem !important;
        display: flex !important;
        justify-content: center !important;
    }
}

/* ============================================================
   6. MOBILE-FIRST MODALS (BOTTOM-SHEET READY)
   ============================================================ */
@media (max-width: 768px) {
    .modal-dialog {
        margin: 0.75rem !important;
        max-width: calc(100% - 1.5rem) !important;
    }

    .modal.bottom-sheet .modal-dialog {
        margin: 0 !important;
        max-width: 100% !important;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        transform: translate3d(0, 100%, 0);
        transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
    }

    .modal.bottom-sheet.show .modal-dialog {
        transform: translate3d(0, 0, 0) !important;
    }

    .modal.bottom-sheet .modal-content {
        border-bottom-left-radius: 0 !important;
        border-bottom-right-radius: 0 !important;
        border-top-left-radius: 22px !important;
        border-top-right-radius: 22px !important;
        border: none !important;
        max-height: 88vh !important;
        overflow-y: auto !important;
        box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.18) !important;
    }

    .modal-header {
        padding: 1.15rem 1.25rem 0.75rem !important;
    }

    .modal-body {
        padding: 1rem 1.25rem !important;
    }

    .modal-footer {
        padding: 0.85rem 1.25rem 1.25rem !important;
        flex-direction: column-reverse !important;
        gap: 0.5rem !important;
    }

    .modal-footer .btn {
        width: 100% !important;
        margin: 0 !important;
    }
}

