/**
 * ViverMente App Web — shell 650px + laterais comerciais.
 * Framework7 v5 roda dentro de .nex-app-column (#app).
 */

:root {
  --nex-web-app-width: 650px;
  --nex-web-ad-bg: #f0ebe0;
  --nex-web-ad-border: #e8e4dc;
  --nex-web-ad-accent: #1a2332;
  --nex-web-ad-gold: #c9a227;
  --nex-web-ad-text: #1a2332;
  --nex-web-ad-muted: #6b6560;
}

html {
  height: 100%;
  background: #e8edf3;
}

body.nex-web-body {
  margin: 0;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--nex-web-ad-text);
  background: linear-gradient(180deg, #eef2f7 0%, #e2e8f0 100%);
}

html:not(.jur-styles-ready) #jurAppColumn > #app {
  opacity: 0;
}

html.jur-styles-ready #jurAppColumn > #app {
  opacity: 1;
  transition: opacity 0.18s ease;
}

/* --- Layout 3 colunas --- */
.nex-web-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) min(var(--nex-web-app-width), 100%) minmax(0, 1fr);
  height: 100dvh;
  min-height: 100dvh;
  max-height: 100dvh;
  align-items: stretch;
  overflow: hidden;
}

/* --- Splash de entrada (app web) --- */
.nex-web-splash {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 25000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  opacity: 1;
  transition: opacity 0.26s ease;
  pointer-events: none;
}

.nex-web-splash__logo {
  width: 120px;
  height: 120px;
  max-width: 42vw;
  max-height: 42vw;
  object-fit: contain;
  border-radius: 22%;
  opacity: 0;
  transform: scale(0.88);
  transition:
    opacity 0.32s ease,
    transform 0.32s cubic-bezier(0.34, 1.2, 0.64, 1);
  box-shadow: 0 8px 28px rgba(201, 162, 39, 0.18);
}

.nex-web-splash--in .nex-web-splash__logo {
  opacity: 1;
  transform: scale(1);
}

.nex-web-splash--out {
  opacity: 0;
}

.nex-app-column {
  position: relative;
  width: 100%;
  max-width: var(--nex-web-app-width);
  margin: 0 auto;
  height: 100%;
  max-height: 100dvh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.06),
    0 12px 40px rgba(15, 23, 42, 0.12);
  overflow: hidden;
  isolation: isolate;
}

.nex-app-column #app {
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
}

/* Status bar Cordova não ocupa espaço no browser */
body.nex-web-body #app > .statusbar {
  flex: 0 0 0;
  height: 0;
  min-height: 0;
  overflow: hidden;
  pointer-events: none;
}

/* App web: #app é filho flex da coluna — não usar height:100% do shell Cordova */
body.nex-web-body html.jur-shell-ready #app {
  flex: 1 1 auto !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: 100% !important;
  overflow: hidden !important;
}

/* Rolagem principal do app web — mesmo padrão Cordova (#navegacao) */
body.nex-web-body #navegacao {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
}

body.nex-web-body #navegacao > .page {
  position: relative !important;
  height: auto !important;
  min-height: 0 !important;
  overflow: visible !important;
}

body.nex-web-body #navegacao .page-content {
  height: auto !important;
  overflow: visible !important;
}

#logoInicio.nex-splash-pending {
  width: 50px;
  height: 50px;
  max-width: 50px;
  max-height: 50px;
  opacity: 0;
}

/* --- Painéis comerciais --- */
.nex-web-ad {
  display: flex;
  justify-content: center;
  padding: 24px 16px;
  box-sizing: border-box;
}

.nex-web-ad--left {
  justify-content: flex-end;
  padding-right: 20px;
}

.nex-web-ad--right {
  justify-content: flex-start;
  padding-left: 20px;
}

.nex-web-ad__inner {
  width: 100%;
  max-width: 300px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 24px;
}

.nex-web-ad__badge {
  display: inline-block;
  align-self: flex-start;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--nex-web-ad-accent);
  background: rgba(201, 162, 39, 0.1);
  border-radius: 999px;
  padding: 4px 10px;
}

.nex-web-ad__slot {
  background: #fff;
  border: 1px dashed var(--nex-web-ad-border);
  border-radius: 14px;
  padding: 20px 18px;
  box-shadow: 0 4px 18px rgba(15, 23, 42, 0.04);
}

.nex-web-ad__slot--compact {
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: repeating-linear-gradient(
    -45deg,
    #f8fafc,
    #f8fafc 8px,
    #f1f5f9 8px,
    #f1f5f9 16px
  );
}

.nex-web-ad__label {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--nex-web-ad-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.nex-web-ad__title {
  margin: 0 0 10px;
  font-size: 18px;
  line-height: 1.35;
  color: #0f172a;
}

.nex-web-ad__text {
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--nex-web-ad-muted);
}

.nex-web-ad__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  color: #fff;
  background: var(--nex-web-ad-accent);
  transition: background 0.15s ease, transform 0.15s ease;
}

.nex-web-ad__cta:hover {
  background: #6a22a6;
  transform: translateY(-1px);
}

.nex-web-ad__cta--outline {
  color: var(--nex-web-ad-accent);
  background: transparent;
  border: 1.5px solid rgba(201, 162, 39, 0.35);
}

.nex-web-ad__cta--outline:hover {
  background: rgba(201, 162, 39, 0.08);
}

.nex-web-ad__micro {
  margin: 0;
  font-size: 12px;
  color: var(--nex-web-ad-muted);
  text-align: center;
}

.nex-web-ad--right .nex-web-ad__inner {
  max-width: 260px;
}

.nex-web-ad__slot--solid {
  border-style: solid;
}

.nex-web-ad--right .nex-web-ad__slot--compact {
  min-height: 140px;
}

.jur-web-tips {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.jur-web-tips__item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.jur-web-tips__icon {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(201, 162, 39, 0.12);
  color: var(--nex-web-ad-gold);
}

.jur-web-tips__icon .mdi {
  font-size: 17px;
  line-height: 1;
}

.jur-web-tips__text {
  font-size: 13px;
  line-height: 1.4;
  color: var(--nex-web-ad-muted);
}

.jur-web-tips__text strong {
  color: #0f172a;
  font-weight: 600;
}

/* Esconde laterais em ecrãs estreitos (só coluna do app) */
@media (max-width: 1100px) {
  .nex-web-layout {
    grid-template-columns: 1fr;
  }

  .nex-web-ad {
    display: none;
  }

  .nex-app-column {
    max-width: 100%;
    box-shadow: none;
  }
}

/* --- Overlays/dialogs centrados na coluna 650px (ecrã largo) --- */
@media (min-width: 1101px) {
  body.nex-web-body .dialog-backdrop,
  body.nex-web-body .dialog {
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%);
    width: min(var(--nex-web-app-width), 100vw) !important;
    max-width: var(--nex-web-app-width);
  }

  body.nex-web-body #nexPatientOverlay.nex-patient-overlay {
    left: 50%;
    right: auto;
    width: min(var(--nex-web-app-width), 100vw);
    max-width: var(--nex-web-app-width);
    transform: translateX(-50%);
  }

  body.nex-web-body .nex-tg-jitsi-embed-host,
  body.nex-web-body .nex-tg-jitsi-embed-layer {
    max-width: var(--nex-web-app-width);
    left: 50%;
    transform: translateX(-50%);
  }

  /* Tabbar, header e painéis (chat/casos) dentro da coluna 650px */
  body.nex-web-body .jur-tabbar,
  body.nex-web-body .jur-dash-hero {
    left: 50% !important;
    right: auto !important;
    width: min(var(--nex-web-app-width), 100vw) !important;
    max-width: var(--nex-web-app-width);
    transform: translateX(-50%);
  }

  body.nex-web-body #jurAppColumn > .jur-panel-sheet--web {
    position: absolute;
    inset: 0;
    z-index: 1000;
  }
}

/* Slot preenchido por parceiro (futuro: JS injeta iframe/img) */
.nex-web-ad__slot[data-partner-filled='1'] {
  border-style: solid;
  padding: 0;
  overflow: hidden;
}

.nex-web-ad__slot[data-partner-filled='1'] img,
.nex-web-ad__slot[data-partner-filled='1'] iframe {
  display: block;
  width: 100%;
  border: 0;
}

/* --- Banner PWA — canto inferior direito da coluna 650px --- */
.nex-pwa-install {
  --nex-pwa-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  position: absolute;
  right: 12px;
  bottom: var(--nex-pwa-bottom);
  left: auto;
  z-index: 99990;
  width: min(280px, calc(100% - 24px));
  box-sizing: border-box;
  pointer-events: none;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  transform-origin: bottom right;
  transition:
    transform 0.32s cubic-bezier(0.34, 1.2, 0.64, 1),
    opacity 0.28s ease;
}

.nex-pwa-install--visible {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.nex-pwa-install__inner {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 12px 10px;
  background: linear-gradient(145deg, #ffffff 0%, #faf8ff 100%);
  border: 1px solid rgba(201, 162, 39, 0.18);
  border-radius: 16px;
  box-shadow:
    0 4px 6px rgba(201, 162, 39, 0.06),
    0 16px 40px rgba(15, 23, 42, 0.16);
}

.nex-pwa-install__head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.nex-pwa-install__actions {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.nex-pwa-install__icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(201, 162, 39, 0.22);
}

.nex-pwa-install__copy {
  flex: 1;
  min-width: 0;
}

.nex-pwa-install__title {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.3;
}

.nex-pwa-install__desc {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  line-height: 1.4;
  color: #64748b;
}

.nex-pwa-install__btn {
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
  flex: 1 1 0;
  min-width: 0;
  height: auto;
  margin: 0;
  padding: 9px 10px;
  border: 0;
  border-radius: 10px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-transform: none;
  letter-spacing: 0;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease, background 0.15s ease;
}

.nex-pwa-install__btn--primary {
  color: #fff !important;
  background: linear-gradient(135deg, #8f3fe0 0%, #c9a227 100%) !important;
  box-shadow: 0 4px 14px rgba(201, 162, 39, 0.35);
}

.nex-pwa-install__btn--primary:hover {
  filter: brightness(1.05);
  box-shadow: 0 6px 18px rgba(201, 162, 39, 0.42);
}

.nex-pwa-install__btn--ghost {
  color: #475569 !important;
  background: #f1f5f9 !important;
  box-shadow: none;
  border: 1px solid #e2e8f0;
}

.nex-pwa-install__btn--ghost:hover {
  background: #e2e8f0 !important;
  color: #334155 !important;
}

.nex-pwa-install__btn:active {
  transform: scale(0.98);
}

/* Evita conflito com botões globais do Framework7 / tema */
#nexPwaInstallBar .nex-pwa-install__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  max-width: none;
  flex: 1 1 0;
}

@media (max-width: 1100px) {
  .nex-pwa-install {
    /* fixed no viewport — ligeiramente acima da barra do browser */
    position: fixed;
    --nex-pwa-bottom: calc(28px + env(safe-area-inset-bottom, 0px));
    right: 12px;
    bottom: var(--nex-pwa-bottom);
    width: min(280px, calc(100vw - 24px));
    z-index: 999999;
  }
}

/* --- Ecrã de requisitos / atualização (browser antigo) --- */
body.nex-web-upgrade-mode,
html.nex-web-needs-upgrade {
  overflow: auto;
}

.nex-web-upgrade {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 30000;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 20px 14px 28px;
  box-sizing: border-box;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: linear-gradient(180deg, #faf8ff 0%, #f5f7fb 100%);
}

.nex-web-upgrade__card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 18px;
  border: 1px solid rgba(201, 162, 39, 0.14);
  box-shadow: 0 12px 36px rgba(15, 23, 42, 0.1);
  padding: 22px 18px 18px;
  text-align: center;
  box-sizing: border-box;
}

.nex-web-upgrade__logo {
  border-radius: 16px;
  box-shadow: 0 6px 18px rgba(201, 162, 39, 0.22);
  margin-bottom: 12px;
}

.nex-web-upgrade__title {
  margin: 0 0 8px;
  font-size: 20px;
  line-height: 1.25;
  color: #c9a227;
}

.nex-web-upgrade__lead {
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 1.5;
  color: #475569;
}

.nex-web-upgrade__req,
.nex-web-upgrade__boot {
  text-align: left;
  background: #f8fafc;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 16px;
}

.nex-web-upgrade__boot .nex-web-upgrade__req-list {
  margin-bottom: 12px;
}

.nex-web-upgrade__req-title {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
}

.nex-web-upgrade__req-list {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  line-height: 1.45;
  color: #334155;
}

.nex-web-upgrade__stores-label {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
  text-align: left;
}

.nex-web-upgrade__stores {
  display: block;
  text-align: left;
  margin-bottom: 14px;
}

.nex-web-upgrade__store {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  margin-bottom: 8px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  background: #fff;
  text-decoration: none;
  color: inherit;
}

.nex-web-upgrade__store--muted {
  opacity: 0.92;
}

.nex-web-upgrade__store-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background-position: center;
  background-repeat: no-repeat;
  background-size: 26px 26px;
}

.nex-web-upgrade__store-icon--chrome {
  background-color: #e8f4ff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Ccircle cx='24' cy='24' r='9' fill='%234285F4'/%3E%3Cpath fill='%23EA4335' d='M24 8a16 16 0 0 1 13.9 8H24z'/%3E%3Cpath fill='%2334A853' d='M10.1 16A16 16 0 0 1 24 8v16z'/%3E%3Cpath fill='%23FBBC05' d='M10.1 32A16 16 0 0 1 24 40V24z'/%3E%3Cpath fill='%234285F4' d='M24 40a16 16 0 0 0 13.9-8H24z'/%3E%3C/svg%3E");
}

.nex-web-upgrade__store-icon--webview {
  background-color: #ecfdf5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23059669' stroke-width='2'%3E%3Crect x='3' y='4' width='18' height='16' rx='2'/%3E%3Cpath d='M3 8h18M8 4v4'/%3E%3C/svg%3E");
}

.nex-web-upgrade__store-icon--gms {
  background-color: #fef3c7;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23d97706'%3E%3Cpath d='M12 2l2.4 7.4H22l-6.2 4.5 2.4 7.4L12 16.8 5.8 21.3 8.2 13.9 2 9.4h7.6z'/%3E%3C/svg%3E");
}

.nex-web-upgrade__store-icon--cache {
  background-color: #ede9fe;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237b2cbf' stroke-width='2'%3E%3Cpath d='M3 6h18M8 6V4h8v2M19 6l-1 14H6L5 6'/%3E%3C/svg%3E");
}

.nex-web-upgrade__store-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  text-align: left;
}

.nex-web-upgrade__store-text strong {
  font-size: 14px;
  color: #0f172a;
}

.nex-web-upgrade__store-text small {
  font-size: 11px;
  color: #64748b;
}

.nex-web-upgrade__retry {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  margin-top: 4px;
  padding: 11px 14px;
  border: 0;
  border-radius: 11px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #8f3fe0 0%, #c9a227 100%);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(201, 162, 39, 0.28);
}
