/* cssTest.css - Fixed architecture with improvements */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  font-family: system-ui, -apple-system, sans-serif;
  overflow: hidden;
  background-color: #171a1c;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  background-color: #171a1c;
}

/* Header Section - only logo now */
.header-text {
  padding: 6px 16px;
  text-align: center;
  flex-shrink: 0;
  background-color: #171a1c;
  z-index: 10;
  border-bottom: 1px solid #171a1c;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* Logo styling - centered, responsive, capped to center 1/3 of header */
.header-logo {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 33.333%;
  margin: 0 auto;
}

.header-logo svg {
  max-width: 320px;
  width: 100%;
  height: auto;
  display: block;
}

/* Feedback Button - top right corner of header, clear of the logo */
.feedback-btn {
  position: absolute;
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #171a1c;
  background-color: #2ebda2;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.2s, opacity 0.2s;
  white-space: nowrap;
  z-index: 20;
}

.feedback-btn:hover {
  background-color: #2ebda2;
}

.feedback-btn:active {
  opacity: 0.85;
}

/* ============================================================
   HELP POPUP
   ============================================================ */

.help-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  padding: 20px;
}

.help-overlay.hidden {
  display: none;
}

.help-modal {
  position: relative;
  width: 100%;
  max-width: 420px;
  max-height: 80vh;
  overflow-y: auto;
  background-color: #0d0f11;
  border: 1px solid #2a2d2f;
  border-radius: 10px;
  padding: 24px 20px 20px;
  color: #e0e0e0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

.help-close-btn {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  color: #e0e0e0;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
}

.help-close-btn:hover,
.help-close-btn:active {
  color: #2ebda2;
}

.help-title {
  font-size: 16px;
  color: #2ebda2;
  margin-bottom: 6px;
}

.help-content p {
  font-size: 13px;
  margin-bottom: 10px;
}

.help-content ul {
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.help-content li {
  font-size: 13px;
  line-height: 1.4;
}

/* Map Viewport - Fills remaining space */
#viewport {
  flex: 1;
  width: 100%;
  min-height: 0;
  position: relative;
  overflow: hidden;
  background: #dcdce1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#viewport:active {
  cursor: grabbing;
}

/* Rotator - rotates the entire SVG */
#rotator {
  position: relative;
  flex-shrink: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: transform;
  pointer-events: none;
  touch-action: none;
}

/* Map SVG - fills the rotator, viewBox controls position + zoom */
#map-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
  touch-action: none;
}

/* Route polyline - drawn inside the SVG */
#route-polyline {
  pointer-events: none;
  vector-effect: non-scaling-stroke;
  stroke-linejoin: round;
  stroke-linecap: round;
}

/* Current location dot */
#current-location-dot {
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}

/* Buttons and Textboxes */
.route-form {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
  background-color: #171a1c;
  z-index: 10;
  border-top: 1px solid #171a1c;
}

.input-row {
  display: flex;
  gap: 10px;
  width: 100%;
}

.input-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  position: relative;
}

.input-group label {
  font-size: 12px;
  font-weight: 600;
  color: #00BF00;
}

.input-wrapper {
  position: relative;
  width: 100%;
}

.input-wrapper input {
  width: 100%;
  padding: 8px 30px 8px 10px;
  font-size: 14px;
  border: 1px solid #2a2d2f;
  border-radius: 6px;
  outline: none;
  background-color: #0d0f11;
  color: #e0e0e0;
  -webkit-appearance: none;
  appearance: none;
}

.input-wrapper input::placeholder {
  color: #555758;
}

.input-wrapper input:focus {
  border-color: #00BF00;
  background-color: #1a1d1f;
}

/* Clear button inside input */
.clear-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #d5dbdf;
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
  display: none;
  touch-action: manipulation;
}

.clear-btn.visible {
  display: block;
}

.clear-btn:active {
  color: #00BF00;
}

/* ============================================================
   DROPDOWN - MOBILE SCROLL SUPPORT (FIXED)
   ============================================================ */

.dropdown {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  background: #0d0f11;
  border: 1px solid #2a2d2f;
  border-radius: 6px;
  max-height: 180px;
  overflow-y: auto;
  overflow-x: hidden;
  display: none;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.dropdown.open {
  display: block;
}

/* Scrollbar styling */
.dropdown::-webkit-scrollbar {
  width: 4px;
}

.dropdown::-webkit-scrollbar-track {
  background: #0d0f11;
}

.dropdown::-webkit-scrollbar-thumb {
  background: #2a2d2f;
  border-radius: 4px;
}

/* ============================================================
   DROPDOWN ITEMS - TOUCH FRIENDLY
   ============================================================ */

.dropdown-item {
  padding: 10px 12px;
  color: #e0e0e0;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid #1a1d1f;
  min-height: 40px;
  display: flex;
  align-items: center;
  word-break: break-word;
  touch-action: pan-y;
}

.dropdown-item:last-child {
  border-bottom: none;
}

.dropdown-item:hover,
.dropdown-item:active {
  background: #1a2a10;
}

.dropdown-item.highlighted {
  background: #1a2a10;
}

.dropdown-item .item-name {
  font-weight: 500;
  color: #e0e0e0;
}

.dropdown-item .item-graph {
  font-size: 10px;
  color: #555758;
  margin-left: 8px;
  flex-shrink: 0;
  background: #1a1d1f;
  padding: 2px 6px;
  border-radius: 3px;
}

.no-results {
  padding: 12px 14px;
  color: #555758;
  text-align: center;
  font-size: 13px;
}

/* Button row: two buttons side by side */
.button-row {
  display: flex;
  gap: 10px;
  width: 100%;
}

.button-row button {
  flex: 1;
  padding: 10px;
  font-size: 15px;
  font-weight: 600;
  color: #171a1c;
  background-color: #00BF00;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.2s, opacity 0.2s;
  min-width: 0;
}

.button-row button:hover {
  background-color: #00BF00;
}

.button-row button:active {
  opacity: 0.85;
}

.button-row button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Back button - RED */
#back-btn {
  background-color: #e53935;
  color: #ffffff;
}
#back-btn:hover {
  background-color: #c62828;
}
#back-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Status Box - below inputs */
.status-box {
  display: flex;
  align-items: flex-start;
  padding: 10px 12px;
  background-color: #0d0f11;
  border: 1px solid #2a2d2f;
  border-radius: 6px;
  min-height: 44px;
  width: 100%;
}

.status-text {
  font-size: 13px;
  line-height: 1.4;
  color: #e0e0e0;
  flex: 1;
  min-width: 0;
  width: 100%;
}

.status-text div:first-child {
  font-size: 11px;
  color: #555758;
  margin-bottom: 2px;
}

#status-line-2 {
  font-weight: 500;
  color: #00BF00;
  font-size: 14px;
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
  line-height: 1.4;
  min-height: 20px;
  width: 100%;
  word-break: break-word;
}

/* ============================================================
   MOBILE OPTIMIZATIONS
   ============================================================ */

@media (max-width: 480px) {
  .header-text {
    padding: 4px 12px;
  }
  
  .header-logo svg {
    max-width: 220px;
  }

  .feedback-btn {
    right: 12px;
    padding: 6px 10px;
    font-size: 11px;
  }

  .help-modal {
    padding: 20px 16px 16px;
  }
  
  .route-form {
    padding: 8px 12px;
    gap: 8px;
  }

  .status-box {
    padding: 8px 10px;
    min-height: 38px;
  }

  .input-wrapper input {
    padding: 6px 28px 6px 8px;
    font-size: 13px;
  }
  
  .button-row button {
    padding: 8px;
    font-size: 14px;
  }
  
  .status-text {
    font-size: 12px;
  }
  
  #status-line-2 {
    font-size: 13px;
    min-height: 18px;
  }

  /* Mobile dropdown - keep relative positioning, just adjust size */
  .dropdown {
    max-height: 140px;
    top: calc(100% + 2px);
    position: absolute;
  }

  .dropdown-item {
    padding: 8px 10px;
    font-size: 12px;
    min-height: 36px;
  }
}

/* Safe area insets for notched phones */
@supports (padding: max(0px)) {
  .route-form {
    padding-bottom: max(12px, env(safe-area-inset-bottom, 12px));
  }
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid #00BF00;
  outline-offset: 2px;
}

button,
input {
  user-select: none;
  -webkit-user-select: none;
}