/* public/assets/css/styles.css (Revised - Fix for Speed Controls) */

body,
html {
  margin: 0;
  padding: 0;
  height: 100%;
  /* Better default font stack */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
}

#map-container {
  width: 100%;
  height: 100vh;
  position: relative;
}

/* --- Avatar Styles --- */
.avatar-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: #ff6b6b;
  /* Default background, JS should override */
  /* Default/Other user border color set by JS or specific classes */
  border: 2px solid #48bfe3;
  /* Default border if JS doesn't set */
  position: relative;
  z-index: 110;
  transform-style: preserve-3d;
  transition: transform 0.3s ease;
  box-sizing: border-box;
}

.avatar.local-user {
  /* JS should set border-color via style attribute,
     or you can uncomment this if JS adds the class */
  /* border-color: #FF5252; */
}

.avatar::after {
  content: "";
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 5px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 50%;
  filter: blur(2px);
  opacity: 0;
  transition: opacity 0.3s;
  z-index: -1;
}

.avatar.view-3d::after {
  opacity: 1;
}

.nickname-label {
  position: absolute;
  top: -25px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(255, 255, 255, 0.9);
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 12px;
  color: #333;
  font-weight: 500;
  white-space: nowrap;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  pointer-events: none;
  z-index: 120;
}

/* --- Join/Create Form Styles --- */
#join-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background-color: #f4f7f6;
}

.join-form {
  background: white;
  padding: 30px 35px;
  border-radius: 10px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 380px;
  box-sizing: border-box;
  margin: 20px;
}

.join-form h2 {
  text-align: center;
  margin-bottom: 25px;
  color: #333;
  font-weight: 600;
}

.tabs {
  display: flex;
  margin-bottom: 25px;
  border-bottom: 1px solid #eee;
}

.tab-btn {
  flex: 1;
  padding: 12px 10px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: #666;
  text-align: center;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  transition: color 0.2s, border-color 0.2s;
}

.tab-btn:hover {
  color: #333;
}

.tab-btn.active {
  color: #4ecdc4;
  border-bottom-color: #4ecdc4;
  font-weight: 600;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  color: #555;
  font-size: 14px;
  font-weight: 500;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 5px;
  box-sizing: border-box;
  font-size: 14px;
}

input:focus {
  border-color: #4ecdc4;
  outline: none;
  box-shadow: 0 0 0 2px rgba(78, 205, 196, 0.2);
}

.color-options {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-top: 10px;
}

.color-option {
  width: 35px;
  height: 35px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid #f0f0f0;
  transition: border-color 0.2s;
}

.color-option:hover {
  border-color: #cccccc;
}

.color-option.active {
  border-color: #4ecdc4;
}

#avatar-preview {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  margin: 15px auto 10px;
  border: 2px solid #ccc;
  background-color: #ff6b6b;
}

.action-btn {
  width: 100%;
  padding: 12px;
  background-color: #4ecdc4;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  margin-top: 15px;
  transition: background-color 0.2s;
}

.action-btn:hover {
  background-color: #3dbdb3;
}

.error-message {
  color: #e53935;
  text-align: center;
  margin-top: 20px;
  font-size: 14px;
  display: none;
}

/* --- Map Overlay UI --- */

#room-info {
  position: fixed;
  top: 15px;
  left: 15px;
  background-color: rgba(255, 255, 255, 0.95);
  padding: 10px 15px;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  z-index: 1010;
  font-size: 14px;
  line-height: 1.6;
}

#room-info strong {
  margin-right: 5px;
}

#leave-room-btn {
  margin-top: 8px;
  padding: 5px 10px;
  background: #f44336;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  display: block;
  width: 100%;
  text-align: center;
  transition: background-color 0.2s;
}

#leave-room-btn:hover {
  background-color: #d32f2f;
}

/* Map Controls (Select Destination) - Bottom Left */
#map-controls {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

.map-btn {
  padding: 10px 15px;
  background-color: #4ecdc4;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: all 0.2s ease;
  font-weight: 500;
}

.map-btn:hover {
  background-color: #3dbdb3;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
}

.map-btn.active {
  background-color: #ff6b6b;
}

.map-btn.active:hover {
  background-color: #e55a5a;
}

.map-tip {
  padding: 8px 12px;
  background-color: rgba(255, 255, 255, 0.95);
  border-radius: 4px;
  font-size: 13px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

/* Route Panel (Top Right) */
#route-panel {
  position: fixed;
  top: 15px;
  right: 15px;
  width: 320px;
  max-width: calc(100vw - 30px);
  max-height: calc(100vh - 30px);
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
  z-index: 1020;
  overflow-y: auto;
  display: none;
}

#route-panel::-webkit-scrollbar {
  width: 6px;
}

#route-panel::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

#route-panel::-webkit-scrollbar-thumb {
  background: #aaa;
  border-radius: 3px;
}

#route-panel::-webkit-scrollbar-thumb:hover {
  background: #888;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 15px;
  border-bottom: 1px solid #eee;
  position: sticky;
  top: 0;
  background-color: white;
  z-index: 1;
}

.panel-header h3 {
  margin: 0;
  color: #333;
  font-size: 16px;
  font-weight: 600;
}

.panel-header .close-btn {
  background: none;
  border: none;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: #888;
  padding: 0;
}

.panel-header .close-btn:hover {
  color: #555;
}

#routes-container {
  padding: 15px;
}

.route-option {
  padding: 15px;
  border-radius: 6px;
  margin-bottom: 12px;
  cursor: pointer;
  border: 1px solid #e0e0e0;
  transition: background-color 0.2s, border-color 0.2s;
  background-color: #fff;
}

.route-option:hover {
  background-color: #f9f9f9;
}

.route-option.selected {
  border-color: #4ecdc4;
  background-color: #f0faf9;
}

.route-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.route-details-main {
  display: flex;
  align-items: center;
}

.route-icon {
  font-size: 20px;
  margin-right: 10px;
  color: #4ecdc4;
}

.route-type {
  font-weight: 600;
  font-size: 14px;
  color: #333;
}

.route-duration {
  font-size: 14px;
  color: #555;
}

.route-distance {
  font-size: 13px;
  color: #777;
  margin-top: 4px;
}

.route-steps {
  margin-top: 10px;
  font-size: 13px;
  color: #666;
  line-height: 1.5;
}

/* Destination Marker (on map) */
.destination-marker {
  width: 22px;
  height: 22px;
  background-color: #f44336;
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
}

/* No Route Message */
.no-route-message {
  padding: 25px;
  text-align: center;
  color: #555;
}

.no-route-message p {
  margin-bottom: 12px;
}

.no-route-message button {
  margin-top: 15px;
  background-color: #607d8b;
}

.no-route-message button:hover {
  background-color: #455a64;
}

/* Confirm Route Button */
#confirm-route {
  margin-top: 15px;
  background-color: #4caf50;
  font-weight: 600;
}

#confirm-route:hover {
  background-color: #388e3c;
}

/* --- Speed Controls (Bottom Right) --- */
#speed-controls {
  position: fixed;
  bottom: 20px;
  /* Align bottom */
  right: 15px;
  background-color: rgba(255, 255, 255, 0.95);
  padding: 12px 15px;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  width: 190px;
  /* Slightly wider */
  box-sizing: border-box;
  /* Include padding in width */
}

.speed-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.speed-title {
  font-size: 13px;
  font-weight: 500;
  color: #444;
}

.current-speed {
  font-size: 13px;
  font-weight: bold;
  color: #4ecdc4;
}

.speed-adjuster {
  display: flex;
  align-items: center;
  gap: 10px;
  /* Increased gap */
}

.speed-adj-btn {
  width: 28px;
  /* Increased size */
  height: 28px;
  border-radius: 50%;
  background-color: #f0f0f0;
  border: 1px solid #ddd;
  font-size: 18px;
  /* Larger +/- sign */
  font-weight: bold;
  color: #555;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0;
  /* Removed padding */
  line-height: 1;
  /* Use line-height for centering */
  flex-shrink: 0;
  /* Prevent shrinking */
  transition: background-color 0.2s, border-color 0.2s;
}

.speed-adj-btn:hover {
  background-color: #e5e5e5;
  border-color: #ccc;
}

.speed-level-display {
  flex-grow: 1;
  /* Take remaining space */
  min-width: 50px;
  /* Prevent collapsing */
}

.speed-track {
  height: 8px;
  /* Thicker track */
  background-color: #e9e9e9;
  border-radius: 4px;
  position: relative;
  overflow: hidden;
  /* IMPORTANT: Clip indicator */
}

.speed-indicator {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background-color: #4ecdc4;
  border-radius: 4px;
  /* Match track radius */
  width: 40%;
  /* Default width, JS updates this */
  transition: width 0.2s ease;
  box-sizing: border-box;
  /* Ensure no unexpected size changes */
  padding: 0;
  /* Reset padding */
  margin: 0;
  /* Reset margin */
  border: none;
  /* Reset border */
}

/* --- Navigation Controls (Above Speed Controls) --- */
#navigation-controls {
  position: fixed;
  /* Calculate bottom based on speed control height + desired gap */
  /* Assuming speed control height is roughly 65px (padding+header+adjuster) */
  bottom: calc(20px + 70px + 10px);
  /* speed_bottom + approx_height + gap */
  right: 15px;
  /* Align horizontally */
  background-color: rgba(255, 255, 255, 0.95);
  padding: 12px 15px;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 160px;
  /* Slightly wider */
  box-sizing: border-box;
  /* display: none; */
  /* JS controls visibility */
}

.nav-info {
  font-size: 14px;
  text-align: center;
  color: #333;
  font-weight: 500;
}

.nav-info.success {
  color: #4caf50;
  font-weight: bold;
}

.nav-btn {
  padding: 8px 15px;
  border: none;
  border-radius: 4px;
  color: white;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  width: 100%;
  text-align: center;
}

.nav-btn.stop-btn {
  background-color: #f44336;
}

.nav-btn.stop-btn:hover {
  background-color: #d32f2f;
}

.nav-btn.close-btn {
  background-color: #9e9e9e;
}

.nav-btn.close-btn:hover {
  background-color: #757575;
}

/* --- Loading Panel --- */
#loading-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  /* display: none; */
}

.loading-spinner {
  width: 45px;
  height: 45px;
  border: 5px solid rgba(255, 255, 255, 0.3);
  border-top-color: #4ecdc4;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-text {
  margin-top: 15px;
  color: white;
  font-size: 16px;
}

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

  100% {
    transform: rotate(360deg);
  }
}

/* --- Button Disabled State --- */
.action-btn:disabled,
.map-btn:disabled,
.nav-btn:disabled,
.speed-adj-btn:disabled {
  background-color: #cccccc !important;
  border-color: #cccccc !important;
  color: #888888 !important;
  cursor: not-allowed;
  opacity: 0.7;
  transform: none !important;
  box-shadow: none !important;
}

.action-btn:disabled:hover,
.map-btn:disabled:hover,
.nav-btn:disabled:hover,
.speed-adj-btn:disabled:hover {
  background-color: #cccccc !important;
  border-color: #cccccc !important;
}