/* ============================================================
   header.css  (was baseX.css)
   Scope: ONLY .topbar / .header and child components.
   Global tokens live in tokens.css — do NOT redeclare :root here.
   ============================================================ */

/* ===== DARK MODE — header-specific overrides only ===== */
[data-theme="dark"] .topbar .c-search__input { background: var(--ink-100); }
[data-theme="dark"] .topbar .topbar .account-fab,
[data-theme="dark"] .topbar .dropdown { background: var(--ink-50); }

/* ===== HEADER SHELL ===== */
.header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.85rem 1.5rem;
}

/* ===== LOGO / BRAND ===== */
.topbar__brand-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}
.topbar__brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--text);
}
.brand-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 9px;
  overflow: hidden;
  flex-shrink: 0;
  display: block;
}
.brand-text {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  display: flex;
}
.brand-primary {
  background: linear-gradient(90deg, var(--gold), var(--pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-secondary { color: var(--text); }

/* ===== ONLINE PRESENCE ===== */
.c-presence {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.6rem;
  background: var(--hover);
  border-radius: 20px;
  font-size: 0.78rem;
  color: var(--muted);
}
.c-presence__dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34,197,94,0.2);
  animation: topbar-pulse 2s infinite;
}
@keyframes topbar-pulse {
  0%,100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.c-presence__count { color: var(--text); }

/* ===== SEARCH ===== */
.c-search {
  flex: 1;
  max-width: 480px;
  position: relative;
  display: flex;
  align-items: center;
}
.c-search__input {
  width: 100%;
  padding: 0.7rem 1rem 0.7rem 2.8rem;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-size: 0.95rem;
  background: var(--surface-sunken);
  color: var(--text);
  transition: all 0.2s;
  outline: none;
}
.c-search__input:focus {
  border-color: var(--primary);
  background: var(--bg);
  box-shadow: 0 0 0 3px rgba(0,0,0,0.06);
}
.c-search__icon {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  width: 18px; height: 18px;
  color: var(--muted);
  pointer-events: none;
}
.c-search__btn {
  position: absolute;
  right: 6px;
  border: none;
  background: var(--primary);
  color: var(--surface);
  width: 34px; height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.c-search__btn svg { width: 16px; height: 16px; }

/* ===== ACTIONS ===== */
.topbar__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
  flex-shrink: 0;
}

/* ===== BUTTONS — scoped to header ===== */
.topbar-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 0.55rem 0.9rem;
  border-radius: var(--radius);
  font: 600 13px/1 var(--font-sans);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--duration) var(--ease),
              border-color var(--duration) var(--ease);
}
.topbar-btn--ghost  { background: transparent; border-color: transparent; }
.topbar-btn--ghost:hover { background: var(--surface-sunken); }
.topbar-btn--primary { background: var(--text); color: var(--surface); border-color: var(--text); }
.topbar-btn--primary:hover { background: var(--accent); border-color: var(--accent); color: var(--text-on-accent); }

/* ===== ICON BUTTONS ===== */
.topbar .icon-btn {
  position: relative;
  width: 44px; height: 44px;
  border: none;
  background: transparent;
  border-radius: 12px;
  cursor: pointer;
  display: grid;
  place-items: center;
  color: var(--text);
  transition: background 0.2s;
}
.topbar .icon-btn:hover { background: var(--hover); }
.topbar .icon-btn svg { width: 22px; height: 22px; }


/* ===== BADGE ===== */
.topbar .badge {
  position: absolute;
  top: 7px; right: 7px;
  min-width: 18px; height: 18px;
  padding: 0 4px;
  background: #ef4444;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  border-radius: 9px;
  display: grid;
  place-items: center;
  border: 2px solid var(--bg);
}

/* ===== ACCOUNT FAB ===== */
.topbar .account-fab {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.3rem 0.6rem 0.3rem 0.35rem;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  background: var(--bg);
  transition: all 0.2s;
}
.topbar .account-fab:hover { border-color: var(--primary); background: var(--hover); }
.topbar .account-fab__image,
.topbar .account-fab__fallback {
  width: 36px; height: 36px;
  border-radius: 50%;
  object-fit: cover;
}
.topbar .account-fab__fallback {
  background: linear-gradient(135deg, var(--gold), var(--pink));
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
}
.account-info { line-height: 1.2; text-align: left; }
.account-info .name { font-size: 0.88rem; font-weight: 600; color: var(--text); }
.account-info .role { font-size: 0.72rem; color: var(--muted); }
.topbar .account-fab .chev { width: 16px; height: 16px; color: var(--muted); }

/* ===== DROPDOWNS ===== */
.topbar .dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.12);
  min-width: 280px;
  opacity: 0;
  visibility: hidden;
  display: none;
  transform: translateY(-8px);
  transition: all 0.2s;
  z-index: 200;
}
.topbar .nf-dropdown {
  min-width: 380px;
  overflow: hidden;
}
.topbar .dropdown.open { display: block; opacity: 1; visibility: visible; transform: translateY(0); }

.topbar .dropdown-head {
  padding: 0.9rem 1rem;
  font-weight: 700;
  font-size: 0.95rem;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  gap: 0.5rem;
}

.topbar .dd-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.8rem 1rem;
  text-decoration: none;
  color: var(--text);
  transition: background 0.15s;
  align-items: flex-start;
}
.topbar .dd-item:hover { background: var(--hover); }
.topbar .dd-item .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--primary); margin-top: 5px; flex-shrink:0; }
.topbar .dd-item .txt { font-size: 0.85rem; }
.topbar .dd-item .txt .t { font-weight: 600; }
.topbar .dd-item .txt .time { color: var(--muted); font-size: 0.75rem; }

.topbar .dd-item--empty {
  cursor: default;
  display: block;
}
.topbar .dd-item--empty:hover {
  background: transparent;
}

.topbar .dropdown-footer {
  padding: 0.5rem 1rem;
  border-top: 1px solid var(--border);
  text-align: center;
  background: var(--surface-sunken);
}

.topbar .menu-item {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.75rem 1rem;
  text-decoration: none;
  color: var(--text);
  font-size: 0.9rem;
  background: none;
  border: none;
  width: 100%;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}
.topbar .menu-item:hover { background: var(--hover); }
.topbar .menu-item svg { width: 18px; height: 18px; color: var(--muted); flex-shrink: 0; }
.topbar .menu-item.is-active { color: var(--accent); background: rgba(180,54,28,0.06); }
.topbar .menu-item.logout { color: #ef4444; border-top: 1px solid var(--border); }
.topbar .menu-item.logout svg { color: #ef4444; }

.topbar .menu-sep { height: 1px; background: var(--border); margin: 0.25rem 0; }

.topbar .nf-wrap,
.topbar .acc-wrap { position: relative; }

/* ===== USER CONSOLE WRAPPER ===== */
.topbar__user-console {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.brand-text--desktop {
  display: inline;
}

.mark-read {
  color: var(--accent);
  border: 1px solid var(--accent) !important; 
  border-radius: 4px; 
  cursor: pointer; 
  max-width: 5rem;
  width: 100%;
  overflow: hidden;
  background: none;
  padding: 1px !important;
  text-align: center;
  font: optional;
}
.mark-read:hover{
  background-color: var(--bg);
}
/* ===== MOBILE MENU TOGGLE ===== */
.topbar__menu-toggle { display: none; }

/* ===== RESPONSIVE — aligned with list.css breakpoints ===== */
@media (max-width: 960px) {
  .header-inner { gap: 0.5rem; flex-wrap: wrap; }
  .account-info { display: none; }
  .brand-text--desktop { display: none; }
  .c-search {
    order: 3;
    flex-basis: 100%;
    max-width: 100%;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
  }
  .c-search.show { max-height: 60px; padding-top: 0.25rem; }
  .topbar__menu-toggle {
    display: grid;
    place-items: center;
    width: 44px; height: 44px;
    border: none; background: transparent;
    border-radius: 12px; cursor: pointer;
    color: var(--text);
  }
  .topbar__menu-toggle:hover { background: var(--hover); }
  .topbar__menu-toggle svg { width: 22px; height: 22px; }
  .topbar .dropdown { min-width: 240px; }
}

@media (max-width: 640px) {
  .header {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .header.header--hidden {
    transform: translateY(-100%);
  }

  .header-inner {
    position: relative;
    padding: 0.2rem 0.65rem;
    gap: 0.35rem;
  }

  .brand-text { font-size: 1.05rem; }
  .brand-icon { width: 30px; height: 30px; padding: 0; border-radius: 7px; }
  .topbar__actions { gap: 0.15rem; }
  .topbar__user-console { gap: 0.15rem; }
  .topbar .icon-btn { width: 34px; height: 34px; }
  .topbar .icon-btn svg { width: 18px; height: 18px; }
  .topbar .account-fab { padding: 0.15rem 0.4rem; gap: 0.35rem; }
  .topbar .account-fab__image,
  .topbar .account-fab__fallback { width: 26px; height: 26px; }

  /* Anchor dropdowns to header-inner so they never overflow mobile screen edges */
  .topbar .nf-wrap,
  .topbar .acc-wrap {
    position: static;
  }

  .topbar .dropdown {
    min-width: 0;
    width: auto;
    left: 0.65rem;
    right: 0.65rem;
    max-width: calc(100vw - 1.3rem);
    top: calc(100% + 6px);
  }

  .topbar .nf-dropdown {
    min-width: 0;
    right: 0.65rem;
  }

  .topbar .dd-items-container {
    max-height: 60vh;
    overflow-y: auto;
  }
}
