/**
 * PWA Installation UI Styles
 * Beautiful install banner and notification styles
 */

/* ========================================
   PWA INSTALL BANNER
======================================== */

.pwa-install-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
  color: white;
  padding: 12px 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  display: none;
  opacity: 0;
  transition: all 0.3s ease-out;
  margin-top: 0;
  animation: slideDown 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.pwa-install-banner.show {
  display: flex;
  opacity: 1;
}

@keyframes slideDown {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.pwa-banner-content {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  padding: 8px 0;
}

.pwa-banner-icon {
  flex-shrink: 0;
  font-size: 24px;
  animation: bounce 2s ease-in-out infinite;
}

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

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

.pwa-banner-text h5 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: white;
  margin-bottom: 4px;
}

.pwa-banner-text p {
  margin: 0;
  font-size: 13px;
  opacity: 0.95;
  color: rgba(255, 255, 255, 0.9);
}

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

.btn-install,
.btn-dismiss {
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.btn-install {
  background: rgba(255, 255, 255, 0.95);
  color: #0ea5e9;
}

.btn-install:hover {
  background: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn-install:active {
  transform: translateY(0);
}

.btn-dismiss {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.btn-dismiss:hover {
  background: rgba(255, 255, 255, 0.3);
}

.btn-dismiss:active {
  background: rgba(255, 255, 255, 0.15);
}

/* ========================================
   PWA INSTALL BUTTON (for placement in UI)
======================================== */

.pwa-install-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
}

.pwa-install-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(14, 165, 233, 0.4);
}

.pwa-install-button:active {
  transform: translateY(0);
}

.pwa-install-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* ========================================
   PWA NOTIFICATIONS
======================================== */

.pwa-notification {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: 16px 24px;
  min-width: 320px;
  max-width: 500px;
  opacity: 0;
  transform: translateY(100px) scale(0.9);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  animation: none;
}

.pwa-notification.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  animation: slideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideUp {
  from {
    transform: translateY(100px) scale(0.9);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.pwa-notif-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pwa-notif-content strong {
  font-size: 14px;
  color: #0f172a;
  margin: 0;
}

.pwa-notif-content p {
  font-size: 13px;
  color: #64748b;
  margin: 0;
}

/* Notification Types */
.pwa-notification-success {
  border-left: 4px solid #10b981;
  background: linear-gradient(to right, rgba(16, 185, 129, 0.05), white);
}

.pwa-notification-success .pwa-notif-content strong {
  color: #10b981;
}

.pwa-notification-error {
  border-left: 4px solid #ef4444;
  background: linear-gradient(to right, rgba(239, 68, 68, 0.05), white);
}

.pwa-notification-error .pwa-notif-content strong {
  color: #ef4444;
}

.pwa-notification-info {
  border-left: 4px solid #0ea5e9;
  background: linear-gradient(to right, rgba(14, 165, 233, 0.05), white);
}

.pwa-notification-info .pwa-notif-content strong {
  color: #0ea5e9;
}

.pwa-notification-warning {
  border-left: 4px solid #f59e0b;
  background: linear-gradient(to right, rgba(245, 158, 11, 0.05), white);
}

.pwa-notification-warning .pwa-notif-content strong {
  color: #f59e0b;
}

/* ========================================
   PWA STATUS INDICATOR (optional)
======================================== */

.pwa-status-indicator {
  position: fixed;
  top: 90px;
  right: 24px;
  z-index: 999;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
  }
  50% {
    box-shadow: 0 0 16px rgba(16, 185, 129, 0.8);
  }
}

.pwa-status-indicator.offline {
  background: #ef4444;
}

.pwa-status-indicator.offline {
  animation: pulse-red 1s ease-in-out infinite;
}

@keyframes pulse-red {
  0%, 100% {
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
  }
  50% {
    box-shadow: 0 0 16px rgba(239, 68, 68, 0.8);
  }
}

/* ========================================
   RESPONSIVE ADJUSTMENTS
======================================== */

@media (max-width: 768px) {
  .pwa-install-banner {
    padding: 10px 12px;
  }

  .pwa-banner-content {
    gap: 12px;
  }

  .pwa-banner-text h5 {
    font-size: 14px;
  }

  .pwa-banner-text p {
    font-size: 12px;
  }

  .btn-install,
  .btn-dismiss {
    padding: 6px 12px;
    font-size: 12px;
  }

  .pwa-notification {
    bottom: 16px;
    right: 16px;
    min-width: 280px;
    padding: 12px 16px;
  }

  .pwa-notif-content strong {
    font-size: 13px;
  }

  .pwa-notif-content p {
    font-size: 12px;
  }
}

@media (max-width: 480px) {
  .pwa-install-banner {
    padding: 8px 10px;
  }

  .pwa-banner-content {
    gap: 10px;
    padding: 6px 0;
  }

  .pwa-banner-icon {
    font-size: 20px;
  }

  .pwa-banner-text h5 {
    font-size: 13px;
    margin-bottom: 2px;
  }

  .pwa-banner-text p {
    font-size: 11px;
  }

  .btn-install,
  .btn-dismiss {
    padding: 6px 10px;
    font-size: 11px;
    gap: 4px;
  }

  .pwa-notification {
    bottom: 12px;
    right: 12px;
    left: 12px;
    min-width: unset;
    max-width: unset;
    padding: 12px 16px;
  }
}

/* ========================================
   DARK MODE SUPPORT
======================================== */

@media (prefers-color-scheme: dark) {
  .pwa-notification {
    background: #1e293b;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  }

  .pwa-notif-content strong {
    color: #f1f5f9;
  }

  .pwa-notif-content p {
    color: #cbd5e1;
  }

  .pwa-notification-success,
  .pwa-notification-error,
  .pwa-notification-info,
  .pwa-notification-warning {
    background: #1e293b;
  }
}

/* ========================================
   PRINT STYLES
======================================== */

@media print {
  .pwa-install-banner,
  .pwa-notification,
  .pwa-status-indicator,
  .pwa-install-button {
    display: none !important;
  }
}

/* ========================================
   ADDITIONAL MODERN ENHANCEMENTS
======================================== */

/* Smooth scrolling for better UX */
.pwa-install-banner,
.pwa-notification {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* Improved focus states for accessibility */
.btn-install:focus,
.btn-dismiss:focus,
.pwa-install-button:focus {
  outline: 2px solid #0ea5e9;
  outline-offset: 2px;
}

/* Glassmorphism effect for notifications */
.pwa-notification {
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* Subtle gradient for banner */
.pwa-install-banner {
  background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 50%, #0369a1 100%);
}

/* Improved button hover effects */
.btn-install:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.btn-dismiss:hover {
  transform: translateY(-2px) scale(1.02);
}

/* Loading state animation */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.pwa-loading {
  animation: spin 1s linear infinite;
}

/* Success checkmark animation */
@keyframes checkmark {
  0% { stroke-dashoffset: 100; }
  100% { stroke-dashoffset: 0; }
}

.pwa-checkmark {
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  animation: checkmark 0.5s ease-in-out forwards;
}

/* Progress bar for installation */
.pwa-progress-bar {
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 8px;
}

.pwa-progress-fill {
  height: 100%;
  background: white;
  border-radius: 2px;
  transition: width 0.3s ease;
  width: 0%;
}

/* Tooltip for install button */
.pwa-install-button[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  margin-bottom: 8px;
  opacity: 0;
  animation: fadeIn 0.3s ease forwards;
}

@keyframes fadeIn {
  to { opacity: 1; }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .pwa-install-banner,
  .pwa-notification,
  .btn-install,
  .btn-dismiss {
    animation: none;
    transition: none;
  }
  
  .pwa-banner-icon {
    animation: none;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .pwa-install-banner {
    border: 2px solid #000;
  }
  
  .pwa-notification {
    border: 2px solid #000;
  }
}

/* Large text support */
@media (prefers-reduced-data: reduce) {
  .pwa-install-banner {
    background: #0ea5e9;
    background-image: none;
  }
}

/* ========================================
   CUSTOM STANDALONE SPLASH
======================================== */

.pwa-splash {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--pwa-splash-bg, #ffffff);
  opacity: 0;
  transition: opacity 0.4s ease;
}

.pwa-splash.is-visible {
  opacity: 1;
}

.pwa-splash.is-hiding {
  opacity: 0;
  pointer-events: none;
}

.pwa-splash__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  text-align: center;
  padding: 1.5rem;
}

.pwa-splash__logo {
  width: 96px;
  height: 96px;
  border-radius: 22px;
  object-fit: cover;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.18);
}

.pwa-splash__mark {
  width: 96px;
  height: 96px;
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--pwa-splash-theme, #0ea5e9);
  color: #fff;
  font-size: 1.6rem;
  font-weight: 800;
}

.pwa-splash__name {
  font-size: 1.25rem;
  color: #0f172a;
  letter-spacing: -0.02em;
}

.pwa-splash__loader {
  width: 36px;
  height: 4px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  overflow: hidden;
  margin-top: 0.35rem;
}

.pwa-splash__loader::after {
  content: "";
  display: block;
  width: 40%;
  height: 100%;
  border-radius: inherit;
  background: var(--pwa-splash-theme, #0ea5e9);
  animation: pwaSplashLoad 1s ease-in-out infinite;
}

@keyframes pwaSplashLoad {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(280%); }
}

.pwa-install-banner--user {
  background: linear-gradient(135deg, #0369a1 0%, #0ea5e9 100%);
}

/* ========================================
   3-SCREEN SPLASH CAROUSEL
======================================== */

.pwa-splash--carousel {
  background: var(--pwa-splash-bg, #000B1E);
  padding: 0;
}

.pwa-splash__slide {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.pwa-splash__media {
  position: relative;
  flex: 1;
  min-height: 58%;
  overflow: hidden;
  background: #000B1E;
}

.pwa-splash__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.pwa-splash__shade {
  position: absolute;
  inset: auto 0 0;
  height: 42%;
  background: linear-gradient(to top, rgba(0, 11, 30, 0.95), transparent);
}

.pwa-splash__copy {
  position: relative;
  z-index: 2;
  margin-top: -3.5rem;
  padding: 1.25rem 1.4rem calc(1.4rem + env(safe-area-inset-bottom, 0px));
  text-align: center;
  color: #fff;
}

.pwa-splash__brand {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  object-fit: cover;
  margin-bottom: 0.75rem;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.pwa-splash__copy strong {
  display: block;
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 0.45rem;
}

.pwa-splash__copy p {
  margin: 0 auto 1rem;
  max-width: 18rem;
  color: rgba(226, 232, 240, 0.9);
  font-size: 0.92rem;
  line-height: 1.45;
}

.pwa-splash__dots {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
}

.pwa-splash__dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.28);
}

.pwa-splash__dot.is-active {
  width: 18px;
  background: var(--pwa-splash-theme, #0056D2);
}

.pwa-splash__skip {
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

/* ========================================
   INSTALL / OPEN APP MODAL
======================================== */

html.pwa-modal-open,
html.pwa-modal-open body {
  overflow: hidden;
}

.pwa-app-modal {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.pwa-app-modal.is-open {
  pointer-events: auto;
  opacity: 1;
  visibility: visible;
}

.pwa-app-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
}

.pwa-app-modal__sheet {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  margin: 0;
  padding: 1.35rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom, 0px));
  border-radius: 20px 20px 0 0;
  background:
    radial-gradient(120% 80% at 50% -20%, rgba(14, 165, 233, 0.18), transparent 55%),
    linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  box-shadow: 0 -12px 40px rgba(15, 23, 42, 0.2);
  transform: translateY(24px);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  text-align: center;
}

.pwa-app-modal.is-open .pwa-app-modal__sheet {
  transform: translateY(0);
}

.pwa-app-modal__close {
  position: absolute;
  top: 0.65rem;
  right: 0.75rem;
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.pwa-app-modal__icon-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 0.85rem;
}

.pwa-app-modal__icon {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  object-fit: cover;
  box-shadow: 0 10px 24px rgba(2, 132, 199, 0.28);
  border: 2px solid rgba(14, 165, 233, 0.25);
  background: #fff;
}

.pwa-app-modal__title {
  margin: 0 0 0.4rem;
  font-size: 1.25rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.02em;
}

.pwa-app-modal__text {
  margin: 0 auto 1rem;
  max-width: 22rem;
  color: #475569;
  font-size: 0.95rem;
  line-height: 1.5;
}

.pwa-app-modal__ios {
  text-align: left;
  background: #f1f5f9;
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  margin: 0 0 1rem;
  color: #334155;
  font-size: 0.88rem;
}

.pwa-app-modal__ios ol {
  margin: 0;
  padding-left: 1.15rem;
}

.pwa-app-modal__ios li {
  margin-bottom: 0.35rem;
}

.pwa-app-modal__actions {
  display: grid;
  gap: 0.55rem;
}

.pwa-app-modal__primary,
.pwa-app-modal__secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  width: 100%;
  min-height: 2.75rem;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  border: 0;
}

.pwa-app-modal__primary {
  background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
  color: #fff;
  box-shadow: 0 8px 18px rgba(2, 132, 199, 0.28);
}

.pwa-app-modal__primary:hover {
  filter: brightness(1.05);
}

.pwa-app-modal__secondary {
  background: transparent;
  color: #64748b;
}

.pwa-app-modal__secondary:hover {
  color: #0f172a;
  background: #f1f5f9;
}

@media (min-width: 576px) {
  .pwa-app-modal {
    align-items: center;
    padding: 1rem;
  }

  .pwa-app-modal__sheet {
    border-radius: 20px;
    transform: translateY(12px) scale(0.98);
  }

  .pwa-app-modal.is-open .pwa-app-modal__sheet {
    transform: translateY(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .pwa-app-modal,
  .pwa-app-modal__sheet {
    transition: none;
  }
}
