/**
 * Design System — Navegação híbrida (Story 022 / Proposta C)
 * Tokens e componentes reutilizáveis para expansão (10+ módulos).
 */

:root {
  --nav-height: 3.5rem;
  --subnav-height: 2.5rem;
  --nav-max-width: 1760px;
  --nav-gap: 0.125rem;

  --nav-tab-color: #64748b;
  --nav-tab-color-hover: #0f172a;
  --nav-tab-color-active: #0f172a;
  --nav-tab-indicator: #2563eb;
  --nav-tab-size: 0.875rem;

  --subnav-bg: #fafbfc;
  --subnav-tab-active-bg: #ffffff;
  --subnav-tab-active-border: #e2e8f0;
}

/* ——— Header shell ——— */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.app-header__bar {
  display: flex;
  align-items: stretch;
  gap: 1.25rem;
  min-height: var(--nav-height);
  max-width: var(--nav-max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
  box-sizing: border-box;
}

.app-header__brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex-shrink: 0;
  padding: 0.75rem 0;
}

.app-header__mark {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 6px;
  background: linear-gradient(145deg, #3b82f6 0%, #1d4ed8 100%);
  flex-shrink: 0;
}

.app-header__brand h1 {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--color-text);
  white-space: nowrap;
}

.app-header__utils {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
  margin-left: auto;
  padding: 0.5rem 0;
}

.app-header__sep {
  width: 1px;
  height: 1.25rem;
  margin: 0 0.4rem;
  background: var(--color-border);
}

/* ——— Primary tabs (not buttons) ——— */
.app-nav {
  display: flex;
  align-items: stretch;
  gap: var(--nav-gap);
  flex: 1 1 auto;
  min-width: 0;
}

.app-nav__tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0 0.85rem;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--nav-tab-color);
  font-family: inherit;
  font-size: var(--nav-tab-size);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.005em;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.15s ease;
  box-shadow: none;
}

.app-nav__tab::after {
  content: '';
  position: absolute;
  left: 0.45rem;
  right: 0.45rem;
  bottom: 0;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: transparent;
  transition: background 0.15s ease;
}

.app-nav__tab:hover {
  color: var(--nav-tab-color-hover);
  background: transparent;
}

.app-nav__tab:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
  border-radius: 4px;
}

.app-nav__tab--active {
  color: var(--nav-tab-color-active);
  font-weight: 600;
  background: transparent;
}

.app-nav__tab--active::after {
  background: var(--nav-tab-indicator);
}

/* Utilitário compacto (CSV / overflow trigger) */
.app-nav__util {
  padding: 0.35rem 0.6rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-muted);
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.app-nav__util:hover {
  color: var(--color-text);
  background: var(--color-bg);
  border-color: transparent;
}

.app-nav__icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  margin: 0;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  color: var(--color-muted);
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: none;
}

.app-nav__icon-btn:hover:not(:disabled) {
  color: var(--color-text);
  background: var(--color-bg);
}

.app-nav__icon-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.app-nav__icon-btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Overflow "Mais" — preparado para 10+ módulos */
.app-nav-overflow {
  position: relative;
}

.app-nav-overflow[hidden] {
  display: none !important;
}

.app-nav-overflow__btn {
  position: relative;
}

.app-nav-overflow--active .app-nav-overflow__btn {
  color: var(--nav-tab-color-active);
  font-weight: 600;
}

.app-nav-overflow__menu {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  min-width: 11rem;
  padding: 0.35rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  z-index: 20;
}

.app-nav-overflow__menu[hidden] {
  display: none !important;
}

.app-nav-overflow__item {
  display: block;
  width: 100%;
  text-align: left;
  margin: 0;
  padding: 0.5rem 0.75rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--color-text);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}

.app-nav-overflow__item:hover,
.app-nav-overflow__item--active {
  background: var(--color-bg);
}

/* ——— Secondary contextual nav ——— */
.app-subnav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: var(--subnav-height);
  max-width: var(--nav-max-width);
  margin: 0 auto;
  padding: 0.3rem 1.5rem;
  background: var(--subnav-bg);
  border-top: 1px solid var(--color-border);
  box-sizing: border-box;
}

.app-subnav[hidden] {
  display: none !important;
}

.app-subnav__label {
  flex-shrink: 0;
  margin-right: 0.35rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.app-subnav__items {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.2rem;
}

.app-subnav__tab {
  margin: 0;
  padding: 0.35rem 0.7rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--color-muted);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: none;
}

.app-subnav__tab:hover {
  color: var(--color-text);
  background: rgba(255, 255, 255, 0.7);
}

.app-subnav__tab--active {
  background: var(--subnav-tab-active-bg);
  border-color: var(--subnav-tab-active-border);
  color: var(--color-text);
  font-weight: 600;
}

.app-subnav__tab:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}

/* ——— Module views ——— */
.app-view[hidden] {
  display: none !important;
}

.module-shell {
  max-width: 40rem;
  padding: 2rem 0 1rem;
}

.module-shell__title {
  margin: 0 0 0.5rem;
  font-size: 1.35rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.module-shell__hint {
  margin: 0 0 1.25rem;
  font-size: 0.9375rem;
  color: var(--color-muted);
  line-height: 1.55;
}

.module-shell__actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Desktop density: notebooks → ultrawide (mobile fora do escopo) */
@media (min-width: 1920px) {
  .app-header__bar,
  .app-subnav {
    padding-left: 2rem;
    padding-right: 2rem;
  }
}
