/* ============================================================
   SWM/OS · TopBar shared component
   ------------------------------------------------------------
   Estilos del componente swm-topbar inyectado por swm-topbar.js.
   Theme-aware · usa variables del tokenset de cada página.
   Si la página no define vars, fallback a defaults razonables.
   ============================================================ */

:root {
  --tb-h: 64px;
  --tb-bg: #ffffff;
  --tb-fg: #1a1a1a;
  --tb-fg-mid: #4a4a4a;
  --tb-fg-low: #6b6b6b;
  --tb-line: rgba(26, 26, 26, 0.10);
  --tb-line-strong: rgba(26, 26, 26, 0.16);
  --tb-accent: #039ECD;
  --tb-hover: rgba(26, 26, 26, 0.04);
}

[data-theme="dark"] {
  --tb-bg: #171717;
  --tb-fg: #ECECEC;
  --tb-fg-mid: #A8A8A8;
  --tb-fg-low: #6B6B6B;
  --tb-line: rgba(255, 255, 255, 0.06);
  --tb-line-strong: rgba(255, 255, 255, 0.12);
  --tb-hover: rgba(255, 255, 255, 0.04);
}

.swm-topbar {
  display: flex;
  align-items: center;
  height: var(--tb-h);
  padding: 0 24px;
  background: var(--tb-bg);
  border-bottom: 1px solid var(--tb-line);
  font-family: 'Manrope', system-ui, sans-serif;
  gap: 18px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.swm-topbar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
}
.swm-topbar__brand:hover .swm-topbar__logo { opacity: 0.85; }

.swm-topbar__logo {
  height: 28px;
  width: auto;
  transition: opacity 0.15s;
}

.swm-topbar__divider {
  width: 1px;
  height: 22px;
  background: var(--tb-line-strong);
}

.swm-topbar__product {
  display: flex;
  flex-direction: column;
  line-height: 1;
}
.swm-topbar__product strong {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--tb-fg);
  font-family: 'JetBrains Mono', monospace;
}
.swm-topbar__product small {
  font-size: 11px;
  color: var(--tb-fg-low);
  margin-top: 2px;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.3px;
}

.swm-topbar__search {
  flex: 1;
  max-width: 480px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid var(--tb-line-strong);
  padding: 8px 12px;
  cursor: pointer;
  color: var(--tb-fg-low);
  font-size: 13px;
  transition: border-color 0.15s, background 0.15s;
  min-height: 36px;
}
.swm-topbar__search:hover {
  border-color: var(--tb-accent);
  background: var(--tb-hover);
}
.swm-topbar__search svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.swm-topbar__search span {
  flex: 1;
  text-align: left;
  font-family: 'Manrope', sans-serif;
}
.swm-topbar__search kbd {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  padding: 2px 6px;
  border: 1px solid var(--tb-line-strong);
  background: transparent;
  color: var(--tb-fg-low);
  letter-spacing: 0.5px;
}

.swm-topbar__actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.swm-topbar__icon-btn {
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--tb-fg-mid);
  transition: background 0.15s, color 0.15s;
}
.swm-topbar__icon-btn:hover {
  background: var(--tb-hover);
  color: var(--tb-fg);
}
.swm-topbar__icon-btn svg {
  width: 18px;
  height: 18px;
}

[data-theme="dark"] .swm-topbar__icon-btn .sun { display: inline-flex; }
[data-theme="dark"] .swm-topbar__icon-btn .moon { display: none; }
[data-theme="light"] .swm-topbar__icon-btn .sun { display: none; }
[data-theme="light"] .swm-topbar__icon-btn .moon { display: inline-flex; }
.swm-topbar__icon-btn .sun,
.swm-topbar__icon-btn .moon { display: inline-flex; }

.swm-topbar__user {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid var(--tb-line-strong);
  padding: 4px 10px 4px 4px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, background 0.15s;
  font-family: inherit;
  font-size: 13px;
  min-height: 36px;
  position: relative;
}
.swm-topbar__user:hover {
  border-color: var(--tb-accent);
  background: var(--tb-hover);
}
.swm-topbar__user-avatar {
  width: 26px;
  height: 26px;
  background: var(--tb-accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.swm-topbar__user-name {
  font-weight: 500;
  color: var(--tb-fg);
  font-size: 12px;
}
.swm-topbar__user-role {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: var(--tb-fg-low);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.swm-topbar__menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--tb-bg);
  border: 1px solid var(--tb-line-strong);
  min-width: 220px;
  padding: 6px;
  display: none;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}
.swm-topbar__menu.is-open { display: block; }
.swm-topbar__menu-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--tb-line);
  margin-bottom: 4px;
}
.swm-topbar__menu-email {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--tb-fg-mid);
  word-break: break-all;
}
.swm-topbar__menu-item {
  display: block;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--tb-fg);
  text-decoration: none;
  background: transparent;
  border: 0;
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-family: inherit;
}
.swm-topbar__menu-item:hover { background: var(--tb-hover); }

/* Mobile · search collapsa a icon, user name oculto */
@media (max-width: 720px) {
  .swm-topbar { padding: 0 16px; gap: 10px; }
  .swm-topbar__search span,
  .swm-topbar__search kbd { display: none; }
  .swm-topbar__search {
    width: 36px;
    max-width: 36px;
    flex: 0 0 36px;
    justify-content: center;
    padding: 0;
  }
  .swm-topbar__product { display: none; }
  .swm-topbar__divider { display: none; }
  .swm-topbar__user-name,
  .swm-topbar__user-role { display: none; }
  .swm-topbar__user { padding: 4px; }
}
