/* ─────────────────────────────────────────────────────────
   Responsive breakpoints — app shell + shared components only.
   Page-specific responsive rules (inbox, contacts, ...) live in
   their own page stylesheets.

   Breakpoint system used across the app:
     Mobile:         < 768px   (sidebar hidden, bottom nav shown)
     Tablet:         768–991px (compact icon-rail sidebar)
     Small Desktop:  992–1199px (compact icon-rail sidebar)
     Desktop:        >= 1200px (full sidebar)
   Tablet and Small Desktop share the same compact sidebar treatment —
   a full ~205px sidebar was eating too much of the Inbox/Contacts
   workspace in that whole 769–1199px range, not just 993–1199px.
   ───────────────────────────────────────────────────────── */

/* ─── Compact icon-only sidebar: Tablet + Small Desktop.
   Never triggers at 1280x720, 1366x768 or 1440x900 (all >= 1200px wide),
   and mobile (<768px) hides the sidebar entirely instead (see below). ─── */
@media (min-width: 769px) and (max-width: 1199px) {
  .app-sidebar { width: 64px; }
  .app-sidebar-brand { justify-content: center; padding: 10px 8px; }
  .app-sidebar-brand img { display: none; }
  .app-sidebar-user .user-meta,
  .app-nav-item .nav-label { display: none; }
  .app-sidebar-user { justify-content: center; }
  .app-nav-item { justify-content: center; padding: 10px; }

  /* The collapsed-state tooltip technique (see app-shell.css) also makes
     nav item labels readable in the tablet rail on hover/focus, since the
     nav-label span itself is display:none here. */
  .app-nav-item {
    position: relative;
  }
  .app-nav-item:hover::after,
  .app-nav-item:focus-visible::after {
    content: attr(title);
    position: absolute;
    top: 50%;
    inset-inline-start: calc(100% + 10px);
    transform: translateY(-50%);
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
    z-index: var(--z-dropdown);
    pointer-events: none;
  }

  /* Same idea for the user avatar — its name is hidden in the rail just
     like nav labels are, so it needs the same hover/focus tooltip the
     manually-collapsed desktop sidebar already has (see app-shell.css). */
  .app-sidebar-user .user-avatar:hover::after,
  .app-sidebar-user .user-avatar:focus-visible::after {
    content: attr(data-tooltip);
    position: absolute;
    top: 50%;
    inset-inline-start: calc(100% + 10px);
    transform: translateY(-50%);
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
    z-index: var(--z-dropdown);
    pointer-events: none;
  }
}

/* ─── Page header: keep title/subtitle from pushing actions off-screen.
   Shared by every page via x-ds-page-header (see app-shell.css for the
   base, non-responsive rules). ─── */
.ds-page-header h5 {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ds-page-header-subtitle {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ds-page-header-actions {
  flex-shrink: 0;
}
@media (max-width: 480px) {
  .ds-page-header-subtitle { display: none; }
  .ds-page-header { gap: 8px; }
  .ds-page-header-actions { gap: 6px; }
}

/* ─── Shared page padding: tighten gradually on small screens instead of
   the fixed 20px used everywhere on desktop (Labels/Users/Activity all
   render straight inside .ds-page-body; Inbox/Contacts use their own
   wrapper elements with their own responsive padding in their module CSS). ─── */
@media (max-width: 768px) {
  .ds-page-header { padding: 10px 12px; }
  .ds-page-body { padding: 12px; }
}
@media (max-width: 380px) {
  .ds-page-body { padding: 10px; }
}

/* ─── Mobile: sidebar out, bottom nav in ─── */
@media (max-width: 768px) {
  html, body { overflow-x: hidden; }
  .app-shell {
    overflow-x: hidden;
    padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
  }
  .app-sidebar { display: none; }
  .app-main { width: 100vw !important; min-width: unset !important; flex: 1; }
  .app-main.hidden-mobile { display: none !important; }
  .ds-mobile-header-logo { display: block; }
  .ds-mobile-lang-btn { display: inline-flex; }
  .app-bottom-nav { display: flex; }
  .ds-page { min-height: 0; }

  /* An open conversation is a full-screen, focused view on mobile (its own
     header already has a back button) — the bottom nav would just steal
     ~56px from the message area for redundant navigation chrome. */
  body.ds-full-screen-mobile .app-shell { padding-bottom: 0; }
  body.ds-full-screen-mobile .app-bottom-nav { display: none; }
}

/* ─── Bottom navigation: safe-area for the home indicator on notched
   devices (iPhone X+ and similar Android gesture-nav phones). ─── */
.app-bottom-nav {
  height: calc(56px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* ─── "More" offcanvas: scrollable on short viewports instead of being
   clipped by the viewport edge, and its own safe-area bottom padding. ─── */
.app-more-drawer {
  max-height: min(80vh, 80dvh);
}
.app-more-drawer .offcanvas-body {
  overflow-y: auto;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
}
