/* ============================================================
   RSK ERP – Complete Mobile Responsive System v2.0
   Only affects screens below 992px. Desktop completely unchanged.
   ============================================================ */

/* ============================================================
   MOBILE SIDEBAR – OFF-CANVAS DRAWER
   ============================================================ */
@media (max-width: 991.98px) {
    /* Hide sidebar completely on mobile */
    .main-sidebar {
        display: none !important;
    }

    body.sidebar-open .main-sidebar {
        left: 0 !important;
    }

    /* Mobile sidebar overlay backdrop */
    .mobile-sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0,0,0,0.45);
        z-index: 1049;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }

    body.sidebar-open .mobile-sidebar-overlay {
        opacity: 1;
        visibility: visible;
    }

    /* Sidebar menu items touch friendly */
    .main-sidebar .sidebar-nav li a {
        padding: 14px 18px !important;
        font-size: 15px !important;
        min-height: 48px !important;
        display: flex !important;
        align-items: center !important;
        gap: 12px !important;
    }

    .main-sidebar .sidebar-nav li a .fas,
    .main-sidebar .sidebar-nav li a .fa,
    .main-sidebar .sidebar-nav li a .far {
        font-size: 18px !important;
        width: 24px !important;
        text-align: center !important;
    }

    .main-sidebar .sidebar-nav .treeview-menu li a {
        padding: 12px 18px 12px 44px !important;
        font-size: 14px !important;
    }

    /* Sidebar brand on mobile */
    .main-sidebar .sidebar-brand {
        padding: 18px 16px !important;
        min-height: 64px !important;
    }

    .main-sidebar .sidebar-panel {
        padding: 14px 16px !important;
        margin: 8px 12px !important;
    }

    /* Remove sidebar collapse on mobile */
    body.sidebar-collapse .main-sidebar,
    body.sidebar-collapse .left-side {
        transform: none !important;
    }

    body.sidebar-collapse .content-wrapper,
    body.sidebar-collapse .main-footer {
        margin-left: 0 !important;
    }
}

/* ============================================================
   MOBILE HEADER – ULTRA COMPACT & SLIM
   ============================================================ */
@media (max-width: 991.98px) {
    /* Main header wrapper - hidden on mobile */
    .main-header {
        display: none !important;
    }

    /* Override erp-saas.css large rounded navbar */
    .main-header .navbar,
    .navbar.navbar-static-top {
        min-height: 35px !important;
        height: auto !important;
        margin-left: 0 !important;
        padding: 0 !important;
        border-radius: 10px !important;
        background: rgba(255, 255, 255, 0.96) !important;
        box-shadow: 0 1px 4px rgba(0,0,0,0.06) !important;
        backdrop-filter: blur(12px) !important;
        -webkit-backdrop-filter: blur(12px) !important;
    }

    .topbar-shell {
        padding: 4px 8px !important;
        min-height: 35px !important;
        height: auto !important;
        gap: 6px !important;
    }

    .topbar-left {
        gap: 5px !important;
        flex: 1 !important;
        min-width: 0 !important;
    }

    .topbar-right {
        gap: 3px !important;
        flex-shrink: 0 !important;
    }

    /* Ultra-compact hamburger button */
    .sidebar-toggle.saas-toggle {
        width: 30px !important;
        height: 30px !important;
        min-width: 30px !important;
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        border-radius: 7px !important;
        font-size: 14px !important;
        background: rgba(79,70,229,0.08) !important;
        border: none !important;
        color: var(--primary, #4f46e5) !important;
    }

    .topbar-context {
        min-width: 0 !important;
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
    }

    /* Hide "Workspace" kicker on mobile for extra slimness */
    .topbar-kicker {
        display: none !important;
    }

    .topbar-title {
        font-size: 12px !important;
        line-height: 1.15 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        max-width: 100% !important;
        margin: 0 !important;
        font-weight: 700 !important;
    }

    /* Hide desktop search on mobile */
    .topbar-search {
        display: none !important;
    }

    /* Hide ALL non-essential buttons in topbar-right on mobile */
    .topbar-right > *:not(ul.nav):not(a.btn.saas-primary-btn) {
        display: none !important;
    }

    /* Hide notifications inside the nav */
    .topbar-right .notifications-menu {
        display: none !important;
    }

    /* Keep marketing check-in button compact */
    .topbar-right > a.btn.saas-primary-btn {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        min-width: 30px !important;
        min-height: 30px !important;
        width: 30px !important;
        height: 30px !important;
        padding: 0 !important;
        font-size: 12px !important;
        border-radius: 7px !important;
    }

    /* Keep user menu visible */
    .topbar-right .user-menu {
        display: block !important;
    }

    /* Compact user menu */
    .topbar-right .user-menu > a {
        padding: 1px 3px !important;
        min-height: 30px !important;
        display: flex !important;
        align-items: center !important;
        gap: 4px !important;
    }

    /* Show user name on mobile */
    .topbar-right .user-menu span:not(.sr-only) {
        display: inline !important;
        font-size: 12px !important;
        font-weight: 600 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        max-width: 100px !important;
    }

    /* User avatar */
    .topbar-right .user-image,
    .topbar-right .sidebar-brand-mark {
        width: 24px !important;
        height: 24px !important;
        font-size: 10px !important;
        margin-right: 0 !important;
    }
}

/* ============================================================
   CONTENT WRAPPER & LAYOUT
   ============================================================ */
@media (max-width: 991.98px) {
    .content-wrapper {
        margin-left: 0 !important;
        padding-top: 0px !important;
        min-height: 100vh !important;
        width: 100% !important;
        overflow-x: hidden !important;
    }

    .content-wrapper .content {
        padding: 10px 10px !important;
    }

    .content-header {
        padding: 10px 10px !important;
        margin-bottom: 6px !important;
    }

    .content-header .saas-breadcrumbs {
        font-size: 11px !important;
        flex-wrap: wrap !important;
        gap: 3px !important;
    }

    .content-header .saas-breadcrumbs li {
        white-space: nowrap !important;
    }

    .content-header .saas-breadcrumbs li i {
        font-size: 10px !important;
    }

    /* Page title */
    .content-header h1,
    .saas-page-title h1 {
        font-size: 16px !important;
        margin-bottom: 6px !important;
        font-weight: 700 !important;
    }

    .content-header h1 small,
    .saas-page-title p {
        font-size: 12px !important;
        margin-top: 4px !important;
    }
}

/* ============================================================
   TABLE RESPONSIVENESS
   ============================================================ */
@media (max-width: 991.98px) {
    .table-responsive {
        border: 0 !important;
        border-radius: var(--radius-sm, 8px) !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        margin-bottom: 14px !important;
    }

    .table-responsive table {
        min-width: 600px !important;
        margin-bottom: 0 !important;
    }

    .table-responsive table th,
    .table-responsive table td {
        white-space: nowrap !important;
        font-size: 12px !important;
        padding: 8px 10px !important;
    }

    .table-responsive table th {
        position: sticky !important;
        top: 0 !important;
        z-index: 2 !important;
        background: var(--primary, #4f46e5) !important;
        color: #fff !important;
    }

    /* Alternative: Mobile cards for large tables */
    .mobile-cards .table-responsive table,
    .mobile-cards .table-responsive table thead,
    .mobile-cards .table-responsive table tbody,
    .mobile-cards .table-responsive table th,
    .mobile-cards .table-responsive table td,
    .mobile-cards .table-responsive table tr {
        display: block !important;
    }

    .mobile-cards .table-responsive table thead {
        display: none !important;
    }

    .mobile-cards .table-responsive table tr {
        margin-bottom: 10px !important;
        border: 1px solid #e2e8f0 !important;
        border-radius: var(--radius-md, 12px) !important;
        padding: 12px !important;
        background: #fff !important;
        box-shadow: 0 2px 6px rgba(0,0,0,0.04) !important;
    }

    .mobile-cards .table-responsive table td {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 6px 0 !important;
        border-bottom: 1px solid #f1f5f9 !important;
        white-space: normal !important;
        text-align: right !important;
        font-size: 13px !important;
    }

    .mobile-cards .table-responsive table td:last-child {
        border-bottom: none !important;
    }

    .mobile-cards .table-responsive table td::before {
        content: attr(data-label) !important;
        font-weight: 600 !important;
        color: #475569 !important;
        text-align: left !important;
        flex-shrink: 0 !important;
        margin-right: 12px !important;
    }

    /* DataTables mobile optimization */
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        float: none !important;
        width: 100% !important;
        margin-bottom: 8px !important;
    }

    .dataTables_wrapper .dataTables_filter input {
        width: 100% !important;
        min-height: 44px !important;
    }

    .dataTables_wrapper .dataTables_paginate {
        float: none !important;
        text-align: center !important;
        margin-top: 10px !important;
    }

    .dataTables_wrapper .row:first-child > [class*="col-"] {
        width: 100% !important;
        padding: 0 !important;
    }
}

/* ============================================================
   FORM OPTIMIZATION
   ============================================================ */
@media (max-width: 991.98px) {
    .form-group {
        margin-bottom: 14px !important;
    }

    .form-control,
    .select2-container--default .select2-selection--single,
    .select2-container--default .select2-selection--multiple,
    .input-group .form-control,
    .daterangepicker .input-mini,
    .bootstrap-datetimepicker-widget .form-control {
        min-height: 48px !important;
        font-size: 16px !important;
        padding: 10px 14px !important;
        border-radius: 10px !important;
    }

    /* Prevent iOS zoom on input focus */
    input[type="text"],
    input[type="number"],
    input[type="email"],
    input[type="tel"],
    input[type="search"],
    input[type="password"],
    textarea,
    select {
        font-size: 16px !important;
    }

    .select2-container--default .select2-selection--single .select2-selection__rendered {
        line-height: 28px !important;
    }

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

    .input-group-btn .btn {
        min-height: 48px !important;
        padding: 10px 14px !important;
    }

    .form-group label {
        font-size: 13px !important;
        margin-bottom: 5px !important;
        font-weight: 600 !important;
    }

    /* Checkboxes and radios */
    .checkbox-inline,
    .radio-inline {
        min-height: 44px !important;
        display: inline-flex !important;
        align-items: center !important;
        gap: 8px !important;
    }

    .icheckbox_square-blue,
    .iradio_square-blue {
        transform: scale(1.3) !important;
    }

    /* Date picker mobile */
    .daterangepicker {
        max-width: 100vw !important;
        left: 10px !important;
        right: 10px !important;
    }

    .daterangepicker .ranges,
    .daterangepicker .drp-calendar {
        width: 100% !important;
    }

    .daterangepicker .drp-calendar {
        max-width: 100% !important;
    }

    .daterangepicker .drp-calendar.left,
    .daterangepicker .drp-calendar.right {
        float: none !important;
    }

    /* Bootstrap datetimepicker */
    .bootstrap-datetimepicker-widget.dropdown-menu {
        width: 100% !important;
        max-width: 340px !important;
        left: 10px !important;
        right: 10px !important;
    }

    /* textarea */
    textarea.form-control {
        min-height: 80px !important;
    }
}

/* ============================================================
   BUTTON IMPROVEMENTS
   ============================================================ */
@media (max-width: 991.98px) {
    .btn {
        min-height: 44px !important;
        min-width: 44px !important;
        padding: 10px 16px !important;
        font-size: 14px !important;
        border-radius: 10px !important;
    }

    .btn-xs {
        min-height: 36px !important;
        min-width: 36px !important;
        padding: 6px 10px !important;
        font-size: 12px !important;
    }

    .btn-sm {
        min-height: 40px !important;
        min-width: 40px !important;
        padding: 8px 14px !important;
        font-size: 13px !important;
    }

    .btn-lg {
        min-height: 52px !important;
        padding: 14px 24px !important;
        font-size: 16px !important;
    }

    /* Full-width action buttons on mobile */
    .box-footer .btn,
    .modal-footer .btn,
    .form-group .btn[type="submit"] {
        min-height: 48px !important;
    }

    .box-footer .btn + .btn,
    .modal-footer .btn + .btn {
        margin-left: 8px !important;
    }

    /* Action button groups */
    .btn-group .btn {
        min-height: 44px !important;
    }

    /* DataTables buttons */
    .dt-buttons .btn {
        min-height: 40px !important;
        padding: 8px 12px !important;
    }

    /* Full width buttons in forms */
    .box-footer .btn-primary,
    .box-footer .btn-success,
    .modal-footer .btn-primary,
    .modal-footer .btn-success {
        width: 100% !important;
    }
}

/* ============================================================
   DASHBOARD RESPONSIVENESS
   ============================================================ */
@media (max-width: 991.98px) {
    .info-box,
    .small-box {
        margin-bottom: 10px !important;
    }

    .info-box-icon {
        width: 50px !important;
        height: 50px !important;
        font-size: 22px !important;
    }

    .info-box-content {
        padding: 10px 12px !important;
    }

    .info-box-text,
    .info-box-number {
        font-size: 13px !important;
    }

    .info-box-number {
        font-size: 18px !important;
    }

    .small-box .inner {
        padding: 12px !important;
    }

    .small-box .inner h3 {
        font-size: 22px !important;
    }

    .small-box .inner p {
        font-size: 12px !important;
    }

    .small-box .icon {
        font-size: 50px !important;
    }

    /* Dashboard cards stack */
    .content .row > [class*="col-"] {
        width: 100% !important;
    }

    /* 2 columns on medium mobile for stats */
    @media (min-width: 480px) {
        .content .row > .col-xs-6,
        .content .row > .col-sm-6 {
            width: 50% !important;
        }
    }
}

/* ============================================================
   BOX / CARD OPTIMIZATION
   ============================================================ */
@media (max-width: 991.98px) {
    .box {
        border-radius: var(--radius-sm, 10px) !important;
        margin-bottom: 12px !important;
        box-shadow: 0 1px 6px rgba(0,0,0,0.05) !important;
    }

    .box-header {
        padding: 12px 14px !important;
    }

    .box-header .box-title {
        font-size: 14px !important;
    }

    .box-body {
        padding: 12px 14px !important;
    }

    .box-footer {
        padding: 10px 14px !important;
    }

    .box .overlay {
        border-radius: var(--radius-sm, 10px) !important;
    }

    /* Modal on mobile */
    .modal-dialog {
        margin: 8px !important;
    }

    .modal-content {
        border-radius: var(--radius-md, 12px) !important;
    }

    .modal-header {
        padding: 12px 14px !important;
    }

    .modal-body {
        padding: 12px 14px !important;
    }

    .modal-footer {
        padding: 10px 14px !important;
    }

    .modal-footer .btn {
        min-height: 48px !important;
    }
}

/* ============================================================
   GRID & LAYOUT
   ============================================================ */
@media (max-width: 991.98px) {
    .row {
        margin-left: -8px !important;
        margin-right: -8px !important;
    }

    .col-xs-1, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6,
    .col-xs-7, .col-xs-8, .col-xs-9, .col-xs-10, .col-xs-11, .col-xs-12,
    .col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6,
    .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12,
    .col-md-1, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6,
    .col-md-7, .col-md-8, .col-md-9, .col-md-10, .col-md-11, .col-md-12,
    .col-lg-1, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6,
    .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-10, .col-lg-11, .col-lg-12 {
        padding-left: 8px !important;
        padding-right: 8px !important;
    }

    /* Full width on very small screens */
    .col-xs-6,
    .col-sm-4,
    .col-sm-3 {
        width: 100% !important;
    }

    /* 2 columns on medium mobile */
    .col-xs-6 {
        width: 50% !important;
    }

    .col-xs-12 {
        width: 100% !important;
    }
}

/* ============================================================
   SPECIFIC BREAKPOINTS
   ============================================================ */

/* 320px - Extra small */
@media (max-width: 320px) {
    .topbar-title {
        max-width: 80px !important;
        font-size: 12px !important;
    }

    .main-sidebar {
        width: 260px !important;
        left: -260px !important;
    }

    .content-wrapper .content {
        padding: 8px 6px !important;
    }

    .box-body {
        padding: 10px 10px !important;
    }

    .main-header .navbar,
    .navbar.navbar-static-top {
        border-radius: 10px !important;
    }

    .topbar-shell {
        padding: 4px 8px !important;
    }
}

/* 360px - Small mobile */
@media (min-width: 321px) and (max-width: 360px) {
    .topbar-title {
        max-width: 100px !important;
    }

    .main-header .navbar,
    .navbar.navbar-static-top {
        border-radius: 10px !important;
    }
}

/* 375px - iPhone standard */
@media (min-width: 361px) and (max-width: 390px) {
    .topbar-title {
        max-width: 120px !important;
    }

    .main-header .navbar,
    .navbar.navbar-static-top {
        border-radius: 10px !important;
    }
}

/* 414px - iPhone Plus / Pro Max */
@media (min-width: 391px) and (max-width: 480px) {
    .topbar-title {
        max-width: 150px !important;
    }

    .col-xs-6 {
        width: 50% !important;
    }

    .main-header .navbar,
    .navbar.navbar-static-top {
        border-radius: 12px !important;
    }
}

/* 480px - Large mobile */
@media (min-width: 481px) and (max-width: 576px) {
    .topbar-title {
        max-width: 200px !important;
    }

    .col-xs-6,
    .col-sm-6 {
        width: 50% !important;
    }
}

/* 576px - Small tablets */
@media (min-width: 577px) and (max-width: 767px) {
    .col-xs-6,
    .col-sm-6 {
        width: 50% !important;
    }

    .col-sm-4 {
        width: 50% !important;
    }
}

/* 768px - Tablets */
@media (min-width: 768px) and (max-width: 991px) {
    .main-sidebar {
        left: -260px !important;
    }

    body.sidebar-open .main-sidebar {
        left: 0 !important;
    }

    .content-wrapper {
        margin-left: 0 !important;
    }

    .col-sm-6 {
        width: 50% !important;
    }

    .col-sm-4 {
        width: 33.333333% !important;
    }

    .main-header .navbar,
    .navbar.navbar-static-top {
        border-radius: 14px !important;
    }
}

/* ============================================================
   TOUCH EXPERIENCE & SMOOTH SCROLLING
   ============================================================ */
@media (max-width: 991.98px) {
    html {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }

    body {
        overscroll-behavior-y: none;
        -webkit-touch-callout: none;
        touch-action: manipulation;
    }

    * {
        -webkit-tap-highlight-color: transparent;
    }

    a, button, .btn, .sidebar-toggle, .nav>li>a, .dropdown-toggle {
        touch-action: manipulation;
        -webkit-touch-callout: none;
    }

    /* Smooth scrolling for table containers */
    .table-responsive {
        scroll-behavior: smooth;
    }

    /* Better scroll indicators */
    .table-responsive::after {
        content: '';
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        width: 30px;
        background: linear-gradient(to right, transparent, rgba(0,0,0,0.03));
        pointer-events: none;
    }

    .table-responsive {
        position: relative;
    }

    /* Active press states for buttons */
    .btn:active,
    .sidebar-toggle.saas-toggle:active {
        transform: scale(0.97) !important;
    }
}

/* ============================================================
   PRINT – Ensure desktop print unchanged, mobile print works
   ============================================================ */
@media print {
    .mobile-sidebar-overlay {
        display: none !important;
    }

    .main-sidebar {
        position: absolute !important;
        left: 0 !important;
    }

    .content-wrapper {
        margin-left: 0 !important;
        padding-top: 0 !important;
    }

    .table-responsive {
        overflow: visible !important;
    }

    .table-responsive table {
        min-width: auto !important;
    }
}

/* ============================================================
   SELECT2 MOBILE
   ============================================================ */
@media (max-width: 991.98px) {
    .select2-container--open .select2-dropdown {
        border-radius: 0 0 10px 10px !important;
    }

    .select2-container--default .select2-results > .select2-results__options {
        max-height: 280px !important;
    }

    .select2-results__option {
        padding: 12px 14px !important;
        font-size: 15px !important;
    }
}

/* ============================================================
   DROPZONE / FILE UPLOAD MOBILE
   ============================================================ */
@media (max-width: 991.98px) {
    .dropzone {
        min-height: 100px !important;
        padding: 16px !important;
    }

    .dropzone .dz-message {
        font-size: 14px !important;
    }
}

/* ============================================================
   NOTIFICATIONS & TOAST MOBILE
   ============================================================ */
@media (max-width: 991.98px) {
    .toast {
        left: 10px !important;
        right: 10px !important;
        width: auto !important;
        min-width: auto !important;
    }

    .dropdown-menu {
        max-width: 100vw !important;
        border-radius: 12px !important;
    }

    .dropdown-menu-right {
        right: 4px !important;
    }

    .navbar-nav > .notifications-menu > .dropdown-menu {
        width: 100vw !important;
        left: 10px !important;
        right: 10px !important;
    }
}

/* ============================================================
   POS FORM ACTIONS MOBILE
   ============================================================ */
@media (max-width: 991.98px) {
    .pos-form-actions {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 1000 !important;
        padding: 10px !important;
        background: #fff !important;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.06) !important;
    }

    .pos-form-actions .btn {
        min-height: 48px !important;
    }
}

/* ============================================================
   WIZARD MOBILE
   ============================================================ */
@media (max-width: 991.98px) {
    .wizard > .steps > ul > li {
        width: 100% !important;
        float: none !important;
    }

    .wizard > .steps > ul > li > a {
        padding: 10px 12px !important;
        font-size: 13px !important;
    }
}

/* ============================================================
   NAV TABS MOBILE
   ============================================================ */
@media (max-width: 991.98px) {
    .nav-tabs {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        gap: 4px !important;
    }

    .nav-tabs > li {
        flex-shrink: 0 !important;
    }

    .nav-tabs > li > a {
        padding: 8px 12px !important;
        font-size: 13px !important;
        white-space: nowrap !important;
    }

    .nav-tabs-custom > .nav-tabs {
        padding: 8px 8px 0 !important;
    }
}

/* ============================================================
   SCROLL TO TOP MOBILE
   ============================================================ */
@media (max-width: 991.98px) {
    .scrolltop {
        bottom: 76px !important; /* Move up to prevent overlap with bottom nav */
        right: 16px !important;
    }

    .scrolltop .scroll.icon {
        width: 40px !important;
        height: 40px !important;
        font-size: 16px !important;
    }

    /* Padding offset for content wrapper to clear fixed bottom nav */
    .content-wrapper, 
    body:not(.sidebar-collapse) .content-wrapper,
    body.hold-transition .content-wrapper {
        padding-bottom: 70px !important;
        margin-left: 0 !important;
    }
}

/* ============================================================
   MOBILE BOTTOM NAVIGATION BAR
   ============================================================ */
@media (max-width: 991.98px) {
    .mobile-bottom-nav-wrapper {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 64px;
        background: rgba(255, 255, 255, 0.94);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.06);
        border-top: 1px solid rgba(226, 232, 240, 0.8);
        z-index: 1040;
        display: block !important;
    }

    .mobile-bottom-nav {
        display: flex;
        align-items: center;
        justify-content: space-around;
        height: 100%;
        padding: 0 8px;
        position: relative;
    }

    .mobile-bottom-nav .nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        color: #64748b;
        text-decoration: none !important;
        font-size: 10px;
        font-weight: 600;
        transition: all 0.2s ease;
        flex: 1;
        height: 100%;
        position: relative;
    }

    .mobile-bottom-nav .nav-item i {
        font-size: 20px;
        margin-bottom: 3px;
        transition: transform 0.2s ease;
    }

    .mobile-bottom-nav .nav-item.active,
    .mobile-bottom-nav .nav-item:active {
        color: #4f46e5;
    }

    .mobile-bottom-nav .nav-item.active i {
        transform: scale(1.1);
        color: #4f46e5;
    }

    /* Badge on Alert button */
    .mobile-bottom-nav .nav-item .badge {
        position: absolute;
        top: 4px;
        right: 22%;
        font-size: 9px;
        padding: 3px 6px;
        border-radius: 50px;
        border: 2px solid #fff;
    }

    /* Floating Action Button (FAB) */
    .nav-fab-container {
        position: relative;
        flex: 0 0 70px !important;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 1041;
    }

    .nav-fab-btn {
        width: 52px;
        height: 52px;
        border-radius: 50%;
        background: linear-gradient(135deg, #4f46e5 0%, #3b82f6 100%);
        color: #fff;
        border: none;
        box-shadow: 0 6px 16px rgba(79, 70, 229, 0.35);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 24px;
        position: absolute;
        top: -18px;
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        outline: none !important;
    }

    .nav-fab-btn:active {
        transform: scale(0.9) rotate(45deg);
        box-shadow: 0 3px 8px rgba(79, 70, 229, 0.2);
    }
}

/* ============================================================
   MOBILE SHEETS (Quick Action & App Drawers)
   ============================================================ */
.mobile-sheet-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0);
    z-index: 1045;
    visibility: hidden;
    transition: background-color 0.3s ease, visibility 0.3s ease;
}

.mobile-sheet-overlay.active {
    visibility: visible;
    background: rgba(15, 23, 42, 0.5);
}

.mobile-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 24px 24px 0 0;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1046;
    padding: 16px 20px 32px;
    box-shadow: 0 -10px 40px rgba(0,0,0,0.15);
}

.mobile-sheet-overlay.active .mobile-sheet {
    transform: translateY(0);
}

.mobile-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f1f5f9;
}

.mobile-sheet-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
}

.drag-handle {
    width: 36px;
    height: 4px;
    background: #cbd5e1;
    border-radius: 2px;
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    cursor: grab;
}

.sheet-close {
    background: #f1f5f9;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-size: 12px;
    outline: none !important;
}

/* Quick Actions Grid inside Sheet */
.quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.action-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none !important;
    font-size: 11px;
    font-weight: 600;
    color: #334155;
    transition: transform 0.2s ease;
}

.action-card:active {
    transform: scale(0.95);
}

.action-icon {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 8px;
}

.bg-success-light { background: #f0fdf4; color: #10b981; }
.bg-danger-light { background: #fef2f2; color: #ef4444; }
.bg-info-light { background: #f0f9ff; color: #0ea5e9; }
.bg-warning-light { background: #fffbeb; color: #f59e0b; }
.bg-primary-light { background: #eef2ff; color: #4f46e5; }
.bg-secondary-light { background: #f8fafc; color: #64748b; }

/* More App Navigation */
.mobile-profile-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: #f8fafc;
    border-radius: 16px;
    margin-bottom: 16px;
}

.mobile-profile-card .avatar {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: #4f46e5;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
}

.mobile-profile-card .details h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
}

.mobile-profile-card .details p {
    margin: 2px 0 0;
    font-size: 11px;
    color: #64748b;
}

.btn-logout {
    margin-left: auto;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: #fee2e2;
    color: #ef4444;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

/* Styled Menu Tree in 'More' Drawer */
.mobile-rendered-menu ul.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.mobile-rendered-menu ul.sidebar-menu > li {
    margin-bottom: 6px;
}

.mobile-rendered-menu ul.sidebar-menu > li > a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    font-weight: 600;
    color: #334155;
    text-decoration: none !important;
}

.mobile-rendered-menu ul.sidebar-menu > li > a i {
    font-size: 16px;
    color: #4f46e5;
}

.mobile-rendered-menu ul.sidebar-menu .treeview-menu {
    display: none;
    list-style: none;
    padding: 6px 0 6px 16px;
}

.mobile-rendered-menu ul.sidebar-menu .treeview.menu-open > .treeview-menu {
    display: block;
}

.mobile-rendered-menu ul.sidebar-menu .treeview > a {
    position: relative;
}

.mobile-rendered-menu ul.sidebar-menu .treeview > a .pull-right-container {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    transition: transform 0.2s ease;
}

.mobile-rendered-menu ul.sidebar-menu .treeview.menu-open > a .pull-right-container {
    transform: translateY(-50%) rotate(90deg);
}

.mobile-rendered-menu ul.sidebar-menu .treeview-menu li a {
    display: block;
    padding: 8px 12px;
    font-size: 13px;
    color: #64748b;
    text-decoration: none !important;
}

/* ============================================================
   MOBILE SEARCH SCREEN OVERLAY
   ============================================================ */
.mobile-search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #fff;
    z-index: 1050;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.mobile-search-overlay.active {
    transform: translateX(0);
}

.mobile-search-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #e2e8f0;
    gap: 12px;
}

.search-back-btn {
    background: none;
    border: none;
    font-size: 20px;
    color: #475569;
    padding: 4px;
    outline: none !important;
}

.search-input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    background: #f1f5f9;
    border-radius: 50px;
    padding: 0 16px;
    height: 40px;
    gap: 8px;
}

.search-input-wrapper i {
    color: #94a3b8;
    font-size: 16px;
}

.search-input-wrapper input {
    background: none;
    border: none;
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    outline: none !important;
    color: #0f172a;
}

#clearSearchInput {
    background: none;
    border: none;
    color: #94a3b8;
    padding: 0;
    font-size: 16px;
}

.mobile-search-body {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
}

.mobile-search-suggested h4 {
    font-size: 12px;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}

.quick-search-links {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.quick-search-links a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: #f8fafc;
    border-radius: 12px;
    text-decoration: none !important;
    color: #334155;
    font-weight: 600;
    font-size: 13px;
}

.mobile-search-results-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.search-result-item {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    color: #0f172a;
    text-decoration: none !important;
    font-weight: 600;
    font-size: 13px;
    transition: background-color 0.2s ease;
}

.search-result-item:active {
    background-color: #f8fafc;
}

.result-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #eef2ff;
    color: #4f46e5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    margin-right: 12px;
}

.search-empty {
    text-align: center;
    color: #94a3b8;
    padding: 40px 0;
    font-size: 14px;
}

/* ============================================================
   TABLE TO RESPONSIVE CARD CONVERSION STYLES
   ============================================================ */
@media (max-width: 991.98px) {
    .mobile-table-cards-container {
        display: flex;
        flex-direction: column;
        gap: 12px;
        padding: 4px 0;
    }

    .mobile-record-card {
        background: #ffffff;
        border: 1px solid #e2e8f0;
        border-radius: 16px;
        padding: 16px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .card-title-header {
        font-size: 14px;
        font-weight: 700;
        color: #0f172a;
        border-bottom: 1px solid #f1f5f9;
        padding-bottom: 8px;
    }

    .card-body-details {
        display: flex;
        flex-direction: column;
        gap: 6px;
    }

    .card-detail-row {
        display: flex;
        justify-content: space-between;
        font-size: 12px;
    }

    .detail-label {
        color: #64748b;
        font-weight: 500;
    }

    .detail-val {
        color: #0f172a;
        font-weight: 600;
        text-align: right;
    }

    .card-actions-footer {
        display: flex;
        justify-content: flex-end;
        gap: 8px;
        border-top: 1px solid #f1f5f9;
        padding-top: 8px;
        margin-top: 4px;
    }

    .card-actions-footer .btn-group {
        display: flex !important;
        gap: 4px;
        float: none !important;
    }

    .card-actions-footer .btn-group > .btn,
    .card-actions-footer .btn {
        margin: 0 !important;
        border-radius: 8px !important;
        padding: 6px 12px !important;
        font-size: 12px !important;
    }
}

/* ============================================================
   MOBILE HOME DASHBOARD  (max-width: 991.98px)
   ============================================================ */
@media (max-width: 991.98px) {

    /* ── Outer wrapper ─────────────────────────────────────── */
    .mobile-dashboard-wrapper {
        padding: 200px 0 60px;
        background: #f0f4f8;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: stretch;
    }

    /* ── Top greeting bar ───────────────────────────────────── */
    .mobile-top-bar {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 10px;
        padding: 28px 16px 22px;
        background: linear-gradient(135deg, #1a237e 0%, #283593 60%, #3949ab 100%);
        border-radius: 0 0 24px 24px;
        box-shadow: 0 6px 24px rgba(26, 35, 126, 0.35);
    }

    .user-greeting .greeting-subtitle {
        font-size: 11px;
        color: rgba(255, 255, 255, 0.70);
        margin: 0 0 3px;
        letter-spacing: 0.4px;
    }

    .user-greeting h3 {
        font-size: 20px;
        font-weight: 700;
        color: #fff;
        margin: 0;
        letter-spacing: -0.2px;
    }

    .mobile-location-filter select.form-control {
        background: rgba(255, 255, 255, 0.15) !important;
        color: #fff !important;
        border: 1px solid rgba(255, 255, 255, 0.3) !important;
        font-size: 12px !important;
        border-radius: 12px !important;
        height: 36px !important;
        padding: 4px 10px !important;
        box-shadow: none !important;
    }

    .mobile-location-filter select.form-control option {
        color: #1a237e;
        background: #fff;
    }

    /* ── Stats cards grid ───────────────────────────────────── */
    .mobile-stats-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
        padding: 24px 14px 4px;
    }

    .m-stats-card {
        display: flex;
        align-items: center;
        gap: 12px;
        border-radius: 18px;
        padding: 16px 14px;
        box-shadow: 0 4px 18px rgba(0, 0, 0, 0.10);
        transition: transform 0.2s ease, box-shadow 0.2s ease;
        overflow: hidden;
        position: relative;
    }

    .m-stats-card::after {
        content: '';
        position: absolute;
        top: -18px;
        right: -18px;
        width: 70px;
        height: 70px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.12);
    }

    .m-stats-card:active {
        transform: scale(0.97);
    }

    .bg-sales      { background: linear-gradient(135deg, #1565c0, #1e88e5); }
    .bg-collection { background: linear-gradient(135deg, #6a1b9a, #ab47bc); }
    .bg-due        { background: linear-gradient(135deg, #b71c1c, #e53935); }
    .bg-profit     { background: linear-gradient(135deg, #1b5e20, #43a047); }

    .m-stats-card .card-icon {
        font-size: 26px;
        color: rgba(255, 255, 255, 0.85);
        flex-shrink: 0;
        line-height: 1;
    }

    .m-stats-card .card-info {
        display: flex;
        flex-direction: column;
        min-width: 0;
    }

    .m-stats-card .m-label {
        font-size: 10px;
        font-weight: 600;
        color: rgba(255, 255, 255, 0.75);
        text-transform: uppercase;
        letter-spacing: 0.6px;
        margin-bottom: 3px;
        white-space: nowrap;
    }

    .m-stats-card h4 {
        font-size: 15px;
        font-weight: 700;
        color: #fff;
        margin: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* ── Module grid section ────────────────────────────────── */
    .mobile-modules-section {
        padding: 28px 14px 10px;
    }

    .mobile-modules-section .section-title {
        font-size: 15px;
        font-weight: 700;
        color: #1a237e;
        margin: 0 0 14px 2px;
        letter-spacing: -0.1px;
    }

    .mobile-modules-grid {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 12px;
    }

    .module-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 8px;
        text-decoration: none !important;
        transition: transform 0.2s ease;
    }

    .module-item:active {
        transform: scale(0.93);
    }

    .module-icon {
        width: 58px;
        height: 58px;
        border-radius: 18px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 24px;
        color: #fff;
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
        transition: box-shadow 0.2s ease;
    }

    .module-item span {
        font-size: 11px;
        font-weight: 600;
        color: #374151;
        text-align: center;
        line-height: 1.2;
    }

    /* Module icon background colours */
    .bg-sales-icon      { background: linear-gradient(135deg, #1565c0, #42a5f5); }
    .bg-purchase-icon   { background: linear-gradient(135deg, #4527a0, #7e57c2); }
    .bg-inventory-icon  { background: linear-gradient(135deg, #00695c, #26a69a); }
    .bg-crm-icon        { background: linear-gradient(135deg, #e65100, #ffa726); }
    .bg-accounts-icon   { background: linear-gradient(135deg, #1b5e20, #66bb6a); }
    .bg-hr-icon         { background: linear-gradient(135deg, #880e4f, #e91e63); }
    .bg-reports-icon    { background: linear-gradient(135deg, #0277bd, #29b6f6); }
    .bg-admin-icon      { background: linear-gradient(135deg, #37474f, #78909c); }

    /* ── Hide legacy desktop chrome on mobile dashboard ─────── */
    .mobile-dashboard-wrapper ~ .content-header,
    .mobile-dashboard-wrapper .premium-hero,
    .mobile-dashboard-wrapper .premium-charts-row {
        display: none !important;
    }

    /* ── Empty state for mobile table cards ─────────────────── */
    .mobile-empty-state {
        text-align: center;
        padding: 40px 20px;
        color: #94a3b8;
    }
    .mobile-empty-state i {
        font-size: 40px;
        display: block;
        margin-bottom: 10px;
        opacity: 0.5;
    }
    .mobile-empty-state p {
        font-size: 13px;
        font-weight: 500;
        margin: 0;
    }
}

/* ============================================================
   PHASE 8: FORM FULLSCREEN BOTTOM SHEET  (max-width: 991.98px)
   ============================================================ */
@media (max-width: 991.98px) {

    /* Overlay backdrop */
    .mobile-form-sheet-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.55);
        z-index: 9800;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }
    .mobile-form-sheet-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    /* The drawer panel itself */
    .mobile-form-sheet {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 94vh;
        background: #fff;
        border-radius: 24px 24px 0 0;
        display: flex;
        flex-direction: column;
        transform: translateY(100%);
        transition: transform 0.38s cubic-bezier(0.32, 0.72, 0, 1);
        z-index: 9801;
        overflow: hidden;
    }
    .mobile-form-sheet-overlay.active .mobile-form-sheet {
        transform: translateY(0);
    }

    /* Drag handle */
    .form-sheet-handle {
        flex-shrink: 0;
        display: flex;
        justify-content: center;
        padding: 10px 0 4px;
    }
    .form-sheet-handle::after {
        content: '';
        width: 40px;
        height: 4px;
        background: #e2e8f0;
        border-radius: 4px;
    }

    /* Sheet sticky header */
    .form-sheet-header {
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 6px 16px 14px;
        border-bottom: 1px solid #f1f5f9;
    }
    .form-sheet-header h4 {
        font-size: 16px;
        font-weight: 700;
        color: #0f172a;
        margin: 0;
    }
    .form-sheet-close {
        width: 34px;
        height: 34px;
        border-radius: 50%;
        background: #f1f5f9;
        border: none;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 18px;
        color: #475569;
        cursor: pointer;
        line-height: 1;
    }

    /* Scrollable body */
    .form-sheet-body {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 16px;
    }

    /* Sticky action footer */
    .form-sheet-footer {
        flex-shrink: 0;
        display: flex;
        gap: 10px;
        padding: 12px 16px;
        border-top: 1px solid #f1f5f9;
        background: #fff;
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }
    .form-sheet-footer .btn {
        flex: 1;
        border-radius: 12px !important;
        font-size: 14px !important;
        font-weight: 600 !important;
        padding: 12px !important;
    }
}

/* ============================================================
    MOBILE SPLASH / LOADING SCREEN
    ============================================================ */
.mobile-splash-screen {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: linear-gradient(135deg, #0d3b4f 0%, #0a5c6e 40%, #0d7a8a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.mobile-splash-screen.fade-out {
    opacity: 0;
    visibility: hidden;
}

.splash-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
}

.splash-logo {
    width: 260px;
    max-width: 75vw;
    height: auto;
    filter: none;
    animation: splashPulse 1.8s ease-in-out infinite;
}

@keyframes splashPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.04); opacity: 0.85; }
}

.splash-spinner {
    position: relative;
    width: 44px;
    height: 44px;
}

.spinner-ring {
    position: absolute;
    inset: 0;
    border: 3px solid transparent;
    border-top-color: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    animation: spinRing 1.2s linear infinite;
}

.spinner-ring:nth-child(2) {
    inset: 6px;
    border-top-color: rgba(255, 255, 255, 0.6);
    animation-duration: 1.6s;
    animation-direction: reverse;
}

.spinner-ring:nth-child(3) {
    inset: 12px;
    border-top-color: rgba(255, 255, 255, 0.35);
    animation-duration: 2s;
}

@keyframes spinRing {
    to { transform: rotate(360deg); }
}

.splash-text {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    letter-spacing: 2px;
    text-transform: uppercase;
    animation: textFade 1.4s ease-in-out infinite;
}

@keyframes textFade {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 0.3; }
}
