:root{
  --bg: #f6f7fb;
  --card: #ffffff;
  --accent: #0a84ff;
  --muted: #7b7f87;
  --text: #000000;
  --border: #e0e0e0;
  --gradient-start: #f5f7fa;
  --gradient-end: #c3cfe2;
  --shadow: rgba(133,173,255,0.5);
  --radius: 12px;
  --box-shadow: 0 6px 18px rgba(133,173,255,0.5); 
  font-family: 'Kanit', sans-serif;
}

/* Dark theme */
body.dark-theme {
  --bg: #1a1a1a;
  --card: #2a2a2a;
  --accent: #0a84ff;
  --muted: #999999;
  --text: #ffffff;
  --border: #3a3a3a;
  --gradient-start: #2a2a2a;
  --gradient-end: #1a1a1a;
  --shadow: rgba(0,0,0,0.5);
}

body.dark-theme #map {
  filter: brightness(0.7) contrast(1.1);
}

* {
  box-sizing: border-box;
}

/* Toast slide down with water droplet squash effect */
@keyframes x-animation {
  0% { 
    transform: translateY(0) scaleY(1) scaleX(1);
    opacity: 1;
    border-radius: 40px;
  }
  40% {
    transform: translateY(25px) scaleY(0.9) scaleX(1.05);
    opacity: 0.9;
    border-radius: 40px 40px 30px 30px;
  }
  70% {
    transform: translateY(40px) scaleY(0.4) scaleX(1.4); /* Squashes down */
    opacity: 0.6;
    border-radius: 50% 50% 10% 10%; /* Droplet shape */
  }
  85% {
    transform: translateY(45px) scaleY(0.1) scaleX(1.6); /* Almost flat */
    opacity: 0.3;
    border-radius: 80% 80% 0 0;
  }
  100% { 
    transform: translateY(48px) scaleY(0.05) scaleX(1.8); /* Completely flat */
    opacity: 0;
    border-radius: 100% 100% 0 0;
  }
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  background: var(--bg);
  overflow: hidden;
}

#map { 
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
}

/* Topbar */
#topbar { 
  position: fixed;
  top: 18px; 
  left: 18px; 
  right: 140px; 
  z-index: 1200;
  display: flex;
  gap: 12px;
  align-items: center;
  pointer-events: none;
}

#topbar > * {
  pointer-events: auto;
}

#searchInput {
  flex: 1;
  max-width: 420px; 
  padding: 10px 14px;   
  border-radius: 50px; 
  border: none;
  box-shadow: var(--box-shadow); 
  background: var(--card); 
  color: var(--text);
  font-size: 15px; 
  outline: none;
}

/* Search Recommendations */
.search-recommendations {
  position: fixed;
  top: 68px;
  left: 18px;
  width: 420px;
  max-width: calc(100vw - 36px);
  background: var(--card);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.15);
  z-index: 1250;
  display: none;
  overflow: hidden;
  animation: slideDown 0.3s ease-out;
}

.search-recommendations.active {
  display: block;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.search-result-item {
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.2s;
  color: var(--text);
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover {
  background: var(--gradient-start);
}

.search-result-item.not-found {
  color: var(--muted);
  cursor: default;
  text-align: center;
  font-style: italic;
}

.search-result-item.not-found:hover {
  background: transparent;
}

/* Menu Toggle Button */
#menuToggle {
  padding: 10px 16px;
  border: none;
  border-radius: 30px;
  background: var(--card);
  box-shadow: var(--box-shadow);
  color: var(--text);
  cursor: pointer;
  font-size: 20px;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
}

#menuToggle:hover {    
  transform: scale(1.1) rotate(2deg);
  box-shadow: 0 8px 24px var(--shadow);
  background: linear-gradient(328deg, #d1e5ff 0%, #0084ff 100%);
  color: white;
}

body.dark-theme #menuToggle:hover {
  background: linear-gradient(328deg, #1a5fb4 0%, #62a0ea 100%);
}

#menuToggle:active {
  transform: scale(0.95);
}

/* Dev Button */
.floating-btn {
  font-size: 28px;
  position: fixed;
  right: 35px;
  bottom: 35px;
  z-index: 1200;
  width: 58px;
  height: 58px;
  background: linear-gradient(90deg, #3d7dff, #92c9ff);
  color: white;
  border: none;
  border-radius: 50%;
  box-shadow: 0 8px 30px rgba(61,125,255,0.35);
  cursor: pointer;
  transition: transform 240ms ease, box-shadow 240ms ease;
  display: none;
}

.floating-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 14px 40px rgba(61,125,255,0.45);
}

.floating-btn:active {
  transform: scale(0.98);
}

/* Sidebar Base */
.sidebar-panel {
  position: fixed;
  top: 0;
  bottom: 0;
  width: 340px;
  max-width: 92vw;
  background: var(--card);
  box-shadow: 0 24px 60px rgba(0,0,0,0.12);
  z-index: 1400;
  display: flex;
  flex-direction: column;
  padding: 18px;
  gap: 12px;
  transition: transform 360ms cubic-bezier(.22,.9,.35,1);
}

.sidebar-panel.right {
  right: 0;
  transform: translateX(110%);
}

.sidebar-panel.left {
  left: 0;
  transform: translateX(-110%);
}

.sidebar-panel.open.right {
  transform: translateX(0);
}

.sidebar-panel.open.left {
  transform: translateX(0);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sidebar-title {
  font-weight: 700;
  font-size: 16px;
}

.close-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  transition: transform 0.2s;
  padding: 4px 8px;
}

.close-btn:hover {
  transform: scale(1.2);
}

.sidebar-body {
  overflow: hidden; /* Hide overflow to contain animations */
  overflow-y: auto; /* Allow vertical scrolling */
  padding-top: 8px;
  flex: 1;
}

/* Menu Items with Cascade Animation */
.sidebar-menu {
  list-style: none;
  padding: 0;
  margin: 0;
  overflow: hidden;
}

.menu-item {
  padding: 14px 16px;
  margin-bottom: 8px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 15px;
  position: relative;
  overflow: hidden;
  
  /* Initial state - hidden */
  opacity: 0;
  transform: translateY(-20px);
  
  /* Base gradient (white) */
  background: linear-gradient(350deg,rgb(209, 229, 255) 0%, rgb(255, 255, 255) 100%);
  
  /* Ensure text is above gradient */
  color: var(--text);
}

/* Animated gradient overlay on hover */
.menu-item::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(270deg,rgb(209, 229, 255) 0%, rgb(0, 132, 255) 100%);
  opacity: 0;
  transition: opacity 0.5s ease;
  z-index: -1;
}

.menu-item:hover::before {
  opacity: 1;
}

.menu-item:hover {
  color: white;
}

body.dark-theme .menu-item {
  background: linear-gradient(350deg, #2a3a4a 0%, #1a2a3a 100%);
}

body.dark-theme .menu-item::before {
  background: linear-gradient(270deg, #1a5fb4 0%, #62a0ea 100%);
}

/* Keep text above gradient - removed, text naturally appears above ::before */

/* Cascade animation when sidebar opens */
.sidebar-panel.open .menu-item {
  animation: menuItemSlideIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.sidebar-panel.open .menu-item:nth-child(1) {
  animation-delay: 0.1s;
}

.sidebar-panel.open .menu-item:nth-child(2) {
  animation-delay: 0.15s;
}

.sidebar-panel.open .menu-item:nth-child(3) {
  animation-delay: 0.2s;
}

.sidebar-panel.open .menu-item:nth-child(4) {
  animation-delay: 0.25s;
}

.sidebar-panel.open .menu-item:nth-child(5) {
  animation-delay: 0.3s;
}

@keyframes menuItemSlideIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: fadeIn 0.2s cubic-bezier(0,1.394,1,0.971);
}

.modal-overlay.active {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: var(--card);
  color: var(--text);
  border-radius: 16px;
  padding: 24px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow: auto;
  box-shadow: 0 24px 60px rgba(0,0,0,0.3);
  animation: slideUp 0.3s linear(0, 0.067, 0.1294, 0.1877, 0.2421, 0.2929, 0.3402, 0.3844, 0.4257, 0.4641, 0.5, 0.5335, 0.5647, 0.5939, 0.6211, 0.6464, 0.6701, 0.6922, 0.7128, 0.7321, 0.75, 0.7667, 0.7824, 0.7969, 0.8105, 0.8232, 0.8351, 0.8461, 0.8564, 0.866, 0.875, 0.8834, 0.8912, 0.8985, 0.9053, 0.9116, 0.9175, 0.9231, 0.9282, 0.933, 0.9375, 0.9417, 0.9456, 0.9492, 0.9526, 0.9558, 0.9588, 0.9615, 0.9641, 0.9665, 0.9688, 0.9708, 0.9728, 0.9746, 0.9763, 0.9779, 0.9794, 0.9808, 0.9821, 0.9833, 0.9844, 0.9854, 0.9864, 0.9873, 0.9882, 0.989, 0.9897, 0.9904, 0.991, 0.9916, 0.9922, 0.9927, 0.9932, 0.9937, 0.9941, 0.9945, 0.9948, 0.9952, 0.9955, 0.9958, 0.9961, 0.9964, 0.9966, 0.9968, 0.997, 0.9972, 0.9974, 0.9976, 0.9978, 0.9979, 0.998, 0.9982, 0.9983, 0.9984, 0.9985, 0.9986, 0.9987, 0.9988, 0.9989, 0.999, 1);
}

.modal-overlay.closing .modal-content {
  animation: shrinkDown 0.3s cubic-bezier(0,1.394,1,0.971);
}

@keyframes slideUp {
  from {
    transform: translateY(30px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes shrinkDown {
  from {
    transform: scale(1);
    opacity: 1;
  }
  to {
    transform: scale(0.8);
    opacity: 0;
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid #f0f0f0;
}

.modal-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.2s;
  padding: 0;
  line-height: 1;
}

.modal-close:hover {
  opacity: 1;
}

.modal-body {
  line-height: 1.6;
}

.modal-body h3 {
  margin-top: 0;
}

.modal-body ul {
  padding-left: 20px;
}

/* Google Maps Style Path Drawing */
.path-section {
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  padding: 16px;
  border-radius: 12px;
  margin-bottom: 16px;
  transition: background 0.5s ease;
}

.path-section:hover {
  background: linear-gradient(135deg, #e0e7ff 0%, #b8c5e0 100%);
}

.path-section h4 {
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 16px;
}

/* Route Steps */
.route-step {
  background: white;
  padding: 16px;
  border-radius: 10px;
  margin-bottom: 12px;
  border-left: 4px solid var(--accent);
}

.step-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.step-number {
  background: var(--accent);
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.step-title {
  font-weight: 600;
  font-size: 14px;
  color: #333;
}

.drawing-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-route {
  width: 100%;
  padding: 12px 16px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  cursor: pointer;
  font-size: 15px;
  font-family: 'Kanit', sans-serif;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-route:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-route:active {
  transform: translateY(0);
}

.btn-icon {
  font-size: 18px;
}

.drawing-tools {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.btn-tool {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #ddd;
  background: white;
  color: #666;
  cursor: pointer;
  font-size: 13px;
  font-family: 'Kanit', sans-serif;
  transition: all 0.2s;
}

.btn-tool:hover {
  background: #f5f5f5;
  border-color: #999;
  transform: translateY(-1px);
}

.btn-tool-primary {
  padding: 10px 12px;
  border-radius: 8px;
  border: none;
  background: #28a745;
  color: white;
  cursor: pointer;
  font-size: 13px;
  font-family: 'Kanit', sans-serif;
  font-weight: 600;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
}

.btn-tool-primary:hover {
  background: #218838;
  transform: translateY(-1px);
}

.btn-save-route {
  width: 100%;
  padding: 14px 16px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: white;
  cursor: pointer;
  font-size: 15px;
  font-family: 'Kanit', sans-serif;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(245, 87, 108, 0.3);
}

.btn-save-route:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(245, 87, 108, 0.4);
}

.btn-save-route:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.path-controls {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.path-input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.path-input-group label {
  font-size: 13px;
  font-weight: 600;
  color: #666;
}

.path-input-group input[type="text"],
.path-input-group input[type="file"] {
  padding: 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  font-family: 'Kanit', sans-serif;
  transition: all 0.2s;
}

.path-input-group input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.1);
}

/* Path Status */
.path-status {
  padding: 10px 12px;
  background: #f8f9fa;
  border-radius: 8px;
  margin-top: 10px;
  font-size: 13px;
  color: #666;
  text-align: center;
  border: 1px dashed #ddd;
}

.path-status.active {
  background: #d1ecf1;
  color: #0c5460;
  border: 1px solid #bee5eb;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.8; }
}

/* Saved Routes Header */
.saved-routes-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  margin-bottom: 12px;
}

.saved-routes-header h4 {
  margin: 0;
  font-size: 16px;
}

.route-count {
  background: var(--accent);
  color: white;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}

/* Saved Paths List */
.paths-list {
  max-height: 250px;
  overflow: auto;
  background: white;
  border-radius: 10px;
  padding: 8px;
}

.paths-list:empty::after {
  content: 'No routes yet. Create your first route!';
  display: block;
  text-align: center;
  color: #999;
  padding: 30px 20px;
  font-size: 14px;
}

.path-item {
  padding: 12px;
  background: #f8f9fa;
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.path-item:hover {
  background: #e9ecef;
  transform: translateX(4px);
}

.path-item-content {
  flex: 1;
  min-width: 0;
}

.path-item-name {
  font-weight: 600;
  font-size: 14px;
  color: #333;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.path-item-info {
  font-size: 12px;
  color: #666;
  display: flex;
  gap: 12px;
  align-items: center;
}

.path-item-badge {
  background: var(--accent);
  color: white;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.path-item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.btn-delete {
  background: #dc3545;
  color: white;
  border: none;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-family: 'Kanit', sans-serif;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-delete:hover {
  background: #c82333;
  transform: scale(1.05);
}

.btn-view {
  background: var(--accent);
  color: white;
  border: none;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-family: 'Kanit', sans-serif;
  transition: all 0.2s;
}

.btn-view:hover {
  background: #0056b3;
  transform: scale(1.05);
}

/* Generic button styles */
.btn {
  padding: 10px 12px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: white;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(10,132,255,0.3);
  transition: all 0.2s;
  font-size: 14px;
  font-family: 'Kanit', sans-serif;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(10,132,255,0.4);
}

.btn:active {
  transform: translateY(0);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid #ddd;
  box-shadow: none;
}

.btn-full {
  width: 100%;
}

.path-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* Viewer */
#viewerOverlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  background: rgba(0,0,0,0.85);
  animation: fadeIn 0.3s;
}

.viewer-card {
  width: 92vw;
  max-width: 1200px;
  height: 78vh;
  background: #000;
  border-radius: 14px;
  overflow: hidden;
  position: relative;
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
}

#viewerClose {
  position: absolute;
  top: 20px;
  right: 20px;
  color: white;
  font-size: 32px;
  cursor: pointer;
  z-index: 2100;
  background: rgba(0,0,0,0.5);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  border: none;
}

#viewerClose:hover {
  background: rgba(255,255,255,0.2);
  transform: scale(1.1);
}

/* Toast */
#toastContainer {
  position: fixed;
  left: 20px;
  bottom: 20px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: var(--card);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 40px;
  min-width: 200px;
  max-width: 360px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transform: translateY(10px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.hide {
  animation: x-animation 0.5s ease forwards;
}

.toast .message {
  flex: 1;
  font-size: 15px;
}

.toast .close {
  background: transparent;
  border: none;
  color: var(--text);
  opacity: 0.6;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: opacity 0.2s;
  line-height: 1;
}

.toast .close:hover {
  opacity: 1;
}

.toast.info {
  background: #FFFFFF;
  box-shadow: 0 10px 30px rgba(133, 173, 255, 0.6);
}

.toast.success {
  background: #85adff;
  box-shadow: 0 10px 30px rgb(86, 143, 255);
  color: white;
}

.toast.success .close {
  color: white;
}

.toast.error {
  background: #ff7979;
  box-shadow: 0 10px 30px rgb(255, 47, 75);
  color: white;
}

.toast.error .close {
  color: white;
}

/* Drawing mode cursor */
body.drawing-path {
  cursor: crosshair;
}

body.drawing-path #map {
  cursor: crosshair !important;
}

/* Placing pin mode */
body.placing-pin {
  cursor: crosshair;
}

body.placing-pin #map {
  cursor: crosshair !important;
}

/* Pin preview marker animation */
@keyframes pinPulse {
  0%, 100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
  50% {
    transform: translateY(-5px) scale(1.1);
    opacity: 0.8;
  }
}

.pin-preview-marker {
  animation: pinPulse 1s ease-in-out infinite;
}

.btn-success {
  background: #28a745;
  box-shadow: 0 4px 12px rgba(40,167,69,0.3);
}

.btn-success:hover {
  background: #218838;
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(40,167,69,0.4);
}

/* Beautiful iOS-style theme toggle */
.theme-toggle-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: var(--card);
  border-radius: 10px;
  margin-bottom: 12px;
}

.theme-toggle-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.theme-toggle {
  position: relative;
  width: 56px;
  height: 28px;
  background: #e0e0e0;
  border-radius: 50px;
  cursor: pointer;
  transition: background 0.3s ease;
}

.theme-toggle.active {
  background: var(--accent);
}

.theme-toggle-slider {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  background: white;
  border-radius: 50%;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.theme-toggle.active .theme-toggle-slider {
  transform: translateX(28px);
}

/* Settings row */
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px;
  background: var(--gradient-start);
  border-radius: 10px;
  margin-bottom: 10px;
  transition: background 0.2s ease;
}

.settings-row:hover {
  background: var(--border);
}

.settings-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.settings-select {
  padding: 8px 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  font-family: 'Kanit', sans-serif;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.settings-select:focus {
  outline: none;
  border-color: var(--accent);
}

/* Leaflet popup custom style */
.leaflet-popup-content-wrapper {
  border-radius: 12px;
  font-family: 'Kanit', sans-serif;
  background: var(--card);
  color: var(--text);
}

.leaflet-popup-content {
  margin: 16px;
}

/* =================== FLOOR SELECTOR =================== */
.floor-selector-btn {
  padding: 10px 16px;
  border: none;
  border-radius: 30px;
  background: var(--card);
  box-shadow: var(--box-shadow);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 100px;
}

.floor-selector-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 10px 30px rgb(86, 143, 255);
}

.floor-arrow {
  font-size: 10px;
  transition: transform 0.3s;
}

.floor-selector-btn.active .floor-arrow {
  transform: rotate(180deg);
}

/* Floor Dropdown */
.floor-dropdown {
  position: fixed;
  top: 78px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--card);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.15);
  z-index: 1300;
  width: 200px;
  max-height: 400px;
  overflow: hidden;
  display: none;
  opacity: 0;
  transform: translateX(-50%) translateY(-10px) scale(0.95);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.floor-dropdown.active {
  display: block;
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
}

.floor-dropdown-header {
  padding: 16px;
  border-bottom: 2px solid var(--border);
  text-align: center;
}

.floor-dropdown-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
}

.floor-list {
  max-height: 220px; /* Show ~4 floors (4 x 52px + padding) */
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px;
}

/* Hide scrollbar but keep functionality */
.floor-list::-webkit-scrollbar {
  width: 0px;
  background: transparent;
}

.floor-item {
  padding: 12px 16px;
  margin: 4px 0;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 600;
  color: var(--text);
  background: var(--gradient-start);
  display: flex;
  align-items: center;
  justify-content: center;
}

.floor-item:hover {
  background: linear-gradient(135deg, #e0e7ff 0%, #b8c5e0 100%);
  transform: translateX(4px);
}

.floor-item.active {
  background: var(--accent);
  color: white;
}

/* =================== LANGUAGE LOADING OVERLAY =================== */
.language-loading-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #ffffff 0%, #88d3ff 100%);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.5s ease;
}

body.dark-theme .language-loading-overlay {
  background: linear-gradient(135deg, #000000 0%, #0d00be 100%);
}

.language-loading-overlay.active {
  display: flex;
  opacity: 1;
}

.language-loading-content {
  text-align: center;
  max-width: 500px;
  width: 90%;
}

.language-loading-title {
  font-size: 48px;
  font-weight: 700;
  color: #141414;
  margin: 0 0 40px 0;
  animation: pulseGlow 2s ease-in-out infinite;
}

body.dark-theme .language-loading-title {
  color: #f7f7f7;
}

@keyframes pulseGlow {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(1.02);
  }
}

.language-loading-bar {
  width: 100%;
  height: 8px;
  background: rgba(255,255,255,0.2);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}

body.dark-theme .language-loading-bar {
  background: rgba(0,0,0,0.2);
  box-shadow: 0 10px 30px rgb(86, 143, 255);
}

.language-loading-progress {
  height: 100%;
  background: linear-gradient(90deg, #0a84ff, #92c9ff, #0a58ff);
  background-size: 200% 100%;
  border-radius: 10px;
  width: 0%;
  animation: progressBar 1.5s ease-out forwards, shimmer 1.5s ease-in-out infinite;
}

@keyframes progressBar {
  0% {
    width: 0%;
  }
  100% {
    width: 100%;
  }
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* =================== UPDATED THEME TOGGLE =================== */
.theme-toggle-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px;
  background: var(--gradient-start);
  border-radius: 10px;
  margin-bottom: 10px;
  transition: background 0.2s ease;
}

.theme-toggle-container:hover {
  background: var(--border);
}

.theme-toggle-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-icon {
  font-size: 18px;
}

.theme-toggle {
  position: relative;
  width: 56px;
  height: 30px;
  background: #e0e0e0;
  border-radius: 50px;
  cursor: pointer;
  transition: background 0.3s ease;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

.theme-toggle.active {
  background: var(--accent);
}

.theme-toggle-slider {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  background: white;
  border-radius: 50%;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.theme-toggle.active .theme-toggle-slider {
  transform: translateX(26px);
}

/* =================== MOBILE RESPONSIVE =================== */
@media (max-width: 768px) {
  .sidebar-panel {
    width: 100vw;
    max-width: 100vw;
  }
  
  #topbar {
    right: 12px;
    left: 12px;
    gap: 8px;
    padding: 8px 10px;
  }
  
  #searchInput {
    max-width: none;
    flex: 1;
    padding: 8px 12px;
    font-size: 14px;
  }
  
  #floorSelector {
    padding: 6px 10px;
    font-size: 13px;
    min-width: 85px;
  }
  
  #currentFloorText {
    font-size: 13px;
  }
  
  #menuToggle {
    width: 36px;
    height: 36px;
    font-size: 18px;
  }
  
  /* Floor dropdown positioning for mobile */
  .floor-dropdown {
    left: 50%;
    transform: translateX(-50%);
    width: 90vw;
    max-width: 300px;
  }
  
  /* Search recommendations for mobile */
  .search-recommendations {
    left: 12px;
    right: 12px;
    width: auto;
    max-width: none;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .sidebar-panel {
    width: 400px;
  }
}
