/* mobile-nav.css — mobile navigation system
   Load AFTER layout-sidebar.css */

/* ══════════════════════════════════════════════
   MOBILE ONLY (≤920px)
   ══════════════════════════════════════════════ */
@media (max-width: 920px) {

  /* ── Topbar: hide desktop-only items, keep hamburger + title + avatar ── */
  .topbar__page-title { display: none !important; }
  #globalSearchOpen { display: none !important; }
  #notifDropdownWrap { display: none !important; }
  #chatDropdownWrap { display: none !important; }
  .topbar__clock-badge { display: none !important; }
  .topbar__nav { display: none !important; }

  /* ── Title button gets all available space ── */
  .topbar__spacer { display: none; }
  .topbar__title-sub { flex-shrink: 1; min-width: 0; }

  /* ── Hide sub-header entirely on mobile — action bar replaces it ── */
  .pg-head { display: none !important; }

  /* ── Hide FAB stack on mobile — action bar replaces it ── */
  .fab-stack { display: none !important; }

  /* ── Hide bug widget FAB on mobile — bug button in action bar ── */
  .bug-widget { display: none !important; }

  /* ── Mobile-only profile dropdown items (Notifications, Messages) ── */
  .topbar__dropdown-item--mobile-only { display: flex !important; }

  /* ── Topbar: Tappable title button ── */
  .topbar__title-btn {
    display: flex; align-items: center; gap: .375rem;
    flex: 1; min-width: 0;
    padding: .25rem .375rem; border-radius: .5rem;
    border: none; background: transparent; cursor: pointer;
    font-family: var(--font-heading);
    -webkit-tap-highlight-color: transparent; transition: background .15s;
  }
  .topbar__title-btn:hover { background: var(--bg-hover); }
  .topbar__title-main {
    font-size: 1rem; font-weight: 900; color: var(--text-primary);
    letter-spacing: -.4px; white-space: nowrap; flex-shrink: 0;
  }
  .topbar__title-sep { font-size: .875rem; font-weight: 400; color: var(--text-muted); flex-shrink: 0; }
  .topbar__title-sub {
    font-size: .875rem; font-weight: 600; color: var(--text-secondary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .topbar__title-caret {
    flex-shrink: 0; color: var(--text-muted); display: flex; align-items: center; justify-content: center;
    transition: transform .2s cubic-bezier(.4,0,.2,1);
  }
  .topbar__title-caret svg { width: 13px; height: 13px; }
  .topbar__title-caret.is-open { transform: rotate(180deg); }
  .topbar__title-btn[data-no-sub] .topbar__title-sep,
  .topbar__title-btn[data-no-sub] .topbar__title-sub,
  .topbar__title-btn[data-no-sub] .topbar__title-caret { display: none; }
  .topbar__title-btn[data-no-sub] { cursor: default; }
  .topbar__title-btn[data-no-sub]:hover { background: transparent; }

  /* ── Topbar: Sub-nav dropdown ── */
  .topbar__subnav-bd {
    position: fixed; inset: 0; z-index: calc(var(--z-topbar) - 2);
    background: rgba(0,0,0,.25); opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  .topbar__subnav-bd.is-open { opacity: 1; pointer-events: auto; }
  .topbar__subnav {
    overflow: hidden; max-height: 0; opacity: 0; pointer-events: none;
    background: var(--bg-card); border-bottom: 1px solid var(--border);
    transition: max-height .28s cubic-bezier(.4,0,.2,1), opacity .2s;
    position: relative; z-index: calc(var(--z-topbar) - 1);
  }
  .topbar__subnav.is-open { max-height: 360px; opacity: 1; pointer-events: auto; }
  .topbar__subnav-inner { padding: 8px 12px 12px; }
  .topbar__subnav-label {
    display: block; font-size: .625rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .09em; color: var(--text-muted); padding: 4px 4px 8px;
  }
  .topbar__subnav-list { display: flex; flex-direction: column; gap: 2px; }
  .topbar__subnav-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 9px 12px; border-radius: var(--radius-md); cursor: pointer;
    border: 1px solid transparent; background: transparent; font-family: var(--font-body);
    width: 100%; text-align: left; transition: background .12s;
    -webkit-tap-highlight-color: transparent;
  }
  .topbar__subnav-item:hover { background: var(--bg-hover); }
  .topbar__subnav-item.is-active { background: var(--accent-bg); border-color: rgba(16,185,129,.2); }
  .topbar__subnav-item__name { font-size: .8125rem; font-weight: 500; color: var(--text-secondary); }
  .topbar__subnav-item.is-active .topbar__subnav-item__name { color: var(--text-primary); font-weight: 600; }
  .topbar__subnav-item__right { display: flex; align-items: center; gap: 8px; }
  .topbar__subnav-item__cnt {
    font-size: .625rem; font-weight: 700; color: var(--text-muted); background: var(--bg-hover);
    padding: 1px 6px; border-radius: 10px; font-family: var(--font-mono);
  }
  .topbar__subnav-item.is-active .topbar__subnav-item__cnt { color: var(--accent); background: var(--accent-bg); }
  .topbar__subnav-check {
    width: 17px; height: 17px; border-radius: 50%; border: 1.5px solid var(--border-hover);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  }
  .topbar__subnav-item.is-active .topbar__subnav-check { border-color: var(--accent); background: var(--accent); }
  .topbar__subnav-check svg { width: 9px; height: 9px; color: #fff; display: none; }
  .topbar__subnav-item.is-active .topbar__subnav-check svg { display: block; }

  /* ── Action bar: fixed to bottom of screen ── */
  .mob-action-bar {
    display: flex; align-items: stretch; height: 62px; padding: 0 6px; gap: 4px;
    background: var(--bg-card); border-top: 1px solid var(--border);
    position: fixed; bottom: 0; left: 0; right: 0;
    z-index: 90; flex-shrink: 0;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .mob-action-btn {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; font-size: .625rem; font-weight: 600; color: var(--text-muted); letter-spacing: .02em;
    cursor: pointer; border: none; background: transparent; font-family: var(--font-body);
    border-radius: var(--radius-md); transition: color .15s, background .15s;
    -webkit-tap-highlight-color: transparent;
  }
  .mob-action-btn svg { width: 20px; height: 20px; }
  .mob-action-btn:hover { color: var(--text-secondary); background: var(--bg-hover); }
  .mob-action-btn:active { opacity: .7; }
  .mob-action-btn.has-active { color: var(--accent); }
  .mob-action-btn--add { color: var(--accent); }
  .mob-action-btn--add:hover { background: transparent; }
  .mob-action-btn--add span { font-size: .625rem; }
  .mob-action-ico {
    width: 38px; height: 38px; border-radius: 12px; background: var(--accent);
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 12px rgba(16,185,129,.3); transition: transform .15s, background .15s;
  }
  .mob-action-ico svg { width: 18px; height: 18px; color: #fff; }
  .mob-action-btn--add:hover .mob-action-ico { background: #047857; transform: scale(1.05); }
  .mob-action-btn--add:active .mob-action-ico { transform: scale(.96); }

  /* ── Filter/Sort bottom sheet ── */
  .mob-sheet-bd {
    position: fixed; inset: 0; z-index: 500; background: rgba(0,0,0,.35);
    opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  .mob-sheet-bd.is-open { opacity: 1; pointer-events: auto; }
  .mob-sheet {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 501;
    background: var(--bg-card); border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 30px rgba(0,0,0,.15);
    transform: translateY(100%); transition: transform .28s cubic-bezier(.4,0,.2,1);
    padding: 16px 20px calc(16px + env(safe-area-inset-bottom, 0));
    max-height: 60vh; overflow-y: auto;
  }
  .mob-sheet-bd.is-open + .mob-sheet,
  .mob-sheet.is-open { transform: translateY(0); }
  .mob-sheet__handle {
    width: 36px; height: 4px; border-radius: 2px; background: var(--border);
    margin: 0 auto 14px;
  }
  .mob-sheet__title {
    font-size: 15px; font-weight: 700; color: var(--text-primary); margin: 0 0 12px;
  }
  .mob-sheet__options { display: flex; flex-direction: column; gap: 2px; }
  .mob-sheet__option {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px; border-radius: var(--radius-md); cursor: pointer;
    border: none; background: transparent; font-family: var(--font-body);
    font-size: 14px; font-weight: 500; color: var(--text-secondary);
    width: 100%; text-align: left; transition: background .12s;
    -webkit-tap-highlight-color: transparent;
  }
  .mob-sheet__option:hover { background: var(--bg-hover); }
  .mob-sheet__option.is-active { background: var(--accent-bg); color: var(--text-primary); font-weight: 600; }
  .mob-sheet__check {
    width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--border-hover);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  }
  .mob-sheet__option.is-active .mob-sheet__check { border-color: var(--accent); background: var(--accent); }
  .mob-sheet__check svg { width: 10px; height: 10px; color: #fff; display: none; }
  .mob-sheet__option.is-active .mob-sheet__check svg { display: block; }

  [data-theme="dark"] .mob-action-bar { background: #0c0c0f; border-color: rgba(255,255,255,.07); }
  [data-theme="dark"] .mob-action-ico { box-shadow: 0 4px 12px rgba(16,185,129,.18); }
  [data-theme="dark"] .mob-sheet { background: #18181b; }

  /* Pad main content so fixed action bar doesn't cover it */
  .main { padding-bottom: max(80px, calc(70px + env(safe-area-inset-bottom))) !important; }
}

/* ══════════════════════════════════════════════
   Shared: Desktop filter bar (visible on desktop, hidden on mobile via pg-head)
   ══════════════════════════════════════════════ */
.pg-filter-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 24px; background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}
.pg-filter-select {
  padding: 7px 32px 7px 12px; font-size: 13px; font-weight: 500;
  font-family: var(--font-body); color: var(--text-primary);
  background: var(--bg-base); border: 1px solid var(--border);
  border-radius: var(--radius-md); cursor: pointer; outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.pg-filter-select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(5,150,105,.12);
}
[data-theme="dark"] .pg-filter-select {
  background-color: var(--bg-input);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}
@media (max-width: 920px) {
  /* Filter bar hidden on mobile — replaced by bottom sheets */
  .pg-filter-bar { display: none !important; }
}

/* ══════════════════════════════════════════════
   DESKTOP ONLY (≥921px) — hide all mobile elements
   ══════════════════════════════════════════════ */
@media (min-width: 921px) {
  .mob-action-bar { display: none !important; }
  .mob-sheet-bd { display: none !important; }
  .mob-sheet { display: none !important; }
  .topbar__title-btn { display: none !important; }
  .topbar__subnav { display: none !important; }
  .topbar__subnav-bd { display: none !important; }
  .topbar__dropdown-item--mobile-only { display: none !important; }
}
