/* PWA-specific styles for native app experience */

/* Prevent text selection on mobile (scoped, not global) */
/* If you need to disable selection for a specific area, add class .no-text-select */
.no-text-select, .no-text-select * {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* Allow text selection for input fields and content areas */
input, textarea, [contenteditable], .selectable {
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
}

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
}

/* Mobile-first responsive design */
@media (max-width: 768px) {
  /* Hide scrollbars on mobile except for message textareas */
  ::-webkit-scrollbar {
    display: none;
  }
  
  /* Keep scrollbars visible for message textareas on mobile */
  textarea[name="msg"]::-webkit-scrollbar,
  #direct-chat-input::-webkit-scrollbar {
    display: block !important;
    width: 4px;
  }
  
  /* Prevent zoom on input focus */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="search"],
  input[type="tel"],
  input[type="url"],
  textarea,
  select {
    font-size: 16px !important;
  }
  
  /* Better touch targets */
  button, a, [role="button"] {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Mobile navigation improvements */
  .navbar-nav .nav-link {
    padding: 12px 16px;
    border-bottom: 1px solid #f8f9fa;
  }
  
  /* Mobile menu improvements */
  .pwa-mobile-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    z-index: 9999;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }
  
  .pwa-mobile-menu.active {
    transform: translateX(0);
  }
  
  /* PWA status bar spacing */
  body {
    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);
  }
}

/* PWA-specific animations */
@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

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

/* PWA loading states */
.pwa-loading {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.pwa-loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid var(--color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* PWA offline indicator */
.pwa-offline-indicator {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  background: #dc3545;
  color: white;
  text-align: center;
  padding: 8px;
  font-size: 14px;
  z-index: 9998;
  transform: translateY(-100%);
  transition: transform 0.3s ease;
}

.pwa-offline-indicator.show {
  transform: translateY(0);
}

/* PWA install prompt styling */
.pwa-install-prompt {
  position: fixed;
  bottom: 20px;
  left: 20px;
  right: 20px;
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  z-index: 9997;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  /* Hide on desktop by default */
  display: none;
}

/* Show only on mobile devices */
@media (max-width: 768px) {
  .pwa-install-prompt {
    display: block;
  }
}

.pwa-install-prompt.show {
  transform: translateY(0);
}

.pwa-install-prompt .prompt-content {
  display: flex;
  align-items: center;
  gap: 15px;
}

.pwa-install-prompt .app-icon {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 24px;
}

.pwa-install-prompt .prompt-text {
  flex: 1;
}

.pwa-install-prompt .prompt-text h4 {
  margin: 0 0 5px 0;
  font-size: 16px;
  font-weight: 600;
}

.pwa-install-prompt .prompt-text p {
  margin: 0;
  font-size: 14px;
  color: #666;
}

.pwa-install-prompt .prompt-actions {
  display: flex;
  gap: 10px;
  margin-top: 15px;
}

.pwa-install-prompt .btn {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.pwa-install-prompt .btn-primary {
  background: var(--color-primary);
  color: white;
}

.pwa-install-prompt .btn-secondary {
  background: #f8f9fa;
  color: #333;
}

/* PWA splash screen */
.pwa-splash {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #F4813C !important; /* Fallback color */
  background: var(--color-primary) !important;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary)) !important;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10001 !important; /* Higher than main preloader */
  transition: opacity 0.5s ease;
}

/* Hide main preloader when PWA splash is active */
.pwa-splash:not(.hide) ~ #preLoader,
.pwa-splash:not(.hide) ~ .request-loader {
  display: none !important;
}

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

.pwa-splash .splash-icon {
  width: 80px;
  height: 80px;
  border-radius: 16px;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.pwa-splash .splash-title {
  color: white;
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 10px;
}

.pwa-splash .splash-subtitle {
  color: rgba(255, 255, 255, 0.8);
  font-size: 16px;
}

/* PWA navigation improvements */
.pwa-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: white;
  border-top: 1px solid #e9ecef;
  padding: 10px 0;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  z-index: 1000;
}

.pwa-nav .nav-items {
  display: flex;
  justify-content: space-around;
  align-items: center;
}

.pwa-nav .nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: #666;
  font-size: 12px;
  transition: color 0.3s ease;
}

.pwa-nav .nav-item.active {
  color: var(--color-primary);
}

.pwa-nav .nav-item i {
  font-size: 20px;
  margin-bottom: 4px;
}

/* PWA pull-to-refresh indicator */
.pwa-pull-refresh {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 60px;
  background: #f8f9fa;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9996;
  transform: translateY(-100%);
  transition: transform 0.3s ease;
}

.pwa-pull-refresh.show {
  transform: translateY(0);
}

.pwa-pull-refresh .refresh-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #e9ecef;
  border-top: 2px solid var(--color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
} 