/* ════════════════════════════════════════════════
   TOP BAR — breadcrumb, search, utilities, account menu.
   Loaded after main.css and enterprise-ui.css so it owns the topbar.
   Every control is 40px tall and vertically centred on one line; the
   bar height matches the sidebar header (var(--topbar-h)) so their bottom
   borders meet in one straight line.
   ════════════════════════════════════════════════ */

#topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--space-3);
  padding: 0 var(--space-5) 0 var(--space-3);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

/* Shared 40px icon button */
#topbar .sidebar-toggle,
.topbar-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; flex-shrink: 0; position: relative;
  background: transparent; border: 1px solid transparent; border-radius: var(--radius-ui);
  color: var(--color-text-secondary); cursor: pointer;
  transition: background var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease);
}
#topbar .sidebar-toggle:hover,
.topbar-icon-btn:hover { background: var(--color-surface-muted); color: var(--color-text); }
.topbar-icon-btn .material-symbols-outlined,
#topbar .sidebar-toggle .material-symbols-outlined { font-size: 22px; width: 22px; height: 22px; }

/* ── Breadcrumb ── */
.topbar-breadcrumb-nav { flex: 1 1 auto; min-width: 0; }
.breadcrumb {
  display: flex; align-items: center; list-style: none; margin: 0; padding: 0;
  min-width: 0; font-size: var(--text-sm); line-height: 1;
}
.breadcrumb li { display: flex; align-items: center; min-width: 0; flex-shrink: 1; }
.breadcrumb li + li::before {
  content: ''; flex-shrink: 0;
  width: 6px; height: 6px; margin: 0 10px;
  border-top: 1.5px solid var(--color-border-strong); border-right: 1.5px solid var(--color-border-strong);
  transform: rotate(45deg);
}
.crumb-link, .crumb-text, .breadcrumb [aria-current="page"] {
  display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 6px 4px; border-radius: var(--radius-ui);
}
.crumb-link {
  background: none; border: none; cursor: pointer; font: inherit;
  color: var(--color-text-secondary);
  transition: color var(--duration-fast) var(--ease), background var(--duration-fast) var(--ease);
}
.crumb-link:hover { color: var(--color-text); background: var(--color-surface-muted); }
.crumb-text { color: var(--color-text-secondary); }
.breadcrumb li:not(.crumb-current) { flex-shrink: 2; max-width: 220px; }
.crumb-current { flex-shrink: 1; }
.breadcrumb [aria-current="page"] { color: var(--color-text); font-weight: 600; font-size: var(--text-base); }
.crumb-home { flex-shrink: 0 !important; }
.crumb-home-btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0; margin-left: -4px; }
.crumb-home-btn .material-symbols-outlined { font-size: 20px; width: 20px; height: 20px; }

/* Page-specific actions slot */
#topbar .topbar-actions:empty { display: none; }

/* ── Right-hand tools ── */
.topbar-tools { display: flex; align-items: center; gap: var(--space-1); flex-shrink: 0; }
.topbar-divider { width: 1px; height: 24px; background: var(--color-border); margin: 0 var(--space-2); flex-shrink: 0; }

/* Search trigger — looks like a field, opens the command palette */
#topbar .command-trigger {
  display: inline-flex; align-items: center; gap: var(--space-2);
  height: 40px; width: 240px; padding: 0 6px 0 12px;
  background: var(--color-surface-muted); border: 1px solid var(--color-border); border-radius: var(--radius-ui);
  color: var(--color-text-secondary); font: inherit; font-size: var(--text-sm); cursor: pointer; text-align: left;
  transition: border-color var(--duration-fast) var(--ease), background var(--duration-fast) var(--ease);
}
#topbar .command-trigger:hover { border-color: var(--color-border-strong); background: var(--color-surface); }
#topbar .command-trigger .material-symbols-outlined { font-size: 20px; width: 20px; height: 20px; }
#topbar .command-trigger-label { flex: 1; }
#topbar .command-trigger kbd {
  font: inherit; font-size: var(--text-xs); line-height: 1; color: var(--color-text-secondary);
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-ui);
  padding: 5px 6px;
}

/* Notification count — sits on the bell's corner */
#topbar .notification-bell-badge { top: 4px; right: 3px; }

/* ── Account menu ── */
.profile-menu { position: relative; }
.profile-trigger {
  display: inline-flex; align-items: center; gap: 10px;
  height: 44px; padding: 0 6px 0 4px; max-width: 240px;
  background: transparent; border: 1px solid transparent; border-radius: var(--radius-ui);
  color: var(--color-text); cursor: pointer; font: inherit; text-align: left;
  transition: background var(--duration-fast) var(--ease), border-color var(--duration-fast) var(--ease);
}
.profile-trigger:hover, .profile-menu.open .profile-trigger { background: var(--color-surface-muted); }
.profile-menu.open .profile-trigger { border-color: var(--color-border); }
.profile-trigger-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.profile-trigger-name { font-size: var(--text-sm); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.profile-trigger-role { font-size: var(--text-xs); color: var(--color-text-secondary); white-space: nowrap; }
.profile-trigger-chevron { font-size: 20px !important; width: 20px; height: 20px; color: var(--color-text-secondary); transition: transform var(--duration) var(--ease); }
.profile-menu.open .profile-trigger-chevron { transform: rotate(180deg); }

/* Avatar — circle (allowed exception to the 1px radius rule). A person
   silhouette is the placeholder when there's no photo. */
.topbar-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--color-surface-muted); color: var(--color-text-secondary);
  box-shadow: inset 0 0 0 1px var(--color-border);
}
.topbar-avatar .material-symbols-outlined { font-size: 22px; width: 22px; height: 22px; font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }
.topbar-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.topbar-avatar.has-photo { box-shadow: none; }
.topbar-avatar-lg { width: 44px; height: 44px; }
.topbar-avatar-lg .material-symbols-outlined { font-size: 28px; width: 28px; height: 28px; }

.profile-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: var(--z-dropdown);
  width: 280px; padding: var(--space-2) 0;
  background: var(--color-surface-raised); border: 1px solid var(--color-border); border-radius: var(--radius-ui);
  box-shadow: var(--shadow-overlay);
  animation: menuIn var(--duration) var(--ease);
}
.profile-dropdown[hidden] { display: none; }
@keyframes menuIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.profile-dropdown-head {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4) var(--space-4);
  border-bottom: 1px solid var(--color-border); margin-bottom: var(--space-2);
}
.profile-dropdown-id { min-width: 0; display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }
.profile-dropdown-name { font-weight: 600; font-size: var(--text-sm); max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-dropdown-email { font-size: var(--text-xs); color: var(--color-text-secondary); max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-dropdown-id .badge { margin-top: 4px; }
.profile-menu-item {
  display: flex; align-items: center; gap: var(--space-3); width: 100%;
  min-height: 40px; padding: 0 var(--space-4);
  background: none; border: none; cursor: pointer; font: inherit; font-size: var(--text-sm);
  color: var(--color-text); text-align: left;
}
.profile-menu-item .material-symbols-outlined { font-size: 20px; width: 20px; height: 20px; color: var(--color-text-secondary); }
.profile-menu-item:hover, .profile-menu-item:focus-visible { background: var(--color-surface-muted); outline: none; }
.profile-menu-item:focus-visible { box-shadow: inset 2px 0 0 var(--color-focus); }
.profile-menu-sep { height: 1px; background: var(--color-border); margin: var(--space-2) 0; }
.profile-menu-signout, .profile-menu-signout .material-symbols-outlined { color: var(--color-danger); }

/* ── Responsive ── */
@media (max-width: 1279px) {
  #topbar .command-trigger { width: 200px; }
  .profile-trigger-text { display: none; }
}
@media (max-width: 1024px) {
  #topbar { padding-right: var(--space-3); }
  #topbar .command-trigger { width: 40px; padding: 0; justify-content: center; background: transparent; border-color: transparent; }
  #topbar .command-trigger:hover { background: var(--color-surface-muted); }
  #topbar .command-trigger-label, #topbar .command-trigger kbd { display: none; }
}
@media (max-width: 768px) {
  /* Phone: show only the current page name; Back buttons and the drawer
     handle hierarchy. */
  .breadcrumb li:not(.crumb-current) { display: none; }
  .breadcrumb li.crumb-current::before { display: none; }
  #help-trigger, #preferences-trigger, .topbar-divider { display: none; }
  .profile-trigger-chevron { display: none; }
  .profile-trigger { padding: 0 2px; }
  .topbar-tools { gap: 0; }
}
@media (max-width: 480px) {
  #topbar { gap: var(--space-1); padding: 0 var(--space-2); }
  .profile-dropdown { position: fixed; top: calc(var(--topbar-h) + 4px); right: 8px; left: 8px; width: auto; }
}
