/* QuangIT Mobile M1: persistent Metronic header + bottom bar, desktop unchanged. */
.mobile-shell-bottom {
  display: none;
}

.mobile-shell-logo {
  display: block;
  max-width: 34px;
  max-height: 34px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.mobile-shell-brand-text {
  max-width: clamp(72px, 27vw, 190px);
}

@media (max-width: 991.98px) {
  /* The fixed tab bar must not intercept controls brought into view by keyboard/automation. */
  html {
    scroll-padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  }
  body[data-mobile-shell="true"] [data-admin-root] button,
  body[data-mobile-shell="true"] [data-admin-root] input,
  body[data-mobile-shell="true"] [data-admin-root] select,
  body[data-mobile-shell="true"] [data-admin-root] textarea,
  body[data-mobile-shell="true"] [data-admin-root] a[href] {
    scroll-margin-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  }

  #kt_app_header .mobile-shell-drawer {
    width: 34px;
    height: 38px;
    flex-shrink: 0;
  }

  #kt_app_header .mobile-shell-brand {
    flex: 1 1 auto;
    overflow: hidden;
  }

  #kt_app_header .mobile-shell-brand-text {
    overflow: hidden;
  }

  body[data-mobile-shell="true"] #kt_app_header {
    background-color: var(--bs-body-bg);
    border-bottom: 1px solid var(--bs-gray-200);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.035);
  }

  body[data-mobile-shell="true"] #kt_app_header_container {
    padding-inline: 14px;
    gap: 4px;
    min-height: 64px;
    padding-top: env(safe-area-inset-top, 0px);
  }

  body[data-mobile-shell="true"] #kt_app_header_wrapper {
    flex: 0 0 auto;
    min-width: 0;
  }

  body[data-mobile-shell="true"] #kt_app_header .app-navbar {
    gap: 2px;
    align-items: center;
  }

  body[data-mobile-shell="true"] #kt_app_header .app-navbar-item {
    margin-inline: 0 !important;
  }

  /* The sidebar hamburger already exposes all desktop destinations on phones. */
  body[data-mobile-shell="true"] #kt_app_header_menu_toggle,
  body[data-mobile-shell="true"] #kt_app_header [data-pwa-install] {
    display: none !important;
  }

  body[data-mobile-shell="true"] #kt_app_content {
    padding-top: 1rem;
  }

  body[data-mobile-shell="true"] #kt_app_main {
    padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  }

  body[data-mobile-shell="true"] .mobile-shell-bottom {
    display: block;
    position: fixed;
    z-index: 102;
    bottom: 0;
    inset-inline: 0;
    background: var(--bs-body-bg);
    border-top: 1px solid var(--bs-gray-200);
    box-shadow: 0 -5px 22px rgba(0, 0, 0, 0.06);
    padding: 6px max(10px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px))
      max(10px, env(safe-area-inset-left, 0px));
  }

  .mobile-shell-bottom-inner {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    max-width: 540px;
    margin-inline: auto;
  }

  .mobile-shell-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 54px;
    gap: 3px;
    border-radius: 11px;
    padding: 5px 2px;
    color: var(--bs-gray-600);
    text-decoration: none;
    width: 100%;
    border: 0;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.2;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-shell-tab span {
    display: block;
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .mobile-shell-tab.active,
  .mobile-shell-tab[aria-current="page"] {
    color: var(--bs-primary);
    background: var(--bs-primary-light);
  }

  /* Keyboard focus remains visible but never looks like a second active tab.
     Touch screens can retain :hover after the user taps Notifications. */
  @media (hover: hover) and (pointer: fine) {
    .mobile-shell-tab:not(.active):not([aria-current="page"]):hover {
      color: var(--bs-primary);
    }
  }

  .mobile-shell-tab:focus-visible {
    outline: 2px solid var(--bs-primary);
    outline-offset: -2px;
  }

  body[data-mobile-shell="true"] #kt_app_scrolltop {
    bottom: calc(90px + env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 359.98px) {
  body[data-mobile-shell="true"] #kt_app_header .mobile-shell-brand-text > .text-muted {
    display: none;
  }

  body[data-mobile-shell="true"] #kt_app_header .mobile-shell-brand-text {
    max-width: 68px;
  }

  body[data-mobile-shell="true"] #kt_app_header_container {
    padding-inline: 8px;
  }

  .mobile-shell-tab {
    font-size: 0.67rem;
  }
}

/* M2 dashboard: Metronic color tokens work in light/dark modes. */
.mobile-dashboard-wallet {
  color: #fff;
  background: linear-gradient(125deg, var(--bs-primary), #3456ac);
  border-radius: 1rem;
}
.mobile-dashboard-wallet [data-mobile-wallet-status],
.mobile-dashboard-wallet .fs-6 {
  color: rgba(255, 255, 255, 0.9);
}
.mobile-dashboard-wallet .btn.btn-light {
  background: rgba(255, 255, 255, 0.95);
  color: #263c65;
}
.mobile-dashboard-shortcut:focus-visible {
  outline: 2px solid var(--bs-primary);
  outline-offset: 4px;
  border-radius: 0.5rem;
}
.mobile-dashboard-shortcut .symbol-label {
  transition: transform 0.15s ease;
}
.mobile-dashboard-shortcut:hover .symbol-label {
  transform: translateY(-2px);
}
.mobile-shell-notification-dot {
  position: absolute;
  top: 3px;
  right: 22%;
  border-radius: 50%;
  width: 8px;
  height: 8px;
  background: var(--bs-danger);
}
.mobile-shell-notification-dot[hidden] {
  display: none !important;
}

@media (max-width: 991.98px) {
  /* The bottom tab owns notifications on mobile; the old bell stays on desktop. */
  body[data-mobile-shell="true"] #kt_app_header [data-notification-center] > [data-notification-toggle] {
    display: none !important;
  }
  body[data-mobile-shell="true"] #kt_app_header [data-notification-center] {
    width: 0;
    margin: 0 !important;
    padding: 0 !important;
  }
  .mobile-shell-tab {
    position: relative;
  }
  body.mobile-notifications-open {
    overflow: hidden;
  }
  .mobile-notifications-layer {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    flex-direction: column;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--bs-body-bg);
  }
  .mobile-notifications-layer .notification-menu {
    /* Reparenting the actual dropdown retains inbox actions and socket updates. */
    display: flex !important;
    flex-direction: column;
    position: static !important;
    inset: auto !important;
    transform: none !important;
    flex: 1 1 auto;
    width: 100% !important;
    max-width: none !important;
    max-height: none !important;
    height: 100%;
    min-height: 0;
    border: 0 !important;
    border-radius: 0;
    margin: 0;
    padding: 0;
    box-shadow: none !important;
    background: var(--bs-body-bg);
    overflow: hidden;
  }
  .mobile-notifications-layer [data-notification-list] {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
  }
  .mobile-notifications-layer [data-notification-read-all] {
    max-width: 44vw;
  }
  .mobile-notifications-layer .notification-menu > .p-4 {
    flex: 0 0 auto;
    padding-bottom: 1rem !important;
    max-height: 29vh;
    overflow-y: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mobile-dashboard-shortcut .symbol-label {
    transition: none;
  }
}

/* Confirmation/approval dialogs must render above the fullscreen inbox. */
body.mobile-notifications-open .swal2-container,
body.mobile-notifications-open .modal.show {
  z-index: 1300 !important;
}
@media (max-width: 991.98px) {
  .mobile-notifications-layer .notification-menu > .d-flex:first-child {
    flex-wrap: wrap;
    gap: 0.75rem !important;
  }
}

/* M3.1: remove desktop sidebar offsets and clamped wrappers on narrow viewports. */
@media (max-width: 991.98px) {
  body[data-mobile-shell="true"] {
    --mobile-bottom-nav-height: calc(66px + env(safe-area-inset-bottom, 0px));
    max-width: 100%;
    overflow-x: clip;
  }
  body[data-mobile-shell="true"] #kt_app_root,
  body[data-mobile-shell="true"] #kt_app_page,
  body[data-mobile-shell="true"] #kt_app_wrapper,
  body[data-mobile-shell="true"] #kt_app_main,
  body[data-mobile-shell="true"] #kt_app_content,
  body[data-mobile-shell="true"] #kt_app_content_container {
    box-sizing: border-box;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin-inline-start: 0 !important;
    margin-inline-end: 0 !important;
  }
  body[data-mobile-shell="true"] #kt_app_wrapper {
    padding-inline-start: 0 !important;
  }
  body[data-mobile-shell="true"] #kt_app_content_container {
    padding-inline: 16px !important;
    margin-inline: 0 !important;
  }
  body[data-mobile-shell="true"] #kt_app_header,
  body[data-mobile-shell="true"] #kt_app_header_container {
    box-sizing: border-box;
    width: 100% !important;
    max-width: 100% !important;
    margin-inline: 0 !important;
  }
  body[data-mobile-shell="true"] .mobile-dashboard {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
  body[data-mobile-shell="true"] .mobile-dashboard .card,
  body[data-mobile-shell="true"] .mobile-dashboard .col-6,
  body[data-mobile-shell="true"] .mobile-dashboard .col-3,
  body[data-mobile-shell="true"] .mobile-dashboard [data-mobile-addons-list] {
    min-width: 0;
    max-width: 100%;
  }
  body[data-mobile-shell="true"] #kt_app_main {
    padding-bottom: var(--mobile-bottom-nav-height);
  }
  body[data-mobile-shell="true"] .mobile-shell-bottom {
    z-index: 1250;
    height: var(--mobile-bottom-nav-height);
    box-sizing: border-box;
    width: 100%;
  }
  body[data-mobile-shell="true"] .mobile-notifications-layer {
    bottom: var(--mobile-bottom-nav-height);
    padding-bottom: 0;
    z-index: 1200;
  }
  body[data-mobile-shell="true"] .mobile-shell-bottom-inner {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  body[data-mobile-shell="true"] [data-mobile-nav-count="5"] .mobile-shell-bottom-inner {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
  body[data-mobile-shell="true"] .mobile-shell-tab {
    min-width: 0;
    font-size: clamp(0.62rem, 2.45vw, 0.75rem);
  }
  body[data-mobile-shell="true"] .mobile-dashboard-shortcut .symbol-label .fa-solid,
  body[data-mobile-shell="true"] .mobile-dashboard .symbol-label .fa-solid {
    line-height: 1;
  }
  body[data-mobile-shell="true"] .mobile-dashboard .mobile-dashboard-wallet {
    width: 100%;
  }
  body[data-mobile-shell="true"] #kt_app_scrolltop {
    bottom: calc(var(--mobile-bottom-nav-height) + 18px);
  }
}

/* M3.2 mobile addon explorer; desktop manager stays unchanged. */
@media (max-width: 991.98px) {
  body[data-mobile-shell="true"] [data-mobile-addon-explorer] {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding-bottom: 1rem;
  }
  body[data-mobile-shell="true"] [data-mobile-addon-explorer] .card,
  body[data-mobile-shell="true"] [data-mobile-addon-explorer] .row > div {
    min-width: 0;
  }
  body[data-mobile-shell="true"] [data-mobile-addon-explorer] .card-body {
    overflow-wrap: anywhere;
  }
  body[data-mobile-shell="true"] .mobile-addon-scopes .btn {
    flex: 1 1 0 !important;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    padding-inline: 0.375rem;
    font-size: clamp(0.68rem, 2.65vw, 0.8rem);
  }
}

/* Allow the full addon description to wrap within the mobile dashboard card. */
.mobile-dashboard [data-mobile-addons-list] .mobile-addon-wrap {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  min-width: 0;
}
.mobile-dashboard [data-mobile-addons-list] a > .flex-grow-1 {
  flex: 1 1 0;
  min-width: 0;
}

/* Compact Push + Read all share one row; on narrow phones the actions
   form a second row, never a full-width footer beneath notifications. */
.notification-toolbar-actions .btn {
  padding: 0.4rem 0.65rem;
  font-size: 0.8rem;
  line-height: 1.25;
  min-height: 32px;
}
.notification-toolbar-actions .notification-push-button {
  min-width: 0;
}
[data-push-status]:empty {
  display: none;
}
@media (max-width: 575.98px) {
  .notification-toolbar #mobile-notifications-heading {
    flex-basis: 100%;
  }
  .notification-toolbar-actions {
    width: 100%;
    min-width: 0;
  }
  .notification-toolbar-actions .btn {
    flex: 1 1 0;
    min-width: 0;
  }
}

/* Admin mobile: keep language selector and dropdown above the fixed tab bar. */
@media (max-width: 991.98px) {
  body[data-mobile-shell="true"] #kt_app_footer {
    padding-bottom: calc(var(--mobile-bottom-nav-height) + 16px) !important;
  }
  body[data-mobile-shell="true"] .mobile-language-dropdown .dropdown-menu {
    max-height: min(40vh, 280px);
    overflow-y: auto;
  }
}
/* Bootstrap badge defaults to nowrap; a long TWA warning must wrap inside its card. */
.mobile-app-verification-badge {
  display: block;
  width: fit-content;
  max-width: 100%;
  white-space: normal !important;
  overflow-wrap: anywhere;
  word-break: normal;
  text-align: start;
  line-height: 1.5;
}
