/* up_portal/portal.css — layout específico do portal upcore (grade de tiles).
 *
 * Reaproveita SOMENTE os tokens/classes de up_design/base_layout.css
 * (--primary, --card, .page-header, .page-body, .card, .btn) — zero hex
 * hardcoded aqui, zero redefinição de token (up_design é a fonte única).
 *
 * O upcore é uma landing sem sidebar (portal de troca de produto, não um
 * produto com navegação interna própria) — por isso não usa `.main-content`
 * (que assume `margin-left: var(--sidebar-width)`); usa um shell simples
 * centralizado.
 */

.upcore-body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.upcore-shell {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}

.tile-card {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  gap: 0;
}

.tile-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--ring);
}

.tile-card-header {
  padding: 20px 20px 0;
  align-items: flex-start;
}

.tile-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--primary);
}

.tile-icon svg {
  width: 22px;
  height: 22px;
}

.tile-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.tile-badge--core_compativel {
  background: var(--status-success-bg);
  color: var(--status-success-fg);
}

.tile-badge--link_externo {
  background: var(--muted);
  color: var(--muted-foreground);
}

.tile-card-body {
  padding: 12px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tile-live {
  font-weight: 600;
}

.tile-live--ok {
  color: var(--status-success-fg);
}

.tile-live--degraded {
  color: var(--status-warning-fg);
}

.tile-live--desconhecido {
  color: var(--muted-foreground);
}

@media (max-width: 640px) {
  .tile-grid {
    grid-template-columns: 1fr;
  }
}

/* ===================== SHELL (topbar + iframe) =====================
 * PLANO_CORRECAO_UPCORE_SHELL_2026-07-11.md §1/§5. O shell é full-bleed —
 * ao contrário da grade de tiles (`.upcore-shell` centralizado, max-width
 * 1180px), a topbar e o iframe ocupam 100% da viewport. `.upcore-shell--shell`
 * reseta o max-width/margin herdados de `.upcore-shell` só nesta página.
 */

.upcore-shell--shell {
  max-width: none;
  margin: 0;
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.shell-layout {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 100vh;
}

.shell-topbar {
  height: 48px;
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.shell-logo {
  display: flex;
  align-items: center;
  text-decoration: none;
  margin-right: 12px;
  flex-shrink: 0;
}

.shell-logo-mark {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--navy);
  letter-spacing: -0.02em;
}

.shell-logo-mark-star {
  color: var(--secondary);
}

.shell-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
  flex: 1;
  min-width: 0;
  height: 100%;
}

.shell-nav-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted-foreground);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.shell-nav-item .shell-nav-icon {
  display: inline-flex;
  width: 16px;
  height: 16px;
}

.shell-nav-item .shell-nav-icon svg {
  width: 16px;
  height: 16px;
}

/* Estado 1: embutível (troca o iframe do shell, navegação server-rendered) */
.shell-nav-item--embeddable:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}

.shell-nav-item--embeddable.shell-nav-item--active {
  background: var(--sidebar-accent, var(--accent));
  color: var(--foreground);
  font-weight: 600;
}

/* Estado 2: link externo (abre em nova aba, ícone ↗) */
.shell-nav-item--external {
  color: var(--muted-foreground);
}

.shell-nav-item--external:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}

.shell-nav-external-icon {
  display: inline-flex;
  width: 12px;
  height: 12px;
  opacity: 0.7;
}

.shell-nav-external-icon svg {
  width: 12px;
  height: 12px;
}

/* Estado 3: em breve (desabilitado, sem href — ver portal_shell.html) */
.shell-nav-item--disabled {
  color: var(--muted-foreground);
  opacity: 0.5;
  cursor: not-allowed;
}

.shell-nav-soon-badge {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 6px;
  border-radius: 100px;
  background: var(--muted);
  color: var(--muted-foreground);
}

.shell-nav-item--catalog {
  margin-left: auto;
  color: var(--muted-foreground);
  border-left: 1px solid var(--border);
  border-radius: 0;
  padding-left: 14px;
}

.shell-nav-item--catalog:hover {
  color: var(--foreground);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin-left: 8px;
  flex-shrink: 0;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.theme-toggle:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}

.theme-toggle-icon {
  display: none;
  width: 18px;
  height: 18px;
}

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

/* Tema claro (ou "system" resolvido pra claro) → mostra lua (oferece escuro).
 * Tema escuro → mostra sol (oferece claro). Ver toggleTheme() em base_portal.html. */
.theme-toggle-icon--moon {
  display: inline-flex;
}

[data-theme="dark"] .theme-toggle-icon--moon {
  display: none;
}

[data-theme="dark"] .theme-toggle-icon--sun {
  display: inline-flex;
}

.shell-topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.shell-lang-form {
  display: flex;
  align-items: center;
}

.shell-lang-select {
  height: 32px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--muted-foreground);
  font-size: 0.78rem;
  cursor: pointer;
}

.shell-lang-select:hover {
  color: var(--foreground);
}

.shell-auth {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 8px;
  border-left: 1px solid var(--border);
}

.shell-auth-name {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--foreground);
  white-space: nowrap;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shell-auth-action {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted-foreground);
  text-decoration: none;
  white-space: nowrap;
}

.shell-auth-action:hover {
  color: var(--foreground);
}

/* Sessão Django do upcore expirou (poll de portal_shell.html, ver
 * docs/PLANO_SESSAO_AUTO_RENOVACAO_2026-07-12.md) — cor de aviso, mesma
 * paleta usada em .login-form-error, pra não parecer só "trocou de nome". */
.shell-auth-name--expired {
  color: var(--status-danger-fg);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 640px) {
  .shell-auth-name {
    max-width: 80px;
  }
}

.shell-iframe {
  width: 100%;
  height: calc(100vh - 48px);
  border: 0;
  flex: 1;
  display: block;
}

@media (max-width: 640px) {
  .shell-nav-label {
    display: none;
  }

  .shell-nav-item--catalog .shell-nav-label {
    display: none;
  }

  .shell-nav-item {
    padding: 0 8px;
  }
}
