/* Barra superior: menú, buscador, ayuda, avisos y cuenta; buscador redondo del celular y cortes de 1024 a 1279 y de 768 a 1023. */

/* --- Barra superior ---
   Base (celular, compacta como la de Órbita): menú (lleva a «Más»), buscador
   como ícono, ayuda, avisos y cuenta, con áreas de 44 px. El contexto vive en
   «Más». Desde 768 px: migas, buscador ancho con `Ctrl K`, «Ayuda» con texto,
   tema, avisos y avatar. */
.topbar { border-bottom-color: var(--border); }
.migas { display: none; min-width: 0; }
.topbar__espacio { flex: 1 1 auto; min-width: 0; }
.topbar__menu { color: var(--label); text-decoration: none; }

.topbar__buscar,
.topbar__ayuda,
.topbar__icono {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  gap: var(--space-2);
  min-width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--label-secondary);
  font: inherit;
  cursor: pointer;
  transition: background-color var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast);
}
.topbar__buscar:hover,
.topbar__icono:hover { background: var(--surface-3); color: var(--label); }
/* En el celular el buscador es un círculo con borde, como el de Órbita. */
.topbar__buscar { width: 44px; border: 1px solid var(--border); background: var(--bg-grupo); }
.topbar__buscar-texto,
.topbar__kbd,
.topbar__ayuda-texto { display: none; }
.topbar__tema { display: none; }
.topbar__ayuda { color: var(--acento-700); }
.topbar__ayuda:hover { background: var(--acento-50); }
.topbar__icono { position: relative; }
.topbar__badge {
  position: absolute;
  top: 4px;
  right: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: var(--radius-full);
  background: var(--destructive-fill);
  color: var(--on-destructive);
  font-size: var(--text-caption2-size);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 2px var(--bg-grupo);
}
.topbar__badge[hidden] { display: none; }
.topbar__avatar .avatar { width: 32px; height: 32px; font-size: var(--text-caption2-size); }
.topbar__buscar:focus-visible,
.topbar__ayuda:focus-visible,
.topbar__icono:focus-visible,
.migas a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (min-width: 768px) {
  .topbar {
    gap: var(--space-2);
    padding: 0 var(--space-6);
    min-height: 60px;
  }
  .topbar__menu { display: none; }
  /* Las migas no ceden: cede primero el buscador (hasta 160 px). */
  .migas { display: block; flex: 0 0 auto; max-width: 50%; }
  .migas ol {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: var(--text-subhead-size);
    line-height: var(--text-subhead-lh);
    white-space: nowrap;
  }
  .migas__item { min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--label-secondary); }
  .migas__item + .migas__item::before {
    content: '/';
    margin-right: var(--space-2);
    color: var(--text-3);
  }
  .migas__empresa { font-weight: 500; max-width: 180px; flex: none; }
  .migas__item[aria-current="page"] { color: var(--label); font-weight: 600; }
  .migas a { color: inherit; text-decoration: none; }
  .migas a:hover { color: var(--label); text-decoration: underline; }

  .topbar__buscar {
    width: auto;
    flex: 0 1 420px;
    min-width: 160px;
    height: 40px;
    margin-left: var(--space-4);
    padding: 0 var(--space-2) 0 var(--space-4);
    justify-content: flex-start;
    border: 1px solid var(--border);
    background: var(--bg-grupo);
    color: var(--label-secondary);
    box-shadow: var(--sh-xs);
  }
  .topbar__buscar:hover { background: var(--bg-grupo); border-color: var(--border-strong); }
  .topbar__buscar-texto {
    display: block;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: var(--text-subhead-size);
  }
  .topbar__kbd {
    display: inline-flex;
    align-items: center;
    flex: none;
    height: 24px;
    margin-left: auto;
    padding: 0 var(--space-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--surface-2);
    color: var(--label-secondary);
    font-family: var(--font-sans);
    font-size: var(--text-caption1-size);
    font-weight: 500;
  }
  .topbar__ayuda {
    height: 36px;
    padding: 0 var(--space-3);
    font-size: var(--text-subhead-size);
    font-weight: 600;
  }
  .topbar__ayuda-texto { display: inline; }
  .topbar__tema { display: inline-flex; }
  .topbar__icono { min-width: 36px; width: 36px; height: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}

/* Entre 1024 y 1279 la barra lateral está expandida y la superior mide
   ~710 px útiles: con las migas de una ficha («Ascensores del Norte / Órdenes
   de trabajo / OT-2026-0156») la barra desbordaba 45 px a 1024 (medido en el
   Rediseño 7). La empresa ya se lee en la tarjeta de contexto de la barra
   lateral, así que se omite, y las migas no pasan del 40 %. */
@media (min-width: 1024px) and (max-width: 1279.98px) {
  .migas { max-width: 40%; }
  .migas__empresa { display: none; }
  .migas__empresa + .migas__item::before { content: none; }
}

/* Entre 768 y 1023 el buscador cede el ancho a las migas, y las migas
   arrancan en la pantalla: la empresa ya se lee en la tarjeta de contexto. */
@media (min-width: 768px) and (max-width: 1023.98px) {
  .migas__empresa { display: none; }
  /* «Ayuda» queda como ícono y el tema vive en el menú de cuenta: con la
     barra expandida (264 px) las migas no entraban a 800 px. */
  .topbar__ayuda { width: 36px; padding: 0; }
  .topbar__ayuda-texto, .topbar__tema { display: none; }
  .migas__empresa + .migas__item::before { content: none; }
  .topbar__buscar { flex-basis: 44px; min-width: 40px; width: 40px; padding: 0; justify-content: center; margin-left: var(--space-2); }
  .topbar__buscar-texto, .topbar__kbd { display: none; }
}

