/* ═══════════════════════════════════════════
   Header — TailAdmin‑style
   ═══════════════════════════════════════════ */

.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--color-header);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  z-index: 100;
  gap: var(--spacing-md);
}

.header-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 2px solid var(--color-border);
}

.header-info {
  flex: 1;
}

.header-greeting {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin: 0;
  line-height: 1.3;
}

.header-username {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  margin: 0;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Header actions area */
.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.header-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--color-text-muted);
  cursor: pointer;
  border-radius: var(--radius-full);
  position: relative;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.header-icon:hover {
  background: var(--color-background);
  color: var(--color-text);
}

/* ── Dark Mode Toggle ── */
.theme-toggle {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--color-text-muted);
  cursor: pointer;
  border-radius: var(--radius-full);
  transition: background var(--transition-fast), color var(--transition-fast);
}

.theme-toggle:hover {
  background: var(--color-background);
  color: var(--color-text);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  display: none;
}

/* Light mode shows moon (to switch to dark) */
:root .theme-toggle .icon-moon,
[data-theme="light"] .theme-toggle .icon-moon {
  display: block;
}

/* Dark mode shows sun (to switch to light) */
[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}
[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

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

.notification-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--color-danger);
  color: #fff;
  font-size: 10px;
  font-weight: var(--font-weight-bold);
  line-height: 18px;
  text-align: center;
  border-radius: var(--radius-full);
  pointer-events: none;
}

.notification-badge:empty,
.notification-badge[hidden] {
  display: none;
}

.notification-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: -8px;
  width: 340px;
  max-height: 420px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity var(--transition-fast), transform var(--transition-fast), visibility var(--transition-fast);
  z-index: 200;
}

.notification-dropdown.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.notif-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px var(--spacing-md);
  border-bottom: 1px solid var(--color-border);
}

.notif-header strong {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
}

.notif-mark-read {
  background: none;
  border: none;
  color: var(--color-primary);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.notif-mark-read:hover {
  background: rgba(var(--color-primary-rgb), 0.08);
}

.notif-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 360px;
  overflow-y: auto;
}

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: var(--spacing-sm);
  padding: 12px var(--spacing-md);
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.notif-item:last-child {
  border-bottom: none;
}

.notif-item:hover {
  background: var(--color-background);
}

.notif-item.unread {
  background: rgba(var(--color-primary-rgb), 0.04);
}

.notif-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: transparent;
  flex-shrink: 0;
  margin-top: 6px;
}

.notif-item.unread .notif-dot {
  background: var(--color-primary);
}

.notif-content {
  flex: 1;
  min-width: 0;
}

.notif-text {
  margin: 0;
  font-size: var(--font-size-sm);
  line-height: 1.5;
  color: var(--color-text-secondary);
}

.notif-text strong {
  color: var(--color-text);
}

.notif-time {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
  display: block;
}

/* ── Responsive ── */
@media (max-width: 480px) {
  .notification-dropdown {
    position: fixed;
    top: calc(var(--header-height) + 12px);
    left: 12px;
    right: 12px;
    width: auto;
    max-width: none;
    max-height: calc(100vh - var(--header-height) - 100px);
    right: 12px; /* overwrite fixed right if needed */
  }
}
