body {
  padding-top: 0;
  background-color: #f8f9fa;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Hero Section Styles */
.hero-section {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  position: relative;
  overflow: hidden;
}

.hero-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.1);
  z-index: 1;
}

.hero-section .container {
  position: relative;
  z-index: 2;
}

.hero-section h1 {
  font-weight: 700;
  text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.hero-section .lead {
  font-size: 1.25rem;
  font-weight: 400;
  opacity: 0.95;
}

.hero-section .alert-light {
  background-color: rgba(255, 255, 255, 0.95);
  border: none;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

#heroFeatures .col-md-4 {
  color: rgba(255, 255, 255, 0.9);
  font-weight: 500;
}

#heroFeatures i {
  opacity: 0.9;
}

.card {
  border: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  margin-bottom: 1.5rem;
  border-radius: 0.75rem;
  transition: box-shadow 0.3s ease;
}

.card:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}

.card-body {
  padding: 2rem;
}

.card-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: 0.75rem 0.75rem 0 0 !important;
  padding: 1.25rem 2rem;
}

.card-header h4 {
  font-weight: 600;
  margin: 0;
}

.border-primary {
  border-color: #667eea !important;
}

.form-check {
  margin-bottom: 0.75rem;
}

.form-check-label {
  cursor: pointer;
  font-weight: 400;
}

.form-check-input:checked {
  background-color: #667eea;
  border-color: #667eea;
}

.form-select {
  border-radius: 0.5rem;
  border: 2px solid #e9ecef;
  transition: border-color 0.3s ease, box-shadow 0.3s ease, color 0.3s ease;
  font-size: 0.95rem;
  padding: 0.75rem 1rem;
}

.form-select:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

/* Gray out selects that haven't been answered by user */
.form-select.not-answered {
  color: #adb5bd;
}

/* Black text for user-answered selects */
.form-select.user-answered {
  color: #212529;
  font-weight: 500;
}

.border-start.border-3.border-primary {
  border-color: #667eea !important;
  border-width: 4px !important;
  padding-left: 1.5rem !important;
  background: rgba(102, 126, 234, 0.03);
  border-radius: 0 0.5rem 0.5rem 0;
  margin-bottom: 1rem;
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.card-title {
  color: #495057;
  font-weight: 600;
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

.question-section-instruction {
  font-weight: 500;
  color: #6c757d;
  margin-bottom: 1.5rem;
  font-style: italic;
}

h6.mb-2 {
  font-weight: 500;
  color: #495057;
  line-height: 1.4;
}

#resultsContainer .card {
  background: white;
  color: #495057;
  border: 1px solid #dee2e6;
}

#resultsContainer .card h3,
#resultsContainer .card h1,
#resultsContainer .card p {
  color: #495057;
}

.table {
  background-color: white;
  border-radius: 0.5rem;
  overflow: hidden;
}

.table th {
  background-color: #495057;
  color: white;
  border: none;
}

.table td {
  border-color: #dee2e6;
}

.badge {
  font-size: 0.85em;
}

#quizContainer h1 {
  color: #495057;
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  padding: 0.75rem 2rem;
  font-weight: 500;
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
  transition: all 0.3s ease;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0,0,0,0.3);
}

.btn-primary:focus {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  box-shadow: 0 4px 8px rgba(0,0,0,0.2), 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

.btn-secondary {
  padding: 0.75rem 2rem;
  font-weight: 500;
}

/* Progress Bar Styles */
.progress-container {
  background: linear-gradient(135deg, #fff 0%, #f8f9fa 100%);
  padding: 1.5rem;
  border-radius: 0.75rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  border: 1px solid rgba(102, 126, 234, 0.1);
  position: sticky;
  top: 1rem;
  z-index: 1000;
  margin-bottom: 2rem;
  width: 100vw;
  margin-left: calc(-50vw + 50%);
  margin-right: calc(-50vw + 50%);
}

.progress-label {
  font-weight: 600;
  color: #495057;
  font-size: 0.95rem;
}

.progress-text {
  font-size: 0.9rem;
  color: #6c757d;
  font-weight: 500;
}

.progress {
  border-radius: 10px;
  background-color: #e9ecef;
  overflow: hidden;
}

.progress-bar {
  background: linear-gradient(90deg, #dc3545 0%, #c82333 100%) !important;
  border-radius: 10px;
  transition: width 0.4s ease-in-out;
  position: relative;
}

/* Ensure cross-browser compatibility for progress bar color */
.progress-bar::-webkit-progress-bar {
  background-color: #e9ecef;
}

.progress-bar::-webkit-progress-value {
  background: linear-gradient(90deg, #dc3545 0%, #c82333 100%) !important;
}

.progress-bar::-moz-progress-bar {
  background: linear-gradient(90deg, #dc3545 0%, #c82333 100%) !important;
}

.progress-bar-animated {
  animation: progress-bar-stripes 1s linear infinite;
}

@keyframes progress-bar-stripes {
  0% {
    background-position: 0 0;
  }
  100% {
    background-position: 40px 0;
  }
}

/* Enhanced progress bar on completion */
.progress-complete .progress-bar {
  background: linear-gradient(90deg, #28a745 0%, #20c997 100%);
  animation: none;
}

/* Validation styles for missing questions */
.question-missing {
  border: 2px solid #dc3545 !important;
  background-color: rgba(220, 53, 69, 0.1) !important;
  animation: shake 0.5s ease-in-out;
}

.question-missing .card-header {
  background: linear-gradient(135deg, #dc3545 0%, #c82333 100%) !important;
}

.question-missing .form-select {
  border-color: #dc3545 !important;
  box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25) !important;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.validation-message {
  background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
  color: white;
  padding: 1rem;
  border-radius: 0.5rem;
  margin-bottom: 1rem;
  font-weight: 500;
  border: none;
  box-shadow: 0 4px 8px rgba(220, 53, 69, 0.3);
}

.validation-message .btn-close {
  filter: brightness(0) invert(1);
}

.progress-complete .progress-bar::after {
  content: "✓";
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: white;
  font-weight: bold;
  font-size: 0.75rem;
}

/* Modal Styles */
.modal-dialog {
  max-width: 90vw;
}

.modal-body {
  max-height: 80vh;
  overflow: auto;
  padding: 1rem;
}

.modal-body img {
  max-width: 100%;
  height: auto;
  border-radius: 0.5rem;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  display: block;
  margin: 0 auto;
}

.resource-link {
  background: none !important;
  border: none !important;
  text-align: left !important;
  cursor: pointer;
}

.resource-link:hover {
  text-decoration: underline !important;
}

/* Fix modal z-index and backdrop issues */
.modal {
  z-index: 1055 !important;
}

.modal-backdrop {
  z-index: 1050 !important;
}

.modal.fade {
  transition: opacity 0.15s linear;
}

.modal.fade .modal-dialog {
  transition: transform 0.3s ease-out;
  transform: translate(0, -50px);
}

.modal.show .modal-dialog {
  transform: none;
}

/* Ensure proper modal cleanup */
body.modal-open {
  overflow: hidden !important;
}

/* Carousel Modal Styles */
#imageModal .modal-body {
  padding: 0;
  background-color: #000;
  touch-action: manipulation; /* Improve touch responsiveness */
}

#imageModal .carousel {
  background-color: #000;
  touch-action: pan-y pinch-zoom; /* Allow vertical scrolling and pinch zoom but handle horizontal swipes */
}

#imageModal .carousel-item img {
  border-radius: 0;
  box-shadow: none;
  background-color: #000;
  user-select: none; /* Prevent image selection on touch devices */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

#imageModal .carousel-control-prev,
#imageModal .carousel-control-next {
  background-color: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  border: 2px solid rgba(255, 255, 255, 0.3);
  transition: all 0.3s ease;
}

#imageModal .carousel-control-prev:hover,
#imageModal .carousel-control-next:hover {
  background-color: rgba(0, 0, 0, 0.7);
  border-color: rgba(255, 255, 255, 0.6);
}

#imageModal .carousel-control-prev {
  left: 15px;
}

#imageModal .carousel-control-next {
  right: 15px;
}

#imageModal .carousel-indicators {
  margin-bottom: 15px;
  z-index: 10;
}

#imageModal .carousel-indicators button {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin: 0 3px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  background-color: rgba(255, 255, 255, 0.3);
}

#imageModal .carousel-indicators button.active {
  background-color: rgba(255, 255, 255, 0.9);
  border-color: rgba(255, 255, 255, 0.9);
}

/* Enhanced mobile touch support */
@media (max-width: 768px) {
  #imageModal .carousel-control-prev,
  #imageModal .carousel-control-next {
    width: 60px;
    height: 60px;
    background-color: rgba(0, 0, 0, 0.6);
    border-width: 3px;
  }
  
  #imageModal .carousel-control-prev {
    left: 10px;
  }
  
  #imageModal .carousel-control-next {
    right: 10px;
  }
  
  #imageModal .carousel-indicators button {
    width: 15px;
    height: 15px;
    margin: 0 5px;
  }
  
  /* Ensure proper touch target sizes */
  #imageModal .carousel-indicators {
    padding: 10px 0;
  }
  
  /* Improve swipe detection area */
  #imageModal .carousel-inner {
    min-height: 200px;
  }
}

#carouselInfo {
  display: flex;
  align-items: center;
}

#carouselCounter {
  font-weight: 500;
  color: #6c757d;
}

/* Action buttons container styles */
#actionButtonsContainer {
  gap: 1rem;
}

#actionButtonsContainer .btn {
  min-width: 160px;
  padding: 0.75rem 1.5rem;
  font-weight: 500;
}

#downloadResults {
  background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
  border: none;
  box-shadow: 0 4px 8px rgba(40, 167, 69, 0.3);
  transition: all 0.3s ease;
}

#downloadResults:hover {
  background: linear-gradient(135deg, #218838 0%, #1da88a 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(40, 167, 69, 0.4);
}

#downloadResults:disabled {
  background: #6c757d;
  transform: none;
  box-shadow: none;
  cursor: not-allowed;
}

/* Temporary message styles */
.temporary-message {
  animation: slideInRight 0.3s ease-out;
}

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

/* Mobile responsive adjustments for action buttons */
@media (max-width: 768px) {
  #actionButtonsContainer {
    flex-direction: column;
    align-items: center;
  }
  
  #actionButtonsContainer .btn {
    width: 100%;
    max-width: 300px;
  }
}

/* Footer Styles */
#siteFooter {
  background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
  border-top: 3px solid #667eea;
  margin-top: auto;
}

#footerLinks a {
  transition: all 0.3s ease;
  padding: 0.5rem 0;
  font-weight: 500;
}

#footerLinks a:hover {
  color: #667eea !important;
  transform: translateY(-1px);
}

#footerLinks i {
  opacity: 0.8;
}

#footerCopyright {
  font-size: 0.875rem;
  opacity: 0.7;
}

/* Prevent modal backdrop issues on mobile */
@media (max-width: 768px) {
  .modal {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
  
  .modal-backdrop {
    position: fixed !important;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
  }
}

@media (max-width: 768px) {
  .container {
    padding: 0 15px;
  }
  
  .card-body {
    padding: 1rem;
  }
  
  .progress-container {
    padding: 1rem;
    top: 0.5rem;
    margin-bottom: 1.5rem;
    width: 100vw;
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
  }
  
  .progress-label,
  .progress-text {
    font-size: 0.85rem;
  }
  
  .modal-dialog {
    max-width: 95vw;
    margin: 1rem auto;
  }
  
  /* Footer mobile styles */
  #footerLinks {
    flex-direction: column;
    gap: 0.75rem !important;
  }
  
  #footerLinksColumn,
  #footerCopyrightColumn {
    text-align: center !important;
  }
}
