/* PWA and Mobile Enhancement Styles */

/* Hide elements in PWA mode (when running as standalone app) */
@media (display-mode: standalone) {
  .pwa-hide {
    display: none !important;
  }
}

/* Safe area insets for iOS notch/home indicator */
@supports (padding: max(0px)) {
  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);
  }
}

/* Prevent text size adjustment on orientation change */
html {
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

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

/* Improve tap target sizes on mobile */
@media (width <= 768px) {
  button, a, input[type="submit"], input[type="button"] {
    min-height: 44px;
    min-width: 44px;
  }
}

/* Hide scrollbar but keep functionality */
.hide-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.hide-scrollbar::-webkit-scrollbar {
  display: none;
}

/* Offline indicator */
body.offline::before {
  content: "Offline Mode";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #f59e0b;
  color: white;
  text-align: center;
  padding: 0.5rem;
  font-size: 0.875rem;
  z-index: 9999;
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    transform: translateY(-100%);
  }
  to {
    transform: translateY(0);
  }
}

/* Improve touch feedback */
button, a {
  -webkit-tap-highlight-color: rgba(30, 58, 138, 0.3);
  tap-highlight-color: rgba(30, 58, 138, 0.3);
}

/* Prevent pull-to-refresh on mobile when scrolling */
body {
  overscroll-behavior-y: contain;
}

/* Better focus visible for keyboard navigation */
*:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* Hide elements when running as PWA */
.pwa-installed .hide-in-pwa {
  display: none !important;
}

/* Show elements only when running as PWA */
.show-in-pwa {
  display: none !important;
}

.pwa-installed .show-in-pwa {
  display: block !important;
}

/* Responsive font sizing */
@media (width <= 640px) {
  html {
    font-size: 14px;
  }
}

@media (641px <= width <= 1024px) {
  html {
    font-size: 15px;
  }
}

@media (width >= 1025px) {
  html {
    font-size: 16px;
  }
}

/* Improve sidebar on mobile */
@media (width <= 768px) {
  aside {
    width: 100%;
  }
  
  aside .text {
    font-size: 0.625rem;
  }
}

/* Better modal positioning on mobile */
@media (width <= 768px) {
  dialog, .modal {
    max-width: 95vw !important;
    max-height: 90vh !important;
    margin: auto;
  }
}

/* Improve table responsiveness */
@media (width <= 768px) {
  table {
    font-size: 0.875rem;
  }
  
  th, td {
    padding: 0.5rem !important;
  }
}

/* Loading skeleton for better perceived performance */
.skeleton {
  background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
  background-size: 200% 100%;
  animation: loading 1.5s ease-in-out infinite;
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Improve form inputs on mobile */
@media (width <= 768px) {
  input, select, textarea {
    font-size: 16px !important; /* Prevents zoom on iOS */
  }
}
