/* Mobile and PWA Enhancements */

/* Prevent horizontal scrolling on mobile */
html, body {
  overflow-x: hidden;
  width: 100%;
  position: relative;
}

/* Touch feedback */
.touch-active {
  transform: scale(0.95);
  opacity: 0.8;
  transition: all 0.1s ease;
}

/* Pull to refresh indicator */
#pull-to-refresh {
  z-index: 9999;
  transform-origin: top center;
}

/* Keyboard adjustments */
.keyboard-open {
  position: fixed;
  width: 100%;
  overflow: hidden;
}

/* Mobile navigation optimizations */
@media (max-width: 768px) {
  .navbar-nav {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 0.5rem;
  }

  .navbar-nav .nav-link {
    white-space: nowrap;
    font-size: 0.9rem;
  }

  .navbar-brand {
    font-size: 1.1rem;
  }

  /* Publication name in navbar - mobile optimizations */
  .navbar-brand .navbar-publication-name {
    font-size: 1.1rem !important;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  
  /* Scale down logo slightly on mobile */
  .navbar-brand img {
    width: 50px !important;
    height: 50px !important;
  }
  
  .container {
    padding-left: 10px;
    padding-right: 10px;
  }

  .card {
    margin-bottom: 1rem;
    border-radius: 0.5rem;
  }

  .btn {
    min-height: 44px; /* iOS touch target minimum */
  }
}

/* Tablet optimization */
@media (min-width: 769px) and (max-width: 991px) {
  .navbar-brand .navbar-publication-name {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* PWA install prompt */
.position-fixed.bottom-0.end-0.m-3 {
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Mobile search */
.mobile-search {
  position: sticky;
  top: 0;
  z-index: 100;
  background: white;
  border-bottom: 1px solid #dee2e6;
}

.search-results {
  max-height: 60vh;
  overflow-y: auto;
  background: white;
  border-top: 1px solid #dee2e6;
}

/* Mobile upload */
.upload-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: #0d6efd;
  z-index: 9999;
  transform-origin: left;
  transition: width 0.3s ease;
}

/* Mobile cards */
.mobile-card {
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 0.75rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.mobile-card:active {
  transform: scale(0.98);
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Offline banner */
#offline-banner {
  animation: slideDown 0.3s ease;
}

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

/* Toast notifications */
.position-fixed.bottom-0.end-0.m-3.toast {
  animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Mobile grid optimizations */
@media (max-width: 768px) {
  .row > * {
    margin-bottom: 1rem;
  }
}

/* Mobile tables */
@media (max-width: 768px) {
  .table-responsive {
    font-size: 0.9rem;
  }
  
  .table th, .table td {
    padding: 0.5rem;
  }
}

/* Mobile forms */
@media (max-width: 768px) {
  .form-control {
    font-size: 16px; /* Prevents zoom on iOS */
    min-height: 44px;
  }
  
  .form-label {
    margin-bottom: 0.5rem;
    font-weight: 500;
  }
}

/* Connection status */
#connection-status {
  font-size: 0.8rem;
  padding: 0.25rem 0.5rem;
  border-radius: 1rem;
  background: rgba(255,255,255,0.9);
}

/* PWA manifest link */
.pwa-install-hint {
  position: fixed;
  bottom: 70px;
  right: 20px;
  background: #0d6efd;
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 2rem;
  font-size: 0.8rem;
  z-index: 9998;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

/* Mobile image viewer */
.mobile-image-viewer {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.9);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-image-viewer img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* Pagination mobile optimization */
@media (max-width: 768px) {
  .pagination {
    flex-wrap: wrap;
    justify-content: center;
  }
  
  .pagination .page-item {
    margin: 0.2rem;
  }
  
  .pagination .page-link {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* Dark mode support disabled - app always uses light mode */

/* Safe area insets for iPhone X+ */
@supports (padding: max(0px)) {
  .container {
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
  }

  .navbar {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }
}

/* Device-specific enhancements */
.device-ios input,
.device-ios select,
.device-ios textarea {
  font-size: 16px !important; /* Prevents zoom on focus */
}

.has-notch #camera-modal .modal-header {
  padding-top: calc(env(safe-area-inset-top, 0px) + 70px);
}

.device-small-phone .btn {
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
}

.device-tablet .viewfinder-frame {
  border-width: 3px;
}

.device-android .camera-controls {
  /* Android-specific adjustments if needed */
}