/* ==========================================================================
   PWA & Smart App Installation Banner & Modal Styles
   ========================================================================== */

/* 1. TOP SMART BANNER */
.pwa-smart-banner {
  position: relative;
  width: 100%;
  background: linear-gradient(135deg, #5844d8 0%, #6c5ce7 50%, #4834d4 100%);
  color: #ffffff;
  padding: 10px 16px;
  box-shadow: 0 4px 20px rgba(108, 92, 231, 0.35);
  z-index: 999;
  direction: rtl;
  font-family: var(--font-kids, 'Cairo', 'Tajawal', sans-serif);
  animation: pwaSlideDown 0.4s ease-out;
  border-bottom: 2px solid rgba(253, 203, 110, 0.4);
}

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

.pwa-banner-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.pwa-banner-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 300px;
}

.pwa-banner-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

.pwa-banner-text {
  display: flex;
  flex-direction: column;
}

.pwa-banner-title {
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.3;
  color: #ffffff;
}

.pwa-banner-sub {
  font-size: 0.82rem;
  color: #ffeaa7;
  font-weight: 600;
  line-height: 1.3;
}

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

.btn-pwa-action {
  background: #fdcb6e;
  color: #2d3436;
  border: none;
  font-family: var(--font-kids, 'Cairo', sans-serif);
  font-weight: 800;
  font-size: 0.85rem;
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(253, 203, 110, 0.4);
  transition: transform 0.15s ease, background 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.btn-pwa-action:hover {
  transform: translateY(-2px);
  background: #ffeaa7;
}

.btn-pwa-action:active {
  transform: translateY(1px);
}

.btn-pwa-close {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

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

/* 2. HEADER INSTALL BUTTON */
.btn-header-install {
  background: linear-gradient(135deg, rgba(108, 92, 231, 0.18), rgba(253, 203, 110, 0.25)) !important;
  border: 1.5px solid rgba(108, 92, 231, 0.4) !important;
  color: var(--color-primary, #6c5ce7) !important;
  font-weight: 800 !important;
  padding: 6px 12px !important;
  border-radius: 18px !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  cursor: pointer !important;
  position: relative;
  overflow: hidden;
  transition: all 0.2s ease !important;
}

body.dark-mode .btn-header-install {
  background: linear-gradient(135deg, rgba(108, 92, 231, 0.3), rgba(253, 203, 110, 0.3)) !important;
  border-color: rgba(253, 203, 110, 0.5) !important;
  color: #ffeaa7 !important;
}

.btn-header-install:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(108, 92, 231, 0.35);
  border-color: var(--color-primary, #6c5ce7) !important;
}

.btn-header-install .install-pulse {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle, rgba(253, 203, 110, 0.3) 10%, transparent 70%);
  animation: pwaPulse 2.5s infinite;
  pointer-events: none;
}

@keyframes pwaPulse {
  0%, 100% { opacity: 0; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.1); }
}

/* 3. INSTALLATION GUIDE MODAL */
.pwa-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10005;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  direction: rtl;
  font-family: var(--font-kids, 'Cairo', sans-serif);
  animation: pwaModalFade 0.25s ease-out;
}

@keyframes pwaModalFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.pwa-modal-card {
  background: #ffffff;
  border-radius: 24px;
  max-width: 580px;
  width: 100%;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid rgba(108, 92, 231, 0.2);
}

body.dark-mode .pwa-modal-card {
  background: #1e1b4b;
  color: #ffffff;
  border-color: rgba(253, 203, 110, 0.2);
}

.pwa-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  border-bottom: 2px solid rgba(108, 92, 231, 0.1);
  padding-bottom: 12px;
}

.pwa-modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--color-primary, #6c5ce7);
}

body.dark-mode .pwa-modal-title {
  color: #ffeaa7;
}

.pwa-modal-close {
  background: #f1f2f6;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #2d3436;
  transition: all 0.2s ease;
}

body.dark-mode .pwa-modal-close {
  background: #312e81;
  color: #ffffff;
}

.pwa-modal-close:hover {
  background: #e4e7eb;
  transform: rotate(90deg);
}

/* Device Tabs */
.pwa-tabs-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  background: rgba(108, 92, 231, 0.08);
  padding: 4px;
  border-radius: 14px;
}

.pwa-tab-btn {
  flex: 1;
  padding: 8px 12px;
  border: none;
  background: transparent;
  border-radius: 10px;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.88rem;
  color: #4b5563;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

body.dark-mode .pwa-tab-btn {
  color: #cbd5e1;
}

.pwa-tab-btn.active {
  background: #6c5ce7;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(108, 92, 231, 0.3);
}

/* Steps list */
.pwa-step-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px 14px;
  background: rgba(108, 92, 231, 0.04);
  border: 1px solid rgba(108, 92, 231, 0.12);
  border-radius: 16px;
  margin-bottom: 10px;
  transition: background 0.2s ease;
}

body.dark-mode .pwa-step-card {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.1);
}

.pwa-step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #6c5ce7;
  color: #ffffff;
  font-weight: 900;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(108, 92, 231, 0.3);
}

.pwa-step-content {
  flex: 1;
}

.pwa-step-title {
  font-weight: 800;
  font-size: 0.95rem;
  margin-bottom: 2px;
  color: #1e293b;
}

body.dark-mode .pwa-step-title {
  color: #f8fafc;
}

.pwa-step-desc {
  font-size: 0.85rem;
  color: #64748b;
  line-height: 1.4;
}

body.dark-mode .pwa-step-desc {
  color: #94a3b8;
}

.pwa-step-desc strong {
  color: var(--color-primary, #6c5ce7);
}

body.dark-mode .pwa-step-desc strong {
  color: #fdcb6e;
}

/* Modal Bottom CTA */
.pwa-modal-footer {
  margin-top: 20px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.btn-pwa-primary {
  background: var(--color-primary, #6c5ce7);
  color: #ffffff;
  border: none;
  font-family: inherit;
  font-weight: 800;
  font-size: 0.95rem;
  padding: 10px 24px;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(108, 92, 231, 0.4);
  transition: all 0.2s ease;
}

.btn-pwa-primary:hover {
  background: #5844d8;
  transform: translateY(-2px);
}

/* Responsive adjustments & device optimizations */
@media (max-width: 768px) {
  .btn-header-install {
    padding: 5px 8px !important;
    font-size: 0.76rem !important;
    border-radius: 12px !important;
  }
}

@media (max-width: 600px) {
  .pwa-smart-banner {
    padding-top: max(10px, env(safe-area-inset-top, 10px));
    padding-left: max(12px, env(safe-area-inset-left, 12px));
    padding-right: max(12px, env(safe-area-inset-right, 12px));
  }

  .pwa-banner-inner {
    flex-direction: column;
    align-items: stretch;
    text-align: right;
    gap: 8px;
  }

  .pwa-banner-actions {
    justify-content: space-between;
    width: 100%;
    margin-top: 2px;
  }

  .btn-pwa-action {
    flex: 1;
    justify-content: center;
    font-size: 0.82rem;
    padding: 6px 12px;
  }
}

@media (max-width: 520px) {
  .btn-header-install span {
    font-size: 0.72rem !important;
  }

  .pwa-modal-overlay {
    padding: 10px;
  }

  .pwa-modal-card {
    padding: 16px 12px;
    border-radius: 20px;
    max-height: 94vh;
  }

  .pwa-modal-header {
    margin-bottom: 12px;
    padding-bottom: 8px;
  }

  .pwa-modal-title {
    font-size: 1rem;
    gap: 6px;
  }

  .pwa-tabs-nav {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 3px;
    margin-bottom: 14px;
  }

  .pwa-tab-btn {
    font-size: 0.72rem;
    padding: 8px 4px;
    text-align: center;
    flex-direction: column;
    gap: 2px;
    border-radius: 8px;
  }

  .pwa-step-card {
    padding: 10px;
    gap: 10px;
    border-radius: 12px;
    margin-bottom: 8px;
  }

  .pwa-step-num {
    width: 26px;
    height: 26px;
    font-size: 0.82rem;
  }

  .pwa-step-title {
    font-size: 0.88rem;
  }

  .pwa-step-desc {
    font-size: 0.78rem;
    line-height: 1.35;
  }

  .pwa-modal-footer {
    margin-top: 14px;
  }

  .btn-pwa-primary {
    width: 100%;
    text-align: center;
    justify-content: center;
    padding: 10px 16px;
    font-size: 0.88rem;
  }
}

@media (max-width: 400px) {
  .pwa-banner-icon {
    width: 34px;
    height: 34px;
    font-size: 18px;
    border-radius: 8px;
  }

  .pwa-banner-title {
    font-size: 0.84rem;
  }

  .pwa-banner-sub {
    font-size: 0.73rem;
  }

  .btn-header-install {
    padding: 4px 6px !important;
  }
}
