/* ═══════════════════════════════════════════════
   31-MOBILE.CSS — App-Like Mobile Experience
   Comprehensive UX enhancements for mobile devices
   ═══════════════════════════════════════════════ */

/* ── BOTTOM NAVIGATION BAR (Mobile Only) ── */
.mob-bnav {
  display: none;
}

@media (max-width: 640px) {

  /* ── Bottom Nav: Container ── */
  .mob-bnav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--s1);
    border-top: 1px solid var(--b2);
    z-index: 195;
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    box-shadow: 0 -1px 0 var(--b1), 0 -6px 20px rgba(0,0,0,.08);
    align-items: stretch;
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  [data-theme=dark] .mob-bnav {
    box-shadow: 0 -1px 0 var(--b1), 0 -6px 24px rgba(0,0,0,.35);
  }

  /* ── Bottom Nav: Individual Items ── */
  .mob-bnav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    cursor: pointer;
    color: var(--t3);
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: 0.02em;
    transition: color .15s, background .1s;
    padding: 5px 2px 7px;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    touch-action: manipulation;
    min-height: 56px;
  }

  .mob-bnav-item:active {
    background: rgba(200,149,90,.07);
  }

  .mob-bnav-item.active {
    color: var(--np);
  }

  .mob-bnav-item svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    stroke-width: 1.8;
    transition: transform .22s cubic-bezier(.34,1.56,.64,1), color .15s;
  }

  .mob-bnav-item.active svg {
    transform: translateY(-1px) scale(1.1);
  }

  /* Active indicator bar at top of item */
  .mob-bnav-item::after {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%) scaleX(0);
    width: 28px;
    height: 3px;
    border-radius: 0 0 4px 4px;
    background: var(--np);
    box-shadow: 0 2px 6px rgba(200,149,90,.5);
    transition: transform .22s cubic-bezier(.34,1.56,.64,1);
  }

  .mob-bnav-item.active::after {
    transform: translateX(-50%) scaleX(1);
  }

  /* Badge for unread/pending counts */
  .mob-bnav-badge {
    position: absolute;
    top: 4px;
    right: calc(50% - 20px);
    background: #d94040;
    color: #fff;
    border-radius: 100px;
    font-size: 9px;
    font-weight: 800;
    padding: 1px 5px;
    min-width: 16px;
    text-align: center;
    border: 2px solid var(--s1);
    line-height: 1.3;
    display: none;
  }

  .mob-bnav-badge.show {
    display: block;
  }

  /* ── Content padding to clear bottom nav ── */
  #app.app-visible {
    padding-bottom: calc(56px + env(safe-area-inset-bottom));
  }

  /* ── Hide redundant hamburger (bottom nav "Mehr" handles it) ── */
  .mob-menu-btn {
    display: none !important;
  }

  /* ── TOUCH TARGETS: Minimum 44px for all interactive elements ── */
  .mclose {
    width: 44px !important;
    height: 44px !important;
    border-radius: 12px !important;
  }

  .icon-btn {
    width: 44px !important;
    height: 44px !important;
    border-radius: 12px !important;
  }

  .mob-drawer-close {
    width: 44px !important;
    height: 44px !important;
    border-radius: 12px !important;
  }

  /* ── MODALS: Full bottom sheet on all mobile sizes ── */
  /* Overrides the 10px-padding centered modal from 05-components.css */
  .mbg {
    padding: 0 !important;
    align-items: flex-end !important;
  }

  .modal {
    border-radius: 24px 24px 0 0 !important;
    max-height: 90vh !important;
    max-width: 100% !important;
    margin: 0 !important;
  }

  .modal-sm {
    border-radius: 24px 24px 0 0 !important;
    max-width: 100% !important;
  }

  /* Drag handle indicator at top of bottom sheet */
  .mhd::before {
    content: '';
    display: block;
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: var(--b3);
  }

  .mhd {
    position: relative;
    padding-top: 22px !important;
  }

  /* ── SETTINGS SIDEBAR: better touch targets on mobile ── */
  .set-nav-item {
    min-height: 44px !important;
    padding: 10px 14px !important;
    flex-shrink: 0;
    min-width: 108px;
  }

  /* ── SAVE BAR: raise above safe area ── */
  .set-save-bar {
    padding-bottom: max(13px, calc(13px + env(safe-area-inset-bottom))) !important;
  }

  /* ── KPI GRID: always 2 columns on phone ── */
  .kgrid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* ── CARDS: slightly tighter on mobile ── */
  .cb {
    padding: 12px !important;
  }

  .ch {
    padding: 10px 12px !important;
    gap: 6px !important;
  }

  /* ── EMPTY STATES: reduced top padding ── */
  .empty {
    padding: 36px 16px;
  }

  /* ── STICKY: account for top nav height ── */
  .sticky {
    top: 52px !important;
  }

  /* ── PAGE ANIMATION: slightly snappier ── */
  @keyframes pi {
    from { opacity:0; transform:translateY(4px) }
    to   { opacity:1; transform:none }
  }

  /* ── TABLES: ensure horizontal scroll always works ── */
  .tscroll {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }

  /* ── FAB (Floating Action Buttons): safe area aware ── */
  [class*="fab"], .pshop-cart-fab {
    bottom: calc(72px + env(safe-area-inset-bottom)) !important;
  }
}

/* ── TABLET: Moderate improvements (641-960px) ── */
@media (min-width: 641px) and (max-width: 960px) {
  .page {
    padding: 18px 20px 32px;
  }

  .g3 {
    grid-template-columns: 1fr 1fr;
  }

  .modal {
    max-width: 540px;
  }
}

/* ── LANDSCAPE PHONE: adjust bottom nav height ── */
@media (max-width: 640px) and (orientation: landscape) {
  .mob-bnav {
    height: 48px;
  }

  .mob-bnav-item {
    min-height: 48px;
    font-size: 9px;
  }

  .mob-bnav-item svg {
    width: 18px;
    height: 18px;
  }

  #app.app-visible {
    padding-bottom: calc(48px + env(safe-area-inset-bottom));
  }
}

/* ── PWA: Standalone mode adjustments ── */
@media (display-mode: standalone) {
  /* In PWA mode, ensure status bar area is respected */
  .nav {
    padding-top: env(safe-area-inset-top);
  }
}
