/* Mobile-first responsive layout with Floating Sticky Panels - v1.1 */
body {
  font-family: system-ui, Arial;
  padding: 0;
  margin: 0;
  overflow-x: hidden;
}

/* Main content area with reduced margins for mobile */
.main-content {
  padding: 8px;
}

@media (min-width: 768px) {
  .main-content {
    padding: 16px;
  }
}

/* Floating Panel System */
.floating-panel {
  position: fixed;
  top: 140px; /* Below navbar and title */
  background: rgba(250, 250, 250, 0.98);
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1010;
  max-height: calc(100vh - 240px);
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.floating-panel-left {
  left: 16px;
  width: 320px;
}

.floating-panel-right {
  right: 16px;
  width: 320px;
}

/* Minimized state - higher specificity to override left/right widths */
.floating-panel-left.minimized,
.floating-panel-right.minimized {
  width: 48px !important;
  min-width: 48px !important;
  max-width: 48px !important;
  overflow: hidden;
}

.floating-panel.minimized .floating-panel-body {
  display: none !important;
  opacity: 0;
  visibility: hidden;
}

.floating-panel.minimized .floating-panel-title {
  display: none !important;
  opacity: 0;
  visibility: hidden;
}

.floating-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #f0f0f0;
  border-bottom: 1px solid #ddd;
  border-radius: 8px 8px 0 0;
  flex-shrink: 0;
}

.floating-panel-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
}

.toggle-panel-btn {
  padding: 4px 8px;
  line-height: 1;
}

.toggle-panel-btn svg {
  display: block;
  transition: transform 0.3s ease;
}

.floating-panel-body {
  padding: 12px;
  overflow-y: auto;
  flex: 1;
}

/* Mobile adjustments */
@media (max-width: 767px) {
  .floating-panel-left,
  .floating-panel-right {
    width: 280px;
    max-height: calc(100vh - 200px);
  }
  
  .floating-panel-left {
    left: 8px;
  }
  
  .floating-panel-right {
    right: 8px;
  }
}

/* Small screen landscape mode - reduce spacing */
@media (max-width: 932px) and (max-height: 430px) {
  .floating-panel {
    top: 80px;
    max-height: calc(100vh - 140px);
  }
  
  .boat-rows {
    gap: 4px;
  }
  
  .boat-outline {
    padding: 6px 0;
    gap: 4px;
  }
  
  .row {
    grid-template-columns: 35px 1fr 12px 1fr 60px;
    gap: 4px;
    min-height: 48px;
    padding: 2px 0;
  }

  .row-label {
    font-size: 0.65rem;
    padding-right: 4px;
    width: 35px;
  }
  
  .slot {
    min-width: 70px;
    max-width: 100px;
    height: 44px;
  }
  
  .slot.left {
    justify-content: space-between;
  }
  
  .slot.left .paddler {
    justify-content: center;
  }
  
  .slot-spacer {
    width: 12px;
  }
  
  .slots {
    gap: 8px;
    padding: 0 2px;
  }
  
  .row-stats {
    font-size: 0.6rem;
    padding-left: 4px;
    width: 60px;
  }
}

/* iPad mini portrait and similar tablets - reduce spacing */
@media (min-width: 744px) and (max-width: 834px) and (orientation: portrait) {
  .boat-rows {
    gap: 5px;
  }
  
  .boat-outline {
    padding: 8px 0;
    gap: 5px;
  }
  
  .row {
    grid-template-columns: 40px 1fr 16px 1fr 70px;
    gap: 6px;
    min-height: 52px;
  }
  
  .row-label {
    font-size: 0.75rem;
    padding-right: 6px;
    width: 40px;
  }
  
  .slot {
    height: 46px;
  }
  
  .slot.left {
    justify-content: space-between;
  }
  
  .slot.left .paddler {
    justify-content: center;
  }
  
  .slot-spacer {
    width: 16px;
  }
  
  .row-stats {
    font-size: 0.7rem;
    padding-left: 6px;
    width: 70px;
  }
}



/* Paddlers list */
.paddlers-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.paddler {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: #fff;
  cursor: grab;
  transition: transform 0.1s ease;
  touch-action: none; /* Prevent default touch behaviors */
  user-select: none; /* Prevent text selection during drag */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.paddler .flex-grow-1 {
  overflow: hidden;
}

.paddler .min-width-0 {
  min-width: 0;
}

.paddler .text-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.paddler .badge {
  font-size: 0.7rem;
  padding: 2px 6px;
}

.paddler:active {
  cursor: grabbing;
}

.paddler:hover {
  transform: translateX(2px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Better touch feedback on mobile */
@media (max-width: 767px) {
  .paddler {
    padding: 12px 8px; /* Larger touch target */
    min-height: 56px; /* Ensure adequate touch area */
  }
  
  .paddler:active {
    background: #f0f9ff;
  }
}


.paddler img {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.06);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
  flex-shrink: 0;
}

.paddler .fw-medium {
  font-weight: 500;
  font-size: 0.9rem;
}

.paddler .flex-wrap {
  flex-wrap: wrap;
}

/* Center panel: Boat */
.center-panel {
  flex: 1;
  padding: 0px;
  padding-bottom: 100px; /* Ensure steer is not hidden by footer */
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  order: 1;
}

.boat-wrapper {
  width: 100%;
  max-width: 650px;
  margin: 0 auto;
}

.boat-container {
  width: 100%;
  position: relative;
}

.boat-hull {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 50%;
  transform: translateX(-50%);
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.boat-rows {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.boat-outline {
  border: 4px solid #2b6cb0;
  border-radius: 40px;
  padding: 8px 0;
  background: linear-gradient(#fff, #f7fbff);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.row {
  display: grid;
  grid-template-columns: 45px 1fr 16px 1fr 70px;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
  min-height: 56px;
}

.row-label {
  text-align: right;
  padding-right: 6px;
  font-weight: 600;
  font-size: 0.7rem;
  color: #374151;
  white-space: nowrap;
  width: 45px;
  flex-shrink: 0;
}

.slot-spacer {
  width: 16px;
  background: transparent;
}

.slots-wrapper {
  display: contents; /* Make wrapper transparent to grid */
}

.slots {
  display: contents; /* Make wrapper transparent to grid */
}

.slot {
  min-width: 0;
  height: 48px;
  border: 1px dashed #aaa;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  background: #fff;
  font-size: 0.7rem;
  position: relative;
  transition: all 0.2s ease;
  touch-action: none;
  justify-content: flex-start;
}

.slot.left {
  justify-content: space-between;
}

.slot.left .lock {
  order: 1;
}

.slot.left .paddler {
  order: 2;
  flex: 1;
  display: flex;
  justify-content: center;
}

.slot.left .drag-handle {
  order: 3;
}

.slot.empty-slot {
  border: none;
  background: transparent;
}

.slot .paddler {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 4px 8px;
  border: 1px solid transparent;
  gap: 6px;
}

@media (max-width: 767px) {
  .slot .paddler {
    padding: 1px 2px;
    margin: 0;
    gap: 2px;
  }
}

.slot .paddler .badge {
  font-size: 0.65rem;
  padding: 1px 4px;
}

.slot .paddler .fw-medium {
  font-size: 0.75rem;
}

/* Better visual feedback for touch on mobile */
@media (max-width: 767px) {
  .boat-outline {
    padding: 3px 0;
    gap: 2px;
    border-width: 2px;
  }
  
  .boat-rows {
    gap: 2px;
  }
  
  .row {
    padding: 0;
  }
  
  .slot {
    min-height: 36px;
    height: 36px; /* Compact display for mobile */
  }
  
  /* Force override Bootstrap gap classes */
  .slot .paddler.gap-2 {
    gap: 2px !important;
  }
  
  /* Reduce avatar size in slots */
  .slot .paddler img,
  .slot .paddler .rounded-circle {
    width: 24px !important;
    height: 24px !important;
  }
  
  .slot.drag-over {
    outline: 3px solid #3b82f6;
    background: #dbeafe;
  }
  
  /* Hide images in slots on small screens */
  .slot .paddler img,
  .slot .paddler .rounded-circle {
    display: none;
  }
  
  /* Remove slot spacer width - padding provides sufficient separation */
  .slot-spacer {
    width: 0;
  }
  
  /* Adjust grid layout for compact display */
  .row {
    grid-template-columns: 30px 1fr 0 1fr 50px;
    gap: 3px;
    min-height: 32px;
  }
  
  .row-label {
    font-size: 0.65rem;
    width: 30px;
    padding-right: 3px;
  }
  
  .row-stats {
    width: 50px;
    font-size: 0.6rem;
    padding-left: 3px;
  }
  
  /* Reduce lock button size */
  .slot .lock {
    width: 14px;
    min-height: 20px;
    padding: 0;
    font-size: 0.6rem;
    border-width: 0.5px;
    flex-shrink: 1; /* Allow shrinking */
  }
  
  /* Reduce drag handle size */
  .drag-handle {
    width: 10px;
    margin: 0;
    padding: 0;
    flex-shrink: 1; /* Allow shrinking */
  }
  
  .drag-icon {
    width: 6px;
    height: 6px;
  }
  
  /* Reduce slot padding and gap */
  .slot {
    padding: 1px 2px;
    gap: 1px;
    height: auto;
    min-height: 32px;
  }
  
  .slot.left {
    justify-content: space-between;
  }
  
  .slot.left .paddler {
    justify-content: center;
  }
  
  /* Override Bootstrap flex utilities */
  .slot .paddler .flex-grow-1 {
    flex-grow: 0 !important;
    flex-shrink: 1;
  }
  
  .slot .paddler .gap-1 {
    gap: 1px !important;
  }
  
  .slot .paddler .badge {
    font-size: 0.55rem;
    padding: 0px 2px !important;
  }
  
  .slot .paddler .fw-medium {
    font-size: 0.65rem;
  }
}

.row-stats {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: 6px;
  color: #1f2937;
  font-size: 0.65rem;
  line-height: 1.2;
  width: 70px;
  flex-shrink: 0;
}

.row-stat-total,
.row-stat-imbalance {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-stat-total {
  font-weight: 600;
}

.row-stat-imbalance {
  color: #6b7280;
}

.slot.drag-over {
  outline: 3px dashed #3b82f6;
  background: #eff6ff;
  transform: scale(1.05);
}

.drummer-slot,
.steer-slot {
  grid-column: 3; /* Position at column 3 (the spacer column) */
  justify-self: center;
  max-width: none; /* Remove max-width restriction */
  width: auto; /* Allow natural width based on content */
}

.slot.locked {
  background: #f3f4f6;
  border-color: #e5e7eb;
  color: #6b7280;
  cursor: not-allowed;
}

/* Inline lock button styles */
.slot .lock {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 100%;
  min-height: 40px;
  flex-shrink: 0;
  padding: 4px;
  font-size: 1rem;
  border: 1px solid #d1d5db;
  background-color: #f9fafb;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s;
}

.slot .lock:hover {
  background-color: #f3f4f6;
  border-color: #9ca3af;
}

.slot .lock i {
  color: #6b7280;
}

/* Grey out paddler when slot is locked */
.slot.locked .paddler {
  background-color: #f3f4f6 !important;
  opacity: 0.7;
}

/* Orange border for handedness mismatch */
.slot .paddler.handedness-mismatch {
  border: 2px solid #f97316 !important;
  box-shadow: 0 0 0 1px #f97316;
}

/* Statistics panel */
.stat-item {
  padding: 10px 12px;
  background: #fff;
  border-radius: 6px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border: 1px solid #e5e7eb;
}

.stat-label {
  font-size: 0.85rem;
  color: #6b7280;
  font-weight: 500;
}

.stat-value {
  flex-shrink: 0;
}

/* Fixed footer controls */
.controls-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 2px solid #e5e7eb;
  padding: 12px 16px;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
  z-index: 1000;
}

.controls-container {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.status-text {
  font-size: 0.9rem;
  color: #6b7280;
  font-weight: 500;
}

.footer-stat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: #f9fafb;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
}

.footer-stat-label {
  font-size: 0.85rem;
  color: #6b7280;
  font-weight: 500;
}

/* Tablet and larger screens */
@media (min-width: 768px) {
  .boat-wrapper {
    max-width: 700px;
  }

  .boat-rows {
    gap: 7px;
  }

  .boat-outline {
    padding: 10px 0;
    gap: 7px;
  }

  .row {
    grid-template-columns: 60px 1fr 20px 1fr 100px;
    gap: 8px;
    min-height: 60px;
  }

  .row-label {
    font-size: 0.85rem;
    padding-right: 8px;
    width: 60px;
  }

  .slot {
    height: 50px;
    font-size: 0.75rem;
  }

  .slot-spacer {
    width: 20px;
  }

  .row-stats {
    font-size: 0.75rem;
    padding-left: 8px;
    width: 100px;
  }
}

/* Desktop screens - larger floating panels */
@media (min-width: 992px) {
  .floating-panel-left,
  .floating-panel-right {
    width: 340px;
  }

  .boat-wrapper {
    max-width: 750px;
  }

  .boat-rows {
    gap: 8px;
  }

  .boat-outline {
    padding: 12px 0;
    gap: 8px;
  }

  .row {
    grid-template-columns: 80px 1fr 32px 1fr 140px;
    min-height: 64px;
    gap: 12px;
    padding: 4px 0;
  }

  .row-label {
    font-size: 0.95rem;
    padding-right: 12px;
    width: 80px;
  }

  .slot {
    height: 52px;
    font-size: 0.8rem;
  }

  .slot-spacer {
    width: 32px;
  }

  .row-stats {
    font-size: 0.85rem;
    padding-left: 12px;
    width: 140px;
  }

  .paddler .name {
    font-size: 1rem;
  }

  .paddler img {
    width: 48px;
    height: 48px;
  }

  .stat-item {
    padding: 12px 14px;
  }
}

/* Paddler in slot should fill available space */
.paddler-in-slot {
  display: flex !important;
  align-items: center;
  flex: 1;
  min-width: 0;
}

/* Drag Handle Styles */
.drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 100%;
  flex-shrink: 0;
  cursor: grab;
  touch-action: none;

  margin: 0 4px;
  opacity: 0.4;
  transition: opacity 0.2s;
}

.drag-handle:hover {
  opacity: 0.8;
}

.drag-handle:active {
  cursor: grabbing;
  opacity: 1;
}

.drag-icon {
  display: block;
  width: 16px;
  height: 12px;
  background-image: 
    linear-gradient(to bottom,
      transparent 0%, transparent 15%,
      currentColor 15%, currentColor 30%,
      transparent 30%, transparent 45%,
      currentColor 45%, currentColor 60%,
      transparent 60%, transparent 75%,
      currentColor 75%, currentColor 90%,
      transparent 90%, transparent 100%
    );
  color: #6b7280;
}

.paddler {
  display: flex;
  align-items: center;
}

/* Ensure the existing paddler content flexes properly */
.paddler > .d-flex {
  flex: 1;
  min-width: 0;
}