/* ======================================================================
   mobile-pwa.css — Safe-area insets + install-banner styles
   Phase 2.1 of CampusTrack Mobile App journey (21 Apr 2026).

   Scope (additive-only — never overrides existing styles):
     1. Safe-area insets for iOS notch + home indicator.
     2. Install banner (bottom sheet with 3-step guide) — shown by
        install-banner.js when running in iOS Safari (not yet installed).
     3. Standalone-mode polish (when app IS installed, hide browser UI hints).

   Variables:
     --safe-top, --safe-bottom, --safe-left, --safe-right are available
     to any other stylesheet that wants to respect the notch.
   ====================================================================== */

:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

/* Allow full-bleed backgrounds to extend under the notch. */
html, body {
  padding-top: constant(safe-area-inset-top);
  padding-top: env(safe-area-inset-top);
  padding-bottom: constant(safe-area-inset-bottom);
  padding-bottom: env(safe-area-inset-bottom);
}

/* When running as installed PWA, add a little bottom space for the home indicator.
   The existing bottom-nav (mobile-nav.css) should respect this automatically. */
@media all and (display-mode: standalone) {
  body {
    /* Nothing global — individual components add their own padding via --safe-bottom */
  }
  /* Hide any install hints when already installed */
  .ct-install-banner,
  .ct-install-hint {
    display: none !important;
  }
}

/* ======================================================================
   Install banner (iOS Safari only — Android Chrome has its own prompt)
   Trigger: install-banner.js detects iOS + !standalone + !dismissed.
   ====================================================================== */

.ct-install-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  background: #FFFFFF;
  border-top: 1px solid #E2E8F0;
  box-shadow: 0 -8px 32px rgba(15, 23, 42, 0.15);
  padding: 16px 20px calc(20px + var(--safe-bottom));
  transform: translateY(100%);
  transition: transform 280ms cubic-bezier(0.32, 0.72, 0, 1);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #0F172A;
}

.ct-install-banner.ct-open {
  transform: translateY(0);
}

.ct-install-banner__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.ct-install-banner__title {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.ct-install-banner__title img {
  width: 28px;
  height: 28px;
  border-radius: 7px;
}

.ct-install-banner__close {
  background: transparent;
  border: 0;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: #64748B;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ct-install-banner__close:active {
  background: #F1F5F9;
}

.ct-install-banner__body {
  font-size: 13px;
  color: #475569;
  line-height: 1.5;
  margin: 0 0 12px;
}

.ct-install-banner__steps {
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
}

.ct-install-banner__step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-size: 13px;
  color: #334155;
}

.ct-install-banner__step-num {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #274186;
  color: white;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ct-install-banner__step-icon {
  margin-left: 4px;
  font-size: 14px;
  color: #0EA5E9;
}

.ct-install-banner__foot {
  display: flex;
  gap: 8px;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: #94A3B8;
}

.ct-install-banner__later {
  background: transparent;
  border: 0;
  color: #64748B;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 12px;
  cursor: pointer;
}

.ct-install-banner__later:active {
  color: #334155;
}

/* ======================================================================
   Profile → "Install app" button styles
   (rendered by install-banner.js when user visits Profile)
   ====================================================================== */

.ct-install-profile-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  background: linear-gradient(135deg, #1A2D5E, #274186);
  color: white;
  border: 0;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  box-shadow: 0 4px 12px rgba(26, 45, 94, 0.2);
}

.ct-install-profile-btn:active {
  transform: scale(0.98);
}

.ct-install-profile-btn__icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.ct-install-profile-btn__text {
  flex: 1;
}

.ct-install-profile-btn__title {
  font-size: 14px;
  font-weight: 700;
  margin: 0;
}

.ct-install-profile-btn__sub {
  font-size: 11px;
  opacity: 0.85;
  margin: 2px 0 0;
}

/* Small-screen tuning */
@media (max-width: 480px) {
  .ct-install-banner {
    padding: 14px 16px calc(18px + var(--safe-bottom));
  }
  .ct-install-banner__title { font-size: 14px; }
  .ct-install-banner__body { font-size: 12px; }
}

/* Dark-mode polish (when user has prefers-color-scheme: dark) */
@media (prefers-color-scheme: dark) {
  .ct-install-banner {
    background: #0F172A;
    color: #F1F5F9;
    border-top-color: #1E293B;
  }
  .ct-install-banner__body { color: #CBD5E1; }
  .ct-install-banner__steps {
    background: #1E293B;
    border-color: #334155;
  }
  .ct-install-banner__step { color: #E2E8F0; }
  .ct-install-banner__close { color: #94A3B8; }
  .ct-install-banner__close:active { background: #1E293B; }
}

/* ======================================================================
   iOS Chrome/Firefox/Edge hint toast (added 21 Apr 2026 — quick win #6)
   Shown to iOS users on non-Safari browsers — tells them to open in
   Safari to install the PWA. Includes a "Copy link" button so the user
   can paste the URL into Safari easily.
   ====================================================================== */

.ct-ios-chrome-hint {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(72px + var(--safe-bottom));
  z-index: 10001;
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.18);
  padding: 14px 16px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #0F172A;
  transform: translateY(20px);
  opacity: 0;
  transition: transform 240ms cubic-bezier(0.32, 0.72, 0, 1), opacity 240ms ease;
}

.ct-ios-chrome-hint.ct-open { transform: translateY(0); opacity: 1; }

.ct-ios-chrome-hint__head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 10px;
}
.ct-ios-chrome-hint__icon { font-size: 22px; line-height: 1; flex-shrink: 0; }
.ct-ios-chrome-hint__body { flex: 1; }
.ct-ios-chrome-hint__title {
  font-size: 14px; font-weight: 700; margin-bottom: 2px;
}
.ct-ios-chrome-hint__text {
  font-size: 12px; color: #475569; line-height: 1.45;
}
.ct-ios-chrome-hint__close {
  background: transparent;
  border: 0;
  width: 28px; height: 28px;
  border-radius: 6px;
  color: #64748B;
  font-size: 18px; line-height: 1;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}
.ct-ios-chrome-hint__close:active { background: #F1F5F9; }

.ct-ios-chrome-hint__actions {
  display: flex; gap: 8px; justify-content: flex-end;
}
.ct-ios-chrome-hint__copy, .ct-ios-chrome-hint__later {
  border: 0; border-radius: 8px; padding: 8px 14px;
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.ct-ios-chrome-hint__later {
  background: transparent;
  color: #64748B;
}
.ct-ios-chrome-hint__later:active { background: #F1F5F9; }
.ct-ios-chrome-hint__copy {
  background: #274186;
  color: #FFFFFF;
}
.ct-ios-chrome-hint__copy:active { transform: scale(0.98); }
.ct-ios-chrome-hint__copy.ct-copied {
  background: #10B981;
}

@media (prefers-color-scheme: dark) {
  .ct-ios-chrome-hint {
    background: #0F172A; color: #F1F5F9; border-color: #1E293B;
  }
  .ct-ios-chrome-hint__text { color: #CBD5E1; }
  .ct-ios-chrome-hint__close { color: #94A3B8; }
  .ct-ios-chrome-hint__close:active { background: #1E293B; }
  .ct-ios-chrome-hint__later { color: #94A3B8; }
  .ct-ios-chrome-hint__later:active { background: #1E293B; }
}

@media (max-width: 480px) {
  .ct-ios-chrome-hint { left: 8px; right: 8px; }
}

@media all and (display-mode: standalone) {
  .ct-ios-chrome-hint { display: none !important; }
}
