/* =========================================================
   BenOpsOne Mobile Application Layer
   Author: Benjamin Spargur
   Date: 2026-05-11
   Purpose: Makes BenOpsOne installable and touch-friendly on phones/tablets.
   ========================================================= */

:root {
  --bo-mobile-topbar-height: 64px;
  --bo-mobile-safe-top: env(safe-area-inset-top, 0px);
  --bo-mobile-safe-bottom: env(safe-area-inset-bottom, 0px);
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body.bo-mobile-menu-open {
  overflow: hidden !important;
}

.bo-mobile-appbar,
.bo-mobile-backdrop {
  display: none;
}

.bo-mobile-install-tip {
  display: none;
}

@media (max-width: 820px) {
  body {
    padding-top: calc(var(--bo-mobile-topbar-height) + var(--bo-mobile-safe-top)) !important;
    background: #f3f6fb !important;
  }

  .bo-mobile-appbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10020;
    height: calc(var(--bo-mobile-topbar-height) + var(--bo-mobile-safe-top));
    padding: calc(10px + var(--bo-mobile-safe-top)) 14px 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(7, 20, 38, 0.98);
    color: #fff;
    box-shadow: 0 14px 28px rgba(2, 8, 23, 0.22);
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
    backdrop-filter: blur(12px);
  }

  .bo-mobile-menu-button {
    width: 44px;
    height: 44px;
    border: 1px solid rgba(226, 232, 240, 0.18);
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    cursor: pointer;
    touch-action: manipulation;
  }

  .bo-mobile-menu-button:active {
    transform: scale(0.98);
  }

  .bo-mobile-menu-button span,
  .bo-mobile-menu-button::before,
  .bo-mobile-menu-button::after {
    content: "";
    display: block;
    width: 20px;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
    position: absolute;
  }

  .bo-mobile-menu-button {
    position: relative;
  }

  .bo-mobile-menu-button::before { transform: translateY(-7px); }
  .bo-mobile-menu-button::after { transform: translateY(7px); }

  .bo-mobile-app-title {
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.05;
  }

  .bo-mobile-app-title strong {
    font-size: 16px;
    font-weight: 850;
    letter-spacing: -0.03em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .bo-mobile-app-title span {
    margin-top: 3px;
    color: #b8c6d9;
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .bo-mobile-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: block;
    background: rgba(2, 8, 23, 0.52);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
  }

  body.bo-mobile-menu-open .bo-mobile-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .page-shell {
    display: block !important;
    grid-template-columns: 1fr !important;
    min-height: calc(100vh - var(--bo-mobile-topbar-height)) !important;
    width: 100% !important;
    overflow-x: hidden !important;
  }

  .bo-sidebar,
  .asset-bo-sidebar,
  aside.bo-sidebar {
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    z-index: 10010 !important;
    width: min(86vw, 340px) !important;
    min-width: 0 !important;
    max-width: 340px !important;
    min-height: 100dvh !important;
    height: 100dvh !important;
    padding: calc(18px + var(--bo-mobile-safe-top)) 16px calc(18px + var(--bo-mobile-safe-bottom)) !important;
    overflow-y: auto !important;
    transform: translateX(-105%) !important;
    transition: transform 220ms ease !important;
    box-shadow: 20px 0 36px rgba(2, 8, 23, 0.36) !important;
  }

  body.bo-mobile-menu-open .bo-sidebar,
  body.bo-mobile-menu-open .asset-bo-sidebar,
  body.bo-mobile-menu-open aside.bo-sidebar {
    transform: translateX(0) !important;
  }

  .bo-brand {
    padding-bottom: 16px !important;
    margin-bottom: 16px !important;
  }

  .bo-brand-link {
    gap: 10px !important;
  }

  .bo-brand-logo {
    width: 52px !important;
    height: 52px !important;
    min-width: 52px !important;
    border-radius: 16px !important;
  }

  .bo-brand-name {
    font-size: 24px !important;
    letter-spacing: -0.045em !important;
  }

  .bo-brand-tagline {
    font-size: 12px !important;
    margin-top: 6px !important;
  }

  .bo-nav {
    gap: 6px !important;
  }

  .bo-nav-item,
  .bo-nav-summary {
    min-height: 48px !important;
    border-radius: 13px !important;
    gap: 12px !important;
    padding: 11px 12px !important;
    font-size: 15px !important;
    line-height: 1.15 !important;
  }

  .bo-nav-icon {
    width: 22px !important;
    height: 22px !important;
  }

  .bo-caret {
    font-size: 16px !important;
  }

  .bo-subnav {
    margin-left: 23px !important;
    padding: 6px 0 10px 12px !important;
  }

  .bo-subnav-item {
    min-height: 42px !important;
    gap: 10px !important;
    padding: 10px 11px !important;
    font-size: 14px !important;
  }

  .bo-subnav-icon {
    width: 18px !important;
    height: 18px !important;
  }

  .main,
  main.main,
  .content,
  .page-main {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    padding: 14px !important;
    overflow-x: hidden !important;
  }

  .topbar,
  .page-topbar,
  .standard-page-topbar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
    padding: 16px !important;
    margin-bottom: 14px !important;
    border-radius: 18px !important;
  }

  h1,
  .topbar h1,
  .page-topbar h1 {
    font-size: clamp(24px, 7vw, 30px) !important;
    line-height: 1.08 !important;
  }

  .subtitle,
  .title p {
    font-size: 14px !important;
    line-height: 1.45 !important;
  }

  .user-box {
    width: 100% !important;
    min-width: 0 !important;
    text-align: left !important;
  }

  .summary-grid,
  .module-grid,
  .cards,
  .polished-cards,
  .dashboard-grid,
  .dashboard-grid-v9,
  .layout,
  .grid,
  .kpi-grid,
  .stats-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 12px !important;
    width: 100% !important;
  }

  .module-card,
  .summary-card,
  .panel,
  .hero-panel,
  .mini-panel,
  .card {
    min-width: 0 !important;
    width: 100% !important;
    border-radius: 18px !important;
  }

  .hero-panel {
    flex-direction: column !important;
    align-items: stretch !important;
  }

  .tabs,
  .asset-tabs,
  .standard-asset-tabs {
    display: flex !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    gap: 8px !important;
    padding: 8px !important;
    scrollbar-width: thin;
  }

  .tabs .tab,
  .asset-tabs .tab,
  button,
  .btn,
  input,
  select,
  textarea {
    min-height: 44px;
    font-size: 16px;
  }

  table {
    display: block !important;
    width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    white-space: nowrap;
  }

  .table-wrap,
  .table-responsive,
  .data-table-wrap {
    width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  img,
  svg,
  canvas,
  video {
    max-width: 100%;
  }
}

@media (display-mode: standalone) and (max-width: 820px) {
  .bo-mobile-appbar {
    background: #071426;
  }
}
