/* PWA Styles for Conflingo */

/* Splash Screen Styles */
#app-splash {
  position: fixed;
  inset: 0;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2147483000;
  transition: opacity .35s ease;
}

#app-splash.hidden {
  opacity: 0;
  pointer-events: none;
}

#app-splash .mark {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

#app-splash .mark img,
#app-splash .mark svg {
  width: 48px;
  height: 48px;
}

#app-splash .mark .brand {
  font: 700 22px/1.1 system-ui, Segoe UI, Roboto, Arial, sans-serif;
  color: #ff4040;
}

#app-splash .spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 4px solid rgba(0,0,0,.08);
  border-top-color: #ff4040;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* PWA Bottom Navigation - Always visible in PWA mode */
html[data-pwa="true"] #pwa-bottom-nav,
#pwa-bottom-nav {
  position: fixed !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  height: 80px !important;
  background: rgba(255, 255, 255, 0.95) !important;
  backdrop-filter: blur(20px) !important;
  border-top: 1px solid rgba(0, 0, 0, 0.1) !important;
  display: flex !important;
  justify-content: space-around !important;
  align-items: center !important;
  z-index: 2147483647 !important;
  padding-bottom: env(safe-area-inset-bottom) !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

#pwa-bottom-nav .nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 50px;
}

#pwa-bottom-nav .nav-item:hover {
  background: rgba(255, 64, 64, 0.1);
  transform: translateY(-2px);
}

#pwa-bottom-nav .nav-item.active {
  background: rgba(255, 64, 64, 0.15);
  color: #ff4040;
}

#pwa-bottom-nav .nav-icon {
  font-size: 20px;
  margin-bottom: 4px;
}

#pwa-bottom-nav .nav-label {
  font-size: 11px;
  font-weight: 600;
  text-align: center;
}

/* PWA Refresh Indicator */
#pwa-refresh-indicator {
  position: fixed;
  top: -60px;
  left: 0;
  right: 0;
  height: 60px;
  background: #f8f9fa;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  color: #666;
  z-index: 9999;
  transition: transform 0.3s ease;
  border-bottom: 1px solid #eee;
}

.refresh-icon.spinning {
  animation: spin 1s linear infinite;
}

/* Hide desktop elements in PWA mode - Higher specificity */
html[data-pwa="true"] .header-container nav,
html[data-pwa="true"] #nav-links,
html[data-pwa="true"] .header nav,
html[data-pwa="true"] .header-nav,
html[data-pwa="true"] .main-nav,
html[data-pwa="true"] .navigation {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Hide sidebar toggles in PWA for clean mobile experience */
html[data-pwa="true"] .sidebar-toggle,
html[data-pwa="true"] .right-sidebar-toggle,
html[data-pwa="true"] .sidebar-btn,
html[data-pwa="true"] .menu-toggle {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* But show filter toggle on all_opinions pages where it's needed */
html[data-pwa="true"] body[data-page="all_opinions"] .sidebar-toggle {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

/* Hide sidebars in PWA mode for consistent mobile experience */
html[data-pwa="true"] .right-sidebar,
html[data-pwa="true"] #right-sidebar,
html[data-pwa="true"] .right-sidebar-toggle {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Hide mobile menu icon with higher specificity */
html[data-pwa="true"] body .mobile-menu-icon,
html[data-pwa="true"] .mobile-menu-icon,
html[data-pwa="true"] .hamburger-menu,
html[data-pwa="true"] .menu-icon {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Hide nightmode toggle in PWA */
html[data-pwa="true"] body .nightmode-desktop,
html[data-pwa="true"] .nightmode-desktop,
html[data-pwa="true"] .dark-mode-toggle,
html[data-pwa="true"] .theme-toggle {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Hide desktop notification icons (pen, chat bubble) in PWA */
html[data-pwa="true"] body .notification-icon,
html[data-pwa="true"] body .chat-icon,
html[data-pwa="true"] body .write-icon,
html[data-pwa="true"] body .floating-action-button,
html[data-pwa="true"] body .fab,
html[data-pwa="true"] body .fixed-bottom-right,
html[data-pwa="true"] body .bottom-right-icons,
html[data-pwa="true"] body .desktop-notifications,
html[data-pwa="true"] .notification-icon,
html[data-pwa="true"] .chat-icon,
html[data-pwa="true"] .write-icon,
html[data-pwa="true"] .floating-action-button,
html[data-pwa="true"] .fab,
html[data-pwa="true"] .fixed-bottom-right,
html[data-pwa="true"] .bottom-right-icons,
html[data-pwa="true"] .desktop-notifications {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Hide any fixed positioned elements in bottom-right corner (but not our bottom nav) */
html[data-pwa="true"] body [style*="position: fixed"][style*="bottom"][style*="right"]:not(#pwa-bottom-nav),
html[data-pwa="true"] body [style*="position:fixed"][style*="bottom"][style*="right"]:not(#pwa-bottom-nav),
html[data-pwa="true"] [style*="position: fixed"][style*="bottom"][style*="right"]:not(#pwa-bottom-nav),
html[data-pwa="true"] [style*="position:fixed"][style*="bottom"][style*="right"]:not(#pwa-bottom-nav) {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Additional selectors for common floating UI patterns (but not our elements or form buttons) */
html[data-pwa="true"] body .floating-ui:not(#pwa-bottom-nav),
html[data-pwa="true"] body .floating-buttons:not(#pwa-bottom-nav),
html[data-pwa="true"] body .quick-actions:not(#pwa-bottom-nav),
html[data-pwa="true"] body .corner-buttons:not(#pwa-bottom-nav),
html[data-pwa="true"] body [class*="float"]:not(#pwa-bottom-nav):not(#pwa-refresh-indicator),
html[data-pwa="true"] body [class*="fixed-bottom"]:not(#pwa-bottom-nav),
html[data-pwa="true"] body [id*="floating"]:not(#pwa-bottom-nav):not(#pwa-refresh-indicator),
html[data-pwa="true"] body [id*="notification"]:not(#pwa-bottom-nav):not(#pwa-refresh-indicator),
html[data-pwa="true"] body [id*="quick-action"]:not(#pwa-bottom-nav),
html[data-pwa="true"] .floating-ui:not(#pwa-bottom-nav),
html[data-pwa="true"] .floating-buttons:not(#pwa-bottom-nav),
html[data-pwa="true"] .quick-actions:not(#pwa-bottom-nav),
html[data-pwa="true"] .corner-buttons:not(#pwa-bottom-nav),
html[data-pwa="true"] [class*="float"]:not(#pwa-bottom-nav):not(#pwa-refresh-indicator),
html[data-pwa="true"] [class*="fixed-bottom"]:not(#pwa-bottom-nav),
html[data-pwa="true"] [id*="floating"]:not(#pwa-bottom-nav):not(#pwa-refresh-indicator),
html[data-pwa="true"] [id*="notification"]:not(#pwa-bottom-nav):not(#pwa-refresh-indicator),
html[data-pwa="true"] [id*="quick-action"]:not(#pwa-bottom-nav) {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Hide action-buttons only when they are floating/positioned elements, not form buttons */
html[data-pwa="true"] body .action-buttons:not(#pwa-bottom-nav):not(form .action-buttons),
html[data-pwa="true"] .action-buttons:not(#pwa-bottom-nav):not(form .action-buttons) {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Hide elements positioned in bottom-right quadrant (but not our nav) */
html[data-pwa="true"] body *[style*="bottom: 0"][style*="right: 0"]:not(#pwa-bottom-nav),
html[data-pwa="true"] body *[style*="bottom:0"][style*="right:0"]:not(#pwa-bottom-nav),
html[data-pwa="true"] body *[style*="bottom: 10px"][style*="right: 10px"]:not(#pwa-bottom-nav),
html[data-pwa="true"] body *[style*="bottom: 20px"][style*="right: 20px"]:not(#pwa-bottom-nav),
html[data-pwa="true"] *[style*="bottom: 0"][style*="right: 0"]:not(#pwa-bottom-nav),
html[data-pwa="true"] *[style*="bottom:0"][style*="right:0"]:not(#pwa-bottom-nav),
html[data-pwa="true"] *[style*="bottom: 10px"][style*="right: 10px"]:not(#pwa-bottom-nav),
html[data-pwa="true"] *[style*="bottom: 20px"][style*="right: 20px"]:not(#pwa-bottom-nav) {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Ensure form buttons are always visible - Override any hiding rules */
html[data-pwa="true"] body .btn,
html[data-pwa="true"] body .action-buttons,
html[data-pwa="true"] body button[type="submit"],
html[data-pwa="true"] body .btn-primary,
html[data-pwa="true"] body #save-settings-button,
html[data-pwa="true"] body form .btn,
html[data-pwa="true"] body form .action-buttons,
html[data-pwa="true"] body form button[type="submit"],
html[data-pwa="true"] body form .btn-primary,
html[data-pwa="true"] .btn,
html[data-pwa="true"] .action-buttons,
html[data-pwa="true"] button[type="submit"],
html[data-pwa="true"] .btn-primary,
html[data-pwa="true"] #save-settings-button,
html[data-pwa="true"] form .btn,
html[data-pwa="true"] form .action-buttons,
html[data-pwa="true"] form button[type="submit"],
html[data-pwa="true"] form .btn-primary {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

html[data-pwa="true"] body .action-buttons,
html[data-pwa="true"] body form .action-buttons,
html[data-pwa="true"] .action-buttons,
html[data-pwa="true"] form .action-buttons {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

/* Adjust body padding for bottom nav - moved to consolidated section below */

/* Header scrolls with content - no special margin needed */
html[data-pwa="true"] .main-content {
  margin-top: 60px !important;
}

/* Header should be fixed at top in PWA mode like normal mode */
html[data-pwa="true"] .header-container,
html[data-pwa="true"] .header {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  z-index: 1000 !important;
}

/* Ensure cookie compliance elements have higher z-index priority */
html[data-pwa="true"] #cookie-banner,
html[data-pwa="true"] .cookie-banner,
html[data-pwa="true"] .consent-modal,
html[data-pwa="true"] .consent-overlay,
html[data-pwa="true"] #ft-floating-toolbar,
html[data-pwa="true"] .ft-container,
html[data-pwa="true"] iframe#google_esf,
html[data-pwa="true"] iframe[id*="google_esf"] {
  z-index: 2147483648 !important;
  position: relative !important;
}

/* Prevent PWA styles from interfering with cookie compliance */
html[data-pwa="true"] body.has-consent,
html[data-pwa="true"] body:not(.has-consent) {
  pointer-events: auto !important;
}

/* Fix horizontal overflow issues on all_opinions pages */
html[data-pwa="true"] body[data-page="all_opinions"] .main-content,
html[data-pwa="true"] body[data-page="all_opinions"] .content,
html[data-pwa="true"] body[data-page="all_opinions"] .content-wrapper {
  overflow-x: hidden !important;
  overflow-y: auto !important;
  max-width: 100% !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

/* Fix content margins that cause horizontal overflow on small screens */
html[data-pwa="true"] body[data-page="all_opinions"] .content {
  margin: 0 10px !important; /* Reduce margins on small screens */
  padding: 0 10px !important;
}

@media (min-width: 768px) {
  html[data-pwa="true"] body[data-page="all_opinions"] .content {
    margin: 0 20px !important; /* Restore margins on larger screens */
    padding: 0 20px !important;
  }
}

@media (min-width: 1200px) {
  html[data-pwa="true"] body[data-page="all_opinions"] .content {
    margin: 0 220px !important; /* Restore full margins on desktop */
    padding: 0 20px !important;
  }
}

html[data-pwa="true"] .header-container .logo,
html[data-pwa="true"] .header .logo {
  justify-content: center !important;
  flex: none !important;
  margin: 0 auto !important;
}

/* PWA-specific responsive styles */
@media (max-width: 768px) {
  html[data-pwa="true"] body #pwa-bottom-nav,
  html[data-pwa="true"] #pwa-bottom-nav {
    height: 70px !important;
  }

  html[data-pwa="true"] body {
    padding-bottom: calc(70px + env(safe-area-inset-bottom)) !important;
  }

  html[data-pwa="true"] body #pwa-bottom-nav .nav-icon,
  html[data-pwa="true"] #pwa-bottom-nav .nav-icon {
    font-size: 18px;
  }

  html[data-pwa="true"] body #pwa-bottom-nav .nav-label,
  html[data-pwa="true"] #pwa-bottom-nav .nav-label {
    font-size: 10px;
  }
}

/* Force PWA bottom nav visibility - MAXIMUM PRIORITY */
html[data-pwa="true"] #pwa-bottom-nav,
html[data-pwa="true"] #pwa-bottom-nav {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  position: fixed !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  height: 80px !important;
  background: rgba(255, 255, 255, 0.95) !important;
  backdrop-filter: blur(20px) !important;
  border-top: 1px solid rgba(0, 0, 0, 0.1) !important;
  justify-content: space-around !important;
  align-items: center !important;
  z-index: 2147483647 !important;
  padding-bottom: env(safe-area-inset-bottom) !important;
  transform: translateZ(0) !important;
  -webkit-transform: translateZ(0) !important;
  will-change: transform !important;
}

/* Apply bottom padding only to body to avoid cumulative padding */
html[data-pwa="true"] body {
  padding-bottom: calc(80px + env(safe-area-inset-bottom)) !important;
  margin-bottom: 0 !important;
  box-sizing: border-box !important;
}

/* Remove any existing bottom padding from content containers to prevent double padding */
html[data-pwa="true"] body .main-content,
html[data-pwa="true"] body .content-wrapper,
html[data-pwa="true"] body .content {
  padding-bottom: 0 !important;
}

/* Remove bottom padding from containers that might have it */
html[data-pwa="true"] body .opinion-container,
html[data-pwa="true"] body .opinion-list,
html[data-pwa="true"] body .comments-section {
  padding-bottom: 0 !important;
  margin-bottom: 0 !important;
}

/* Don't add extra padding to individual items */
html[data-pwa="true"] body .opinion-item,
html[data-pwa="true"] body .comment {
  padding-bottom: 0 !important;
  margin-bottom: 10px !important; /* Keep normal spacing between items */
}

/* Override any inline styles that might add bottom padding */
html[data-pwa="true"] body[style*="padding-bottom"],
html[data-pwa="true"] body[style*="clamp"] {
  padding-bottom: calc(80px + env(safe-area-inset-bottom)) !important;
}

/* PWA Links Modal Styles */
#pwa-links-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 999999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

#pwa-links-modal.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

#pwa-links-modal .modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 999998;
}

#pwa-links-modal .modal-content {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  width: 95%;
  max-width: 500px;
  max-height: 85vh;
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 999999;
}

#pwa-links-modal.active .modal-content {
  transform: translate(-50%, -50%) scale(1);
}

#pwa-links-modal .modal-header {
  background: linear-gradient(135deg, #ff4040 0%, #ff6060 100%);
  color: white;
  padding: 20px 25px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 10px rgba(255, 64, 64, 0.3);
}

#pwa-links-modal .modal-header h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

#pwa-links-modal .modal-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 28px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  font-weight: 300;
  line-height: 1;
}

#pwa-links-modal .modal-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

#pwa-links-modal .modal-body {
  padding: 25px;
  max-height: calc(90vh - 140px);
  overflow-y: auto;
}

#pwa-links-modal .links-grid {
  display: grid;
  gap: 25px;
  margin-bottom: 25px;
}

#pwa-links-modal .links-section {
  background: white;
  border-radius: 15px;
  padding: 20px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(255, 64, 64, 0.1);
}

#pwa-links-modal .links-section h3 {
  margin: 0 0 15px 0;
  font-size: 18px;
  font-weight: 600;
  color: #ff4040;
  display: flex;
  align-items: center;
  gap: 8px;
}

#pwa-links-modal .links-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

#pwa-links-modal .links-list li {
  margin-bottom: 12px;
}

#pwa-links-modal .links-list li:last-child {
  margin-bottom: 0;
}

#pwa-links-modal .links-list a {
  display: flex;
  align-items: center;
  padding: 12px 15px;
  background: #f8f9fa;
  border-radius: 10px;
  text-decoration: none;
  color: #333;
  font-weight: 500;
  font-size: 15px;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

#pwa-links-modal .links-list a:hover {
  background: #ff4040;
  color: white;
  transform: translateX(5px);
  box-shadow: 0 4px 12px rgba(255, 64, 64, 0.3);
}

#pwa-links-modal .modal-footer {
  border-top: 1px solid rgba(255, 64, 64, 0.1);
  padding-top: 20px;
  margin-top: 25px;
}

#pwa-links-modal .language-switcher-modal {
  text-align: center;
}

#pwa-links-modal .language-switcher-modal h4 {
  margin: 0 0 15px 0;
  font-size: 16px;
  font-weight: 600;
  color: #ff4040;
}

#pwa-links-modal .language-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

#pwa-links-modal .lang-btn {
  background: linear-gradient(135deg, #ff4040 0%, #ff6060 100%);
  color: white;
  padding: 12px 20px;
  border-radius: 25px;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.2s ease;
  box-shadow: 0 4px 15px rgba(255, 64, 64, 0.3);
}

#pwa-links-modal .lang-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 64, 64, 0.4);
}

/* Mobile optimizations */
@media (max-width: 480px) {
  #pwa-links-modal .modal-content {
    width: 98%;
    max-height: 95vh;
    border-radius: 15px;
  }
  
  #pwa-links-modal .modal-header {
    padding: 15px 20px;
  }
  
  #pwa-links-modal .modal-header h2 {
    font-size: 20px;
  }
  
  #pwa-links-modal .modal-body {
    padding: 20px;
  }
  
  #pwa-links-modal .links-section {
    padding: 15px;
  }
  
  #pwa-links-modal .links-list a {
    padding: 10px 12px;
    font-size: 14px;
  }
}

/* Smooth scrollbar for modal */
#pwa-links-modal .modal-body::-webkit-scrollbar {
  width: 6px;
}

#pwa-links-modal .modal-body::-webkit-scrollbar-track {
  background: rgba(255, 64, 64, 0.1);
  border-radius: 3px;
}

#pwa-links-modal .modal-body::-webkit-scrollbar-thumb {
  background: rgba(255, 64, 64, 0.3);
  border-radius: 3px;
}

#pwa-links-modal .modal-body::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 64, 64, 0.5);
}

/* Emergency override - ensure bottom nav is always visible */
#pwa-bottom-nav[style*="display: none"],
#pwa-bottom-nav[style*="visibility: hidden"],
#pwa-bottom-nav[style*="opacity: 0"],
#pwa-bottom-nav.emergency-visible {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  position: fixed !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  height: 80px !important;
  z-index: 2147483647 !important;
  background: rgba(255, 255, 255, 0.95) !important;
  backdrop-filter: blur(20px) !important;
  border-top: 1px solid rgba(0, 0, 0, 0.1) !important;
  justify-content: space-around !important;
  align-items: center !important;
  padding-bottom: env(safe-area-inset-bottom) !important;
}

/* Emergency bottom nav fallback */
#pwa-bottom-nav-emergency {
  position: fixed !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  height: 80px !important;
  background: rgba(255, 255, 255, 0.95) !important;
  backdrop-filter: blur(20px) !important;
  border-top: 1px solid rgba(0, 0, 0, 0.1) !important;
  display: flex !important;
  justify-content: space-around !important;
  align-items: center !important;
  z-index: 2147483647 !important;
  padding-bottom: env(safe-area-inset-bottom) !important;
}
