/* ════════════════════════════════════════════════════════════════════════════
   header.css
   Page header row — back button, title card, bell panel, user panel,
   header search bar and dropdown results.
   ════════════════════════════════════════════════════════════════════════════ */

/* ── Header row ── */
.page-header-row {
  display: flex; align-items: center;
  height: 68px; min-height: 68px;
  gap: 0.55rem; margin-bottom: 1.1rem;
  position: relative;
}

/* ── Back button ── */
.back-btn {
  flex-shrink: 0; width: 48px; height: 62px; align-self: auto;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--card-bg); border: 1px solid var(--border);
  color: var(--text-dim); font-size: 1.2rem; font-weight: 700;
  text-decoration: none; transition: all 0.2s;
  box-shadow: var(--shadow-card);
  position: relative; overflow: hidden;
}
.back-btn::before {
  content: ''; position: absolute;
  top: 0; left: 10%; right: 10%; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.18), transparent);
}
.back-btn:hover {
  background: var(--accent-dim); border-color: var(--accent-border);
  color: var(--accent2); transform: translateX(-2px);
  box-shadow: 0 0 0 1px rgba(124,92,252,0.2), 0 8px 24px rgba(124,92,252,0.15), inset 0 1px 0 rgba(255,255,255,0.08);
}

/* ── Title card ── */
.title-card {
  flex: 1; display: flex; align-items: center; gap: 0.75rem;
  height: 62px; padding: 0 1.4rem;
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-card);
  position: relative; overflow: hidden;
}
.title-card::before {
  content: ''; position: absolute;
  top: 0; left: 10%; right: 10%; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.18), transparent);
}
.title-card .page-icon { font-size: 1.4rem; line-height: 1; flex-shrink: 0; }
.title-card h1,
.title-card .main-title {
  font-size: 1.3rem; font-weight: 800; color: var(--text);
  letter-spacing: -0.5px; line-height: 1.15; margin: 0;
}
.title-card .page-sub,
.title-card .subtitle,
.title-card p { font-size: 0.72rem; color: var(--text-dim); margin: 0.1rem 0 0; }
.title-text { display: flex; flex-direction: column; }

/* ── Bell + User buttons ── */
.bell-btn, .user-btn {
  position: relative;
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0 1rem;
  color: var(--text-dim); font-size: 1.1rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; min-width: 48px; height: 62px; align-self: auto;
  transition: all 0.18s; box-shadow: var(--shadow-card);
}
.bell-btn:hover, .user-btn:hover { border-color: var(--border-hi); color: var(--text); }
.bell-btn:active, .user-btn:active { transform: scale(0.92); }

/* ── Bell badge ── */
.bell-badge {
  position: absolute; top: 6px; right: 6px;
  min-width: 16px; height: 16px; border-radius: 10px;
  background: var(--red); color: var(--text);
  font-size: 0.58rem; font-weight: 800;
  font-family: 'DM Mono', monospace;
  display: none; align-items: center; justify-content: center;
  padding: 0 3px; line-height: 1;
  box-shadow: 0 0 6px rgba(248,113,113,0.6);
}
.bell-badge.visible { display: flex; }

/* ── Alerts panel + User panel shared base ── */
.alerts-panel, .user-panel {
  position: absolute; top: calc(100% + 0.5rem); right: 0;
  background: rgba(14,14,30,0.72);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius);
  box-shadow: 0 8px 40px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,255,255,0.06), inset 0 1px 0 rgba(255,255,255,0.08);
  z-index: 900; overflow: hidden;
  transform-origin: top right;
  transform: scale(0.94) translateY(-8px); opacity: 0; filter: blur(2px);
  transition: transform 0.18s ease, opacity 0.14s ease, filter 0.14s ease, visibility 0s linear 0.18s;
  visibility: hidden; pointer-events: none;
}
.alerts-panel.open, .user-panel.open {
  transform: scale(1) translateY(0); opacity: 1; filter: blur(0);
  visibility: visible; pointer-events: auto;
  transition: transform 0.22s cubic-bezier(0.16,1,0.3,1), opacity 0.16s ease, filter 0.16s ease, visibility 0s linear 0s;
}
.alerts-panel::before, .user-panel::before {
  content: ''; position: absolute;
  top: 0; left: 10%; right: 10%; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  z-index: 1;
}

/* ── Alerts panel ── */
.alerts-panel { width: 320px; max-height: min(520px,80vh); display: flex; flex-direction: column; }
.alerts-panel-header {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.85rem 1rem 0.7rem;
  border-bottom: 1px solid rgba(255,255,255,0.07); flex-shrink: 0;
}
.alerts-panel-title  { font-size: 0.84rem; font-weight: 700; color: var(--text); flex: 1; }
.alerts-dismiss-all  {
  font-size: 0.68rem; color: var(--text-dim); cursor: pointer;
  background: none; border: none; font-family: inherit;
  padding: 0.2rem 0.4rem; border-radius: 4px; transition: color 0.15s;
}
.alerts-dismiss-all:hover { color: var(--text); }
.alerts-close {
  background: none; border: none; color: var(--text-dim);
  font-size: 0.95rem; cursor: pointer; padding: 0.2rem 0.3rem;
  border-radius: 4px; transition: color 0.15s; font-family: inherit;
}
.alerts-close:hover { color: var(--text); }
.alerts-list  { flex: 1; overflow-y: auto; padding: 0.5rem; display: flex; flex-direction: column; gap: 0.4rem; }
.alert-item   { background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.07); border-radius: var(--radius-xs); padding: 0.65rem 0.8rem; position: relative; }
.alert-item-ts      { font-size: 0.62rem; color: var(--text-muted); font-family: 'DM Mono', monospace; margin-bottom: 0.25rem; }
.alert-item-msg     { font-size: 0.78rem; color: var(--text); line-height: 1.45; white-space: pre-wrap; word-break: break-word; padding-right: 1.8rem; }
.alert-item-dismiss {
  position: absolute; top: 0.5rem; right: 0.55rem;
  background: none; border: none; color: var(--text-muted);
  font-size: 0.72rem; cursor: pointer; padding: 0.1rem 0.3rem;
  border-radius: 3px; transition: color 0.15s; font-family: inherit;
}
.alert-item-dismiss:hover { color: var(--red); }
.alerts-empty  { color: var(--text-muted); font-size: 0.78rem; text-align: center; padding: 1.5rem 1rem; }
.alerts-footer { flex-shrink: 0; border-top: 1px solid rgba(255,255,255,0.07); padding: 0.5rem 0.6rem; }
.alerts-footer a {
  display: flex; align-items: center; justify-content: center;
  gap: 0.35rem; width: 100%; padding: 0.45rem 0.6rem;
  border-radius: var(--radius-xs); font-size: 0.75rem; font-weight: 600;
  color: var(--text-dim); text-decoration: none;
  transition: background 0.12s, color 0.12s;
}
.alerts-footer a:hover { background: rgba(255,255,255,0.06); color: var(--text); }

/* ── User panel ── */
.user-panel { width: 240px; }
.user-panel-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(124,92,252,0.18); border: 1.5px solid rgba(124,92,252,0.35);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem; flex-shrink: 0;
}
.user-panel-info {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.9rem 1rem 0.75rem;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.user-panel-name { font-size: 0.84rem; font-weight: 700; color: var(--text); line-height: 1.2; }
.user-panel-role { font-size: 0.68rem; color: var(--text-muted); margin-top: 0.1rem; }
.user-panel-body { padding: 0.4rem; display: flex; flex-direction: column; }
.user-panel-divider { height: 1px; background: rgba(255,255,255,0.06); margin: 0.3rem 0; }
.user-panel-btn {
  display: flex; align-items: center; gap: 0.6rem;
  width: 100%; background: none; border: none;
  padding: 0.55rem 0.65rem; border-radius: 6px;
  color: var(--text-dim); font-size: 0.8rem; font-weight: 500;
  cursor: pointer; font-family: inherit; text-align: left;
  transition: background 0.12s, color 0.12s; text-decoration: none;
}
.user-panel-btn:hover { background: rgba(255,255,255,0.07); color: var(--text); }
.user-panel-btn .upb-icon { font-size: 0.92rem; width: 1.2rem; text-align: center; flex-shrink: 0; }

/* User login form inside panel */
.user-login-form  { padding: 0.5rem 0.25rem 0.25rem; display: flex; flex-direction: column; gap: 0.4rem; }
.user-login-input {
  width: 100%; background: rgba(0,0,0,0.35); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px; color: var(--text); font-size: 0.8rem;
  padding: 0.45rem 0.65rem; outline: none; font-family: inherit; transition: border-color 0.15s;
}
.user-login-input:focus { border-color: rgba(124,92,252,0.5); }
.user-login-btn {
  width: 100%; background: linear-gradient(135deg, #7c5cfc, #6344e0);
  border: none; border-radius: 6px; color: var(--text);
  font-size: 0.8rem; font-weight: 700; padding: 0.5rem;
  cursor: pointer; font-family: inherit; margin-top: 0.1rem; transition: opacity 0.15s;
}
.user-login-btn:hover { opacity: 0.88; }
.user-login-err { font-size: 0.72rem; color: var(--red); text-align: center; min-height: 1em; }
.user-login-remember {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.74rem; color: var(--text-dim); cursor: pointer; user-select: none;
}
.user-login-remember input[type=checkbox] { display: none; }
.user-login-cb-box {
  width: 14px; height: 14px; border-radius: 3px;
  border: 1.5px solid rgba(255,255,255,0.18); background: rgba(0,0,0,0.3);
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; font-size: 0.55rem; color: transparent;
}
.user-login-remember input:checked ~ .user-login-cb-box { background: var(--accent); border-color: var(--accent); color: #fff; }
.user-login-remember:hover .user-login-cb-box { border-color: var(--accent-border); }

/* ── Header search ── */
.hdr-search-wrapper {
  display: flex; align-items: center;
  max-width: 0; opacity: 0; overflow: hidden;
  transition: max-width 0.35s cubic-bezier(0.16,1,0.3,1), opacity 0.25s ease;
  flex: 0; position: relative; flex-shrink: 0;
}
.hdr-search-wrapper.expanded { max-width: 600px; opacity: 1; flex: 1; overflow: visible; }
.hdr-search-wrapper.collapsing .hdr-search-row {
  opacity: 0; transform: scaleX(0.92) translateX(6px);
  transition: opacity 0.14s ease, transform 0.16s cubic-bezier(0.4,0,1,1);
}
.hdr-search-row {
  display: flex; align-items: center; gap: 0.5rem; width: 100%;
  transition: opacity 0.15s ease, transform 0.18s cubic-bezier(0.16,1,0.3,1);
}
.hdr-search-input {
  flex: 1; background: rgba(0,0,0,0.35); border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-xs, 8px); color: var(--text);
  font-size: 0.88rem; padding: 0.5rem 0.85rem;
  outline: none; font-family: inherit; transition: border-color 0.15s; min-width: 0;
}
.hdr-search-input:focus { border-color: rgba(124,92,252,0.5); }
.hdr-search-input::placeholder { color: var(--text-muted, #5a5a7a); }
.hdr-search-close, .hdr-search-submit {
  background: none; border: none; color: var(--text-muted, #5a5a7a);
  font-size: 1rem; cursor: pointer; padding: 0.3rem;
  border-radius: 4px; transition: color 0.15s; flex-shrink: 0;
}
.hdr-search-close:hover  { color: var(--text); }
.hdr-search-submit:hover { color: var(--accent2, #a78bfa); }

.hdr-search-results {
  position: absolute; top: calc(100% + 0.4rem); left: 0; right: 0;
  background: rgba(14,14,30,0.97); backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid rgba(255,255,255,0.1); border-radius: var(--radius-sm, 10px);
  box-shadow: 0 12px 48px rgba(0,0,0,0.6);
  z-index: 950; max-height: 360px; overflow-y: auto; display: none;
}
.hdr-search-results.open { display: block; }
.hdr-sr-group  { font-size: 0.6rem; font-weight: 700; letter-spacing: 1.8px; text-transform: uppercase; color: var(--text-muted, #5a5a7a); padding: 0.6rem 0.85rem 0.3rem; }
.hdr-sr-item   { display: flex; align-items: center; gap: 0.6rem; padding: 0.55rem 0.85rem; cursor: pointer; transition: background 0.1s; text-decoration: none; color: var(--text); }
.hdr-sr-item:hover { background: rgba(124,92,252,0.08); }
.hdr-sr-icon   { font-size: 1rem; flex-shrink: 0; width: 1.4rem; text-align: center; }
.hdr-sr-title  { font-size: 0.82rem; font-weight: 600; color: var(--text); }
.hdr-sr-desc   { font-size: 0.68rem; color: var(--text-muted, #5a5a7a); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hdr-sr-divider{ height: 1px; background: rgba(255,255,255,0.06); margin: 0.25rem 0; }
.hdr-sr-web    { display: flex; align-items: center; gap: 0.5rem; padding: 0.65rem 0.85rem; cursor: pointer; transition: background 0.1s; color: var(--accent2, #a78bfa); font-size: 0.8rem; font-weight: 600; text-decoration: none; }
.hdr-sr-web:hover { background: rgba(124,92,252,0.08); }

.hdr-search-btn {
  background: var(--card-bg, rgba(255,255,255,0.04));
  border: 1px solid var(--border, rgba(255,255,255,0.1));
  border-radius: var(--radius-sm, 10px); padding: 0 1rem;
  color: var(--text-dim, #9898b8); font-size: 1.1rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all 0.18s;
  box-shadow: var(--shadow-card, 0 0 0 1px rgba(255,255,255,0.06));
  min-width: 48px; height: 62px; align-self: auto;
}
.hdr-search-btn:hover { border-color: var(--border-hi, rgba(255,255,255,0.2)); color: var(--text, #e8e8ff); }

/* ── Mobile header ── */
@media (max-width: 600px) {
  .page-header-row  { flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.75rem; }
  .back-btn         { width: 38px; min-width: 38px; font-size: 1rem; }
  .title-card       { padding: 0.6rem 0.85rem; gap: 0.5rem; min-width: 0; flex: 1; }
  .title-card h1,
  .title-card .main-title { font-size: 1rem; letter-spacing: -0.2px; }
  .page-sub         { font-size: 0.68rem; }
  .page-icon        { font-size: 1.15rem; }
  .user-btn, .bell-btn { padding: 0 0.55rem; font-size: 1rem; }
}
@media (max-width: 640px) {
  .hdr-search-wrapper.expanded {
    position: absolute; left: 0; right: 0; top: 0; z-index: 400;
    max-width: none !important; flex: none !important;
    background: var(--card-bg, rgba(10,10,22,0.97));
    border: 1px solid var(--border, rgba(255,255,255,0.1));
    border-radius: var(--radius-sm, 10px);
    padding: 0.35rem 0.5rem; backdrop-filter: blur(20px);
  }
  .page-header-row { position: relative; }
}
