/* Shared admin navbar — injected by admin-nav.js.
   Loaded by every /admin/* page + /dashboard. Token names match the existing
   design system in dashboard.html (--canvas, --ink, --hairline, etc.) so this
   slots in without theming work. */

.adm-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--canvas, #f5f1ec);
  color: var(--ink, #111);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  height: 56px;
  border-bottom: 1px solid var(--hairline, #d3cec6);
}

.adm-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  font-size: 15px;
  letter-spacing: -0.2px;
  flex-shrink: 0;
}
.adm-brand-icon {
  /* The full SmartSolution-AI lockup (S-symbol + wordmark + tagline).
     The brand asset is taller than wide so we set height and let aspect-ratio
     drive the width. Replaces the old "SS" tile + text + divider combo. */
  width: 44px; height: 44px;
  background: url("/icons/logo-full-tight.png") center/contain no-repeat;
  flex-shrink: 0;
  font-size: 0;
  color: transparent;
}
/* Now that the full lockup is rendered in the icon, the adjacent name/
   divider/sub elements are redundant — hide them. */
.adm-brand-name,
.adm-brand-divider,
.adm-brand-sub { display: none; }
.adm-brand-name { font-weight: 500; }
.adm-brand-divider { height: 18px; width: 1px; background: var(--hairline, #d3cec6); }
.adm-brand-sub { color: var(--ink-subtle, #7b7b78); font-size: 13px; font-weight: 400; }

.adm-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
}
.adm-nav a {
  color: var(--ink-muted, #626260);
  padding: 7px 12px;
  border-radius: 8px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background 120ms ease, color 120ms ease;
}
.adm-nav a:hover {
  color: var(--ink, #111);
  background: var(--surface-2, #ebe7e1);
}
.adm-nav a.active {
  background: var(--surface-1, #fff);
  color: var(--ink, #111);
  border: 1px solid var(--hairline, #d3cec6);
  padding: 6px 11px;
}

.adm-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.adm-search-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-1, #fff);
  border: 1px solid var(--hairline, #d3cec6);
  color: var(--ink-subtle, #7b7b78);
  padding: 6px 10px 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  min-width: 240px;
  text-align: right;
  transition: border-color 120ms ease, background 120ms ease;
}
.adm-search-btn:hover {
  border-color: var(--ink-tertiary, #9c9fa5);
  background: var(--surface-1, #fff);
}
.adm-search-btn .adm-search-placeholder {
  flex: 1;
  text-align: right;
}
.adm-search-btn kbd {
  background: var(--surface-2, #ebe7e1);
  border: 1px solid var(--hairline, #d3cec6);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 11px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  color: var(--ink-muted, #626260);
}

.tnt-biz-chip {
  display: inline-flex;
  align-items: center;
  background: var(--surface-1, #fff);
  border: 1px solid var(--hairline, #d3cec6);
  color: var(--ink-muted, #626260);
  padding: 5px 11px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.2px;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.adm-user {
  position: relative;
}
.adm-user-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid transparent;
  padding: 4px 8px 4px 4px;
  border-radius: 8px;
  font-family: inherit;
  cursor: pointer;
  color: var(--ink, #111);
}
.adm-user-btn:hover { background: var(--surface-2, #ebe7e1); }
.adm-user-avatar {
  width: 26px; height: 26px;
  background: var(--ink, #111);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 500; font-size: 12px;
}
.adm-user-name { font-size: 13px; font-weight: 500; }
.adm-user-chevron { color: var(--ink-tertiary, #9c9fa5); font-size: 10px; }

.adm-user-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 240px;
  background: var(--surface-1, #fff);
  border: 1px solid var(--hairline, #d3cec6);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  padding: 6px;
  display: none;
}
.adm-user-menu.open { display: block; }
.adm-user-menu-head {
  padding: 10px 12px 12px;
  border-bottom: 1px solid var(--hairline-soft, #ebe7e1);
  margin-bottom: 4px;
}
.adm-user-menu-email {
  font-size: 13px;
  color: var(--ink, #111);
  word-break: break-all;
}
.adm-user-menu-role {
  display: inline-block;
  margin-top: 4px;
  font-size: 11px;
  background: var(--surface-2, #ebe7e1);
  color: var(--ink-muted, #626260);
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 500;
}
.adm-user-menu button {
  width: 100%;
  text-align: right;
  background: transparent;
  border: 0;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink, #111);
}
.adm-user-menu button:hover { background: var(--surface-2, #ebe7e1); }
.adm-user-menu button.danger { color: #c41c1c; }

/* ----- Cmd+K search overlay ----- */
.adm-search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 100;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
}
.adm-search-overlay.open { display: flex; }
.adm-search-modal {
  width: min(600px, 90vw);
  background: var(--surface-1, #fff);
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.25);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.adm-search-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--hairline, #d3cec6);
}
.adm-search-icon { color: var(--ink-tertiary, #9c9fa5); font-size: 16px; }
.adm-search-input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  font-family: inherit;
  font-size: 16px;
  color: var(--ink, #111);
}
.adm-search-input::placeholder { color: var(--ink-tertiary, #9c9fa5); }
.adm-search-results {
  max-height: 50vh;
  overflow-y: auto;
  padding: 6px;
}
.adm-search-empty {
  padding: 24px;
  text-align: center;
  color: var(--ink-subtle, #7b7b78);
  font-size: 14px;
}
.adm-search-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 80ms ease;
}
.adm-search-item:hover,
.adm-search-item.active {
  background: var(--surface-2, #ebe7e1);
}
.adm-search-item-name {
  font-weight: 500;
  font-size: 14px;
  color: var(--ink, #111);
}
.adm-search-item-slug {
  font-size: 12px;
  color: var(--ink-subtle, #7b7b78);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
}
.adm-search-item-meta {
  font-size: 11px;
  color: var(--ink-tertiary, #9c9fa5);
}
.adm-search-footer {
  padding: 8px 14px;
  border-top: 1px solid var(--hairline-soft, #ebe7e1);
  background: var(--canvas, #f5f1ec);
  font-size: 11px;
  color: var(--ink-subtle, #7b7b78);
  display: flex;
  gap: 16px;
}
.adm-search-footer kbd {
  background: var(--surface-1, #fff);
  border: 1px solid var(--hairline, #d3cec6);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  margin: 0 2px;
}

/* =================================================================
   MOBILE — hamburger drawer + bottom nav for tenant pages.
   Triggers below 720px.
   ================================================================= */

.adm-mobile-hamburger {
  display: none;
  background: transparent;
  border: 1px solid var(--hairline, #d3cec6);
  border-radius: 8px;
  width: 38px; height: 38px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  color: var(--ink, #111);
}

.adm-mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 60;
}
.adm-mobile-overlay.open { display: block; }

.adm-mobile-drawer {
  position: fixed;
  top: 0; bottom: 0; right: 0;
  width: min(280px, 80vw);
  background: var(--surface-1, #fff);
  z-index: 70;
  transform: translateX(100%);
  transition: transform 0.22s ease;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--hairline, #d3cec6);
  padding-top: env(safe-area-inset-top);
}
.adm-mobile-drawer.open { transform: translateX(0); }
.adm-mobile-drawer .drawer-head {
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--hairline, #d3cec6);
  display: flex; align-items: center; justify-content: space-between;
}
.adm-mobile-drawer .drawer-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 4px;
}
.adm-mobile-drawer .drawer-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  margin: 2px 4px;
  border-radius: 8px;
  color: var(--ink, #111);
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
}
.adm-mobile-drawer .drawer-nav a:hover,
.adm-mobile-drawer .drawer-nav a.active {
  background: var(--surface-2, #ebe7e1);
}
.adm-mobile-drawer .drawer-foot {
  border-top: 1px solid var(--hairline, #d3cec6);
  padding: 12px 18px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}

@media (max-width: 720px) {
  .adm-topbar {
    padding: 0 12px;
    gap: 10px;
    padding-top: env(safe-area-inset-top);
    height: calc(56px + env(safe-area-inset-top));
  }
  .adm-brand-divider, .adm-brand-sub { display: none; }
  .adm-brand-name { font-size: 14px; }
  .adm-nav { display: none; }                /* desktop nav hidden */
  .adm-mobile-hamburger { display: inline-flex; }
  .adm-search-btn { display: none; }         /* search button hidden on mobile */
  .adm-user-name { display: none; }          /* avatar only */
  .adm-user-chevron { display: none; }
  .tnt-biz-chip { display: none; }
}

/* Pages that opt into a bottom tab bar on mobile (chat + inbox).
   Set body class `pwa-bottom-nav` on those pages. */
.pwa-bottom-nav-bar {
  display: none;
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  background: var(--surface-1, #fff);
  border-top: 1px solid var(--hairline, #d3cec6);
  z-index: 50;
  padding: 6px 4px;
  padding-bottom: max(6px, env(safe-area-inset-bottom));
  justify-content: space-around;
  align-items: stretch;
}
.pwa-bottom-nav-bar a {
  flex: 1;
  text-align: center;
  text-decoration: none;
  color: var(--ink-muted, #626260);
  padding: 6px 4px;
  font-size: 10px;
  font-weight: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.pwa-bottom-nav-bar a .ic { font-size: 20px; line-height: 1; }
.pwa-bottom-nav-bar a.active { color: var(--ink, #111); }
.pwa-bottom-nav-bar a.active .ic { transform: scale(1.05); }

@media (max-width: 720px) {
  body.pwa-bottom-nav .pwa-bottom-nav-bar { display: flex; }
  body.pwa-bottom-nav { padding-bottom: 68px; }
}

/* =================================================================
   GLOBAL MOBILE OVERRIDES — apply to all tenant pages.
   ================================================================= */

@media (max-width: 720px) {
  html, body { height: auto !important; min-height: 100vh; }
  body { overflow-x: hidden !important; overflow-y: auto !important; }

  /* Page chrome: tighter padding, full width */
  .page { padding: 14px !important; max-width: none !important; }
  .page.inbox-mode { padding: 0 !important; }
  .page-head { flex-direction: column !important; align-items: stretch !important; gap: 12px !important; }
  .page-title { font-size: 22px !important; }
  .page-sub { font-size: 13px !important; }

  /* Cards / sections */
  .card { padding: 16px !important; border-radius: 10px !important; }

  /* Two-column workspaces collapse to single column scroll */
  .workspace {
    grid-template-columns: 1fr !important;
    height: auto !important;
    min-height: calc(100vh - 56px) !important;
  }
  .sidebar { max-height: 320px !important; border-left: 0 !important; border-top: 1px solid var(--hairline, #d3cec6) !important; }

  .inbox-wrap {
    grid-template-columns: 1fr !important;
    height: calc(100vh - 56px - env(safe-area-inset-top) - 68px) !important;
  }
  /* Inbox: when a chat is open, show only the chat. When none, show only list. */
  .inbox-wrap .inbox-side { display: flex; }
  .inbox-wrap .inbox-main { display: none; }
  .inbox-wrap.has-active .inbox-side { display: none; }
  .inbox-wrap.has-active .inbox-main { display: flex; }

  /* Tables become cards-ish — horizontal scroll allowed; nudge font down */
  table { font-size: 13px !important; }
  th, td { padding: 10px 8px !important; }

  /* Modals → bottom sheets */
  .overlay { align-items: flex-end !important; padding-top: 0 !important; }
  .modal { width: 100% !important; max-width: 100% !important; border-radius: 14px 14px 0 0 !important; max-height: 92vh !important; }

  /* Detail drawer (call detail) takes full screen */
  .detail-drawer { width: 100vw !important; top: calc(56px + env(safe-area-inset-top)) !important; }

  /* Larger touch targets */
  .btn, button.btn, .task-btn, .btn-send {
    min-height: 40px;
    padding: 9px 14px !important;
  }
  .field input, .field textarea, .field select, .search-input, .composer textarea {
    font-size: 16px !important;  /* prevents iOS zoom on focus */
  }

  /* History panel on chat: full width drop-down */
  .history-panel { right: 12px !important; left: 12px !important; width: auto !important; }

  /* Inbox-back button — only meaningful on mobile */
  .inbox-back-btn {
    background: transparent;
    border: 1px solid var(--hairline, #d3cec6);
    border-radius: 8px;
    width: 36px; height: 36px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 18px; cursor: pointer; color: var(--ink, #111);
    flex-shrink: 0;
  }
}
@media (min-width: 721px) {
  .inbox-back-btn { display: none; }
}

/* Tablets: keep most of desktop, just shrink padding */
@media (min-width: 721px) and (max-width: 980px) {
  .page { padding: 20px !important; }
  .workspace { grid-template-columns: minmax(0, 1fr) 320px !important; }
  .inbox-wrap { grid-template-columns: 280px 1fr !important; }
}
