:root {
  --bs-primary: #0066cc;
  --bs-primary-rgb: 0, 102, 204;
  --mobile-header-height: 60px;
  --mobile-safe-area-top: env(safe-area-inset-top, 0px);
  --mobile-safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

/* PWA and Mobile Optimizations */
* {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

html {
  touch-action: manipulation;
}

body {
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
}

/* Mobile Login Styles */
.mobile-login {
  background: linear-gradient(135deg, #0066cc 0%, #004499 100%);
  min-height: 100vh;
  min-height: 100dvh;
}

.login-header {
  padding-top: calc(2rem + var(--mobile-safe-area-top));
  color: white;
}

.app-icon {
  width: 80px;
  height: 80px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
}

.mobile-card {
  border-radius: 20px;
  backdrop-filter: blur(10px);
  background: rgba(255, 255, 255, 0.95);
}

.mobile-input {
  border-radius: 12px;
  border: 2px solid #e9ecef;
  padding: 0.75rem 1rem;
  font-size: 16px; /* Prevents zoom on iOS */
}

.mobile-input:focus {
  border-color: var(--bs-primary);
  box-shadow: 0 0 0 0.2rem rgba(0, 102, 204, 0.25);
}

.mobile-btn {
  border-radius: 12px;
  padding: 0.875rem 1.5rem;
  font-weight: 600;
  font-size: 16px;
  min-height: 50px;
}

.mobile-alert {
  border-radius: 12px;
  border: none;
  font-size: 14px;
}

/* Mobile Dashboard Styles */
.mobile-dashboard {
  background-color: #f8f9fa;
  padding-top: var(--mobile-safe-area-top);
  padding-bottom: var(--mobile-safe-area-bottom);
}

.mobile-navbar {
  min-height: var(--mobile-header-height);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.mobile-search {
  background: rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10px);
}

.mobile-content {
  min-height: calc(100vh - var(--mobile-header-height));
  min-height: calc(100dvh - var(--mobile-header-height));
}

/* Stats Section */
.stats-section {
  border-bottom: 1px solid #dee2e6;
}

.stat-card {
  background: white;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.stat-number {
  font-size: 1.5rem;
  line-height: 1;
}

.stat-label {
  margin-top: 0.25rem;
}

/* Document Cards */
.document-card {
  background: white;
  border-radius: 12px;
  margin-bottom: 1rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  border: 1px solid #e9ecef;
  transition: all 0.2s ease;
}

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

.document-header {
  padding: 1rem;
  border-bottom: 1px solid #f1f3f4;
}

.document-title {
  font-size: 1rem;
  font-weight: 600;
  color: #212529;
  margin-bottom: 0.25rem;
  line-height: 1.3;
}

.document-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.document-body {
  padding: 0 1rem 1rem;
}

.document-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

/* Mobile Badges */
.badge {
  font-size: 0.7rem;
  padding: 0.35em 0.6em;
  border-radius: 6px;
}

/* Mobile Buttons */
.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8rem;
  border-radius: 8px;
  min-height: 36px;
}

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

.pagination-controls {
  display: flex;
  align-items: center;
}

/* Install Prompt */
.install-prompt {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1050;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.05);
  backdrop-filter: blur(10px);
}

/* Offline Indicator */
.offline-indicator {
  position: fixed;
  top: var(--mobile-header-height);
  left: 0;
  right: 0;
  z-index: 1040;
}

/* Modal Optimizations */
.modal-fullscreen-sm-down {
  margin: 0;
}

@media (max-width: 575.98px) {
  .modal-fullscreen-sm-down .modal-dialog {
    width: 100vw;
    height: 100vh;
    margin: 0;
    border-radius: 0;
  }

  .modal-fullscreen-sm-down .modal-content {
    height: 100vh;
    border-radius: 0;
  }
}

/* Touch Optimizations */
.btn,
.form-control,
.dropdown-toggle {
  min-height: 44px; /* Apple's recommended touch target size */
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 102, 204, 0.3);
  border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 102, 204, 0.5);
}

/* Loading States */
.loading-shimmer {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

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

/* Responsive Typography */
@media (max-width: 576px) {
  .display-1 {
    font-size: 3rem;
  }
  .h1,
  h1 {
    font-size: 1.75rem;
  }
  .h2,
  h2 {
    font-size: 1.5rem;
  }
  .h3,
  h3 {
    font-size: 1.25rem;
  }
  .h4,
  h4 {
    font-size: 1.1rem;
  }
  .h5,
  h5 {
    font-size: 1rem;
  }
}

/* Safe Area Support */
@supports (padding: max(0px)) {
  .mobile-login {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }

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