/* ================================================================
   UNIFIED TOPBAR — SauerlandAI Global Navigation
   Include this on EVERY page for consistent navigation.
   Height: 56px, sticky at top, z-index: 9000
   ================================================================ */

/* ── Topbar Container ── */
.sai-unified-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 56px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(218,220,224,0.6);
  position: sticky;
  top: 0;
  z-index: 9000;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  flex-shrink: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* Dark theme support */
[data-theme="dark"] .sai-unified-topbar,
body[style*="background:#1a1a2e"] .sai-unified-topbar,
body[style*="background: #1a1a2e"] .sai-unified-topbar {
  background: rgba(15, 23, 42, 0.92);
  border-bottom-color: rgba(148, 163, 184, 0.12);
}

/* Admin dashboard dark override */
body[data-admin-dark="true"] .sai-unified-topbar {
  background: rgba(15, 23, 42, 0.95);
  border-bottom-color: rgba(148, 163, 184, 0.12);
}

/* ── Brand (left) ── */
.sai-unified-topbar .ut-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  flex-shrink: 0;
}
.sai-unified-topbar .ut-brand object {
  height: 32px;
  width: 32px;
  pointer-events: none;
}
.sai-unified-topbar .ut-brand-text {
  font-size: 16px;
  font-weight: 700;
  color: #1E293B;
  letter-spacing: 0.5px;
}
[data-theme="dark"] .sai-unified-topbar .ut-brand-text,
body[data-admin-dark="true"] .sai-unified-topbar .ut-brand-text {
  color: #f1f5f9;
}
.sai-unified-topbar .ut-brand-text .ai {
  color: #3D8B50;
}

/* ── Center Navigation ── */
.sai-unified-topbar .ut-center {
  display: flex;
  align-items: center;
  gap: 2px;
}

.sai-unified-topbar .ut-nav-item {
  position: relative;
  display: inline-block;
}
.sai-unified-topbar .ut-nav-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  color: #3C4043;
  background: none;
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  font-family: inherit;
}
[data-theme="dark"] .sai-unified-topbar .ut-nav-btn,
body[data-admin-dark="true"] .sai-unified-topbar .ut-nav-btn {
  color: #94a3b8;
}
.sai-unified-topbar .ut-nav-btn:hover {
  background: #F1F3F4;
  color: #1A73E8;
}
[data-theme="dark"] .sai-unified-topbar .ut-nav-btn:hover,
body[data-admin-dark="true"] .sai-unified-topbar .ut-nav-btn:hover {
  background: rgba(148, 163, 184, 0.1);
  color: #14b8a6;
}
.sai-unified-topbar .ut-nav-btn .ut-arrow {
  font-size: 9px;
  color: #9AA0A6;
  transition: transform 0.2s;
}
/* Direct link (no dropdown) — styled as primary action */
.sai-unified-topbar .ut-nav-direct {
  background: linear-gradient(135deg, #3D8B50, #2D6B3E) !important;
  color: #fff !important;
  font-weight: 600;
  border-radius: 8px;
  padding: 6px 14px;
  text-decoration: none;
}
.sai-unified-topbar .ut-nav-item:hover > .ut-nav-btn .ut-arrow {
  transform: rotate(180deg);
}

/* ── Dropdowns ── */
.sai-unified-topbar .ut-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 220px;
  background: rgba(255,255,255,0.97);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid #DADCE0;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  padding: 4px 0;
  z-index: 9100;
  animation: utDropIn 0.15s ease-out;
}
[data-theme="dark"] .sai-unified-topbar .ut-dropdown,
body[data-admin-dark="true"] .sai-unified-topbar .ut-dropdown {
  background: rgba(30, 41, 59, 0.97);
  border-color: rgba(148, 163, 184, 0.15);
}
@keyframes utDropIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.sai-unified-topbar .ut-nav-item:hover > .ut-dropdown {
  display: block;
}

.sai-unified-topbar .ut-dropdown a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  font-size: 13px;
  color: #3C4043;
  text-decoration: none;
  transition: background 0.12s;
}
[data-theme="dark"] .sai-unified-topbar .ut-dropdown a,
body[data-admin-dark="true"] .sai-unified-topbar .ut-dropdown a {
  color: #cbd5e1;
}
.sai-unified-topbar .ut-dropdown a:hover {
  background: #F1F3F4;
}
[data-theme="dark"] .sai-unified-topbar .ut-dropdown a:hover,
body[data-admin-dark="true"] .sai-unified-topbar .ut-dropdown a:hover {
  background: rgba(148, 163, 184, 0.1);
}
.sai-unified-topbar .ut-dropdown .ut-dd-icon {
  width: 20px;
  text-align: center;
  font-size: 15px;
  flex-shrink: 0;
}
.sai-unified-topbar .ut-dropdown .ut-dd-label {
  flex: 1;
}
.sai-unified-topbar .ut-dropdown .ut-dd-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  background: #E8F5E9;
  color: #2E7D32;
}
[data-theme="dark"] .sai-unified-topbar .ut-dropdown .ut-dd-badge,
body[data-admin-dark="true"] .sai-unified-topbar .ut-dropdown .ut-dd-badge {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}
.sai-unified-topbar .ut-dropdown .ut-dd-divider {
  height: 1px;
  background: #E8EAED;
  margin: 4px 0;
}
[data-theme="dark"] .sai-unified-topbar .ut-dropdown .ut-dd-divider,
body[data-admin-dark="true"] .sai-unified-topbar .ut-dropdown .ut-dd-divider {
  background: rgba(148, 163, 184, 0.12);
}

/* Active page indicator */
.sai-unified-topbar .ut-dropdown a.ut-active {
  background: #E8F5E9;
  color: #2E7D32;
  font-weight: 600;
}
[data-theme="dark"] .sai-unified-topbar .ut-dropdown a.ut-active,
body[data-admin-dark="true"] .sai-unified-topbar .ut-dropdown a.ut-active {
  background: rgba(34, 197, 94, 0.12);
  color: #22c55e;
}
.sai-unified-topbar .ut-dropdown a.ut-active::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #34A853;
  flex-shrink: 0;
  margin-right: -4px;
}

/* ── Right section: Status + User ── */
.sai-unified-topbar .ut-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.sai-unified-topbar .ut-status {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 11px;
  color: #5F6368;
}
[data-theme="dark"] .sai-unified-topbar .ut-status,
body[data-admin-dark="true"] .sai-unified-topbar .ut-status {
  color: #94a3b8;
}
.sai-unified-topbar .ut-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 2px;
}
.sai-unified-topbar .ut-dot.green { background: #34A853; }
.sai-unified-topbar .ut-dot.red { background: #EA4335; }

/* User avatar button */
.sai-unified-topbar .ut-user-btn {
  position: relative;
  display: inline-block;
}
.sai-unified-topbar .ut-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #3D8B50;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: box-shadow 0.15s;
  font-family: inherit;
}
.sai-unified-topbar .ut-user-avatar:hover {
  box-shadow: 0 0 0 3px rgba(61,139,80,0.2);
}

.sai-unified-topbar .ut-user-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 200px;
  background: rgba(255,255,255,0.97);
  backdrop-filter: blur(16px);
  border: 1px solid #DADCE0;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  padding: 4px 0;
  z-index: 9100;
  margin-top: 4px;
  animation: utDropIn 0.15s ease-out;
}
[data-theme="dark"] .sai-unified-topbar .ut-user-dropdown,
body[data-admin-dark="true"] .sai-unified-topbar .ut-user-dropdown {
  background: rgba(30, 41, 59, 0.97);
  border-color: rgba(148, 163, 184, 0.15);
}
.sai-unified-topbar .ut-user-btn:hover > .ut-user-dropdown {
  display: block;
}
.sai-unified-topbar .ut-user-dropdown a,
.sai-unified-topbar .ut-user-dropdown button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  font-size: 13px;
  color: #3C4043;
  text-decoration: none;
  width: 100%;
  border: none;
  background: none;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
  font-family: inherit;
}
[data-theme="dark"] .sai-unified-topbar .ut-user-dropdown a,
[data-theme="dark"] .sai-unified-topbar .ut-user-dropdown button,
body[data-admin-dark="true"] .sai-unified-topbar .ut-user-dropdown a,
body[data-admin-dark="true"] .sai-unified-topbar .ut-user-dropdown button {
  color: #cbd5e1;
}
.sai-unified-topbar .ut-user-dropdown a:hover,
.sai-unified-topbar .ut-user-dropdown button:hover {
  background: #F1F3F4;
}
[data-theme="dark"] .sai-unified-topbar .ut-user-dropdown a:hover,
[data-theme="dark"] .sai-unified-topbar .ut-user-dropdown button:hover,
body[data-admin-dark="true"] .sai-unified-topbar .ut-user-dropdown a:hover,
body[data-admin-dark="true"] .sai-unified-topbar .ut-user-dropdown button:hover {
  background: rgba(148, 163, 184, 0.1);
}

/* Dark mode toggle */
.sai-unified-topbar .ut-dm-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 13px;
  color: #3C4043;
  cursor: pointer;
}
[data-theme="dark"] .sai-unified-topbar .ut-dm-toggle,
body[data-admin-dark="true"] .sai-unified-topbar .ut-dm-toggle {
  color: #cbd5e1;
}
.sai-unified-topbar .ut-dm-toggle:hover {
  background: #F1F3F4;
}
[data-theme="dark"] .sai-unified-topbar .ut-dm-toggle:hover,
body[data-admin-dark="true"] .sai-unified-topbar .ut-dm-toggle:hover {
  background: rgba(148, 163, 184, 0.1);
}
.sai-unified-topbar .ut-dm-switch {
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: #DADCE0;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.sai-unified-topbar .ut-dm-switch::after {
  content: '';
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: transform 0.2s;
}
.sai-unified-topbar .ut-dm-switch.active {
  background: #3D8B50;
}
.sai-unified-topbar .ut-dm-switch.active::after {
  transform: translateX(16px);
}

/* ── Hamburger Button (hidden on desktop) ── */
.sai-unified-topbar .ut-hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  margin-left: auto;
  margin-right: 8px;
}
.sai-unified-topbar .ut-hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: #94a3b8;
  margin: 5px 0;
  border-radius: 2px;
  transition: all 0.3s ease;
}
.sai-unified-topbar .ut-hamburger.ut-active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}
.sai-unified-topbar .ut-hamburger.ut-active span:nth-child(2) {
  opacity: 0;
}
.sai-unified-topbar .ut-hamburger.ut-active span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .sai-unified-topbar .ut-hamburger { display: block; }
  .sai-unified-topbar .ut-center {
    display: none;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    background: #1e293b;
    border-bottom: 1px solid #334155;
    padding: 8px 0;
    flex-direction: column;
    z-index: 9001;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  }
  .sai-unified-topbar .ut-center.ut-mobile-open { display: flex; }
  .sai-unified-topbar .ut-center .ut-nav-item { width: 100%; }
  .sai-unified-topbar .ut-center .ut-nav-btn { width: 100%; text-align: left; padding: 10px 20px; }
  .sai-unified-topbar .ut-center .ut-dropdown {
    position: static;
    box-shadow: none;
    border: none;
    padding-left: 20px;
  }
  .sai-unified-topbar .ut-status { display: none; }
}

@media (max-width: 560px) {
  .sai-unified-topbar { padding: 0 10px; height: 48px; }
  .sai-unified-topbar .ut-brand-text { font-size: 14px; }
}
