/* Base variables */
:root {
  --primary: #0f2bab;
  --primary-dark: #0a1f7d;
  --primary-light: #3a51c6;
  --secondary: #ff3b30;
  --dark: #333333;
  --light: #f8f9fa;
  --gray: #6c757d;
  --gray-light: #e9ecef;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.1);
  --transition-normal: all 0.2s ease;
  --white: #ffffff;
}

/* Map container */
#map {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1;
  width: 100vw;
  height: 100vh;       /* fallback */
  height: 100dvh;      /* modern dynamic viewport */
  touch-action: pan-x pan-y pinch-zoom;
  -webkit-user-select: none;
  user-select: none;
  will-change: transform;
}

/* Preloader - full screen */
#preloader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url('https://www.mnthen.com/images/header/mnthen_splash_page.webp'); 
  background-size: cover;
  background-position: center;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  color: white;
  font-family: 'Montserrat', sans-serif;
}

/* Darker overlay */
#preloader::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: -1;
}

/* Simple content container */
.preloader-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 80%;
  text-align: center;
  padding: 40px;
  border-radius: 12px;
  background-color: rgba(20, 20, 20, 0.4);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

/* Logo */
#preloader .logo {
  width: 140px;
  height: auto;
  margin-bottom: 25px;
}

/* Title */
#preloader h1 {
  font-size: 48px;
  font-weight: 800;
  margin-bottom: 15px;
  color: #ffffff;
}

/* Tagline */
#preloader h2 {
  font-size: 20px;
  font-weight: 400;
  margin-bottom: 40px;
  max-width: 700px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.9);
}

/* Loading text */
#preloader p {
  margin-top: 20px;
  font-size: 16px;
  color: rgba(255, 255, 255, 0.85);
  font-style: italic; 
  font-weight: 600;
}

/* Progress container */
#preloader .progress-container {
  width: 90%;
  max-width: 320px;
  height: 6px;
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  margin-top: 30px;
  overflow: hidden;
}

/* Progress bar */
#preloader .progress-bar {
  height: 100%;
  background: #ffffff;
  width: 0;
  transition: width 0.4s ease;
  border-radius: 6px;
}

/* Status message */
#preloader .status-message {
  margin-top: 15px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  #preloader h1 {
    font-size: 36px;
  }
  
  #preloader h2 {
    font-size: 18px;
    margin-bottom: 30px;
  }
  
  .preloader-content {
    padding: 30px;
    max-width: 90%;
  }
}

@media (max-width: 480px) {
  #preloader h1 {
    font-size: 30px;
  }
  
  #preloader h2 {
    font-size: 16px;
  }
  
  .preloader-content {
    padding: 20px;
    max-width: 95%;
  }
}

/* User marker styling with pulse effect */
.user-marker {
  z-index: 1000;
}

.user-marker-icon {
  width: 16px;
  height: 16px;
  background-color: var(--secondary);
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
  position: relative;
}

/* Double pulse effect with two ::before and ::after elements */
.user-marker-icon::before,
.user-marker-icon::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 100, 100, 0.6);
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(1.5);
  z-index: -1;
}

.user-marker-icon::before {
  animation: pulse1 4.5s infinite; 
}

.user-marker-icon::after {
  animation: pulse2 4.5s infinite; 
  animation-delay: 2.5s; 
}

@keyframes pulse1 {
  0% {
    transform: translate(-50%, -50%) scale(1.5);
    opacity: 0.8;
  }
  100% {
    transform: translate(-50%, -50%) scale(3.5);
    opacity: 0;
  }
}

@keyframes pulse2 {
  0% {
    transform: translate(-50%, -50%) scale(1.5);
    opacity: 0.8;
  }
  100% {
    transform: translate(-50%, -50%) scale(3.5);
    opacity: 0;
  }
}

/* Loading and stabilizing modals */
.stabilizing-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: rgba(255, 255, 255, 0.95);
  padding: 24px;
  border-radius: 12px;
  z-index: 2000;
  text-align: center;
  box-shadow: var(--shadow-lg);
  max-width: 80%;
  width: 320px;
  opacity: 0;
  transition: opacity 0.3s ease-out;
  pointer-events: none;
  will-change: opacity; 
  transform: translateZ(0); 
}

.stabilizing-modal.visible {
  opacity: 1;
  pointer-events: auto;
}

.stabilizing-modal h3 {
  margin: 12px 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--dark);
}

.stabilizing-modal p {
  margin-bottom: 0;
  font-size: 14px;
  color: var(--gray);
  line-height: 1.5;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(15, 43, 171, 0.2);
  border-top: 4px solid var(--primary);
  border-radius: 50%;
  margin: 0 auto 15px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Ensures smooth marker transition after stabillity found */
.leaflet-marker-icon {
  transition: opacity 0.5s ease !important;
}

        /* Green route button and dark blue summary button */
.button.route-button {
    background-color: #1b5e20 !important; /* Dark green color */
    color: white !important;
    border: none !important;
    padding: 8px 15px !important;
    border-radius: 0px !important;
    cursor: pointer !important;
    font-size: 17px !important;
    font-weight: 500 !important;
    transition: background-color 0.3s ease !important;
}

.button.summary-button {
    background-color: #0f2bab !important; /* Dark blue color */
    color: white !important;
    border: none !important;
    padding: 8px 15px !important;
    border-radius: 0px !important;
    cursor: pointer !important;
    font-size: 17px !important;
    font-weight: 500 !important;
    transition: background-color 0.3s ease !important;
}

.button.route-button:hover {
    background-color: #0d3c12 !important; /* Darker green on hover */
}

.button.summary-button {
     background-color: #0f2bab !important;
}

.button.summary-button:hover {
    background-color: #0a1f80 !important; /* Darker blue on hover */
}
        
/* Controls */
.map-controls {
  position: absolute;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 500;
}

.control-button {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background-color: var(--white);
  border: none;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-normal);
  color: var(--primary);
}

.control-button:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-lg);
}

.control-button.active {
  background-color: var(--primary);
  color: var(--white);
}

/* Popup styling */
.custom-popup {
  padding: 0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  max-width: 280px;
}

.popup-content {
  padding: 0;
}

.location-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
  display: block;
}

.location-name {
  padding: 12px 16px;
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--dark);
}

.popup-buttons {
  display: flex;
  border-top: 1px solid var(--gray-light);
}

.popup-buttons .button {
  flex: 1;
  padding: 10px;
  background: none;
  border: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--primary);
  cursor: pointer;
  transition: var(--transition-normal);
}

.popup-buttons .button:hover {
  background-color: var(--gray-light);
}

.popup-buttons .button:first-child {
  border-right: 1px solid var(--gray-light);
}

/* Modal styling - fixed issues */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.modal-content {
  background-color: var(--white);
  padding: 24px;
  border-radius: 12px;
  max-width: 90%;
  width: 320px;
  box-shadow: var(--shadow-lg);
}

.modal-content h3 {
  margin-top: 0;
  margin-bottom: 16px;
  font-size: 18px;
  font-weight: 600;
  color: var(--dark);
  text-align: center;
}

.modal-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

.modal-button {
  padding: 12px;
  border-radius: 8px;
  border: none;
  background-color: var(--primary);
  color: var(--white);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-normal);
}

.modal-button:hover {
  background-color: var(--primary-dark);
}

.modal-button.cancel {
  background-color: var(--gray-light);
  color: var(--dark);
}

.modal-button.cancel:hover {
  background-color: var(--gray);
  color: var(--white);
}

/* Additional info container */
.additional-info-container {
  display: none;
  background-color: var(--white);
  padding: 20px;
  border-radius: 0 0 12px 12px;
  margin-top: -12px;
}

.additional-info-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 12px 0;
  color: var(--dark);
}

.additional-info-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--dark);
  margin-bottom: 20px;
}

.continue-button {
  display: block;
  width: 100%;
  padding: 12px;
  background-color: var(--primary);
  color: var(--white);
  border: none;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-normal);
}

.continue-button:hover {
  background-color: var(--primary-dark);
}

/* Summary modal */
#summaryModal {
  display: none;
}

.summary-content {
  background-color: var(--white);
  padding: 24px;
  border-radius: 12px;
  max-width: 90%;
  width: 400px;
  box-shadow: var(--shadow-lg);
}

.summary-heading {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 16px 0;
  color: var(--dark);
}

/* Navigation tips */
.navigation-tips {
    position: fixed;
    top: 50%; /* Center vertically */
    left: 50%; /* Center horizontally */
    transform: translate(-50%, -50%); /* Adjust to true center */
    background-color: var(--white);
    padding: 24px; /* Increased padding for better spacing */
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    max-width: 90%; /* Take up to 80% of the screen width */
    max-height: 80%; /* take up to 80% of the screen height */
    overflow-y: auto; /* Add scroll if content exceeds height */
    display: none;
    z-index: 1500;
    box-sizing: border-box; /* Include padding in width/height calculations */
}

.navigation-tips h3 {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 12px 0;
  color: var(--dark);
}

.navigation-tips ul {
  margin: 0;
  padding: 0 0 0 20px;
}

.navigation-tips li {
  margin-bottom: 8px;
  font-size: 18px;
  color: var(--dark);
}

.close-button {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  font-size: 16px;
  color: var(--gray);
  cursor: pointer;
}

/* Marker clusters */
.marker-cluster-custom {
  background-color: rgba(0, 100, 0, .6);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.marker-cluster-custom div {
  background-color: rgba(47, 99, 47, 1);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.marker-cluster-custom span {
  color: var(--white);
  font-weight: 600;
  font-size: 12px;
}

/* Popup */
.popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: var(--white);
  padding: 24px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 2000;
  text-align: center;
  max-width: 80%;
  width: 320px;
}

/* Responsive adjustments */
@media (min-width: 768px) {
  .modal-content {
    width: 400px;
  }

  .modal-buttons {
    flex-direction: row;
    justify-content: center;
  }

  .lochunt-content {
    max-width: 600px;
  }

  .lochunt-image {
    height: 300px;
  }
}
