/**
 * PWA CSS Styly pro Salon Rose
 * 
 * Obsah:
 * - Offline banner (upozornění bez internetu)
 * - Install modal (popup na mobile)
 * - Install button styling (fallback na desktop)
 * - Safe area padding pro notched devices
 * - Fullscreen app styling
 * - Loading animations
 */

/* ============================================================
   OFFLINE BANNER
   ============================================================ */

.pwa-offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: linear-gradient(135deg, #ff3b30 0%, #ff453a 100%);
  color: white;
  padding: 12px 16px;
  z-index: 10000;
  box-shadow: 0 4px 12px rgba(255, 59, 48, 0.3);
  animation: slideDownBanner 0.3s ease-out;
  transition: transform 0.3s ease-out;
}

@keyframes slideDownBanner {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.pwa-offline-hidden {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}

.pwa-offline-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
}

.pwa-offline-icon {
  font-size: 18px;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

/* ============================================================
   INSTALL MODAL (POPUP)
   ============================================================ */

.pwa-modal-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9999;
  animation: fadeInModal 0.3s ease-out;
}

@keyframes fadeInModal {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.pwa-modal-content {
  position: relative;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(250, 250, 250, 0.95) 100%);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 24px;
  padding: 40px 30px;
  max-width: 380px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(201, 58, 138, 0.25);
  border: 1px solid rgba(201, 58, 138, 0.15);
  text-align: center;
  animation: slideUpModal 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideUpModal {
  from {
    transform: translateY(40px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.pwa-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  font-size: 24px;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.pwa-modal-close:hover {
  background: rgba(201, 58, 138, 0.1);
  color: #c93a8a;
}

.pwa-modal-icon {
  font-size: 48px;
  margin-bottom: 16px;
  animation: bounceIcon 0.6s ease-out 0.2s both;
}

@keyframes bounceIcon {
  0% {
    transform: scale(0.3);
    opacity: 0;
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.pwa-modal-content h2 {
  font-size: 24px;
  color: #1d1d1f;
  margin: 0 0 12px 0;
  font-weight: 700;
  text-align: center;
}

.pwa-modal-content p {
  font-size: 14px;
  color: #555;
  margin: 0 0 24px 0;
  line-height: 1.5;
  text-align: center;
}

.pwa-modal-buttons {
  display: flex;
  gap: 12px;
  flex-direction: column;
}

.pwa-btn-install {
  padding: 12px 24px;
  background: linear-gradient(135deg, #c93a8a 0%, #a82d72 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(201, 58, 138, 0.3);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
}

.pwa-btn-install:active {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(201, 58, 138, 0.4);
}

.pwa-btn-install:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(201, 58, 138, 0.3);
}

.pwa-btn-cancel {
  padding: 12px 24px;
  background: rgba(0, 0, 0, 0.05);
  color: #666;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.pwa-btn-cancel:active {
  background: rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

/* ============================================================
   iOS INSTRUKČNÍ MODAL
   ============================================================ */

.pwa-ios-overlay {
  background: rgba(0, 0, 0, 0.6);
}

.pwa-ios-content {
  max-width: 340px;
  padding: 30px 24px;
}

.pwa-ios-steps {
  margin: 24px 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
}

.pwa-ios-step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.pwa-ios-step-number {
  min-width: 32px;
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #c93a8a 0%, #a82d72 100%);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.pwa-ios-step p {
  font-size: 14px;
  color: #333;
  margin: 0;
  padding-top: 4px;
}

.pwa-ios-step strong {
  color: #c93a8a;
  font-weight: 600;
}

/* ============================================================
   INSTALL BUTTON STYLING (FALLBACK NA DESKTOP)
   ============================================================ */

.pwa-install-btn {
  display: none;
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 999;
  padding: 10px 16px;
  background: linear-gradient(135deg, #c93a8a 0%, #a82d72 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(201, 58, 138, 0.3);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
  text-transform: none;
  letter-spacing: 0.3px;
  outline: none;
  white-space: nowrap;
}

.pwa-install-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(201, 58, 138, 0.4);
}

.pwa-install-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(201, 58, 138, 0.3);
}

.pwa-install-btn:focus {
  outline: 2px solid #c93a8a;
  outline-offset: 2px;
}

/* ============================================================
   INSTALOVANÁ APLIKACE (STANDALONE MODE)
   ============================================================ */

html.pwa-installed {
  /* Fullscreen experience */
}

body.pwa-installed {
  /* Safe area pro notched devices (iPhone X+, Android) */
  padding-top: max(12px, env(safe-area-inset-top));
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  padding-left: max(12px, env(safe-area-inset-left));
  padding-right: max(12px, env(safe-area-inset-right));
}

/* Skryj install tlačítko v nainstalované aplikaci */
body.pwa-installed .pwa-install-btn {
  display: none !important;
}

/* ============================================================
   RESPONSIVE DESIGN PRO INSTALL BUTTON
   ============================================================ */

@media (max-width: 1250px) {
  .pwa-install-btn {
    top: auto;
    bottom: 100px;
    right: 16px;
    padding: 10px 14px;
    font-size: 13px;
  }
}

@media (max-width: 768px) {
  .pwa-install-btn {
    top: auto;
    bottom: 90px;
    right: 12px;
    padding: 12px 14px;
    font-size: 13px;
    border-radius: 24px;
  }
  
  .pwa-install-btn:hover {
    transform: translateY(-1px);
  }
}

@media (max-width: 480px) {
  .pwa-install-btn {
    bottom: 80px;
    right: 8px;
    left: auto;
    padding: 10px 12px;
    font-size: 12px;
    border-radius: 20px;
  }
}

/* Příliš malé obrazovky - přesunout výš */
@media (max-width: 360px) {
  .pwa-install-btn {
    bottom: 70px;
    font-size: 11px;
    padding: 8px 10px;
  }
}

/* ============================================================
   LANDSCAPE ORIENTATION
   ============================================================ */

@media (orientation: landscape) and (max-height: 500px) {
  .pwa-install-btn {
    bottom: auto;
    top: 8px;
    right: 8px;
    padding: 8px 12px;
    font-size: 12px;
  }
}

/* ============================================================
   FULLSCREEN MODE ADJUSTMENTS
   ============================================================ */

@supports (padding: max(0px)) {
  body {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
}

/* Vibrancy efekty pro iOS PWA */
@supports (backdrop-filter: blur(10px)) {
  .pwa-install-btn {
    backdrop-filter: blur(10px);
    background: rgba(201, 58, 138, 0.9);
  }
}

/* ============================================================
   LOADING ANIMATION
   ============================================================ */

@keyframes pwa-pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

.pwa-loading {
  animation: pwa-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* ============================================================
   OFFLINE INDICATOR (POKUD JE POTŘEBA)
   ============================================================ */

.pwa-offline-indicator {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #f39c12;
  color: white;
  padding: 12px 16px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  z-index: 999;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ============================================================
   PRINT STYLES (když se uživatel pokusí "tisk")
   ============================================================ */

@media print {
  .pwa-install-btn,
  .pwa-offline-indicator {
    display: none !important;
  }
}

/* ============================================================
   ACCESSIBILITY & HIGH CONTRAST
   ============================================================ */

@media (prefers-contrast: more) {
  .pwa-install-btn {
    border: 2px solid currentColor;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  }
}

@media (prefers-reduced-motion: reduce) {
  .pwa-install-btn {
    transition: none;
  }
  
  .pwa-install-btn:hover {
    transform: none;
  }
  
  .pwa-loading {
    animation: none;
    opacity: 1;
  }
  
  .pwa-offline-indicator {
    animation: none;
  }
}

/* ============================================================
   DARK MODE SUPPORT
   ============================================================ */

@media (prefers-color-scheme: dark) {
  .pwa-install-btn {
    background: linear-gradient(135deg, #c93a8a 0%, #a82d72 100%);
    box-shadow: 0 4px 12px rgba(201, 58, 138, 0.5);
  }
  
  .pwa-offline-indicator {
    background: #e67e22;
  }
}

/* ============================================================
   UTILITIES
   ============================================================ */

.pwa-hidden {
  display: none !important;
}

.pwa-visible {
  display: block !important;
}

.pwa-no-scroll {
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
}
