/* ═══════════════════════════════════════
   TOPBAR — Premium SaaS Topbar
   ═══════════════════════════════════════ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-h);
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

/* ─── Left Section ──────────────────── */
.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
  flex: 1;
}

.menu-toggle {
  display: none;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-light);
  flex-shrink: 0;
}

.menu-toggle svg {
  width: 20px;
  height: 20px;
}

/* ─── Page Heading ──────────────────── */
.page-heading {
  min-width: 0;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 11px;
  color: var(--muted);
}

.breadcrumb span {
  color: var(--muted);
  font-weight: 500;
}

.breadcrumb b {
  font-weight: 400;
  color: #CBD5E1;
}

.breadcrumb strong {
  color: var(--brand);
  font-weight: 700;
}

.page-heading h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
  line-height: 1.2;
}

.page-heading p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

/* ─── Right Actions ─────────────────── */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ─── Add Button ────────────────────── */
.btn-add {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.btn-add:hover {
  background: #1D4ED8;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.32);
  transform: translateY(-1px);
}

.btn-add svg {
  width: 16px;
  height: 16px;
}

/* ─── Global Search ─────────────────── */
.global-search {
  height: 38px;
  width: min(280px, 22vw);
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--muted);
  transition: all var(--duration-fast) var(--ease-out);
}

.global-search:focus-within {
  border-color: var(--brand);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

.global-search svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.global-search input {
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  min-width: 0;
  flex: 1;
  font-size: 12px;
  font-weight: 400;
}

.global-search input::placeholder {
  color: var(--muted);
}

.global-search kbd {
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  background: var(--surface);
  border-radius: 5px;
  padding: 2px 6px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 600;
  font-family: inherit;
  flex-shrink: 0;
}

/* ─── Theme Toggle ──────────────────── */
.theme-sun {
  display: block;
}

.theme-moon {
  display: none;
}

html[data-theme="dark"] .theme-sun {
  display: none;
}

html[data-theme="dark"] .theme-moon {
  display: block;
}

/* ─── Notification Button ───────────── */
.notification-button {
  position: relative;
}

.notification-button .badge-dot {
  position: absolute;
  right: 10px;
  top: 10px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #EF4444;
  border: 2px solid var(--surface);
}

/* ─── Profile Menu ──────────────────── */
.profile-menu-wrap {
  position: relative;
}

.profile-button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 12px 4px 4px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  transition: all var(--duration-fast) var(--ease-out);
  cursor: pointer;
}

.profile-button:hover {
  background: var(--bg-alt);
  border-color: var(--line);
}

.profile-button > svg {
  width: 14px;
  height: 14px;
  color: var(--muted);
  flex-shrink: 0;
  transition: transform var(--duration-fast) var(--ease-out);
}

.profile-menu-wrap.open .profile-button > svg {
  transform: rotate(180deg);
}

.user-avatar {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #DBEAFE, #EDE9FE);
  color: #2563EB;
  font-weight: 800;
  font-size: 14px;
  flex-shrink: 0;
}

.user-copy strong,
.user-copy small {
  display: block;
  text-align: left;
  line-height: 1.3;
}

.user-copy strong {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.user-copy small {
  font-size: 10px;
  color: var(--muted);
  font-weight: 500;
}

html[data-theme="dark"] .user-avatar {
  background: #1E3A5F;
  color: #93C5FD;
}

/* ─── Profile Dropdown ──────────────── */
.profile-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: 52px;
  width: 210px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  z-index: 100;
  animation: dropdownIn var(--duration-fast) var(--ease-out);
}

.profile-dropdown.open {
  display: block;
}

.profile-dropdown .dropdown-header {
  padding: 10px 12px 6px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
}

.profile-dropdown .dropdown-header strong {
  display: block;
  font-size: 13px;
  font-weight: 700;
}

.profile-dropdown .dropdown-header span {
  display: block;
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
}

.profile-dropdown a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-light);
  transition: all var(--duration-fast) var(--ease-out);
}

.profile-dropdown a:hover {
  background: var(--bg-alt);
  color: var(--ink);
}

.profile-dropdown a svg {
  width: 16px;
  height: 16px;
  color: var(--muted);
}

.profile-dropdown .dropdown-divider {
  height: 1px;
  background: var(--line);
  margin: 4px 0;
}

.profile-dropdown .danger-link {
  color: var(--danger);
}

.profile-dropdown .danger-link:hover {
  background: var(--danger-soft);
}

@keyframes dropdownIn {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ─── Responsive ────────────────────── */
@media (max-width: 1024px) {
  .menu-toggle {
    display: grid;
    place-items: center;
  }

  .topbar {
    padding: 0 20px;
  }
}

@media (max-width: 780px) {
  .global-search {
    display: none;
  }

  .user-copy {
    display: none;
  }

  .profile-button {
    padding: 4px;
  }

  .topbar {
    height: 64px;
  }

  .breadcrumb {
    display: none;
  }
}

@media (max-width: 520px) {
  .topbar {
    padding: 0 14px;
    gap: 12px;
  }

  .page-heading h1 {
    font-size: 17px;
  }

  .page-heading p {
    display: none;
  }

  .btn-add span {
    display: none;
  }

  .btn-add {
    width: 38px;
    padding: 0;
    justify-content: center;
  }

  .notification-button {
    display: none;
  }
}