/* SAI Online PWA UI — install banner, push prompt, standalone polish */

:root {
  --sai-pwa-navy: #042954;
  --sai-pwa-navy-deep: #021a36;
  --sai-pwa-accent: #ffae01;
  --sai-pwa-surface: #ffffff;
  --sai-pwa-text: #111111;
  --sai-pwa-muted: #646464;
  --sai-pwa-shadow: 0 18px 50px rgba(2, 26, 54, 0.28);
  --sai-pwa-safe-bottom: env(safe-area-inset-bottom, 0px);
  --sai-pwa-safe-top: env(safe-area-inset-top, 0px);
  /* Same stack as body.app-ui / style.css */
  --sai-pwa-font: 'Roboto', sans-serif;
}

/* Force app template typography on every PWA overlay (buttons reset UA fonts). */
.sai-pwa-btn,
.sai-pwa-install,
.sai-pwa-install *,
.sai-pwa-push,
.sai-pwa-push *,
.sai-pwa-inbox,
.sai-pwa-inbox *,
.sai-pwa-update,
.sai-pwa-update *,
.sai-pwa-demo-bar,
.sai-pwa-demo-bar *,
.sai-pwa-offline-chip {
  font-family: var(--sai-pwa-font) !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.sai-pwa-inbox,
.sai-pwa-push,
.sai-pwa-install,
.sai-pwa-update,
.sai-pwa-demo-bar {
  font-size: 14px;
  font-weight: 400;
  line-height: 1.45;
  color: var(--sai-pwa-text);
}

.sai-pwa-btn {
  appearance: none;
  border: 0;
  border-radius: 4px;
  padding: 0.55rem 1rem;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  line-height: 1.35;
  white-space: nowrap;
}

.sai-pwa-btn--primary {
  background: var(--sai-pwa-accent);
  color: #1a1200;
}

.sai-pwa-btn--ghost {
  background: rgba(15, 23, 42, 0.06);
  color: var(--sai-pwa-text);
}

/* Install App popup */
.sai-pwa-install {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10050;
  padding: 0 12px calc(12px + var(--sai-pwa-safe-bottom));
  pointer-events: none;
  transform: translateY(120%);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.sai-pwa-install.is-visible {
  transform: translateY(0);
  pointer-events: auto;
}

.sai-pwa-install__card {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  max-width: 640px;
  margin: 0 auto;
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--sai-pwa-surface);
  box-shadow: var(--sai-pwa-shadow);
  border: 1px solid rgba(4, 41, 84, 0.08);
}

.sai-pwa-install__icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  flex: 0 0 auto;
  background: var(--sai-pwa-navy);
}

.sai-pwa-install__copy {
  flex: 1 1 160px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.sai-pwa-install__copy strong {
  color: var(--sai-pwa-text);
  font-size: 14px;
  font-weight: 600;
}

.sai-pwa-install__hint {
  color: var(--sai-pwa-muted);
  font-size: 14px;
  line-height: 1.45;
  font-weight: 400;
}

.sai-pwa-install__actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

/* Push soft-prompt — centered and hard to miss */
.sai-pwa-push {
  position: fixed;
  inset: 0;
  z-index: 10055;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px 16px calc(16px + var(--sai-pwa-safe-bottom));
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.sai-pwa-push.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.sai-pwa-push__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 26, 54, 0.45);
  backdrop-filter: blur(2px);
}

.sai-pwa-push__card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(420px, 100%);
  padding: 20px 18px 16px;
  border-radius: 22px;
  background: linear-gradient(165deg, #0b4776 0%, var(--sai-pwa-navy) 55%, #021a36 100%);
  color: #e8eef6;
  box-shadow: var(--sai-pwa-shadow);
  border: 1px solid rgba(255, 174, 1, 0.35);
  transform: translateY(24px);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.sai-pwa-push.is-visible .sai-pwa-push__card {
  transform: translateY(0);
}

.sai-pwa-push__icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 1.35rem;
  color: var(--sai-pwa-accent);
  background: rgba(255, 174, 1, 0.18);
  border: 1px solid rgba(255, 174, 1, 0.45);
}

.sai-pwa-push__copy {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sai-pwa-push__copy strong {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0;
}

.sai-pwa-push__copy span {
  font-size: 14px;
  line-height: 1.45;
  font-weight: 400;
  opacity: 0.88;
}

.sai-pwa-push__actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 4px;
}

.sai-pwa-push .sai-pwa-btn--ghost {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

/* In-app notification inbox (1 or many) */
.sai-pwa-inbox {
  position: fixed;
  inset: 0;
  z-index: 10070;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px 12px calc(12px + var(--sai-pwa-safe-bottom));
  background: rgba(2, 26, 54, 0.42);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.sai-pwa-inbox.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.sai-pwa-inbox__panel {
  width: min(440px, 100%);
  max-height: min(72vh, 560px);
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 16px 40px rgba(4, 41, 84, 0.18);
  border: 1px solid #e5eaf0;
  transform: translateY(28px);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.sai-pwa-inbox.is-visible .sai-pwa-inbox__panel {
  transform: translateY(0);
}

.sai-pwa-inbox__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: #fff;
  color: #111;
  border-bottom: 1px solid #edf2f7;
}

.sai-pwa-inbox__header-text {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
}

.sai-pwa-inbox__badge {
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #042954;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.sai-pwa-inbox__close {
  appearance: none;
  border: 0;
  background: #f0f4f9;
  color: #042954;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
}

.sai-pwa-inbox__list {
  overflow: auto;
  padding: 8px;
  flex: 1 1 auto;
  -webkit-overflow-scrolling: touch;
}

.sai-pwa-inbox__item {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  text-align: left;
  border: 1px solid #edf2f7;
  background: #fff;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 400;
  color: var(--sai-pwa-text);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.sai-pwa-inbox__item:hover,
.sai-pwa-inbox__item:focus-visible {
  background: #f8fafc;
  border-color: #c5d4e8;
  outline: none;
}

.sai-pwa-inbox__item:active {
  transform: none;
}

.sai-pwa-inbox__item-index {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #042954;
  color: transparent;
  font-size: 0;
  display: block;
  margin-top: 6px;
}

.sai-pwa-inbox__item-copy {
  flex: 1 1 auto;
  min-width: 0;
}

.sai-pwa-inbox__item-copy strong {
  display: block;
  color: #111111;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
  line-height: 1.4;
}

.sai-pwa-inbox__item-copy p {
  margin: 0;
  color: #646464;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.45;
}

.sai-pwa-inbox__item-chevron {
  color: #94a3b8;
  font-size: 18px;
  font-weight: 400;
  line-height: 1;
  margin-top: 2px;
}

.sai-pwa-inbox__footer {
  padding: 10px 12px 12px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: flex-end;
}

@media (min-width: 768px) {
  .sai-pwa-inbox,
  .sai-pwa-push {
    align-items: center;
  }
}

/* Demo / try-it bar on App Notifications */
.sai-pwa-demo-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-radius: 16px;
  background: linear-gradient(120deg, #042954, #0b4776);
  color: #e8eef6;
  box-shadow: 0 12px 30px rgba(4, 41, 84, 0.22);
}

.sai-pwa-demo-bar__copy {
  flex: 1 1 220px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sai-pwa-demo-bar__copy strong {
  font-size: 16px;
  font-weight: 600;
}

.sai-pwa-demo-bar__copy span {
  font-size: 14px;
  font-weight: 400;
  opacity: 0.85;
  line-height: 1.45;
}

.sai-pwa-demo-bar__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sai-pwa-demo-bar__actions .btn-app {
  background: #ffae01;
  color: #1a1200;
  border: 0;
}

.sai-pwa-demo-bar__actions .btn-app:hover {
  filter: brightness(1.05);
}

/* Version update toast */
.sai-pwa-update {
  position: fixed;
  left: 50%;
  bottom: calc(88px + var(--sai-pwa-safe-bottom));
  transform: translate(-50%, 20px);
  z-index: 10060;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100% - 24px);
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--sai-pwa-navy-deep);
  color: #e8eef6;
  box-shadow: var(--sai-pwa-shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.sai-pwa-update.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.sai-pwa-update span {
  font-size: 14px;
  font-weight: 400;
}

/* Standalone / mobile-friendly polish */
html.sai-pwa-standalone body,
body.sai-pwa-standalone {
  padding-top: var(--sai-pwa-safe-top);
  padding-bottom: var(--sai-pwa-safe-bottom);
}

@media (max-width: 991px) {
  body.app-ui .dashboard-content-one {
    padding-left: 10px;
    padding-right: 10px;
  }

  body.app-ui .breadcrumbs-area {
    margin-bottom: 0.55rem;
  }

  body.app-ui .breadcrumbs-area h3 {
    font-size: 1.15rem;
  }

  body.app-ui .app-page-card {
    margin-bottom: 0.85rem;
  }

  body.app-ui .app-page-card .card-body {
    padding: 0.85rem;
  }

  body.app-ui .app-page-header,
  body.app-ui .heading-layout1.app-page-header {
    margin-bottom: 0.75rem;
    padding-bottom: 0.65rem;
    gap: 0.65rem;
  }

  body.app-ui .table-responsive {
    -webkit-overflow-scrolling: touch;
  }

  body.app-ui .btn-app,
  body.app-ui .btn {
    min-height: 40px;
  }

  /* Login page: friendlier on phones */
  body.login-body .login-card {
    margin: 0;
    border-radius: 20px;
  }

  body.login-body .login-panel {
    padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  }
}

@media (display-mode: standalone) {
  #preloader {
    display: none !important;
  }

  body.app-ui .navbar {
    padding-top: max(0.35rem, env(safe-area-inset-top));
  }
}

/* Offline indicator (optional hook) */
.sai-pwa-offline-chip {
  position: fixed;
  top: calc(10px + var(--sai-pwa-safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 10030;
  padding: 6px 12px;
  border-radius: 999px;
  background: #b45309;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  display: none;
}

html.sai-pwa-offline .sai-pwa-offline-chip {
  display: inline-flex;
}
