/* ==========================================================================
   Shared Auth Widget, Account Menu, Toast & Segmented Controls
   Loaded by index.html, /briefing/, /weekly/, and /bookmarks/
   ========================================================================== */

.segmented {
  display: inline-flex;
  align-items: stretch;
  height: 32px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.seg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  border: 0;
  background: transparent;
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  padding: 0 10px;
  border-radius: 4px;
  cursor: pointer;
}

.seg-btn.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.auth-widget {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.auth-mount {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.auth-signin-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 11px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink-secondary);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.auth-signin-btn:hover {
  border-color: var(--border-strong);
  color: var(--ink);
}

.auth-avatar-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 3px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth-avatar-btn:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.auth-avatar-btn img,
.auth-avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  transition: filter 0.15s ease;
}

.auth-avatar-initials {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--surface-subtle);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

[data-theme="dark"] .auth-avatar-btn img,
[data-theme="dark"] .auth-avatar-img {
  filter: brightness(0.84) contrast(0.96);
}

[data-theme="dark"] .auth-avatar-btn:hover img,
[data-theme="dark"] .auth-avatar-btn:hover .auth-avatar-img {
  filter: brightness(0.94);
}

.auth-sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--pos);
}

.auth-sync-status.is-syncing .auth-sync-dot {
  background: var(--warn);
}

.auth-sync-status.is-local .auth-sync-dot {
  background: var(--ink-muted);
}

.auth-popover,
.auth-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 80;
  width: 264px;
  max-width: calc(100vw - 24px);
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 10px;
  box-shadow: var(--shadow-md);
  text-align: left;
}

[data-theme="dark"] .auth-popover,
[data-theme="dark"] .auth-menu {
  background: #0f141c;
  border-color: var(--border-strong);
}

.auth-menu-head {
  padding: 4px 6px 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}

.auth-menu-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-sync-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-muted);
  line-height: 1.4;
}

.auth-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 7px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-secondary);
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.auth-menu-item:hover {
  background: var(--surface-subtle);
  color: var(--ink);
}

.auth-gis-slot {
  display: flex;
  justify-content: center;
  min-height: 40px;
  padding: 4px 0;
}

.auth-toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 95;
  max-width: calc(100vw - 32px);
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
}

[data-theme="dark"] .auth-toast {
  background: #0f141c;
  border-color: var(--border-strong);
}

.auth-popover-title {
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--ink);
}

.auth-popover-status {
  margin: 8px 0 0;
  font-size: 11.5px;
  color: var(--ink-muted);
  line-height: 1.4;
}

.auth-popover-status.is-error {
  color: var(--neg);
}

.auth-retry-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  padding: 0 11px;
  margin-top: 6px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink-secondary);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.auth-retry-btn:hover {
  border-color: var(--border-strong);
  color: var(--ink);
}

.auth-menu-count {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  color: var(--ink-secondary);
}
