/* ============================================================
   TuniBill — Modern Topbar (header-only override)
   Matches tb-modern sidebar: white glass bar, pill icon buttons,
   gradient accents. Scoped to .main-header.tb-topbar-modern so
   content / tables / modals are untouched.
   Geometry (fixed 70px header, #content padding) preserved.
   ============================================================ */

.main-header.tb-topbar-modern {
  background: rgba(255, 255, 255, 0.86) !important;
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid #e2e8f0 !important;
  box-shadow: 0 4px 24px rgba(12, 29, 58, 0.08) !important;
  left: 0;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 999 !important; /* below sidebar (1001) so logo owns corner */
  height: 70px !important;
}

.main-header.tb-topbar-modern .navbar.navbar-default {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  margin: 0 !important;
  min-height: 70px !important;
  border-radius: 0 !important;
}

.main-header.tb-topbar-modern .tb-topbar-inner {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 12px;
  height: 70px !important;
  padding: 0 20px 0 268px !important; /* 248px sidebar + 20px gutter */
  transition: padding 0.3s ease !important;
}

/* when sidebar collapsed, reclaim the space */
.main-header.tb-topbar-modern.tb-collapsed .tb-topbar-inner {
  padding-left: 20px !important;
}

/* ---------- Left ---------- */
.tb-topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex: 1 1 auto;
}

.main-header.tb-topbar-modern #sidebarCollapse {
  flex: 0 0 42px;
  width: 42px !important;
  height: 42px !important;
  margin: 0 !important;
  padding: 0 !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  background: #f1f5f9 !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 12px !important;
  color: #0c1d3a !important;
  font-size: 16px !important;
  cursor: pointer;
  transition: all 0.18s ease !important;
  box-shadow: none !important;
}
.main-header.tb-topbar-modern #sidebarCollapse:hover {
  background: linear-gradient(135deg, #2f80ed 0%, #1f9bf0 60%, #22b8e6 100%) !important;
  border-color: transparent !important;
  color: #fff !important;
  box-shadow: 0 6px 16px rgba(47, 128, 237, 0.4) !important;
  transform: translateY(-1px);
}
.main-header.tb-topbar-modern #sidebarCollapse:active { transform: translateY(0); }

.tb-page-title { min-width: 0; line-height: 1.2; }
.tb-page-title h2 {
  margin: 0 !important;
  font-size: 17px !important;
  font-weight: 800 !important;
  color: #0c1d3a !important;
  letter-spacing: -0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tb-page-title p {
  margin: 1px 0 0 !important;
  font-size: 12px !important;
  color: #718096 !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tb-page-title p i,
.tb-page-title p svg {
  color: #22b8e6 !important;
  margin-right: 4px;
  font-size: 11px;
  width: 11px !important;
  height: 11px !important;
  vertical-align: -1px;
}
#tb-clock {
  font-variant-numeric: tabular-nums !important;
  font-weight: 700 !important;
  color: #2d3748 !important;
  letter-spacing: 0.3px;
}
.tb-clock-sep { margin: 0 5px; color: #cbd5e1; }

/* global search pill — modern */
.tb-global-search {
  position: relative;
  display: flex !important;
  align-items: center !important;
  flex: 1 1 auto;
  min-width: 200px;
  max-width: 440px;
  margin-left: 8px;
  height: 42px;
}
/* icon wrapper (span survives FontAwesome <i> -> <svg> replacement) */
.tb-search-ico {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  color: #94a3b8 !important;
  font-size: 13px;
  pointer-events: none;
  z-index: 2;
  transition: color 0.18s ease !important;
}
.tb-search-ico svg {
  width: 14px !important;
  height: 14px !important;
  color: inherit !important;
}
.tb-global-search:focus-within .tb-search-ico { color: #0284c7 !important; }
.tb-global-search input {
  width: 100% !important;
  height: 42px !important;
  margin: 0 !important;
  border: 1px solid #e2e8f0 !important;
  background: linear-gradient(180deg, #f8fafc, #f1f5f9) !important;
  border-radius: 999px !important;
  padding: 0 74px 0 40px !important;
  font-size: 13px !important;
  color: #1a202c !important;
  box-shadow: inset 0 1px 2px rgba(12, 29, 58, 0.05) !important;
  outline: none !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease !important;
}
.tb-global-search input::placeholder { color: #a0aec0 !important; opacity: 1; }
.tb-global-search input:hover {
  border-color: #cbd5e1 !important;
  background: #fff !important;
}
.tb-global-search input:focus {
  background: #fff !important;
  border-color: #38bdf8 !important;
  box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.18), 0 4px 14px rgba(12, 29, 58, 0.08) !important;
}
.tb-global-search kbd {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 700;
  color: #64748b;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 2px 6px;
  pointer-events: none;
  line-height: 1.4;
  transition: opacity 0.15s ease !important;
}
.tb-search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px !important;
  height: 26px !important;
  min-width: 26px !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  padding: 0 !important;
  border: none !important;
  border-radius: 50% !important;
  background: #e2e8f0 !important;
  color: #475569 !important;
  font-size: 11px !important;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, background 0.15s ease !important;
}
.tb-search-clear svg { width: 11px !important; height: 11px !important; }
.tb-search-clear:hover { background: #cbd5e1 !important; color: #0c1d3a !important; }
/* when typing: hide hint, show clear */
.tb-global-search.has-value kbd { opacity: 0; }
.tb-global-search.has-value .tb-search-clear { opacity: 1; pointer-events: auto; }

/* history shortcut — icon only, no border / no background / no shape */
.main-header.tb-topbar-modern .tb-global-search button.tb-history-btn.tb-history-inside,
.main-header.tb-topbar-modern .tb-global-search button.tb-history-btn.tb-history-inside:hover,
.main-header.tb-topbar-modern .tb-global-search button.tb-history-btn.tb-history-inside:focus,
.main-header.tb-topbar-modern .tb-global-search button.tb-history-btn.tb-history-inside:active {
  position: absolute !important;
  right: 48px !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  width: 26px !important;
  height: 26px !important;
  min-width: 26px !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  background: transparent none !important;
  background-color: transparent !important;
  box-shadow: none !important;
  outline: none !important;
  appearance: none !important;
  -webkit-appearance: none !important;
  color: #2f80ed !important;
  font-size: 14px !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  transition: transform 0.16s ease, color 0.16s ease !important;
}
.tb-global-search .tb-history-btn.tb-history-inside svg {
  width: 14px !important;
  height: 14px !important;
  color: #2f80ed !important;
  background: transparent !important;
  border: none !important;
  transition: transform 0.2s ease !important;
}
.tb-global-search .tb-history-btn.tb-history-inside:hover {
  border: none !important;
  background: transparent none !important;
  background-color: transparent !important;
  box-shadow: none !important;
  outline: none !important;
  filter: none !important;
  color: #1a5fc1 !important;
  transform: translateY(-50%) scale(1.15) !important;
}
.tb-global-search .tb-history-btn.tb-history-inside:hover svg { transform: none; color: #1a5fc1 !important; }
.tb-global-search .tb-history-btn.tb-history-inside:active {
  transform: translateY(-50%) scale(0.92) !important;
}
/* hidden while typing (clear button takes its place) */
.tb-global-search.has-value .tb-history-btn.tb-history-inside { display: none !important; }
.tb-global-search .tb-hist-dot {
  position: absolute !important;
  top: 2px !important;
  right: 2px !important;
  width: 8px !important;
  height: 8px !important;
  min-width: 8px !important;
  margin: 0 !important;
  padding: 0 !important;
  border-radius: 50% !important;
  background: linear-gradient(135deg, #2f80ed, #22b8e6) !important;
  border: 2px solid #fff !important;
  box-shadow: 0 1px 4px rgba(47, 128, 237, 0.5) !important;
}
.tb-hist-dot[hidden] { display: none !important; }

/* ---------- Live results panel ---------- */
.tb-search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  min-width: 340px;
  max-height: 400px;
  overflow-y: auto;
  background: #fff !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 16px !important;
  box-shadow: 0 20px 50px rgba(12, 29, 58, 0.20) !important;
  padding: 8px !important;
  z-index: 1200;
  animation: tb-drop-in 0.16s cubic-bezier(0.16, 1, 0.3, 1) both;
  transform-origin: top center;
}
@keyframes tb-drop-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.tb-search-results[hidden] { display: none !important; }
.tb-result-group {
  padding: 8px 10px 4px !important;
  font-size: 10.5px !important;
  font-weight: 800 !important;
  letter-spacing: 1px !important;
  text-transform: uppercase !important;
  color: #7d96b8 !important;
}
.tb-result-group i { margin-right: 6px; color: #38bdf8 !important; font-size: 11px; }
.tb-result-group svg { margin-right: 6px; color: #38bdf8 !important; width: 11px !important; height: 11px !important; }
a.tb-result-item {
  display: flex !important;
  align-items: center !important;
  gap: 11px !important;
  padding: 9px 10px !important;
  border-radius: 11px !important;
  text-decoration: none !important;
  border: 1px solid transparent !important;
  transition: background 0.13s ease, border-color 0.13s ease !important;
}
a.tb-result-item:hover,
a.tb-result-item.tb-active {
  background: #f1f8fd !important;
  border-color: #bae6fd !important;
}
.tb-result-ico {
  flex: 0 0 34px;
  width: 34px !important;
  height: 34px !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  border-radius: 10px !important;
  background: #f1f5f9 !important;
  color: #0284c7 !important;
  font-size: 14px !important;
}
.tb-result-ico svg { width: 14px !important; height: 14px !important; }
.tb-result-txt { flex: 1 1 auto; min-width: 0; line-height: 1.3; }
.tb-result-txt strong {
  display: block;
  font-size: 13px !important;
  font-weight: 700 !important;
  color: #0c1d3a !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tb-result-txt small {
  display: block;
  font-size: 11.5px !important;
  color: #718096 !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tb-result-go { color: #cbd5e1 !important; font-size: 13px !important; }
a.tb-result-item:hover .tb-result-go,
a.tb-result-item.tb-active .tb-result-go { color: #0284c7 !important; }
.tb-result-empty {
  text-align: center;
  padding: 26px 16px !important;
  color: #94a3b8 !important;
}
.tb-result-empty i, .tb-result-empty svg {
  font-size: 22px !important;
  width: 22px !important;
  height: 22px !important;
  margin-bottom: 8px;
  color: #cbd5e1 !important;
}
.tb-result-empty p { margin: 0 !important; font-size: 13px !important; font-weight: 600 !important; color: #64748b !important; }
.tb-result-loading {
  display: flex !important;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 22px 0 !important;
}
.tb-result-loading span {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #38bdf8;
  animation: tb-blink 1s infinite ease-in-out;
}
.tb-result-loading span:nth-child(2) { animation-delay: 0.15s; }
.tb-result-loading span:nth-child(3) { animation-delay: 0.3s; }
@keyframes tb-blink {
  0%, 100% { opacity: 0.25; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1); }
}
.tb-result-foot {
  margin-top: 6px;
  padding: 8px 10px 4px !important;
  border-top: 1px solid #eef2f7 !important;
  font-size: 11px !important;
  color: #94a3b8 !important;
  text-align: center;
}
.tb-history-clear {
  background: none !important;
  border: none !important;
  padding: 2px 8px !important;
  font-size: 11.5px !important;
  font-weight: 700 !important;
  color: #94a3b8 !important;
  cursor: pointer;
  border-radius: 6px !important;
  transition: color 0.13s ease, background 0.13s ease !important;
}
.tb-history-clear:hover { color: #dc2626 !important; background: #fef2f2 !important; }
.tb-result-remove {
  flex: 0 0 22px;
  width: 22px !important;
  height: 22px !important;
  display: none !important;
  align-items: center;
  justify-content: center;
  border-radius: 50% !important;
  background: #f1f5f9 !important;
  color: #94a3b8 !important;
  font-size: 14px !important;
  line-height: 1 !important;
  cursor: pointer;
}
a.tb-result-item:hover .tb-result-remove { display: inline-flex !important; }
.tb-result-remove:hover { background: #fee2e2 !important; color: #dc2626 !important; }

/* ---------- Right ---------- */
.tb-topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}
.main-header.tb-topbar-modern .header-top-section,
.main-header.tb-topbar-modern .header-top-right-section {
  display: flex !important;
  align-items: center !important;
}
.main-header.tb-topbar-modern ul.nav-top {
  display: flex !important;
  align-items: center !important;
  gap: 6px;
  margin: 0 !important;
  padding: 0 !important;
  list-style: none !important;
}
.main-header.tb-topbar-modern ul.nav-top::before,
.main-header.tb-topbar-modern ul.nav-top::after { display: none !important; }
.main-header.tb-topbar-modern ul.nav-top > li { margin: 0 !important; padding: 0 !important; }
.main-header.tb-topbar-modern ul.nav-top > li:last-child { margin-right: 0 !important; }

/* icon action buttons */
.main-header.tb-topbar-modern .tb-icon-btn {
  position: relative;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 42px !important;
  height: 42px !important;
  padding: 0 !important;
  margin: 0 !important;
  border-radius: 12px !important;
  background: #f1f5f9 !important;
  border: 1px solid #e2e8f0 !important;
  color: #334155 !important;
  font-size: 16px !important;
  line-height: 1 !important;
  transition: all 0.18s ease !important;
}
.main-header.tb-topbar-modern .tb-icon-btn:hover,
.main-header.tb-topbar-modern .nav > li.open > a.tb-icon-btn,
.main-header.tb-topbar-modern .nav .open > a.tb-icon-btn {
  background: #fff !important;
  border-color: #38bdf8 !important;
  color: #0c1d3a !important;
  box-shadow: 0 6px 16px rgba(56, 189, 248, 0.22) !important;
  transform: translateY(-1px);
}
.main-header.tb-topbar-modern .nav > li > a:focus { background: #fff !important; }

/* notification count badge */
.main-header.tb-topbar-modern #js-count {
  position: absolute !important;
  top: -6px !important;
  right: -6px !important;
  min-width: 20px !important;
  height: 20px !important;
  width: auto !important;
  margin: 0 !important;
  padding: 0 5px !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #ef4444, #f43f5e) !important;
  border: 2px solid #fff !important;
  border-radius: 999px !important;
  color: #fff !important;
  font-size: 10.5px !important;
  font-weight: 800 !important;
  line-height: 1 !important;
  box-shadow: 0 4px 10px rgba(239, 68, 68, 0.45) !important;
  top: -6px !important;
}
.main-header.tb-topbar-modern #js-count.tb-zero {
  background: #cbd5e1 !important;
  box-shadow: none !important;
}

/* vertical divider */
.tb-v-divider {
  width: 1px;
  height: 28px;
  background: #e2e8f0;
  margin: 0 6px;
}

/* profile pill (direct link, no dropdown) */
.main-header.tb-topbar-modern a.tb-profile-btn {
  display: inline-flex !important;
  align-items: center !important;
  gap: 10px !important;
  height: 48px !important;
  padding: 4px 12px 4px 4px !important;
  margin: 0 !important;
  background: #fff !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 999px !important;
  box-shadow: 0 2px 10px rgba(12, 29, 58, 0.06) !important;
  overflow: hidden !important;
  max-width: 240px;
  transition: all 0.18s ease !important;
}
.main-header.tb-topbar-modern a.tb-profile-btn:hover {
  border-color: #38bdf8 !important;
  box-shadow: 0 8px 20px rgba(56, 189, 248, 0.22) !important;
  transform: translateY(-1px);
}
/* logout icon button */
.main-header.tb-topbar-modern .tb-logout-btn:hover {
  background: #fef2f2 !important;
  border-color: #fca5a5 !important;
  color: #dc2626 !important;
  box-shadow: 0 6px 16px rgba(220, 38, 38, 0.18) !important;
}
.tb-profile-avatar { position: relative; flex: 0 0 38px; }
img.profile-avator.tb-avatar-img {
  width: 38px !important;
  height: 38px !important;
  border-radius: 50% !important;
  float: none !important;
  margin: 0 !important;
  object-fit: cover;
  border: 2px solid #38bdf8 !important;
  display: block;
}
.tb-online-dot {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid #fff;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.7);
}
.main-header.tb-topbar-modern .profile-avatar-txt {
  margin: 0 !important;
  min-width: 0;
  text-align: left;
  line-height: 1.2;
}
.main-header.tb-topbar-modern .profile-avatar-txt > p {
  display: block !important;
  margin: 0 !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  color: #0c1d3a !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}
.main-header.tb-topbar-modern .profile-avatar-txt > span {
  display: block;
  font-size: 11px !important;
  color: #718096 !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}
.main-header.tb-topbar-modern .profile-avatar-txt > i {
  display: none !important;
}
/* ---------- Responsive ---------- */
@media only screen and (max-width: 1100px) {
  .tb-global-search { max-width: 260px; min-width: 160px; }
  .tb-page-title p { display: none; }
}
@media only screen and (max-width: 991px) {
  .main-header.tb-topbar-modern .tb-topbar-inner { padding-left: 20px !important; }
  .tb-global-search { display: none !important; }
  .tb-page-title h2 { font-size: 15px !important; }
}
@media only screen and (max-width: 640px) {
  .main-header.tb-topbar-modern .tb-topbar-inner { padding: 0 12px !important; gap: 8px; }
  .tb-page-title { display: none !important; }
  .main-header.tb-topbar-modern .profile-avatar-txt { display: none !important; }
  .main-header.tb-topbar-modern a.tb-profile-btn {
    padding: 4px !important;
    height: 44px !important;
  }
  .tb-v-divider { display: none; }
}

/* dark huma theme compat: keep glass but tint */
html.theme-huma .main-header.tb-topbar-modern {
  background: rgba(255, 255, 255, 0.9) !important;
}

@media (prefers-reduced-motion: reduce) {
  .main-header.tb-topbar-modern *,
  .main-header.tb-topbar-modern *::before,
  .main-header.tb-topbar-modern *::after {
    animation: none !important;
    transition: none !important;
  }
}
