/* ============================================================
   Master Header Component — 360eDash
============================================================= */

.edash-header {
  --hd-primary: #0f6a71;
  --hd-primary-dark: #0b4f54;
  --hd-primary-light: #6DC3BB;
  --hd-primary-soft: #e4f1f1;
  --hd-bg: #0f6a71;
  --hd-danger: #d64545;
  --hd-danger-soft: #fdeceb;
  --hd-warning: #e3a21a;
  --hd-warning-soft: #fbf1e0;
  --hd-success: #1a9455;
  --hd-success-soft: #e3f8ec;
  --hd-info: #2f80ed;
  --hd-info-soft: #eaf2fe;
  --hd-ink: #16262a;
  --hd-muted: #7c8b8d;
  --hd-border: #e7edee;
  --hd-surface: #ffffff;

  font-family: 'Poppins', sans-serif;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: var(--hd-bg);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  box-sizing: border-box;
  position: sticky;
  top: 0;
  /* Harus lebih tinggi dari z-index tertinggi milik konten halaman apa pun
     (mis. panel peta di Project Selector pakai z-index:600) supaya header
     — dan dropdown notifikasi/profil di dalamnya — selalu tampil di atas
     konten halaman, konsisten di semua tab. Tetap di bawah modal full-screen
     (logout-modal, alert, add-project, dll di rentang 999–9999) supaya
     modal itu tetap bisa menutupi header saat aktif. */
  z-index: 800;
}

.edash-header * {
  box-sizing: border-box;
}

.hd-left,
.hd-right {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

/* ---------- Mobile sidebar toggle ----------
   Hidden on desktop/laptop (sidebar is always visible there);
   shown only under the 900px breakpoint where the sidebar becomes
   an off-canvas panel (see sidebar.css). */
.hd-menu-toggle {
  display: none;
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--hd-surface);
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 1px 3px rgba(11, 79, 84, 0.15);
  color: var(--hd-ink);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 15px;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.hd-menu-toggle:hover {
  background: var(--hd-primary-soft);
  border-color: var(--hd-primary-soft);
  color: var(--hd-primary-dark);
}

.hd-caret {
  font-size: 10px;
  color: var(--hd-muted);
  transition: transform 0.2s ease;
}

/* ---------- Language switch ---------- */
.hd-lang {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--hd-surface);
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 1px 3px rgba(11, 79, 84, 0.15);
  color: var(--hd-ink);
  cursor: pointer;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.hd-lang i {
  font-size: 13px;
  color: var(--hd-primary);
}
.hd-lang:hover {
  background: var(--hd-primary-soft);
  border-color: var(--hd-primary-soft);
  color: var(--hd-primary-dark);
}
.hd-lang-current {
  letter-spacing: 0.02em;
}

/* Google Translate widget: sembunyikan tampilan bawaannya,
   kita hanya pakai <select> internalnya lewat tombol .hd-lang */
.hd-lang-widget {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
.goog-te-banner-frame.skiptranslate,
#goog-gt-tt,
.goog-te-balloon-frame {
  display: none !important;
}
.goog-text-highlight {
  background: none !important;
  box-shadow: none !important;
}
body {
  top: 0 !important;
}

/* ---------- Notification bell ---------- */
.hd-notif-wrap {
  position: relative;
}

.hd-notif {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--hd-surface);
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 1px 3px rgba(11, 79, 84, 0.15);
  color: var(--hd-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 15px;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.hd-notif:hover,
.hd-notif.is-active {
  background: var(--hd-primary-soft);
  border-color: var(--hd-primary-soft);
  color: var(--hd-primary-dark);
  transform: translateY(-1px);
}

.hd-notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  border-radius: 999px;
  background: var(--hd-danger);
  color: #fff;
  border: 1.5px solid var(--hd-surface);
  font-size: 9.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 3px rgba(214, 69, 69, 0.15);
}
/* [hidden] harus menang dari display:flex di atas, supaya badge
   otomatis hilang saat jumlah notifikasi 0 (lihat hdNotifBadge). */
.hd-notif-badge[hidden] {
  display: none;
}

/* ---------- Notification dropdown panel ---------- */
/* Dipicu lewat .hd-notif-wrap.is-open (di-toggle oleh headerNotifDropdown()
   di main.js) — bukan class di .hd-notif-panel itu sendiri — supaya pola
   buka/tutupnya konsisten dengan dropdown profil di bawah. */
.hd-notif-panel {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  width: 360px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 96px);
  display: flex;
  flex-direction: column;
  background: var(--hd-surface);
  border-radius: 16px;
  box-shadow: 0 18px 40px rgba(11, 79, 84, 0.22);
  border: 1px solid var(--hd-border);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
  z-index: 40;
  color: var(--hd-ink);
}
.hd-notif-wrap.is-open .hd-notif-panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.hd-notif-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--hd-border);
  flex-shrink: 0;
}
.hd-notif-panel-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--hd-ink);
}

.hd-notif-markall {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--hd-primary);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background 0.15s ease, color 0.15s ease;
}
.hd-notif-markall:hover:not(:disabled) {
  background: var(--hd-primary-soft);
  color: var(--hd-primary-dark);
}
.hd-notif-markall:disabled {
  color: var(--hd-muted);
  cursor: not-allowed;
}

.hd-notif-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.hd-notif-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-bottom: 1px solid var(--hd-border);
  background: var(--hd-surface);
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.18s ease;
}
.hd-notif-item:last-child {
  border-bottom: none;
}
.hd-notif-item:hover {
  background: var(--hd-primary-soft);
}
.hd-notif-item.is-unread {
  background: #f2f9f9;
}
.hd-notif-item.is-unread:hover {
  background: var(--hd-primary-soft);
}

/* Brief highlight right after a click, before we navigate away —
   gives the user visible confirmation the click registered. */
.hd-notif-item.is-clicked {
  background: var(--hd-primary-soft);
  cursor: default;
}

.hd-notif-item-icon {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}
.hd-notif-item-icon.type-success { background: var(--hd-success-soft); color: var(--hd-success); }
.hd-notif-item-icon.type-warning { background: var(--hd-warning-soft); color: var(--hd-warning); }
.hd-notif-item-icon.type-danger  { background: var(--hd-danger-soft);  color: var(--hd-danger); }
.hd-notif-item-icon.type-info    { background: var(--hd-info-soft);    color: var(--hd-info); }

.hd-notif-item-body {
  flex: 1;
  min-width: 0;
}
.hd-notif-item-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--hd-ink);
}
.hd-notif-item-dot {
  flex-shrink: 0;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--hd-primary);
}
.hd-notif-item-msg {
  margin-top: 2px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--hd-muted);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.hd-notif-item-time {
  display: block;
  margin-top: 6px;
  font-size: 10.5px;
  color: var(--hd-muted);
}

.hd-notif-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 36px 16px;
  color: var(--hd-muted);
  font-size: 12.5px;
}
.hd-notif-empty[hidden] {
  display: none;
}
.hd-notif-empty i {
  font-size: 22px;
}

/* ---------- Profile trigger (collapsed pill in the header bar) ---------- */
.hd-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  border-radius: 999px;
  background: var(--hd-surface);
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 1px 3px rgba(11, 79, 84, 0.15);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.hd-profile:hover {
  background: var(--hd-primary-soft);
  border-color: var(--hd-primary-soft);
  box-shadow: 0 4px 10px rgba(11, 79, 84, 0.15);
}

.hd-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--hd-primary-dark), var(--hd-primary-light));
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.hd-profile-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  text-align: left;
  white-space: nowrap;
}
.hd-profile-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--hd-ink);
}
.hd-profile-role {
  font-size: 11px;
  color: var(--hd-muted);
}

/* ---------- Profile dropdown menu ---------- */
.hd-profile-wrap {
  position: relative;
}

.hd-profile-menu {
  position: absolute;
  top: calc(100% + 14px);
  right: 0;
  width: 280px;
  background: var(--hd-surface);
  border-radius: 22px;
  box-shadow: 0 24px 48px -12px rgba(11, 79, 84, 0.35), 0 4px 12px rgba(11, 79, 84, 0.12);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px) scale(0.98);
  transform-origin: top right;
  transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), visibility 0s linear 0.2s;
  z-index: 40;
}

/* Small pointer arrow, visually "connects" the menu back to the avatar */
.hd-profile-menu::before {
  content: '';
  position: absolute;
  top: -6px;
  right: 22px;
  width: 14px;
  height: 14px;
  background: var(--hd-primary);
  border-radius: 3px;
  transform: rotate(45deg);
}

.hd-profile-wrap.is-open .hd-profile-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), visibility 0s linear 0s;
}

.hd-profile-wrap.is-open .hd-caret {
  transform: rotate(180deg);
}

/* Gradient banner with avatar + name + email */
.hd-profile-menu-banner {
  position: relative;
  background:
    linear-gradient(120deg, #3cd791 0%, var(--hd-primary) 100%);
  padding: 22px 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  overflow: hidden;
}

.hd-profile-menu-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.hd-profile-menu-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.16);
  border: 2px solid rgba(255, 255, 255, 0.55);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Small green "online" dot sitting on the avatar's edge */
.hd-profile-menu-avatar-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--hd-success);
  border: 2.5px solid var(--hd-primary-dark);
  box-sizing: content-box;
}

.hd-profile-menu-id {
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}
.hd-profile-menu-name {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hd-profile-menu-email {
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.82);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Body: Role / Login Terakhir / Status rows */
.hd-profile-menu-body {
  padding: 10px 12px 6px;
  display: flex;
  flex-direction: column;
}

.hd-profile-menu-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 6px;
  border-radius: 12px;
  transition: background 0.15s ease;
}
.hd-profile-menu-row:hover {
  background: var(--hd-primary-soft);
}

.hd-profile-menu-icon-wrap {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--hd-primary-soft);
}
.hd-profile-menu-icon {
  font-size: 14px;
  color: var(--hd-primary);
}

/* Warna aksen beda per baris biar gampang di-scan sekilas */
.hd-profile-menu-row:nth-child(3) .hd-profile-menu-icon-wrap {
  background: var(--hd-warning-soft);
}
.hd-profile-menu-row:nth-child(3) .hd-profile-menu-icon {
  color: var(--hd-warning);
}
.hd-profile-menu-row:nth-child(5) .hd-profile-menu-icon-wrap {
  background: var(--hd-success-soft);
}
.hd-profile-menu-row:nth-child(5) .hd-profile-menu-icon {
  color: var(--hd-success);
}

.hd-profile-menu-divider {
  height: 1px;
  margin: 2px 6px;
  background: var(--hd-border);
}

.hd-profile-menu-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.hd-profile-menu-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--hd-muted);
}
.hd-profile-menu-value {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--hd-ink);
  margin-top: 3px;
}

.hd-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  margin-top: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--hd-success-soft);
  color: var(--hd-success);
  font-size: 12px;
  font-weight: 600;
}
.hd-status-badge i {
  font-size: 7px;
  animation: hd-status-pulse 1.8s ease-in-out infinite;
}
@keyframes hd-status-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.8); }
}

/* Footer: Logout button */
.hd-profile-menu-foot {
  padding: 12px 14px 16px;
  margin-top: 4px;
}

.hd-profile-menu-logout {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--hd-danger-soft);
  background: var(--hd-danger-soft);
  color: var(--hd-danger);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.hd-profile-menu-logout:hover {
  background: var(--hd-danger);
  border-color: var(--hd-danger);
  color: #fff;
  transform: translateY(-1px);
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .hd-menu-toggle {
    display: flex;
  }
}

@media (max-width: 640px) {
  .edash-header {
    padding: 12px 16px;
    gap: 10px;
  }
  .hd-right {
    gap: 8px;
  }
  .hd-profile-info {
    display: none;
  }
  .hd-lang {
    padding: 0 10px;
  }
  .hd-lang-current {
    display: none;
  }
  .hd-profile-menu {
    width: 260px;
    max-width: calc(100vw - 32px);
  }
  .hd-notif-panel {
    position: fixed;
    top: 66px;
    right: 16px;
    left: 16px;
    width: auto;
    max-height: calc(100vh - 90px);
  }
}

@media (max-width: 380px) {
  .hd-notif,
  .hd-menu-toggle {
    width: 34px;
    height: 34px;
  }
  .hd-lang {
    height: 34px;
  }
}