/* ============================================================
   RAILWAY TRACKING SYSTEM — MOBILE.CSS
   Mobile-first responsive overrides for the entire application.
   Load order: adminlte.min.css → custom.css → mobile.css
   ============================================================ */

/* ============================================================
   1. GLOBAL RESETS & BASE MOBILE RULES
   ============================================================ */

/* Prevent horizontal overflow on all pages */
html,
body {
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

.status-filters-wrapper {
  display: contents;
}

/* Smooth scrolling */
* {
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
  box-sizing: border-box;
}

/* Minimum touch target size for all interactive elements */
@media (max-width: 991.98px) {

  a,
  button,
  .btn,
  input[type="button"],
  input[type="submit"],
  .nav-link,
  .select2-selection {
    min-height: 44px;
  }

  /* Ensure text inputs are legible on mobile (prevents iOS zoom) */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="date"],
  input[type="time"],
  input[type="tel"],
  select,
  textarea {
    font-size: 16px !important;
    min-height: 44px;
  }

  /* Select2 height fix for mobile */
  .select2-container .select2-selection--single {
    height: 44px !important;
    line-height: 44px !important;
  }

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

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

  /* Better button styles on mobile */
  .btn {
    padding: 10px 16px;
    font-size: 15px;
  }

  .btn-sm {
    padding: 8px 14px;
    font-size: 14px;
    min-height: 38px;
  }

  /* Prevent content from being clipped under sidebar on mobile */
  .content-wrapper {
    min-height: 100vh !important;
    max-height: none !important;
    overflow-y: auto;
  }
}

/* ============================================================
   2. CAPACITOR / PWA — SAFE AREA INSETS (Notch & Home Bar)
   ============================================================ */

body {
  padding-top: env(safe-area-inset-top, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
}

/* Ensure top navbar clears safe area on notch devices */
@media (max-width: 991.98px) {
  .main-header.navbar {
    padding-top: max(8px, env(safe-area-inset-top, 8px));
  }
}

/* ============================================================
   3. HEADER / TOP NAVBAR
   ============================================================ */

@media (max-width: 767.98px) {

  /* Full-width dropdowns on mobile (battery alert, notifications) */
  .dropdown-menu-lg,
  .dropdown-menu-right {
    width: 100vw !important;
    max-width: 100vw !important;
    left: auto !important;
    right: -16px !important;
    position: fixed !important;
    border-radius: 0 !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2) !important;
  }

  /* Properly sized navbar icons */
  .main-header .nav-link {
    padding: 8px 10px !important;
    display: flex;
    align-items: center;
  }

  .main-header .navbar-nav {
    align-items: center;
  }

  /* Battery icon and badge */
  .main-header .far.fa-battery-quarter,
  .main-header .fas.fa-sign-out-alt,
  .main-header .fas.fa-cog {
    font-size: 22px !important;
  }

  /* Low battery list height on mobile */
  #lowlevelBattery-list {
    height: 60vh;
    max-height: 60vh;
  }

  /* Notification item wrapping */
  #notification-list .dropdown-item,
  #lowlevelBattery-list .dropdown-item {
    white-space: normal;
    padding: 10px 12px;
    line-height: 1.5;
  }
}

/* ============================================================
   4. SIDEBAR — SLIDE-OUT OVERLAY ON MOBILE
   ============================================================ */

@media (max-width: 991.98px) {

  /* Sidebar should overlay, not push, content */
  .main-sidebar {
    position: fixed !important;
    top: 0 !important;
    left: -250px !important;
    height: 100vh !important;
    z-index: 1050 !important;
    transition: left 0.3s ease !important;
    overflow-y: auto;
  }

  /* When pushmenu opens sidebar */
  body.sidebar-open .main-sidebar {
    left: 0 !important;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.4);
  }

  /* Backdrop overlay when sidebar is open */
  body.sidebar-open::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1049;
    animation: fadeIn 0.3s ease;
  }

  @keyframes fadeIn {
    from {
      opacity: 0;
    }

    to {
      opacity: 1;
    }
  }

  /* Content wrapper — no push, full width always */
  .content-wrapper,
  .main-footer {
    margin-left: 0 !important;
  }

  /* Increase sidebar nav link touch targets */
  .main-sidebar .nav-link {
    padding: 12px 16px !important;
    font-size: 15px !important;
  }

  .main-sidebar .nav-icon {
    font-size: 18px !important;
    margin-right: 10px !important;
  }

  /* Treeview submenu items */
  .main-sidebar .nav-treeview .nav-link {
    padding: 10px 16px 10px 30px !important;
  }

  /* Brand link area */
  .main-sidebar .brand-link {
    padding: 14px 16px !important;
  }

  /* Ensure header hamburger is always visible and tappable */
  .nav-item a[data-widget="pushmenu"] {
    padding: 10px 14px !important;
    font-size: 20px !important;
  }
}

/* ============================================================
   5. AUTH PAGES — LOGIN / FORGOT PASSWORD
   ============================================================ */

@media (max-width: 575.98px) {
  body.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 16px;
    background: #1a2035;
  }

  /* Full-width login box on mobile */
  .login-box {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 auto !important;
    padding: 0 !important;
  }

  .login-box .card {
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  }

  .login-card-body {
    padding: 28px 24px !important;
  }

  .login-logo {
    font-size: 22px !important;
    margin-bottom: 16px !important;
  }

  /* Input fields - full width, proper sizing */
  .login-card-body .input-group,
  .login-card-body .form-group {
    margin-bottom: 16px;
  }

  .login-card-body .input-group-text {
    background: #f8f9fa;
    border-left: none;
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 0 14px;
  }

  .login-card-body .form-control {
    border-right: none;
    height: 44px !important;
    padding: 10px 14px !important;
  }

  /* Sign In button — full width, prominent */
  .login-card-body .btn-primary.btn-block {
    height: 48px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 8px;
    margin-top: 8px;
    letter-spacing: 0.5px;
  }

  /* Forgot password link */
  .login-card-body .mb-1 {
    text-align: center;
    margin-top: 16px !important;
    font-size: 15px;
  }
}

@media (min-width: 576px) and (max-width: 767.98px) {
  .login-box {
    width: 380px !important;
  }
}

/* ============================================================
   6. DASHBOARD — LIVE MAP (Most Complex Section)
   ============================================================ */

@media (max-width: 767.98px) {

  /* Map fills the full viewport on mobile */
  #map {
    height: calc(100vh - 57px) !important;
    /* viewport minus navbar height */
    width: 100vw !important;
    position: relative;
  }

  /* Settings icon & dropdown — repositioned below infoBar-custom to avoid overlap */
  .settings-icon {
    top: calc(57px + max(8px, env(safe-area-inset-top, 8px)) + 46px) !important;
    right: 12px !important;
    z-index: 1001 !important;
  }

  body.has-navbar-imei .settings-icon {
    top: calc(57px + max(8px, env(safe-area-inset-top, 8px)) + 74px) !important;
  }

  .settings-dropdown {
    top: calc(57px + max(8px, env(safe-area-inset-top, 8px)) + 82px) !important;
    right: 12px !important;
    width: 200px !important;
    z-index: 1015 !important;
  }

  body.has-navbar-imei .settings-dropdown {
    top: calc(57px + max(8px, env(safe-area-inset-top, 8px)) + 110px) !important;
  }

  /* Shift Leaflet bottom-right control container up to sit nicely above collapsed bottom drawer */
  .leaflet-bottom.leaflet-right {
    bottom: 56px !important;
  }

  /* Content wrapper for dashboard — no overflow clipping */
  .content-wrapper {
    padding: 0 !important;
    max-height: none !important;
    overflow: hidden;
  }

  /* ── Status Filter Pill Bar (All/Moving/Idle/Stop/Not Reachable) ── */
  .info-bar-parent {
    position: fixed !important;
    top: calc(57px + max(8px, env(safe-area-inset-top, 8px))) !important;
    left: 0 !important;
    width: 100% !important;
    max-width: none !important;
    height: auto !important;
    z-index: 1008 !important;
  }

  .info-bar-parent .card-custom {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  #infoBar-custom,
  .info-bar-custom {
    position: relative !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    z-index: 1008 !important;
    border-radius: 0 !important;
    padding: 6px 8px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 4px !important;
    background: rgba(255, 255, 255, 0.97) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
  }

  .info-bar-custom::-webkit-scrollbar {
    display: none;
  }

  .navbar-imei-container {
    width: 100% !important;
    justify-content: center !important;
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    cursor: default !important;
    margin: 0 !important;
    padding: 2px 0 !important;
  }

  .navbar-imei-sep {
    display: none !important;
  }

  .status-filters-wrapper {
    display: flex !important;
    width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    flex-wrap: nowrap !important;
    justify-content: flex-start !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 4px;
    padding: 2px 0 !important;
  }

  .status-filters-wrapper::-webkit-scrollbar {
    display: none !important;
  }

  .status-filters-wrapper .info-separator {
    display: none !important;
  }

  .info-item-2 {
    flex-shrink: 0;
    padding: 3px 6px !important;
    border-radius: 20px;
    background: #f0f0f0;
    margin: 1px !important;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 11.5px !important;
  }

  .info-item-2:active {
    background: #343a40;
    color: white;
  }

  .info-item-2 p {
    margin: 0;
    font-size: 11.5px;
    white-space: nowrap;
  }

  /* Hide raw separators or unwanted siblings */
  .info-bar-custom>*:not(.info-item-2):not(.navbar-imei-sep):not(.status-filters-wrapper) {
    display: none !important;
  }

  /* ── InfoBar Overlay overrides for dynamic positioning and sizing ── */
  #infoBar {
    position: fixed !important;
    top: calc(57px + max(8px, env(safe-area-inset-top, 8px)) + 46px) !important;
    left: 10px !important;
    right: 10px !important;
    width: calc(100% - 20px) !important;
    max-width: none !important;
    z-index: 1000 !important;
    padding: 0 10px !important; /* vertical padding removed, horizontal padding kept */
  }

  body.has-navbar-imei #infoBar {
    top: calc(57px + max(8px, env(safe-area-inset-top, 8px)) + 74px) !important;
  }

  #infoBar .device-title-accent {
    font-size: 13px !important; /* smaller user name text size */
  }

  #infoBar .info-card-header {
    padding-bottom: 2px !important;
    margin-bottom: 3px !important;
  }

  /* ── Device List Panel — becomes a left-sliding side drawer on mobile ── */
  /* Mobile panel backdrop overlay */
  .mobile-panel-backdrop {
    position: fixed;
    top: calc(57px + max(8px, env(safe-area-inset-top, 8px)));
    left: 0;
    width: 100vw;
    height: calc(100vh - (57px + max(8px, env(safe-area-inset-top, 8px))));
    background: rgba(0, 0, 0, 0.4);
    z-index: 1050 !important;
    display: none;
  }

  /* The device list col */
  #mobileDevicePanel {
    position: fixed !important;
    top: calc(57px + max(8px, env(safe-area-inset-top, 8px))) !important;
    /* below mobile navbar header */
    bottom: auto !important;
    left: 0 !important;
    width: 290px !important;
    max-width: 80vw !important;
    z-index: 1060 !important;
    background: white !important;
    border-radius: 0 0 16px 0 !important;
    box-shadow: 4px 4px 20px rgba(0, 0, 0, 0.2) !important;
    height: auto !important;
    max-height: calc(100vh - (57px + max(8px, env(safe-area-inset-top, 8px))) - 16px) !important;
    overflow: hidden !important;
    /* Collapsed: panel off-screen on the left */
    transform: translateX(-100%) !important;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1) !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  /* Mobile device panel — open state: panel slides in from the left */
  .mobile-panel-open #mobileDevicePanel,
  .mobile-panel-full #mobileDevicePanel {
    transform: translateX(0) !important;
  }

  /* Flexbox drawer layout to prevent datetime fields from hiding */
  #mobileDevicePanel .card {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    max-height: 100% !important;
    margin: 0 !important;
    border: none !important;
    border-radius: 0 0 16px 0 !important;
  }

  #mobileDevicePanel .card-body#deviceList {
    flex: 1 1 auto !important;
    height: 100% !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 0 !important;
  }

  #mobileDevicePanel #deviceList .table-responsive {
    flex: 1 1 auto !important;
    height: 100% !important;
    max-height: none !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  /* Card header in device panel */
  .col-md-2 .card .card-header.header-device-list {
    border-radius: 0 16px 0 0 !important;
    padding: 8px 12px !important;
    cursor: pointer;
    flex-shrink: 0 !important;
  }

  /* Device row touch target */
  #deviceList .table td {
    padding: 10px 12px !important;
    font-size: 14px !important;
    border-bottom: 1px solid #f0f0f0 !important;
  }

  /* Date pickers in device footer - stack them */
  .card-footer.clearfix {
    padding: 8px 12px !important;
  }

  /* Hide top handle on mobile side panel */
  .mobile-panel-handle {
    display: none !important;
  }

  /* ── Bottom panel (trip details) responsive ── */
  #bottomPanelView {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    z-index: 996 !important;
    height: 45vh !important;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.15);
    overflow: hidden;
  }

  #bottomPanelView table.table {
    font-size: 13px;
  }

  #bottomPanelView .bottom-container {
    padding: 8px 14px !important;
    font-size: 13px;
  }
}

/* ============================================================
   7. DATATABLES — RESPONSIVE ON MOBILE
   ============================================================ */

@media (max-width: 767.98px) {

  /* Wrapper scrolls horizontally with smooth touch scrolling */
  .dataTables_wrapper {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  /* Make the table itself responsive */
  .dataTables_wrapper .table {
    min-width: 600px;
    /* Allow scrolling for wide tables */
  }

  /* Responsive column hiding for very wide tables (device has 14 cols) */
  /* Priority columns shown: Name, Department, Action */
  table#datalist .desktop-only {
    display: none !important;
  }

  /* DataTable search, length, info controls */
  .dataTables_length,
  .dataTables_filter,
  .dataTables_info,
  .dataTables_paginate {
    text-align: center !important;
    float: none !important;
    margin: 8px 0 !important;
  }

  .dataTables_filter input {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
  }

  .dataTables_length select {
    margin: 0 4px !important;
  }

  /* Pagination buttons — larger touch targets */
  .paginate_button {
    padding: 8px 12px !important;
    font-size: 14px !important;
  }

  /* Table header */
  .table thead th {
    font-size: 13px;
    padding: 8px 10px;
    white-space: nowrap;
  }

  /* Table cells */
  .table tbody td {
    font-size: 13px;
    padding: 10px 10px;
    vertical-align: middle;
  }

  /* Action buttons in table cells */
  .table tbody td .btn-sm {
    padding: 6px 10px !important;
    min-height: 36px;
    margin-bottom: 2px;
  }

  /* Card header with table controls (Add button + company filter) */
  .card-header {
    flex-wrap: wrap;
  }

  .card-header .float-right {
    float: none !important;
    margin-top: 10px;
    display: flex !important;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
  }

  .card-header .float-right select {
    flex: 1;
    min-width: 150px;
  }

  .card-header .float-right .btn-add-record {
    margin-left: 0 !important;
    flex: 0 0 auto;
  }

  /* Card title full width on mobile */
  .card-title {
    width: 100% !important;
  }
}

/* ============================================================
   8. MODALS — FULL-SCREEN BOTTOM SHEETS ON MOBILE
   ============================================================ */

@media (max-width: 575.98px) {

  /* All modals become full-screen on phones */
  .modal-dialog,
  .modal-dialog.modal-lg,
  .modal-dialog.modal-xl {
    margin: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    min-height: 100vh !important;
  }

  .modal-content {
    border: none !important;
    border-radius: 0 !important;
    min-height: 100vh !important;
    height: auto !important;
  }

  .modal-header {
    padding: 14px 16px !important;
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
    border-bottom: 1px solid #dee2e6;
  }

  .modal-title {
    font-size: 17px !important;
  }

  .modal-body {
    padding: 16px !important;
    overflow-y: auto;
  }

  .modal-footer {
    padding: 12px 16px !important;
    position: sticky;
    bottom: 0;
    background: white;
    border-top: 1px solid #dee2e6;
  }

  .modal-footer .btn {
    flex: 1;
    margin: 0 4px !important;
  }

  /* Close button — larger touch target */
  .modal-header .close {
    padding: 8px 14px !important;
    font-size: 22px !important;
  }
}

@media (min-width: 576px) and (max-width: 767.98px) {

  /* On large phones/small tablets — modal takes 95% width */
  .modal-dialog,
  .modal-dialog.modal-lg,
  .modal-dialog.modal-xl {
    margin: 16px auto !important;
    max-width: 96% !important;
  }
}

/* ============================================================
   9. MODAL FORM FIELDS — SINGLE COLUMN ON MOBILE
   ============================================================ */

@media (max-width: 575.98px) {

  /* All multi-column form rows become single-column */
  .modal-body .row .col-md-2,
  .modal-body .row .col-md-3,
  .modal-body .row .col-md-4,
  .modal-body .row .col-md-5,
  .modal-body .row .col-md-6,
  .modal-body .row .col-md-8 {
    flex: 0 0 100% !important;
    max-width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  .modal-body .form-group {
    margin-bottom: 14px !important;
  }

  .modal-body label {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
    display: block;
  }

  /* Leaflet map inside modal (geofence create/edit) */
  .modal-body #map {
    height: 45vh !important;
    border-radius: 8px;
    overflow: hidden;
  }
}

/* ============================================================
   10. REPORT FILTER BAR
   ============================================================ */

@media (max-width: 767.98px) {

  /* Stack all filter columns vertically */
  .content-wrapper section.content .row .col-md-2,
  .content-wrapper section.content .row .col-md-1 {
    flex: 0 0 100% !important;
    max-width: 100% !important;
    padding-bottom: 4px !important;
  }

  /* Search/submit button — full width */
  #search_filter {
    width: 100% !important;
    margin-top: 4px;
    height: 44px;
    font-size: 15px;
  }

  /* Date picker inputs */
  .class-date {
    font-size: 16px !important;
  }

  /* Report filter card */
  section.content>.card>.card-body {
    padding: 12px !important;
  }
}

/* ============================================================
   11. CONTENT PAGES — PAGE HEADER & BREADCRUMB
   ============================================================ */

@media (max-width: 575.98px) {

  /* Page title row — stack on mobile */
  .content-header .row.mb-2 .col-sm-6 {
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }

  .content-header h1 {
    font-size: 20px !important;
    margin-bottom: 4px !important;
  }

  /* Breadcrumb */
  .breadcrumb {
    float: none !important;
    margin-bottom: 0 !important;
    padding: 4px 0 !important;
    background: transparent;
    font-size: 13px;
  }

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

/* ============================================================
   12. PROFILE & SETTINGS PAGES
   ============================================================ */

@media (max-width: 575.98px) {

  /* Stack label + input vertically */
  .form-horizontal .form-group.row .col-sm-2,
  .form-horizontal .form-group.row .col-sm-10 {
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }

  .form-horizontal .col-form-label {
    text-align: left !important;
    padding-bottom: 4px !important;
    font-weight: 600;
  }

  /* Submit button alignment */
  .form-group.row .offset-sm-11 {
    margin-left: 0 !important;
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }

  .form-group.row .offset-sm-11 .btn {
    width: 100%;
    height: 48px;
    font-size: 16px;
  }

  /* Settings file import row */
  .setting-import-row .col-sm-3,
  .setting-import-row .col-sm-2 {
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }

  /* Profile image preview */
  .form-group .img-size-32.rounded {
    width: 80px !important;
    height: 80px !important;
    object-fit: cover;
    border-radius: 50% !important;
  }
}

/* ============================================================
   13. REPORT MAP PAGES (mapRoute, mapEventPoint)
   ============================================================ */

@media (max-width: 767.98px) {

  /* Full-screen map in modal reports */
  .modal-dialog.modal-xl {
    position: fixed !important;
    margin: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100% !important;
  }

  .modal-dialog.modal-xl .modal-content {
    height: 100vh !important;
    border-radius: 0 !important;
  }

  /* Report map height */
  .modal-dialog.modal-xl #map {
    height: 55vh !important;
  }

  /* Info bar — positioned at the top of the map overlay below the filter pill bar */
  .info-bar {
    position: fixed !important;
    top: 105px !important;
    left: 10px !important;
    right: 10px !important;
    width: calc(100% - 20px) !important;
    transform: none !important;
    z-index: 1000 !important;
    background: rgba(255, 255, 255, 0.96) !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    padding: 10px 12px !important;
    box-sizing: border-box !important;
  }

  .info-bar .row {
    width: 100% !important;
    margin: 0 !important;
  }

  /* Trip list bottom panel in report map */
  #bottomPanelView {
    height: auto !important;
    max-height: 35vh !important;
  }

  #bottomPanelView table.table th,
  #bottomPanelView table.table td {
    font-size: 12px !important;
    padding: 6px 8px !important;
  }
}

/* ============================================================
   14. CARD LAYOUT OVERRIDES
   ============================================================ */

@media (max-width: 575.98px) {
  .card {
    border-radius: 8px !important;
    margin-bottom: 12px !important;
  }

  .card-header {
    padding: 12px 14px !important;
    flex-direction: column;
    align-items: flex-start !important;
  }

  .card-header h3.card-title {
    font-size: 15px !important;
    margin-bottom: 8px;
  }

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

/* ============================================================
   15. MISC UTILITIES FOR MOBILE
   ============================================================ */

@media (max-width: 767.98px) {

  /* Hide desktop-only separators */
  .d-mobile-none {
    display: none !important;
  }

  /* Mobile-only visible */
  .d-mobile-block {
    display: block !important;
  }

  .d-mobile-flex {
    display: flex !important;
  }

  /* Mobile drag handle for bottom panels */
  .mobile-panel-handle {
    width: 40px;
    height: 4px;
    background: #ccc;
    border-radius: 2px;
    margin: 10px auto 6px;
    cursor: pointer;
  }

  /* Floating action button for mobile (panel toggle) */
  .fab-mobile {
    position: fixed;
    bottom: 76px !important;
    left: auto !important;
    right: 16px !important;
    z-index: 9999 !important;
    /* Make sure it stays on top */
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #343a40;
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    transition: transform 0.2s;
  }

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

  /* Page loading spinner — full cover */
  .page-loading {
    align-items: center;
    justify-content: center;
    display: none;
  }

  .page-loading[style*="display: block"],
  .page-loading[style*="display:block"] {
    display: flex !important;
  }

  /* Toastr position on mobile — top right as requested */
  #toast-container {
    top: 60px !important;
    right: 16px !important;
    bottom: auto !important;
    left: auto !important;
    transform: none !important;
    width: auto !important;
    max-width: 90vw !important;
  }

  #toast-container>.toast {
    width: auto !important;
    max-width: 100% !important;
    border-radius: 8px !important;
  }
}

/* ============================================================
   16. TABLET ADJUSTMENTS (768px – 991px)
   ============================================================ */

@media (min-width: 768px) and (max-width: 991.98px) {

  /* Sidebar overlays at tablet size too */
  .main-sidebar {
    position: fixed !important;
  }

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

  /* Dashboard map on tablet */
  #map {
    height: calc(100vh - 57px) !important;
  }

  /* Device list panel — narrower side panel on tablet */
  #map>.col-md-2 {
    position: absolute !important;
    top: 60px !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 280px !important;
    max-width: 280px !important;
    max-height: calc(100vh - 120px) !important;
    border-radius: 12px 0 0 12px !important;
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.1) !important;
    z-index: 997 !important;
    overflow-y: auto;
  }
}

/* ============================================================
   17. PRINT STYLES (preserve existing functionality)
   ============================================================ */

@media print {

  .main-sidebar,
  .main-header,
  .fab-mobile,
  .mobile-panel-handle {
    display: none !important;
  }

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

/* ── Telemetry Custom Styles: User Live Location Pulse & Progress Bar ── */
.user-live-location-icon {
  z-index: 1000 !important;
}

.user-live-location-icon div {
  animation: userLivePulse 1.8s infinite;
}

@keyframes userLivePulse {
  0% {
    box-shadow: 0 0 0 0 rgba(0, 123, 255, 0.8);
  }

  70% {
    box-shadow: 0 0 0 10px rgba(0, 123, 255, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(0, 123, 255, 0);
  }
}

/* Adjust map settings dropdown spacing to fit telemetry inputs */
.settings-dropdown {
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}