/* PWA Install & Notification UI – Portal Médico RHP */

/* ── Banner de instalação (Android/Chrome) ─────────────────────────────────── */
#pwa-install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 99999;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#pwa-install-banner.show {
  transform: translateY(0);
}

.pwa-banner-inner {
  background: #ffffff;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.15);
  padding: 20px 24px 28px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
}

.pwa-banner-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(25, 130, 90, 0.25);
}

.pwa-banner-text {
  flex: 1;
  min-width: 0;
}

.pwa-banner-text h3 {
  margin: 0 0 2px;
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  font-family: 'Inter', 'Plus Jakarta Sans', sans-serif;
  line-height: 1.3;
}

.pwa-banner-text p {
  margin: 0;
  font-size: 12px;
  color: #64748b;
  font-family: 'Inter', 'Plus Jakarta Sans', sans-serif;
  line-height: 1.4;
}

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

.pwa-btn-install {
  background: #19825a;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Inter', 'Plus Jakarta Sans', sans-serif;
  white-space: nowrap;
  transition: background 0.2s, transform 0.1s;
  box-shadow: 0 4px 12px rgba(25, 130, 90, 0.3);
}

.pwa-btn-install:hover {
  background: #136b48;
  transform: translateY(-1px);
}

.pwa-btn-dismiss {
  background: transparent;
  color: #94a3b8;
  border: none;
  font-size: 12px;
  cursor: pointer;
  font-family: 'Inter', 'Plus Jakarta Sans', sans-serif;
  padding: 10px 8px;
  white-space: nowrap;
  transition: color 0.2s;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.pwa-btn-dismiss:hover { color: #475569; }

.pwa-banner-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: transparent;
  border: none;
  color: #cbd5e1;
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

/* ── Card iOS (Safari) ──────────────────────────────────────────────────────── */
#pwa-ios-card {
  position: fixed;
  bottom: 20px;
  left: 16px;
  right: 16px;
  z-index: 99999;
  transform: translateY(calc(100% + 20px));
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 400px;
  margin: 0 auto;
}

#pwa-ios-card.show {
  transform: translateY(0);
}

.pwa-ios-inner {
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
  padding: 20px;
  border: 1px solid #e2e8f0;
  position: relative;
}

.pwa-ios-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.pwa-ios-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: 0 3px 10px rgba(25, 130, 90, 0.2);
}

.pwa-ios-header-text h3 {
  margin: 0 0 2px;
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  font-family: 'Inter', 'Plus Jakarta Sans', sans-serif;
}

.pwa-ios-header-text p {
  margin: 0;
  font-size: 11px;
  color: #64748b;
  font-family: 'Inter', 'Plus Jakarta Sans', sans-serif;
}

.pwa-ios-badge {
  background: #f0fdf4;
  color: #19825a;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  margin-left: auto;
  border: 1px solid #bbf7d0;
  font-family: 'Inter', 'Plus Jakarta Sans', sans-serif;
}

.pwa-ios-steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.pwa-ios-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.pwa-ios-step-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #f0fdf4;
  border: 1.5px solid #19825a;
  color: #19825a;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: 'Inter', sans-serif;
}

.pwa-ios-step-text {
  font-size: 13px;
  color: #374151;
  font-family: 'Inter', 'Plus Jakarta Sans', sans-serif;
  line-height: 1.5;
  padding-top: 3px;
}

.pwa-ios-step-text strong { color: #0f172a; }

.pwa-ios-share-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #007AFF;
  color: white;
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 12px;
  vertical-align: middle;
  margin: 0 2px;
}

.pwa-ios-arrow {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}

.pwa-ios-arrow svg {
  animation: pwa-bounce 2s infinite;
}

@keyframes pwa-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(6px); }
}

.pwa-ios-dismiss {
  width: 100%;
  text-align: center;
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 12px;
  cursor: pointer;
  font-family: 'Inter', 'Plus Jakarta Sans', sans-serif;
  padding: 8px;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.2s;
}

.pwa-ios-dismiss:hover { color: #475569; }

.pwa-card-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: transparent;
  border: none;
  color: #cbd5e1;
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

/* ── Bottom Navigation (Mobile PWA) ────────────────────────────────────────── */
.rhp-bottom-nav-wrap {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 8px 12px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 9000;
  pointer-events: none;
  display: none;
}

@media (max-width: 767px) {
  .rhp-bottom-nav-wrap {
    display: block;
  }

  .body {
    padding-bottom: 96px !important;
  }
}

.rhp-bottom-nav {
  background: rgba(255, 255, 255, 0.90);
  backdrop-filter: blur(28px) saturate(200%);
  -webkit-backdrop-filter: blur(28px) saturate(200%);
  border-radius: 26px;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.13),
    0 2px 8px rgba(0, 0, 0, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.65);
  pointer-events: all;
  overflow: hidden;
  animation: rhp-nav-slide-up 0.38s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes rhp-nav-slide-up {
  from { transform: translateY(120%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.rhp-bottom-nav-inner {
  display: flex;
  align-items: stretch;
  padding: 6px 4px;
}

.rhp-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  border-radius: 20px;
  text-decoration: none !important;
  transition:
    transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1),
    background 0.22s ease;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  outline: none;
  position: relative;
}

.rhp-nav-item:active {
  transform: scale(0.88);
}

.rhp-nav-item i {
  font-size: 20px;
  color: #94a3b8;
  transition:
    color 0.22s ease,
    transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: block;
  line-height: 1;
}

.rhp-nav-item span {
  font-size: 10px;
  font-weight: 600;
  color: #94a3b8;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  transition: color 0.22s ease;
  white-space: nowrap;
  letter-spacing: 0.02em;
  line-height: 1;
}

.rhp-nav-item.active {
  background: rgba(25, 130, 90, 0.10);
}

.rhp-nav-item.active i {
  color: var(--primary, #19825a);
  transform: translateY(-1px) scale(1.08);
}

.rhp-nav-item.active span {
  color: var(--primary, #19825a);
  font-weight: 700;
}

/* Active dot indicator above icon */
.rhp-nav-item.active::before {
  content: '';
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--primary, #19825a);
  opacity: 0;
  animation: rhp-dot-in 0.3s 0.1s ease forwards;
}

@keyframes rhp-dot-in {
  from { opacity: 0; transform: translateX(-50%) scale(0); }
  to   { opacity: 1; transform: translateX(-50%) scale(1); }
}

/* ── Toast de notificação ────────────────────────────────────────────────────── */
#pwa-notif-toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(-80px);
  z-index: 99998;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 360px;
  width: calc(100% - 32px);
}

#pwa-notif-toast.show {
  transform: translateX(-50%) translateY(0);
}

.pwa-toast-inner {
  background: #0f172a;
  color: #fff;
  border-radius: 14px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

.pwa-toast-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
}

.pwa-toast-text strong {
  display: block;
  font-size: 13px;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
}

.pwa-toast-text span {
  display: block;
  font-size: 12px;
  color: #94a3b8;
  font-family: 'Inter', sans-serif;
  margin-top: 2px;
}

/* ── Botão "Permanecer conectado" ─────────────────────────────────────────── */
.pwa-remember-block {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s;
  user-select: none;
}

.pwa-remember-block:hover { background: #dcfce7; }

.pwa-remember-toggle {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.pwa-remember-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.pwa-remember-slider {
  position: absolute;
  inset: 0;
  background: #cbd5e1;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.2s;
}

.pwa-remember-slider::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.pwa-remember-toggle input:checked + .pwa-remember-slider {
  background: #19825a;
}

.pwa-remember-toggle input:checked + .pwa-remember-slider::before {
  transform: translateX(18px);
}

.pwa-remember-label {
  font-size: 13px;
  color: #374151;
  font-family: 'Inter', 'Plus Jakarta Sans', sans-serif;
}

.pwa-remember-label strong {
  display: block;
  font-size: 14px;
  color: #0f172a;
  font-weight: 700;
  margin-bottom: 1px;
}

.pwa-remember-label span {
  color: #64748b;
  font-size: 12px;
}

/* ── WebAuthn: Card de registro biométrico (pós-login, só no PWA) ─────────── */

#webauthn-register-card {
  display: none; /* JS ativa quando necessário */
  position: fixed;
  bottom: 72px; /* acima da bottom nav */
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.14);
  border: 1px solid #e2e8f0;
  padding: 18px 18px 14px;
  width: calc(100% - 32px);
  max-width: 420px;
  z-index: 1060;
  animation: wauthn-slideup 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes wauthn-slideup {
  from { transform: translateX(-50%) translateY(24px); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0);    opacity: 1; }
}

#webauthn-close-btn {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: #94a3b8;
  cursor: pointer;
  padding: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wauthn-card-body {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
  padding-right: 24px;
}

.wauthn-card-icon {
  width: 48px;
  height: 48px;
  background: #ecfdf5;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 22px;
  color: #10b981;
}

.wauthn-card-text strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 2px;
}

.wauthn-card-text span {
  font-size: 12px;
  color: #64748b;
  line-height: 1.45;
}

.wauthn-card-actions {
  display: flex;
  gap: 8px;
}

#webauthn-register-btn {
  flex: 1;
  background: #10b981;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: background 0.15s;
}

#webauthn-register-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

#webauthn-register-btn:hover:not(:disabled) {
  background: #059669;
}

#webauthn-dismiss-btn {
  flex: 1;
  background: #f1f5f9;
  color: #64748b;
  border: none;
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

#webauthn-dismiss-btn:hover {
  background: #e2e8f0;
}

/* ── WebAuthn: Botão biométrico na tela de login ─────────────────────────── */

#webauthn-login-btn {
  display: none; /* JS ativa apenas no PWA standalone com credencial salva */
  width: 100%;
  height: 3.5rem;
  background: #fff;
  color: #10b981;
  border: 2px solid #10b981;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: background 0.15s, color 0.15s;
}

#webauthn-login-btn:hover:not(:disabled) {
  background: #ecfdf5;
}

#webauthn-login-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

#webauthn-login-hint {
  display: none;
  text-align: center;
  color: #94a3b8;
  font-size: 0.8rem;
  font-weight: 600;
  margin: 4px 0 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#webauthn-divider {
  display: none;
  align-items: center;
  gap: 12px;
  margin: 4px 0;
}

#webauthn-divider::before,
#webauthn-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #e2e8f0;
}

#webauthn-divider span {
  color: #94a3b8;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
