/* =========================================================
   DENTOS — PWA Styles
   Install button + Splash screen + iOS guide + Branding
   ========================================================= */

/* -------------------------
   Bouton Installation discret
   ------------------------- */
#apex-install-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  opacity: 0;
  transform: translateY(16px) scale(0.95);
  transition: opacity 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
              transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

#apex-install-btn.apex-install-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

#apex-install-btn.apex-install-hiding {
  opacity: 0;
  transform: translateY(16px) scale(0.9);
}

.apex-install-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px 10px 14px;
  background: rgba(13, 122, 110, 0.96);
  backdrop-filter: blur(16px) saturate(1.8);
  -webkit-backdrop-filter: blur(16px) saturate(1.8);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 56px;
  cursor: pointer;
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  box-shadow:
    0 4px 24px rgba(13, 122, 110, 0.45),
    0 1px 3px rgba(0,0,0,0.12),
    inset 0 1px 0 rgba(255,255,255,0.15);
  transition: all 0.22s ease;
  position: relative;
  white-space: nowrap;
}

.apex-install-trigger:hover {
  background: rgba(10, 100, 90, 0.98);
  transform: translateY(-2px);
  box-shadow:
    0 8px 32px rgba(13, 122, 110, 0.55),
    0 2px 8px rgba(0,0,0,0.15),
    inset 0 1px 0 rgba(255,255,255,0.2);
}

.apex-install-trigger:active {
  transform: translateY(0);
  box-shadow: 0 2px 12px rgba(13, 122, 110, 0.4);
}

.apex-install-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.apex-install-icon svg {
  width: 18px;
  height: 18px;
  animation: apex-install-bounce 2.5s ease-in-out infinite;
}

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

.apex-install-text {
  line-height: 1;
}

.apex-install-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: rgba(255,255,255,0.85);
  padding: 0;
  margin-left: 4px;
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.apex-install-close:hover {
  background: rgba(255,255,255,0.3);
  color: white;
}

.apex-install-close svg {
  width: 10px;
  height: 10px;
}

/* Mobile — bouton en bas centré */
@media (max-width: 640px) {
  #apex-install-btn {
    bottom: 16px;
    right: 50%;
    transform: translateX(50%) translateY(16px) scale(0.95);
  }
  #apex-install-btn.apex-install-visible {
    transform: translateX(50%) translateY(0) scale(1);
  }
  #apex-install-btn.apex-install-hiding {
    transform: translateX(50%) translateY(16px) scale(0.9);
  }
  .apex-install-trigger {
    padding: 12px 20px 12px 16px;
    font-size: 14px;
  }
}

/* -------------------------
   Splash Screen
   ------------------------- */
#apex-splash {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: linear-gradient(160deg, #0D7A6E 0%, #1BAF9E 60%, #0f9a8a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: apex-splash-in 0.4s ease-out;
}

#apex-splash.apex-splash-fade-out {
  animation: apex-splash-out 0.6s ease-in forwards;
}

@keyframes apex-splash-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes apex-splash-out {
  from { opacity: 1; transform: scale(1); }
  to { opacity: 0; transform: scale(1.04); }
}

.apex-splash-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  animation: apex-splash-content-in 0.6s 0.1s both cubic-bezier(0.34, 1.2, 0.64, 1);
}

@keyframes apex-splash-content-in {
  from { opacity: 0; transform: translateY(16px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.apex-splash-logo {
  width: 96px;
  height: 96px;
  border-radius: 24px;
  overflow: hidden;
  background: rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.3);
}

.apex-splash-logo img {
  width: 80px;
  height: 80px;
  object-fit: contain;
}

.apex-splash-name {
  color: white;
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
  text-shadow: 0 2px 8px rgba(0,0,0,0.15);
  margin-top: 4px;
}

.apex-splash-tagline {
  color: rgba(255,255,255,0.72);
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.apex-splash-loader {
  width: 140px;
  height: 3px;
  background: rgba(255,255,255,0.2);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 20px;
}

.apex-splash-progress {
  height: 100%;
  background: white;
  border-radius: 99px;
  animation: apex-splash-load 2s ease-in-out;
}

@keyframes apex-splash-load {
  0% { width: 0%; }
  30% { width: 45%; }
  70% { width: 75%; }
  100% { width: 100%; }
}

/* -------------------------
   Guide iOS
   ------------------------- */
#apex-ios-guide {
  position: fixed;
  inset: 0;
  z-index: 99998;
}

.apex-ios-guide-overlay {
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 20px;
  animation: apex-overlay-in 0.25s ease;
}

@keyframes apex-overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.apex-ios-guide-modal {
  background: #fff;
  border-radius: 20px;
  padding: 24px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 -4px 40px rgba(0,0,0,0.15);
  animation: apex-modal-up 0.35s cubic-bezier(0.34, 1.3, 0.64, 1);
}

@keyframes apex-modal-up {
  from { opacity: 0; transform: translateY(32px); }
  to { opacity: 1; transform: translateY(0); }
}

.apex-ios-guide-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.apex-ios-guide-header img {
  border-radius: 12px;
  flex-shrink: 0;
}

.apex-ios-guide-title {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 17px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.2;
}

.apex-ios-guide-sub {
  font-size: 13px;
  color: #64748b;
  margin-top: 3px;
}

.apex-ios-guide-steps {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 22px;
}

.apex-ios-guide-step {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: #334155;
  font-family: 'Inter', system-ui, sans-serif;
}

.apex-ios-guide-step svg {
  display: inline-block;
  vertical-align: middle;
  margin: 0 2px;
}

.apex-ios-step-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: linear-gradient(135deg, #0D7A6E, #1BAF9E);
  color: white;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.apex-ios-guide-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #0D7A6E, #1BAF9E);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  font-family: 'Inter', system-ui, sans-serif;
  cursor: pointer;
  transition: opacity 0.2s;
}

.apex-ios-guide-btn:hover {
  opacity: 0.9;
}

/* -------------------------
   Bannière mise à jour
   ------------------------- */
#apex-update-banner .apex-update-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9997;
  background: #0D7A6E;
  color: white;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 2px 16px rgba(13,122,110,0.35);
}

#apex-update-banner .apex-update-banner button {
  padding: 5px 12px;
  background: rgba(255,255,255,0.2);
  color: white;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: background 0.15s;
}

#apex-update-banner .apex-update-banner button:hover {
  background: rgba(255,255,255,0.35);
}

/* -------------------------
   Modal Upload Logo (Settings)
   ------------------------- */
.apex-branding-upload-zone {
  border: 2px dashed #cbd5e1;
  border-radius: 14px;
  padding: 32px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: #f8fafc;
}

.apex-branding-upload-zone:hover,
.apex-branding-upload-zone.drag-over {
  border-color: #0D7A6E;
  background: rgba(13, 122, 110, 0.04);
}

.apex-branding-upload-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, #0D7A6E, #1BAF9E);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  color: white;
}

.apex-branding-preview {
  width: 100%;
  max-height: 80px;
  object-fit: contain;
  border-radius: 8px;
  margin: 8px 0;
}

/* -------------------------
   Standalone mode adjustments
   ------------------------- */
html.apex-standalone body {
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}

html.apex-standalone .landing-nav {
  /* Ajout padding top pour notch iOS */
  padding-top: max(env(safe-area-inset-top), 0px);
}

/* Safe area insets pour iOS (notch) */
@supports (padding: max(0px)) {
  html.apex-standalone .apex-shell {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
}
