/* Roalla Auth Hub — shared light/dark theme tokens and header controls */

html[data-theme="light"] {
  --bg: #f8fafc;
  --bg-elevated: #f1f5f9;
  --card: #ffffff;
  --card-hover: #f1f5f9;
  --text: #0f172a;
  --muted: #64748b;
  --muted-dim: #94a3b8;
  --pass: #059669;
  --pass-bg: rgba(5, 150, 105, 0.1);
  --pass-border: rgba(5, 150, 105, 0.28);
  --fail: #dc2626;
  --fail-bg: rgba(220, 38, 38, 0.08);
  --fail-border: rgba(220, 38, 38, 0.25);
  --warn: #d97706;
  --warn-bg: rgba(217, 119, 6, 0.1);
  --warn-border: rgba(217, 119, 6, 0.28);
  --skip: #64748b;
  --skip-bg: rgba(100, 116, 139, 0.1);
  --border: #e2e8f0;
  --border-subtle: #f1f5f9;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --internal: #7c3aed;
  --internal-bg: rgba(124, 58, 237, 0.08);
  --internal-border: rgba(124, 58, 237, 0.25);
  --client: #0891b2;
  --client-bg: rgba(8, 145, 178, 0.08);
  --client-border: rgba(8, 145, 178, 0.25);
  --ok: #16a34a;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.08);
  --topbar-bg: rgba(248, 250, 252, 0.92);
  --input-bg: #ffffff;
  --social-btn-bg: #ffffff;
  --nav-hover-bg: rgba(15, 23, 42, 0.05);
  --link-accent: #2563eb;
  --gradient-blue: rgba(59, 130, 246, 0.1);
  --gradient-green: rgba(16, 185, 129, 0.06);
  --code-fg: #1d4ed8;
  --body-text-soft: #334155;
  --modal-backdrop: rgba(15, 23, 42, 0.35);
}

html[data-theme="dark"],
html:not([data-theme]) {
  --topbar-bg: rgba(11, 15, 20, 0.85);
  --input-bg: #0b0f14;
  --social-btn-bg: #0f1419;
  --nav-hover-bg: rgba(255, 255, 255, 0.04);
  --link-accent: #93c5fd;
  --gradient-blue: rgba(59, 130, 246, 0.14);
  --gradient-green: rgba(16, 185, 129, 0.06);
  --code-fg: #93c5fd;
  --body-text-soft: #cbd5e1;
  --modal-backdrop: rgba(0, 0, 0, 0.6);
}

html[data-theme="light"] body.auth-page {
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --input-bg: #ffffff;
  --social-btn-bg: #ffffff;
}

html[data-theme="dark"] body.auth-page,
html:not([data-theme]) body.auth-page {
  --input-bg: #0f1419;
  --social-btn-bg: #0f1419;
}

/* Shared topbar (used on hub pages and auth flows) */
.hub-topbar {
  border-bottom: 1px solid var(--border-subtle, var(--border));
  background: var(--topbar-bg);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.hub-topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 1rem;
}

.hub-topbar .brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.hub-topbar .brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.95rem;
  color: #fff;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.35);
}

.hub-topbar .brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: contain;
}

.hub-auth-powered {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
}

.hub-topbar .brand-text strong {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.hub-topbar .brand-text span {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
}

.hub-topbar .topnav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.15rem;
}

.hub-topbar .topnav a {
  position: relative;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
}

.hub-topbar .topnav a:hover {
  color: var(--text);
  background: var(--nav-hover-bg);
}

.hub-topbar .topnav a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.hub-topbar .topnav a.active {
  color: var(--text);
  background: transparent;
}

.hub-topbar .topnav a.active::after {
  content: "";
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  bottom: 0.2rem;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}

.hub-nav-divider {
  width: 1px;
  height: 18px;
  background: var(--border-subtle, var(--border));
  margin: 0 0.2rem;
  flex-shrink: 0;
}

.hub-skip-link {
  position: absolute;
  left: -9999px;
  top: 0.5rem;
  z-index: 100;
  padding: 0.5rem 0.85rem;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
}

.hub-skip-link:focus {
  left: 0.75rem;
}

.hub-auth-slot {
  display: flex;
  align-items: center;
}

.hub-btn-signin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  transition: filter 0.15s, transform 0.12s;
}

.hub-btn-signin:hover {
  filter: brightness(1.06);
  color: #fff;
}

.hub-btn-signin:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.hub-btn-signin-block {
  width: 100%;
  margin-top: 0.35rem;
}

.hub-user-menu {
  position: relative;
}

.hub-user-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.55rem 0.3rem 0.3rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card, var(--bg-elevated));
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  max-width: 220px;
}

.hub-user-trigger:hover {
  background: var(--nav-hover-bg);
}

.hub-user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--link-accent);
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.hub-user-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hub-user-panel {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  min-width: 220px;
  background: var(--card, #151c26);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 0.35rem;
  z-index: 50;
}

.hub-user-menu.open .hub-user-panel {
  display: block;
}

.hub-user-meta {
  padding: 0.55rem 0.65rem 0.45rem;
  border-bottom: 1px solid var(--border-subtle, var(--border));
  margin-bottom: 0.25rem;
}

.hub-user-meta strong {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 0.1rem;
}

.hub-user-meta span {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hub-user-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text);
  text-decoration: none;
  font: inherit;
  font-size: 0.84rem;
  cursor: pointer;
}

.hub-user-item:hover {
  background: var(--nav-hover-bg);
}

.hub-user-signout {
  color: #fca5a5;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
  justify-self: end;
}

.btn-refresh {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card, var(--bg-elevated));
  color: var(--text);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn-refresh:hover {
  background: var(--card-hover, var(--bg-elevated));
  border-color: var(--muted-dim, var(--muted));
}

.btn-refresh:disabled {
  opacity: 0.6;
  cursor: wait;
}

.btn-refresh svg {
  width: 14px;
  height: 14px;
}

.btn-refresh.spinning svg {
  animation: hub-spin 0.8s linear infinite;
}

@keyframes hub-spin {
  to {
    transform: rotate(360deg);
  }
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card, var(--bg-elevated));
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.theme-toggle:hover {
  background: var(--card-hover, var(--bg-elevated));
  border-color: var(--muted-dim, var(--muted));
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  display: none;
}

html[data-theme="light"] .theme-toggle .icon-moon {
  display: block;
}

html[data-theme="dark"] .theme-toggle .icon-sun,
html:not([data-theme]) .theme-toggle .icon-sun {
  display: block;
}

/* Docs page top bar */
.docs-top {
  padding: 0.85rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--topbar-bg);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.docs-top-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1rem;
}

.docs-top a {
  color: var(--link-accent);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
}

.docs-top a:hover {
  text-decoration: underline;
}

html[data-theme="light"] #swagger-ui .swagger-ui {
  filter: none;
}

@media (max-width: 900px) {
  .hub-desktop-nav {
    display: none;
  }

  .hub-menu-toggle {
    display: inline-flex;
  }

  .hub-topbar-inner {
    grid-template-columns: 1fr auto auto;
  }

  .hub-topbar-center {
    display: none;
  }

  .hub-user-label {
    display: none;
  }

  .hub-user-trigger {
    padding: 0.25rem;
    border-radius: 999px;
  }
}

@media (min-width: 901px) {
  .hub-menu-toggle {
    display: none;
  }

  .hub-mobile-panel {
    display: none !important;
  }
}

/* Aliases for legacy topbar class names */
.topbar {
  border-bottom: 1px solid var(--border-subtle, var(--border));
  background: var(--topbar-bg);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.hub-topbar-center {
  display: flex;
  justify-content: center;
  min-width: 0;
}

.hub-menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card, var(--bg-elevated));
  cursor: pointer;
}

.hub-menu-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  margin: 0 auto;
  background: var(--text);
  border-radius: 1px;
}

.hub-mobile-panel {
  display: none;
  border-bottom: 1px solid var(--border-subtle, var(--border));
  background: var(--topbar-bg);
  padding: 0.5rem 1rem 1rem;
}

.hub-topbar.hub-menu-open .hub-mobile-panel,
.topbar.hub-menu-open .hub-mobile-panel {
  display: block;
}

.hub-mobile-nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.hub-nav-group-label {
  margin: 0.65rem 0.35rem 0.2rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted-dim, var(--muted));
}

.hub-mobile-nav .hub-nav-group-label:first-child {
  margin-top: 0.15rem;
}

.hub-mobile-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
}

.hub-mobile-nav a:hover,
.hub-mobile-nav a.active {
  color: var(--text);
  background: var(--nav-hover-bg);
}

.hub-mobile-nav a.active {
  border-left: 2px solid var(--accent);
  border-radius: 0 8px 8px 0;
}

.hub-mobile-actions {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-subtle, var(--border));
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.hub-mobile-user {
  margin: 0 0 0.35rem;
  padding: 0 0.75rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.hub-mobile-link {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text);
  text-decoration: none;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.hub-mobile-link:hover {
  background: var(--nav-hover-bg);
}

.hub-apps-menu {
  position: relative;
}

.hub-apps-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card, var(--bg-elevated));
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
}

.hub-apps-trigger:hover {
  background: var(--nav-hover-bg);
}

.hub-chevron {
  font-size: 0.7rem;
  opacity: 0.7;
}

.hub-apps-panel {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  min-width: 200px;
  background: var(--card, #151c26);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 0.35rem;
  z-index: 50;
}

.hub-apps-menu.open .hub-apps-panel {
  display: block;
}

.hub-apps-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.85rem;
}

.hub-apps-item:hover {
  background: var(--nav-hover-bg);
}

.hub-apps-fallback {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--link-accent);
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  font-weight: 700;
}

.hub-apps-item img {
  border-radius: 4px;
  object-fit: cover;
}

@media (max-width: 900px) {
  .hub-topbar .topnav {
    display: none;
  }
}
