/* =====================================================================
   Klyvo · dropdown topbar (notifikasi dan profil).
   Dimuat setelah ux.css. Warna memakai variabel tema, sehingga tetap
   mengikuti pengaturan Tampilan dari panel admin.
   ===================================================================== */

/* ---------- Pemicu: ikon lonceng dan avatar ---------- */
.tb-dropdown { position: relative; display: inline-flex; }
.tb-trigger {
  position: relative;
  padding: 0;
  margin: 0;
  font: inherit;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
button.avatar { border: 0; }
.tb-trigger[aria-expanded="true"] {
  background: color-mix(in srgb, var(--primary) 12%, var(--background));
  color: var(--primary);
}
/* Avatar mempertahankan warna primer; keadaan terbuka cukup ditandai cincin */
button.avatar[aria-expanded="true"] {
  background: var(--primary);
  color: var(--primary-contrast);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 40%, transparent), 0 4px 12px color-mix(in srgb, var(--primary) 28%, transparent);
}
.tb-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--danger);
  color: var(--on-danger);
  font-size: 11px;
  font-weight: 800;
  line-height: 19px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--surface);
  pointer-events: none;
}

/* ---------- Panel ---------- */
.tb-panel {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  z-index: 40;
  width: min(360px, calc(100vw - 16px));
  max-height: min(74vh, 580px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  line-height: 1.4;
  text-align: left;
  transform-origin: top right;
  animation: tb-pop 0.18s var(--ease);
}
.tb-panel[hidden] { display: none !important; }
@keyframes tb-pop {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.tb-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 14px 10px 16px;
  border-bottom: 1px solid var(--border);
}
.tb-panel-title { margin: 0; font-size: 16px; font-weight: 800; letter-spacing: -0.01em; }
.tb-panel-foot {
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  background: var(--background);
}

/* Tombol teks kecil di panel (tandai dibaca, coba lagi) */
.tb-link-btn {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 6px 10px;
  border: 0;
  border-radius: 12px;
  background: none;
  color: var(--primary);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.tb-link-btn:hover:not(:disabled) { background: color-mix(in srgb, var(--primary) 10%, transparent); }
.tb-link-btn:disabled { color: var(--muted); cursor: default; }

/* ---------- Daftar notifikasi ---------- */
.tb-notif-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 6px;
}
.tb-notif {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 56px;
  padding: 12px 10px;
  border-radius: 14px;
  color: inherit;
  text-decoration: none;
  transition: background 0.15s var(--ease);
}
.tb-notif:hover { background: var(--background); }
.tb-notif.is-unread { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.tb-notif-ico {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: color-mix(in srgb, var(--primary) 10%, var(--surface));
  color: var(--primary);
}
.tb-notif.is-unread .tb-notif-ico { background: var(--primary); color: var(--primary-contrast); }
.tb-notif-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tb-notif-title {
  font-weight: 700;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tb-notif-text {
  color: var(--muted);
  font-size: 13px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.tb-notif-time { color: var(--muted); font-size: 12px; }
.tb-dot {
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.tb-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.tb-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 28px 16px;
  color: var(--muted);
  text-align: center;
}
.tb-foot-link {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 8px;
  border-radius: 12px;
  color: var(--primary);
  font-weight: 700;
  text-decoration: none;
}
.tb-foot-link:hover { background: color-mix(in srgb, var(--primary) 10%, transparent); }

/* ---------- Profil ---------- */
.tb-profile-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.tb-profile-avatar {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--primary);
  color: var(--primary-contrast);
  font-size: 18px;
  font-weight: 800;
}
.tb-profile-info { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.tb-profile-name { font-weight: 800; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-profile-contact { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.tb-profile-verify { color: var(--muted); font-size: 12px; }
.tb-menu { display: flex; flex-direction: column; gap: 2px; padding: 6px; }
.tb-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 0 10px;
  border: 0;
  border-radius: 14px;
  background: none;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.tb-menu-item:hover { background: var(--background); }
.tb-menu-item[aria-current="page"] {
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, transparent);
}
.tb-menu-ico {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: var(--background);
  color: var(--primary);
}
.tb-menu-label { flex: 1 1 auto; min-width: 0; }
.tb-menu-chev { color: var(--muted); font-size: 18px; line-height: 1; }
.tb-menu-logout { color: var(--danger); }
.tb-menu-logout .tb-menu-ico { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, var(--surface)); }
.tb-menu-divider { height: 1px; margin: 6px 8px; background: var(--border); }

/* ---------- Ponsel kecil ---------- */
@media (max-width: 379px) {
  .tb-panel { max-height: min(80vh, 580px); }
  .tb-panel-head { padding-left: 14px; }
  .tb-notif-title { font-size: 13.5px; }
}

/* ---------- Tablet dan desktop ---------- */
@media (min-width: 768px) {
  .tb-panel { width: min(380px, calc(100vw - 32px)); max-height: min(72vh, 620px); }
}
