﻿/* ==========================================================================
   PWA & iOS Installation System - Styles
   Clinic System - Dr. Mohamed El-Assasi
   ========================================================================== */

/* Safe area support for notch and dynamic island */
:root {
  --ios-safe-top: env(safe-area-inset-top, 0px);
  --ios-safe-bottom: env(safe-area-inset-bottom, 0px);
  --ios-safe-left: env(safe-area-inset-left, 0px);
  --ios-safe-right: env(safe-area-inset-right, 0px);
}

/* Fast touch response without delay or bounce zoom */
button, a, input, select, textarea {
  touch-action: manipulation;
}

/* Prevent unwanted zoom-in on iPhone inputs (if < 16px) */
@media screen and (max-width: 768px) {
  input[type="text"],
  input[type="password"],
  input[type="email"],
  input[type="number"],
  input[type="tel"],
  input[type="search"],
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* Hide install triggers when already running in Standalone PWA */
body.is-pwa-standalone .pwa-install-trigger,
body.is-pwa-standalone #iosInstallPromptBanner,
body.is-pwa-standalone #pwaInstallModal {
  display: none !important;
}

/* --------------------------------------------------------------------------
   1. Floating iOS & PWA Install Prompt Banner
   -------------------------------------------------------------------------- */
.pwa-floating-prompt {
  position: fixed;
  bottom: calc(16px + var(--ios-safe-bottom));
  left: 16px;
  right: 16px;
  max-width: 480px;
  margin: 0 auto;
  background: linear-gradient(135deg, #0a2540 0%, #1e3a8a 100%);
  color: #ffffff;
  padding: 14px 18px;
  border-radius: 20px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.15) inset;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-family: 'Cairo', 'Tajawal', -apple-system, BlinkMacSystemFont, sans-serif;
  direction: rtl;
  animation: pwaSlideUp 0.45s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.pwa-floating-prompt.hidden {
  display: none !important;
}

.pwa-prompt-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.pwa-prompt-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pwa-prompt-body {
  flex: 1;
  min-width: 0;
}

.pwa-prompt-title {
  font-weight: 800;
  font-size: 0.92rem;
  line-height: 1.25;
  color: #ffffff;
}

.pwa-prompt-subtitle {
  font-size: 0.76rem;
  color: #cbd5e1;
  margin-top: 3px;
  line-height: 1.35;
}

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

.pwa-btn-install {
  background: linear-gradient(135deg, #d4af37 0%, #f59e0b 100%);
  color: #0a2540;
  border: none;
  padding: 8px 14px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 0.82rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  box-shadow: 0 4px 12px rgba(212, 175, 55, 0.35);
  transition: transform 0.2s, box-shadow 0.2s;
}

.pwa-btn-install:active {
  transform: scale(0.96);
}

.pwa-btn-close {
  background: rgba(255, 255, 255, 0.16);
  border: none;
  color: #ffffff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  transition: background 0.2s;
}

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

/* --------------------------------------------------------------------------
   2. Interactive iOS / PWA Guide Modal
   -------------------------------------------------------------------------- */
.pwa-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 37, 64, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s;
  direction: rtl;
  font-family: 'Cairo', 'Tajawal', sans-serif;
}

@media (min-width: 640px) {
  .pwa-modal-overlay {
    align-items: center;
  }
}

.pwa-modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.pwa-modal-card {
  background: #ffffff;
  border-radius: 28px 28px 20px 20px;
  width: 100%;
  max-width: 460px;
  padding: 24px 22px calc(24px + var(--ios-safe-bottom));
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.35);
  position: relative;
  transform: translateY(40px) scale(0.96);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  max-height: 90vh;
  overflow-y: auto;
}

@media (min-width: 640px) {
  .pwa-modal-card {
    border-radius: 24px;
    padding: 28px;
    transform: scale(0.92);
  }
}

.pwa-modal-overlay.active .pwa-modal-card {
  transform: translateY(0) scale(1);
}

.pwa-modal-header {
  text-align: center;
  position: relative;
  padding-bottom: 16px;
  border-bottom: 1px solid #f1f5f9;
  margin-bottom: 20px;
}

.pwa-modal-close {
  position: absolute;
  top: -6px;
  left: -4px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #f1f5f9;
  border: none;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  cursor: pointer;
  transition: 0.2s;
}

.pwa-modal-close:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.pwa-modal-app-badge {
  width: 68px;
  height: 68px;
  border-radius: 18px;
  margin: 0 auto 12px;
  box-shadow: 0 10px 24px rgba(10, 37, 64, 0.18);
  overflow: hidden;
  border: 2px solid #ffffff;
}

.pwa-modal-app-badge img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pwa-modal-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: #0a2540;
  line-height: 1.3;
}

.pwa-modal-desc {
  font-size: 0.85rem;
  color: #64748b;
  margin-top: 4px;
}

/* Step cards */
.pwa-steps-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 22px;
}

.pwa-step-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 12px 14px;
  transition: transform 0.2s;
}

.pwa-step-num {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: #eff6ff;
  color: #2563eb;
  font-weight: 900;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.pwa-step-text {
  font-size: 0.88rem;
  color: #1e293b;
  line-height: 1.45;
  flex: 1;
}

.pwa-step-text strong {
  color: #0a2540;
  font-weight: 800;
}

.pwa-step-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: #2563eb;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

/* Safari Pointer Guide Arrow */
.pwa-safari-arrow {
  text-align: center;
  padding-top: 6px;
  color: #2563eb;
  animation: pwaBounce 1.5s infinite;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.pwa-safari-arrow i {
  font-size: 1.6rem;
}

.pwa-safari-arrow span {
  font-size: 0.78rem;
  font-weight: 800;
}

/* Modal Bottom Action */
.pwa-modal-actions {
  display: flex;
  gap: 10px;
}

.pwa-btn-done {
  flex: 1;
  background: #0a2540;
  color: #ffffff;
  border: none;
  padding: 13px;
  border-radius: 14px;
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s;
}

.pwa-btn-done:active {
  background: #1e3a8a;
}

/* --------------------------------------------------------------------------
   3. Animations
   -------------------------------------------------------------------------- */
@keyframes pwaSlideUp {
  0% {
    opacity: 0;
    transform: translateY(60px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pwaBounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(6px);
  }
  60% {
    transform: translateY(3px);
  }
}
