/* Mobile Optimization and Progressive Loading Styles */

/* =================================
   Mobile-First Responsive Design
   ================================= */

/* Base mobile styles (320px and up) */
@media (max-width: 575.98px) {
  /* Navigation optimizations */
  .navbar-nav {
    padding: 0.5rem 0;
  }
  
  .navbar-nav .nav-link {
    padding: 0.75rem 1rem;
    font-size: 1.1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }
  
  .dropdown-menu {
    border-radius: 0;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  }
  
  /* Hero sections */
  .hero-section {
    padding: 2rem 0;
  }
  
  .hero-section h1 {
    font-size: 2rem;
    line-height: 1.2;
  }
  
  .hero-section .lead {
    font-size: 1rem;
  }
  
  /* Card optimizations */
  .card {
    margin-bottom: 1rem;
    border-radius: 0.5rem;
  }
  
  .card-header {
    padding: 0.75rem 1rem;
  }
  
  .card-body {
    padding: 1rem;
  }
  
  /* Button optimizations */
  .btn {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    border-radius: 0.5rem;
    min-height: 44px; /* Touch target size */
  }
  
  .btn-lg {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    min-height: 48px;
  }
  
  /* Form optimizations */
  .form-control {
    padding: 0.75rem;
    font-size: 1rem;
    border-radius: 0.5rem;
    min-height: 44px;
  }
  
  .form-select {
    padding: 0.75rem;
    font-size: 1rem;
    min-height: 44px;
  }
  
  /* Simulation interface mobile optimizations */
  .simulation-card {
    margin-bottom: 1rem;
  }
  
  .decision-option {
    padding: 1rem;
    margin-bottom: 0.5rem;
    border-radius: 0.5rem;
    min-height: 60px;
    display: flex;
    align-items: center;
  }
  
  .cultural-insights-sidebar {
    margin-top: 2rem;
  }
  
  /* Progress bars */
  .progress {
    height: 8px;
    border-radius: 4px;
  }
  
  /* Tables */
  .table-responsive {
    border-radius: 0.5rem;
  }
  
  /* Spacing adjustments */
  .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  
  .py-5 {
    padding-top: 2rem !important;
    padding-bottom: 2rem !important;
  }
  
  .mb-5 {
    margin-bottom: 2rem !important;
  }
}

/* Tablet styles (576px to 991.98px) */
@media (min-width: 576px) and (max-width: 991.98px) {
  .simulation-sidebar {
    margin-top: 2rem;
  }
  
  .cultural-comparison-form {
    padding: 1.5rem;
  }
  
  .country-select-container {
    margin-bottom: 1.5rem;
  }
}

/* =================================
   Progressive Loading Components
   ================================= */

/* Skeleton loading states */
.skeleton {
  background: linear-gradient(90deg, 
    rgba(255, 255, 255, 0.1) 25%, 
    rgba(255, 255, 255, 0.2) 50%, 
    rgba(255, 255, 255, 0.1) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: 0.375rem;
}

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

.skeleton-text {
  height: 1rem;
  margin-bottom: 0.5rem;
}

.skeleton-text.wide {
  width: 100%;
}

.skeleton-text.medium {
  width: 75%;
}

.skeleton-text.narrow {
  width: 50%;
}

.skeleton-card {
  height: 200px;
  margin-bottom: 1rem;
}

.skeleton-button {
  height: 2.5rem;
  width: 8rem;
  margin-right: 0.5rem;
}

/* Loading states for simulation components */
.simulation-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem;
  text-align: center;
}

.simulation-loading .spinner-border {
  width: 3rem;
  height: 3rem;
  margin-bottom: 1rem;
}

.simulation-loading .loading-text {
  color: var(--bs-text-muted);
  font-size: 0.9rem;
}

/* Progressive image loading */
.progressive-image {
  position: relative;
  overflow: hidden;
  background-color: #f8f9fa;
}

.progressive-image img {
  width: 100%;
  height: auto;
  transition: opacity 0.3s ease;
}

.progressive-image.loading img {
  opacity: 0;
}

.progressive-image.loaded img {
  opacity: 1;
}

.progressive-image::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, 
    rgba(255, 255, 255, 0.1) 25%, 
    rgba(255, 255, 255, 0.2) 50%, 
    rgba(255, 255, 255, 0.1) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
}

.progressive-image.loaded::before {
  display: none;
}

/* =================================
   Touch and Gesture Optimizations
   ================================= */

/* Improve touch targets */
.touch-target {
  min-height: 44px;
  min-width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Swipe indicators for mobile carousels */
.swipe-indicator {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.5rem;
  z-index: 10;
}

.swipe-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.5);
  transition: background-color 0.3s ease;
}

.swipe-dot.active {
  background-color: rgba(255, 255, 255, 0.9);
}

/* Pull-to-refresh indicator */
.pull-to-refresh {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: linear-gradient(to bottom, 
    rgba(13, 110, 253, 0.1), 
    rgba(13, 110, 253, 0.05)
  );
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateY(-100%);
  transition: transform 0.3s ease;
  z-index: 1050;
}

.pull-to-refresh.visible {
  transform: translateY(0);
}

.pull-to-refresh .spinner-border {
  width: 1.5rem;
  height: 1.5rem;
}

/* =================================
   Accessibility Enhancements
   ================================= */

/* Focus indicators for keyboard navigation */
.btn:focus,
.form-control:focus,
.form-select:focus {
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
  border-color: #86b7fe;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .card {
    border: 2px solid var(--bs-border-color);
  }
  
  .btn {
    border: 2px solid currentColor;
  }
  
  .form-control {
    border: 2px solid var(--bs-border-color);
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .skeleton {
    animation: none;
  }
  
  .progressive-image::before {
    animation: none;
  }
  
  * {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* =================================
   Performance Optimizations
   ================================= */

/* Contain layout for better performance */
.simulation-card,
.cultural-insight-card,
.progress-tracker {
  contain: layout style;
}

/* GPU acceleration for animations */
.skeleton,
.progressive-image::before {
  transform: translateZ(0);
  will-change: background-position;
}

/* Lazy loading support */
.lazy-load {
  opacity: 0;
  transition: opacity 0.3s ease;
}

.lazy-load.loaded {
  opacity: 1;
}

/* =================================
   Dark Theme Mobile Optimizations
   ================================= */

@media (max-width: 575.98px) {
  .card.bg-dark {
    border: 1px solid rgba(255, 255, 255, 0.125);
  }
  
  .modal-content {
    background-color: var(--bs-dark);
    color: var(--bs-light);
  }
  
  .dropdown-menu {
    background-color: var(--bs-dark);
    border: 1px solid rgba(255, 255, 255, 0.125);
  }
  
  .dropdown-item {
    color: var(--bs-light);
  }
  
  .dropdown-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--bs-light);
  }
}