/* Hub de módulos — direção "liquid glass" estilo Apple, aprovada pelo
   utilizador a partir de um mockup (ver satis-solution.css para a mesma
   linguagem já aplicada ao SatisSolution). Este ficheiro só é carregado
   por hub.html, por isso reescrever aqui classes que hub.html também
   partilha com outras páginas (.lang-switcher, .avatar, .btn, .btn-icon)
   não afeta mais nenhuma página — cada uma carrega a sua própria
   stylesheet de página por cima da mesma base. */

:root {
  /* Valores de glass.css (fonte única do liquid glass). */
  --hub-ink: var(--g-ink);
  --hub-ink-soft: var(--g-ink-soft);
  --hub-secondary: var(--g-secondary);
  --hub-tertiary: var(--g-tertiary);
  --hub-accent: var(--g-accent);
  --hub-glass-bg: var(--g-surface);
  --hub-glass-bg-strong: var(--g-surface-strong);
  --hub-glass-border: var(--g-edge);
  --hub-hairline: var(--g-hairline);
}

body:has(.hub) {
  overflow-y: auto;
  background: #eef0f4;
}

.hub {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: calc(var(--sp-4) + env(safe-area-inset-top, 0px)) var(--sp-4) env(safe-area-inset-bottom, 0px);
  background: transparent;
}
/* O fundo com manchas de cor vem de glass.css (body::before). */

.hub__topbar {
  position: sticky;
  top: calc(var(--sp-4) + env(safe-area-inset-top, 0px));
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  /* Deixa a mesma folga dos dois lados — a da direita existe por causa
     do puxador do hub-drawer (admin), que é position:fixed e sobressai
     da margem direita do ecrã independente deste layout; espelha-se à
     esquerda para o header ficar centrado e simétrico. */
  width: calc(100% - 88px);
  margin: 0 44px var(--sp-6);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--g-r-bar);
  background: var(--hub-glass-bg-strong);
  border: 1px solid var(--hub-glass-border);
  backdrop-filter: var(--g-blur);
  -webkit-backdrop-filter: var(--g-blur);
  box-shadow: var(--g-shadow-bar);
  color: var(--hub-ink);
}

.hub__brand {
  display: flex;
  align-items: center;
}

.hub__brand-logo {
  height: 42px;
  width: auto;
}

.hub__brand-logo-mini {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: var(--r-md);
  background: var(--white);
  padding: 4px;
}

.hub__brand-logo-mini img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

@media (max-width: 640px) {
  .hub__brand-logo { display: none; }
  .hub__brand-logo-mini { display: flex; }
}

.hub__topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

/* .lang-switcher vive em components.css (usado também no login) —
   sobreposto aqui só para esta página, sem tocar no ficheiro partilhado. */
.lang-switcher {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: var(--r-full);
  background: rgba(120, 120, 128, 0.1);
  border: none;
}
.lang-switcher__option {
  padding: 6px 12px;
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--hub-secondary);
  background: none;
  border: none;
}
.lang-switcher__option:hover { color: var(--hub-ink); }
.lang-switcher__option.is-active {
  background: var(--white);
  color: var(--hub-ink);
  box-shadow: var(--sh-xs);
}

.hub__user {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 4px var(--sp-3) 4px 4px;
  margin-right: var(--sp-1);
  border-right: none;
  border-radius: var(--r-full);
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--hub-hairline);
  line-height: 1.2;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--t-fast);
}

.hub__user:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.8);
}

/* .avatar vive em components.css, translúcido/quase invisível sobre o
   novo topbar claro — sobreposto aqui (só nesta página) com o
   gradiente laranja do mockup aprovado. */
.hub__user .avatar {
  background: linear-gradient(155deg, #ffb35c, #ff7a1a);
  color: #fff;
}

.hub__user-name { display: block; font-size: var(--fs-sm); font-weight: 650; color: var(--hub-ink); }
.hub__user-role {
  display: block;
  font-size: var(--fs-xs);
  color: var(--hub-secondary);
}

.btn--on-dark {
  background: rgba(120, 120, 128, 0.1);
  border-color: transparent;
  color: var(--hub-ink-soft);
}
.btn--on-dark:hover { background: rgba(120, 120, 128, 0.18); }

.btn-icon--on-dark {
  background: rgba(120, 120, 128, 0.1);
  border-color: transparent;
  color: var(--hub-secondary);
}
.btn-icon--on-dark:hover {
  background: rgba(120, 120, 128, 0.18);
  color: var(--hub-ink);
}

.hub__topbar-actions [data-tip]::after {
  left: auto;
  right: 0;
  top: calc(100% + 8px);
  bottom: auto;
  transform: none;
}

.hub__main {
  position: relative;
  z-index: 1;
  flex: 1;
  width: min(1320px, 100%);
  margin: 0 auto;
  padding: 0 0 var(--sp-12);
}

.hub__intro {
  margin-bottom: var(--sp-8);
  max-width: 62ch;
}

.hub__title {
  font-size: var(--fs-3xl);
  font-weight: 750;
  letter-spacing: -0.02em;
  color: var(--hub-ink);
}

.hub__subtitle {
  margin-top: var(--sp-2);
  font-size: var(--fs-lg);
  color: var(--hub-secondary);
}

.modules {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--sp-5);
}

.module {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  /* Altura FIXA, não min-height — o grid calcula a altura de cada
     linha de forma independente, por isso um "min" deixava uma linha
     com descrições mais compridas (ex.: Kitchen/Satis) crescer mais
     alta que as outras. */
  height: 320px;
  padding: 0;
  border-radius: 26px;
  overflow: hidden;
  color: var(--white);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 20px 40px -22px rgba(20, 30, 60, 0.35);
  transition: transform var(--t-med), box-shadow var(--t-med);
}

.module:hover {
  transform: translateY(-4px);
  box-shadow: 0 28px 54px -22px rgba(20, 30, 60, 0.45);
}

.module__photo {
  position: absolute;
  inset: 0;
  background-image: var(--module-photo);
  background-size: cover;
  background-position: center;
  transition: transform var(--t-med);
}

.module:hover .module__photo {
  transform: scale(1.04);
}

.module__tint {
  position: absolute;
  inset: 0;
  background: var(--module-bg, linear-gradient(160deg, var(--navy-700), var(--navy-900)));
  opacity: 0.55;
}

.module__scrim {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.24), transparent 45%),
    linear-gradient(0deg, rgba(6, 10, 20, 0.78) 0%, rgba(6, 10, 20, 0.15) 55%, transparent 78%);
}

.module__content {
  /* backdrop-filter cria o seu próprio "containing block" para
     descendentes position:absolute, mesmo sem position:relative
     definido aqui — por isso .module__icon teve de deixar de ser
     descendente desta placa no HTML (passou a irmão dela, direto
     dentro de .module) para resolver contra o card inteiro. Sem essa
     mudança no HTML, só tirar o position:relative daqui não chegava:
     o ícone continuava "preso" dentro deste card interior. */
  display: flex;
  flex-direction: column;
  gap: 2px;
  /* Altura FIXA (não min-height) — com min-height, uma descrição mais
     comprida (ex.: Kitchen/Satis) crescia a placa para além do
     mínimo, o que arrastava a altura de TODA a linha da grelha
     consigo (o grid dimensiona cada linha pela altura do maior item
     nela). overflow:hidden como rede de segurança para texto que não
     caiba, em vez de espremer o resto do card. */
  height: 152px;
  overflow: hidden;
  margin: 14px 10px 10px;
  padding: var(--sp-4) var(--sp-4) var(--sp-5);
  border-radius: 20px;
  background: rgba(20, 25, 35, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
}

/* O ícone flutua sozinho no canto superior do card (posicionado à
   parte, fora da placa de vidro do texto), tal como no mockup — não a
   flex item dentro de .module__content. */
.module__icon {
  position: absolute;
  z-index: 1;
  top: 18px;
  left: 18px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 0;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.module__name {
  font-size: var(--fs-xl);
  font-weight: 750;
  letter-spacing: -0.01em;
  text-transform: none;
  color: var(--white);
}

.module__desc {
  font-size: var(--fs-xs);
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.8);
  max-width: 30ch;
}

.module__cta {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: var(--sp-2);
  /* auto (não um valor fixo) empurra sempre o botão para o fundo da
     placa (altura fixa) — sem isto, a posição do botão seguia o fluxo
     normal a seguir à descrição, que varia entre 1 e 2 linhas
     consoante o módulo, ficando a alturas diferentes de card a card. */
  margin-top: auto;
  padding: 8px 14px;
  border-radius: var(--r-full);
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.28);
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--white);
  transition: background var(--t-fast), border-color var(--t-fast);
}
.module:hover .module__cta {
  background: rgba(255, 255, 255, 0.26);
  border-color: rgba(255, 255, 255, 0.4);
}

.module__cta .icon { transition: transform var(--t-fast); }
.module:hover .module__cta .icon { transform: translateX(3px); }

.module__cta--muted {
  color: rgba(255, 255, 255, 0.5);
  font-weight: 600;
}

.module--soon { cursor: not-allowed; }
.module--soon:hover { transform: none; box-shadow: 0 20px 40px -22px rgba(20, 30, 60, 0.35); }
.module--soon .module__content { opacity: 0.75; }

.module--locked { cursor: not-allowed; }
.module--locked:hover { transform: none; box-shadow: 0 20px 40px -22px rgba(20, 30, 60, 0.35); }
.module--locked .module__content { opacity: 0.75; }

.module__ribbon {
  position: absolute;
  top: var(--sp-4);
  right: var(--sp-4);
  z-index: 2;
  padding: 5px 12px;
  border-radius: var(--r-full);
  background: var(--gold-500);
  color: var(--navy-900);
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.module--management {
  --module-bg: linear-gradient(160deg, #1c3f70, #0a1a33);
  --module-photo: url("../../img/Management_Intro.png");
}
.module--manu {
  --module-bg: linear-gradient(160deg, #1f4d7a, #0a1a33);
  --module-photo: url("../../img/Manu_Intro.png");
}
.module--people {
  --module-bg: linear-gradient(160deg, #2a4a6d, #0a1a33);
  --module-photo: url("../../img/People_Intro.png");
}
.module--beach {
  --module-bg: linear-gradient(160deg, #0e7c86, #0a1a33);
  --module-photo: url("../../img/Beach_Intro.png");
}
.module--academy {
  --module-bg: linear-gradient(160deg, #6b4f9e, #0a1a33);
  --module-photo: url("../../img/Academy.png");
}
.module--kitchen {
  --module-bg: linear-gradient(160deg, #b34a2e, #0a1a33);
  --module-photo: url("../../img/Kitchen_Imagem.png");
}
.module--satis {
  --module-bg: linear-gradient(160deg, #b8457a, #0a1a33);
  --module-photo: url("../../img/Satis_Intro.png");
}
.module--hotel {
  --module-bg: linear-gradient(160deg, #c27a2c, #0a1a33);
  --module-photo: url("../../img/Hotel_Intro.png");
}

.hub__footer {
  position: relative;
  z-index: 1;
  padding: var(--sp-5) var(--sp-8);
  text-align: center;
  font-size: var(--fs-sm);
  color: var(--hub-tertiary);
}

.hub-drawer {
  position: fixed;
  top: var(--sp-8);
  bottom: var(--sp-8);
  right: 0;
  z-index: 50;
}

.hub-drawer__panel {
  position: relative;
  z-index: 2;
  width: 28px;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--hub-glass-bg-strong);
  border: 1px solid var(--hub-glass-border);
  border-right: none;
  border-radius: 24px 0 0 24px;
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  box-shadow: 0 16px 40px -24px rgba(20, 30, 60, 0.25);
  overflow: hidden;
  transition: width var(--t-med);
}

.hub-drawer.is-open .hub-drawer__panel {
  width: min(340px, 88vw);
}

.hub-drawer__toggle {
  position: absolute;
  z-index: 3;
  top: 50%;
  left: -16px;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--r-full);
  background: var(--white);
  border: 1px solid var(--hub-hairline);
  color: var(--hub-secondary);
  box-shadow: var(--sh-sm);
  transition: opacity var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}

.hub-drawer__toggle:hover {
  border-color: var(--hub-accent);
  color: var(--hub-accent);
}

.hub-drawer.is-open .hub-drawer__toggle {
  opacity: 0;
  pointer-events: none;
}

.hub-drawer__backdrop {
  position: fixed;
  z-index: 1;
  inset: 0;
  background: rgba(10, 26, 51, 0.28);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-med);
}

.hub-drawer.is-open .hub-drawer__backdrop {
  opacity: 1;
  pointer-events: auto;
}

.hub-drawer__header,
.hub-drawer__body {
  opacity: 0;
  transition: opacity var(--t-fast);
}

.hub-drawer.is-open .hub-drawer__header,
.hub-drawer.is-open .hub-drawer__body {
  opacity: 1;
  transition: opacity var(--t-med) 100ms;
}

.hub-drawer__header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-shrink: 0;
  height: var(--topbar-h);
  padding: 0 var(--sp-5);
  background: rgba(255, 255, 255, 0.5);
  border-bottom: 1px solid var(--hub-hairline);
}

.hub-drawer__title {
  font-size: var(--fs-sm);
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--hub-ink);
}

.hub-drawer__close {
  margin-left: auto;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--r-full);
  color: var(--hub-secondary);
  transition: background var(--t-fast), color var(--t-fast);
}

.hub-drawer__close:hover {
  background: rgba(120, 120, 128, 0.12);
  color: var(--hub-ink);
}

.hub-drawer__body {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-5);
}

.hub-drawer__action {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  height: 48px;
  padding: 0 var(--sp-4);
  border-radius: var(--r-full);
  background: linear-gradient(155deg, #0a84ff, #0060df);
  color: var(--white);
  font-size: var(--fs-sm);
  font-weight: 650;
  box-shadow: 0 10px 22px -8px rgba(10, 132, 255, 0.5);
  transition: filter var(--t-fast);
}

.hub-drawer__action:hover { filter: brightness(1.08); }

@media (max-width: 1180px) {
  .modules { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .hub__main { padding-bottom: var(--sp-8); }
  .hub__user { display: none; }
  .modules { grid-template-columns: minmax(0, 1fr); }
  .module { height: 280px; }
  .module__content { height: 148px; }
}

@media (max-width: 640px) {
  .hub { padding-left: var(--sp-3); padding-right: var(--sp-3); }
  .hub__topbar {
    width: 100%;
    margin-left: 0;
    margin-right: 0;
    padding-left: var(--sp-3);
    padding-right: var(--sp-3);
    gap: var(--sp-2);
    border-radius: 20px;
  }
  .hub__topbar-actions { gap: var(--sp-2); }

  .hub__logout-text { display: none; }
  .hub__topbar-actions .btn[data-action="logout"] {
    padding: 0;
    width: 40px;
    height: 40px;
    justify-content: center;
    border-radius: var(--r-full);
  }

  .hub-drawer { display: none; }
}

/* Telemóvel: o hub é uma lista de entradas, não uma montra — título mais
   contido e cartões de módulo mais baixos para se verem mais de um de
   cada vez (a placa de texto ajusta-se ao conteúdo). */
@media (max-width: 640px) {
  .hub__intro { margin-bottom: var(--sp-5); }

  .hub__title {
    font-size: 1.625rem;
    line-height: 1.15;
    letter-spacing: -0.025em;
  }

  .hub__subtitle {
    margin-top: 6px;
    font-size: var(--g-text-body);
    line-height: 1.45;
  }

  .modules { gap: var(--sp-3); }

  .module {
    height: 224px;
    border-radius: var(--g-r-sheet);
  }

  .module__content {
    height: auto;
    margin: 10px;
    padding: 14px 16px 16px;
    border-radius: 18px;
  }

  .module__icon {
    top: 14px;
    left: 14px;
    width: 40px;
    height: 40px;
    border-radius: 12px;
  }

  .module__name { font-size: 1.125rem; }

  .module__desc { margin-bottom: 10px; }

  .module__cta { padding: 6px 12px; }

  .hub__footer { padding: var(--sp-4) var(--sp-4) calc(var(--sp-4) + env(safe-area-inset-bottom, 0px)); }
}

/* Colaboradores que não são da Administração: enquanto o hub confirma a
   que soluções têm acesso, a grelha fica invisível (sem módulos a
   aparecer e a desaparecer). */
.modules.is-checking-access { visibility: hidden; }

/* Sem acesso a nenhuma solução. */
.hub__no-access {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  max-width: 420px;
  margin: var(--sp-8) auto 0;
  padding: 28px 24px;
  border: 1px solid var(--g-edge);
  border-radius: var(--g-r-card);
  background: var(--g-surface);
  box-shadow: var(--g-shadow-card);
  backdrop-filter: var(--g-blur);
  -webkit-backdrop-filter: var(--g-blur);
  text-align: center;
}

.hub__no-access-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-bottom: 8px;
  border-radius: 16px;
  background: var(--g-accent-soft);
  color: var(--g-accent);
}

.hub__no-access-title {
  font-size: var(--g-text-headline);
  font-weight: 650;
  color: var(--g-ink);
}

.hub__no-access-text {
  max-width: 34ch;
  font-size: var(--g-text-callout);
  line-height: 1.45;
  color: var(--g-secondary);
}
