/* =====================================================================
   YVETECH health — Hub de entrada (PWA)
   Usa as variáveis de design-tokens.css (carregado antes deste arquivo)
   ===================================================================== */

:root {
  --muted-forte: #55707a;          /* texto secundário com contraste AA sobre --bg */
  --campanha-azul: #2f6fd6;
  --orbita-tamanho: min(460px, 100%);
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body.hub {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-hub);
  color: var(--ink);
  background:
    radial-gradient(900px 520px at 85% -10%, rgba(11, 185, 167, .12), transparent 60%),
    radial-gradient(700px 480px at -10% 110%, rgba(0, 84, 123, .08), transparent 60%),
    var(--bg);
}

.pular {
  position: absolute;
  left: 16px;
  top: -48px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  background: var(--brand-dark);
  color: #fff;
  z-index: 10;
}
.pular:focus { top: 12px; }

:focus-visible {
  outline: 3px solid rgba(11, 185, 167, .55);
  outline-offset: 2px;
}

/* ---------- Topo ---------- */
.hub-topo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: max(16px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) 16px max(24px, env(safe-area-inset-left));
}

.marca {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
}
.yv-marca { width: 36px; height: 36px; flex: none; }
.marca-nome { font-size: 18px; font-weight: 600; letter-spacing: .01em; white-space: nowrap; }
.marca-nome strong { color: var(--brand); font-weight: 700; }

.topo-acoes { display: flex; align-items: center; gap: 10px; }

.rede {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--brand-dark);
  background: var(--soft);
}
.rede::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand);
}
.rede[data-estado="offline"] { color: #8a5a00; background: var(--color-alert-bg); }
.rede[data-estado="offline"]::before { background: var(--color-status-wait); }

.btn-contorno {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--brand-dark);
  font: 600 var(--fs-md) var(--font-hub);
  white-space: nowrap;
  cursor: pointer;
}
.btn-contorno:hover { border-color: var(--brand); }
.btn-contorno[hidden] { display: none; }

.yv-icone {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Conteúdo ---------- */
.hub-principal {
  flex: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 8px 24px 32px;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr);
  gap: 40px;
  align-items: center;
}

.intro-linha { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }

.saudacao {
  margin: 0;
  font-size: var(--fs-greeting);
  font-weight: 600;
  color: var(--brand-dark);
}

.campanha {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: #fff;
  background: var(--campaign-primary);
}
.campanha--novembro-azul { background: var(--campanha-azul); }
.campanha-laco {
  width: 10px;
  height: 10px;
  border: 2px solid #fff;
  border-radius: 50% 50% 0 50%;
  transform: rotate(45deg);
}

.hub-intro h1 {
  margin: 10px 0 12px;
  font-size: var(--fs-title-hub);
  line-height: 1.2;
  font-weight: 700;
  color: var(--ink);
  max-width: 22ch;
}

.lead {
  margin: 0;
  max-width: 56ch;
  font-size: var(--fs-lg);
  line-height: 1.55;
  color: var(--muted-forte);
}

.ecg {
  display: block;
  width: 100%;
  height: 64px;
  margin: 20px 0 4px;
}
.ecg-base {
  fill: none;
  stroke: var(--line);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ecg .yv-ecg-active { stroke-linejoin: round; }

/* ---------- Órbita de módulos ---------- */
.orbita-titulo {
  margin: 8px 0 0;
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--muted-forte);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.orbita {
  position: relative;
  width: var(--orbita-tamanho);
  aspect-ratio: 1;
  margin: 12px auto 0;
  padding: 0;
  list-style: none;
  container-type: inline-size;
}
.orbita::before {
  content: "";
  position: absolute;
  inset: 13%;
  border: 1.5px dashed #cfdde2;
  border-radius: 50%;
}

.orbita-nucleo {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 26cqi;
  height: 26cqi;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-hub);
}
.orbita-marca { width: 52%; height: 52%; }

.orbita-item {
  --raio: 37cqi;
  position: absolute;
  top: 50%;
  left: 50%;
  width: 24cqi;
  transform: translate(-50%, -50%) rotate(var(--angulo)) translateX(var(--raio)) rotate(calc(-1 * var(--angulo)));
}
.m1 { --angulo: -90deg; --cor: var(--mod-estoque); }
.m2 { --angulo: -45deg; --cor: var(--mod-bi); }
.m3 { --angulo: 0deg;   --cor: var(--mod-laboratorio); }
.m4 { --angulo: 45deg;  --cor: var(--mod-atendimento); }
.m5 { --angulo: 90deg;  --cor: var(--mod-financeiro); }
.m6 { --angulo: 135deg; --cor: var(--mod-exame); }
.m7 { --angulo: 180deg; --cor: var(--mod-faturamento); }
.m8 { --angulo: 225deg; --cor: var(--mod-consultorio); }

.modulo {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px 2px;
  border: 0;
  border-radius: var(--radius-lg);
  background: transparent;
  color: var(--ink);
  font-family: var(--font-hub);
  text-align: center;
  cursor: pointer;
}

.modulo-icone {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  color: #fff;
  background: var(--cor);
  box-shadow: 0 8px 18px -6px var(--cor);
  transition: transform .18s ease, box-shadow .18s ease;
}
.modulo-icone .yv-icone { width: 24px; height: 24px; }

.modulo-nome {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
}

.modulo-legenda {
  font-size: 11px;
  line-height: 1.25;
  color: var(--muted-forte);
}

.modulo:hover .modulo-icone { transform: translateY(-2px) scale(1.06); }
.modulo[aria-pressed="true"] .modulo-icone {
  box-shadow: 0 0 0 4px #fff, 0 0 0 7px var(--cor), 0 10px 22px -6px var(--cor);
}
.modulo[aria-pressed="true"] .modulo-nome { color: var(--brand-dark); }

/* ---------- Cartão de acesso ---------- */
.acesso {
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow-hub);
}
.acesso h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}
.acesso-destino {
  margin: 6px 0 20px;
  color: var(--muted-forte);
  font-size: var(--fs-md);
}
.acesso-destino strong { color: var(--brand-dark); }

.campo { display: grid; gap: 6px; margin-bottom: 14px; }
.campo label { font-size: 13px; font-weight: 600; }
.campo input {
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px var(--font-hub);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.campo input:focus {
  outline: none;
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(11, 185, 167, .18);
}
.campo input[aria-invalid="true"] { border-color: var(--color-danger); }

.btn-primario {
  width: 100%;
  height: 46px;
  margin-top: 6px;
  border: 0;
  border-radius: 10px;
  background: var(--gradient-primary);
  color: #fff;
  font: 600 15px var(--font-hub);
  cursor: pointer;
  transition: filter .15s ease;
}
.btn-primario:hover { filter: brightness(1.05); }
.btn-primario:disabled { opacity: .7; cursor: progress; }

.acesso-nota {
  margin: 16px 0 0;
  font-size: var(--fs-sm);
  line-height: 1.5;
  color: var(--muted-forte);
}

/* ---------- Rodapé ---------- */
.hub-rodape {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 20px;
  padding: 16px 24px max(16px, env(safe-area-inset-bottom));
  font-size: var(--fs-sm);
  color: var(--muted-forte);
}
.hub-rodape a { color: var(--brand-dark); }

/* ---------- Toasts ---------- */
.toasts {
  position: fixed;
  right: 16px;
  bottom: max(16px, env(safe-area-inset-bottom));
  display: grid;
  gap: 10px;
  width: min(380px, calc(100vw - 32px));
  z-index: 20;
}
.toast {
  padding: 12px 14px 12px 16px;
  border-left: 5px solid var(--toast-info);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--ink);
  font-size: var(--fs-md);
  line-height: 1.45;
  box-shadow: var(--shadow-dock);
  animation: toastEntra .2s ease-out;
}
.toast--success { border-left-color: var(--toast-success); }
.toast--warning { border-left-color: var(--toast-warning); }
.toast--error { border-left-color: var(--toast-error); }
@keyframes toastEntra {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Página offline ---------- */
.offline {
  flex: 1;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  padding: 32px 16px;
  text-align: center;
}
.offline .yv-marca { width: 64px; height: 64px; }
.offline h1 { margin: 8px 0 0; font-size: 24px; }
.offline p { margin: 0; max-width: 40ch; color: var(--muted-forte); line-height: 1.5; }
.offline a.btn-primario {
  display: inline-grid;
  place-items: center;
  width: auto;
  padding: 0 24px;
  text-decoration: none;
}

/* ---------- Responsivo ---------- */
@media (max-width: 960px) {
  .hub-principal {
    grid-template-columns: 1fr;
    align-content: start;
    gap: 28px;
    padding: 8px 16px 24px;
  }
  .hub-topo { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .acesso { max-width: 520px; width: 100%; margin: 0 auto; }
}

@media (max-width: 640px) {
  .marca-nome { font-size: 16px; }
  .yv-marca { width: 32px; height: 32px; }
  .topo-acoes { gap: 8px; }
  .btn-contorno { height: 34px; padding: 0 10px; }
  .hub-intro h1 { font-size: 24px; }
  .saudacao { font-size: 20px; }
  .lead { font-size: 15px; }
  .ecg { height: 48px; margin-top: 14px; }

  /* Órbita vira grade 4x2 */
  .orbita {
    width: 100%;
    aspect-ratio: auto;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px 6px;
  }
  .orbita::before,
  .orbita-nucleo { display: none; }
  .orbita-item {
    position: static;
    width: auto;
    transform: none;
  }
  .modulo-icone { width: 48px; height: 48px; }
  .modulo-legenda { display: none; }
  .acesso { padding: 22px 18px; }
}

/* Telas estreitas: o status de rede vira só o ponto colorido */
@media (max-width: 420px) {
  .rede { width: 20px; height: 20px; padding: 0; justify-content: center; font-size: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .modulo-icone,
  .toast { transition: none; animation: none; }
}
