/* Optimized CSS for faster loading and mobile-first responsive design */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  color: #333;
  background-color: #fff;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  overflow-x: hidden;
}

/* Mobile-first navigation */
nav {
  background-color: #333;
  padding: 0.5rem 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  position: sticky;
  top: 0;
  z-index: 1000;
}

nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

nav a {
  color: white;
  text-decoration: none;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  transition: all 0.2s ease;
  display: block;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

nav a:hover, nav a:focus {
  color: #007bff;
  background-color: rgba(255,255,255,0.1);
}

/* Active page indicator */
nav a.active {
  color: #007bff !important;
  font-weight: 600;
  background-color: rgba(0,123,255,0.1);
  border-bottom: 2px solid #007bff;
}

/* Mobile menu toggle button */
.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 4px;
  transition: background-color 0.2s ease;
  min-height: 44px;
  min-width: 44px;
}

.mobile-menu-toggle:hover {
  background-color: rgba(255,255,255,0.1);
}

.mobile-menu-toggle:focus {
  outline: 2px solid #007bff;
  outline-offset: 2px;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Mobile-first typography */
h1 {
  color: #333;
  margin: 1.5rem 0;
  text-align: center;
  font-size: 1.8rem;
  font-weight: 600;
  line-height: 1.2;
}

h2 {
  color: #555;
  margin: 1.25rem 0;
  font-size: 1.5rem;
  font-weight: 600;
}

h3 {
  color: #666;
  margin: 1rem 0;
  font-size: 1.25rem;
  font-weight: 600;
}

/* Mobile-first form design */
form {
  background: #f8f9fa;
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  margin-bottom: 1.5rem;
}

label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: #555;
  font-size: 0.95rem;
}

input[type="text"], input[type="file"] {
  width: 100%;
  padding: 0.875rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 1rem;
  margin-bottom: 1rem;
  box-sizing: border-box;
  min-height: 48px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="text"]:focus, input[type="file"]:focus {
  border-color: #007bff;
  box-shadow: 0 0 0 3px rgba(0,123,255,0.1);
  outline: none;
}

input[type="radio"] {
  margin-right: 0.5rem;
  transform: scale(1.2);
  min-height: 20px;
  min-width: 20px;
}

/* Radio button labels */
input[type="radio"] + label {
  display: inline;
  margin-left: 0.5rem;
  font-weight: normal;
}

/* Radio group styling */
.radio-group {
  margin: 1rem 0;
}

.radio-label {
  display: flex;
  align-items: center;
  margin-bottom: 0.75rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.radio-label:hover {
  background-color: rgba(0,123,255,0.05);
}

.radio-label span {
  margin-left: 0.5rem;
  font-weight: normal;
}

/* Mobile-optimized buttons */
.btn, button {
  display: inline-block;
  padding: 0.875rem 1.5rem;
  background-color: #007bff;
  color: white;
  text-decoration: none;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  box-sizing: border-box;
  min-height: 48px;
  min-width: 120px;
  text-align: center;
  line-height: 1.2;
}

.btn:hover, button:hover {
  background-color: #0056b3;
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.btn:active, button:active {
  transform: translateY(1px);
}

/* Button variants */
.btn-light {
  background-color: white;
  color: #667eea;
  border: 2px solid white;
}

.btn-light:hover {
  background-color: #f8f9fa;
  color: #5a6fd8;
}

.btn-primary {
  background-color: #007bff;
}

/* File input styling */
.file-input-container {
  margin-bottom: 1.5rem;
}

.file-input-button {
  background-color: #6c757d;
  margin-right: 0.5rem;
}

.file-name-display {
  margin-top: 0.5rem;
  padding: 0.5rem;
  background-color: #e9ecef;
  border-radius: 4px;
  font-size: 0.9rem;
  color: #495057;
  word-break: break-all;
}

/* MGRS options grid */
#mgrs-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin: 1rem 0;
}

.mgrs-input-group {
  display: flex;
  flex-direction: column;
}

.mgrs-input-group label {
  margin-bottom: 0.5rem;
}

/* Progress indicator */
#progress {
  background: #f8f9fa;
  padding: 1.5rem;
  border-radius: 8px;
  margin: 1.5rem 0;
}

.progress-container {
  background-color: #f0f0f0;
  border-radius: 4px;
  padding: 10px;
  margin-bottom: 1rem;
}

#progressBar {
  background: linear-gradient(90deg, #007bff, #0056b3);
  height: 20px;
  width: 0%;
  border-radius: 4px;
  transition: width 0.3s ease;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

#result {
  background: #d4edda;
  border: 1px solid #c3e6cb;
  color: #155724;
  padding: 1.5rem;
  border-radius: 8px;
  text-align: center;
  margin: 1.5rem 0;
}

/* Content sections */
.intro-section, .seo-content, .professional-applications, .educational-resources, .related-tools {
  margin: 1.5rem 0;
  padding: 1.5rem;
  border-radius: 8px;
}

.intro-section {
  background-color: #f8f9fa;
}

.seo-content {
  background-color: #f8f9fa;
}

.professional-applications {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.educational-resources {
  background-color: #e9ecef;
}

.related-tools {
  background-color: #e9ecef;
}

/* Grid layouts for different screen sizes */
.professional-applications .grid-container,
.educational-resources .grid-container {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 1fr;
}

/* Industry and resource cards */
.industry-card, .resource-card {
  padding: 1rem;
  border-radius: 6px;
  background-color: rgba(255,255,255,0.1);
  backdrop-filter: blur(10px);
}

.resource-card {
  background-color: rgba(255,255,255,0.8);
  color: #333;
}

/* Lists styling */
ul, ol {
  padding-left: 1.5rem;
  margin: 1rem 0;
}

li {
  margin-bottom: 0.5rem;
  line-height: 1.5;
}

/* Links */
a {
  color: #007bff;
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: #0056b3;
  text-decoration: underline;
}

/* Responsive breakpoints */
@media (min-width: 576px) {
  .container {
    padding: 0 1.5rem;
  }
  
  h1 {
    font-size: 2rem;
  }
  
  form {
    padding: 2rem;
  }
  
  #mgrs-options {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 768px) {
  nav {
    padding: 1rem 2rem;
  }
  
  nav ul {
    gap: 2rem;
  }
  
  h1 {
    font-size: 2.25rem;
    margin: 2rem 0;
  }
  
  h2 {
    font-size: 1.75rem;
    margin: 1.5rem 0;
  }
  
  .professional-applications .grid-container,
  .educational-resources .grid-container {
    grid-template-columns: 1fr 1fr;
  }
  
  .intro-section, .seo-content, .professional-applications, .educational-resources, .related-tools {
    padding: 2rem;
    margin: 2rem 0;
  }
}

@media (min-width: 992px) {
  .container {
    max-width: 1000px;
  }
  
  h1 {
    font-size: 2.5rem;
  }
  
  .professional-applications .grid-container,
  .educational-resources .grid-container {
    grid-template-columns: 1fr 1fr 1fr 1fr;
  }
}

@media (min-width: 1200px) {
  .container {
    max-width: 1200px;
  }
  
  .professional-applications .grid-container,
  .educational-resources .grid-container {
    grid-template-columns: 1fr 1fr 1fr 1fr;
  }
}

/* Mobile-specific styles */
@media (max-width: 480px) {
  .mobile-menu-toggle {
    display: block;
  }
  
  nav ul {
    display: none;
    flex-direction: column;
    width: 100%;
    gap: 0;
    margin-top: 1rem;
  }
  
  nav ul.mobile-open {
    display: flex;
  }
  
  nav ul li {
    width: 100%;
  }
  
  nav ul li a {
    width: 100%;
    text-align: center;
    border-radius: 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
  }
  
  nav ul li:last-child a {
    border-bottom: none;
  }
  
  .container {
    padding: 0 0.5rem;
  }
  
  h1 {
    font-size: 1.6rem;
    margin: 1rem 0;
  }
  
  h2 {
    font-size: 1.3rem;
    margin: 1rem 0;
  }
  
  form {
    padding: 1rem;
  }
  
  .intro-section, .seo-content, .professional-applications, .educational-resources, .related-tools {
    padding: 1rem;
    margin: 1rem 0;
  }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
  /* Touch devices */
  .btn, button {
    min-height: 56px;
    min-width: 140px;
    font-size: 1.1rem;
  }
  
  input[type="text"], input[type="file"] {
    min-height: 56px;
    font-size: 1.1rem;
  }
  
  nav a {
    min-height: 56px;
    padding: 0.75rem 1rem;
  }
  
  /* Increase touch targets */
  input[type="radio"] {
    min-height: 24px;
    min-width: 24px;
  }
  
  .radio-label {
    min-height: 56px;
    padding: 0.75rem;
  }
  
  .mobile-menu-toggle {
    min-height: 56px;
    min-width: 56px;
    font-size: 1.8rem;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .btn, button {
    border: 2px solid #000;
  }
  
  input[type="text"], input[type="file"] {
    border: 2px solid #000;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* Focus states for accessibility */
input:focus, button:focus, a:focus {
  outline: 2px solid #007bff;
  outline-offset: 2px;
}

/* Loading states */
.loading {
  opacity: 0.6;
  pointer-events: none;
}

/* Print styles */
@media print {
  nav, .sidebar-ad, .btn, button, .mobile-menu-toggle {
    display: none !important;
  }
  
  body {
    font-size: 12pt;
    line-height: 1.4;
  }
  
  h1, h2, h3 {
    page-break-after: avoid;
  }
}
