/**
 * MapLibre GL Swipe Control Styles
 */

/* ============================================
   Control Button (Toggle)
   ============================================ */
.swipe-control {
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.swipe-control-toggle {
  background: none;
  border: none;
  padding: 0;
  width: 29px;
  height: 29px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  outline: none;
  color: #1f2a37;
}

.swipe-control-toggle:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.swipe-control-toggle:focus {
  box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.4);
}

.swipe-control-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.swipe-control-icon svg {
  width: 22px;
  height: 22px;
}

/* ============================================
   Slider
   ============================================ */
.swipe-slider {
  position: absolute;
  z-index: 100;
  pointer-events: none;
}

.swipe-slider-vertical {
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.7));
  border-left: 1px solid rgba(0, 0, 0, 0.3);
  border-right: 1px solid rgba(0, 0, 0, 0.3);
  cursor: ew-resize;
  transform: translateX(-50%) translateZ(0);
  will-change: left;
  backface-visibility: hidden;
}

.swipe-slider-horizontal {
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(to right, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.7));
  border-top: 1px solid rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid rgba(0, 0, 0, 0.3);
  cursor: ns-resize;
  transform: translateY(-50%) translateZ(0);
  will-change: top;
  backface-visibility: hidden;
}

.swipe-slider-handle {
  position: absolute;
  pointer-events: auto;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  width: 32px;
  height: 32px;
}

.swipe-slider-vertical .swipe-slider-handle {
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  cursor: ew-resize;
}

.swipe-slider-horizontal .swipe-slider-handle {
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) rotate(90deg);
  cursor: ns-resize;
}

.swipe-slider-handle:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.swipe-slider.dragging .swipe-slider-handle {
  transform: translate(-50%, -50%) scale(1.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  transition: box-shadow 0.1s ease;
}

.swipe-slider-horizontal.dragging .swipe-slider-handle {
  transform: translate(-50%, -50%) rotate(90deg) scale(1.1);
  transition: box-shadow 0.1s ease;
}

.swipe-handle-icon {
  color: #666;
  transition: color 0.1s ease;
}

.swipe-slider:hover .swipe-handle-icon,
.swipe-slider.dragging .swipe-handle-icon {
  color: #333;
}

/* ============================================
   Panel
   ============================================ */
.swipe-control-panel {
  position: absolute;
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
  min-width: 240px;
  max-width: 320px;
  overflow: hidden;
  z-index: 1000;
  font-size: 12px;
  line-height: 1.4;
  display: none;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  /* Enable flexbox for proper content scrolling */
  flex-direction: column;
}

.swipe-control-panel.expanded {
  display: flex;
}

.swipe-control-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 600;
  color: #333;
  padding: 10px 12px;
  border-bottom: 1px solid #e0e0e0;
  background: #fafafa;
  flex-shrink: 0;
}

.swipe-control-title {
  flex: 1;
  font-size: 13px;
}

.swipe-control-close {
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  color: #999;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  transition: background-color 0.1s ease, color 0.1s ease;
}

.swipe-control-close:hover {
  background-color: rgba(0, 0, 0, 0.05);
  color: #333;
}

.swipe-control-content {
  padding: 12px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.swipe-control-group {
  margin-bottom: 14px;
}

.swipe-control-group:last-child {
  margin-bottom: 0;
}

.swipe-control-label {
  display: block;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.swipe-control-select {
  width: 100%;
  padding: 8px 10px;
  font-size: 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  outline: none;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.swipe-control-select:hover {
  border-color: #bbb;
}

.swipe-control-select:focus {
  border-color: #4a90d9;
  box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.15);
}

.swipe-control-divider {
  height: 1px;
  background: #e0e0e0;
  margin: 14px 0;
}

/* ============================================
   Layer List
   ============================================ */
.swipe-layer-list {
  /* Let each list grow with its layers and rely on the panel's own scroll area
     (.swipe-control-content) for overflow, so the panel uses the available
     height instead of stacking two short, separately scrolling boxes. A cap
     keeps a single very long list from crowding out the other side. */
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  background: #fafafa;
}

.swipe-layer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  cursor: pointer;
  border-bottom: 1px solid #eee;
  transition: background-color 0.1s ease;
}

.swipe-layer-item:last-child {
  border-bottom: none;
}

.swipe-layer-item:hover {
  background: #f0f0f0;
}

.swipe-layer-item input[type='checkbox'] {
  margin: 0;
  cursor: pointer;
  width: 14px;
  height: 14px;
  accent-color: #4a90d9;
}

.swipe-layer-item label {
  flex: 1;
  font-size: 11px;
  color: #333;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================
   Scrollbar
   ============================================ */
/* Firefox scrollbar */
.swipe-control-content,
.swipe-layer-list {
  scrollbar-width: thin;
  scrollbar-color: #ccc transparent;
}

/* Webkit (Chrome, Safari, Edge) scrollbar */
.swipe-control-content::-webkit-scrollbar,
.swipe-layer-list::-webkit-scrollbar {
  width: 6px;
}

.swipe-control-content::-webkit-scrollbar-track,
.swipe-layer-list::-webkit-scrollbar-track {
  background: transparent;
}

.swipe-control-content::-webkit-scrollbar-thumb,
.swipe-layer-list::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

.swipe-control-content::-webkit-scrollbar-thumb:hover,
.swipe-layer-list::-webkit-scrollbar-thumb:hover {
  background: #aaa;
}

/* ============================================
   Toggle Switch
   ============================================ */
.swipe-toggle-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.swipe-toggle-label {
  font-size: 12px;
  font-weight: 500;
  color: #333;
  cursor: pointer;
}

.swipe-toggle-slider {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  cursor: pointer;
  flex-shrink: 0;
}

.swipe-toggle-slider input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.swipe-toggle-track {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  border-radius: 10px;
  transition: background-color 0.2s ease;
}

.swipe-toggle-track::before {
  content: '';
  position: absolute;
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
  background-color: #fff;
  border-radius: 50%;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.swipe-toggle-slider input:checked + .swipe-toggle-track {
  background-color: #4a90d9;
}

.swipe-toggle-slider input:checked + .swipe-toggle-track::before {
  transform: translateX(16px);
}

.swipe-toggle-slider input:focus + .swipe-toggle-track {
  box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.3);
}

/* ============================================
   Empty State
   ============================================ */
.swipe-layer-list:empty::after {
  content: 'No layers available';
  display: block;
  padding: 12px;
  color: #999;
  font-size: 11px;
  text-align: center;
  font-style: italic;
}
