/* Two-column selector layout */
.selector-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.left-selectors {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  height: 100%;
  justify-content: space-between;
}

.left-selectors .selector-group {
  padding: 0.5rem;
  border-radius: var(--border-radius);
  border: 1px solid transparent;
}

.left-selectors .selector-group:hover {
  border-color: var(--border-color);
  background-color: rgba(255, 255, 255, 0.05);
}

.right-selector {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.right-selector .selector-group {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Make bike type buttons in ONE ROW */
.right-selector .bike-type-select {
  flex: 1;
  display: flex !important;
  flex-direction: row !important; /* Force row direction */
  justify-content: space-between !important;
  gap: 10px !important;
  height: 100% !important;
  flex-wrap: nowrap !important;
  width: 100% !important;
}

.right-selector .bike-type-option {
  flex: 1 !important;
  height: 100% !important;
  min-height: 250px !important; /* Make buttons taller */
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 20px 5px !important;
  margin: 0 !important;
}

.right-selector .bike-type-option .icon {
  font-size: 3.5rem !important;
  margin-bottom: 1.5rem !important;
  display: block !important;
}

.right-selector .bike-type-option span:not(.icon) {
  font-size: 1.2rem !important;
  font-weight: 600 !important;
  display: block !important;
}

/* Responsive Flex Layout for All Screens */
.date-quick-select,
.duration-quick-select,
.quantity-quick-select {
  display: flex;
  width: 100%;
  flex-wrap: nowrap;
  gap: 2%;
}

.date-option,
.duration-option,
.quantity-option {
  flex: 1 1 auto;
  min-width: 0;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0.75rem 0.5rem;
  transition: all 0.25s ease;
}

/* Large Desktop Screens (1280px+) */
@media (min-width: 1281px) {
  .selector-container {
    gap: 2rem;
  }
  
  .date-option,
  .duration-option,
  .quantity-option {
    font-size: 1rem;
    padding: 0.75rem 1rem;
  }
  
  .right-selector .bike-type-option {
    min-height: 250px;
  }
  
  .right-selector .bike-type-option .icon {
    font-size: 3.5rem;
    margin-bottom: 1.5rem;
  }
}

/* Medium Screens (1024px - 1280px) */
@media (max-width: 1280px) {
  .selector-container {
    gap: 1.5rem;
  }
  
  /* Use a flexible grid layout */
  .date-quick-select,
  .duration-quick-select,
  .quantity-quick-select {
    gap: 1.5%;
  }
  
  /* Flexible button sizing - each takes proportional space */
  .date-option,
  .duration-option,
  .quantity-option {
    font-size: 0.9rem;
    padding: 0.6rem 0.25rem;
  }
  
  /* Give more space to longer text buttons */
  .date-option[data-value="today"] { flex-grow: 11; }
  .date-option[data-value="tomorrow"] { flex-grow: 8; }
  .date-option[data-value="weekend"] { flex-grow: 8; }
  .date-option[data-value="custom"] { flex-grow: 11; }
  
  .duration-option[data-value="2h"] { flex-grow: 4; }
  .duration-option[data-value="4h"] { flex-grow: 4; }
  .duration-option[data-value="day"] { flex-grow: 8; }
  .duration-option[data-value="custom"] { flex-grow: 11; }
  
  /* Bike type adjustments */
  .right-selector .bike-type-option {
    min-height: 220px;
  }
  
  .right-selector .bike-type-option .icon {
    font-size: 3rem;
    margin-bottom: 1rem;
  }
  
  .right-selector .bike-type-option span:not(.icon) {
    font-size: 1.1rem;
  }
}

/* Small Desktop and Large Tablets (974px - 1024px) - THE PROBLEM ZONE */
@media (max-width: 1024px) {
  /* Custom flexbox layout for this specific screen size */
  .selector-container {
    gap: 1.25rem;
  }
  
  /* This is the critical screen size - use variable-width flex */
  .date-quick-select,
  .duration-quick-select,
  .quantity-quick-select {
    gap: 1.25%;
  }
  
  /* Size buttons based on text length */
  .date-option,
  .duration-option,
  .quantity-option {
    font-size: 0.85rem;
    padding: 0.6rem 0.25rem;
    border-radius: 6px;
  }
  
  /* CRITICAL: Make "Personnalisé" and "Week-end" have icon indicators */
  .date-option[data-value="custom"] span,
  .duration-option[data-value="custom"] span {
    display: inline-flex;
    align-items: center;
  }
  
  .date-option[data-value="custom"] span:before,
  .duration-option[data-value="custom"] span:before {
    content: "📅";
    margin-right: 4px;
    font-size: 0.9em;
  }
  
  .date-option[data-value="weekend"] span:before {
    content: "🗓️";
    margin-right: 4px;
    font-size: 0.9em;
  }
  
  .duration-option[data-value="day"] span:before {
    content: "☀️";
    margin-right: 4px;
    font-size: 0.9em;
  }
  
  /* Specific spacing adjustments */
  .date-option[data-value="today"] { flex-grow: 10; }
  .date-option[data-value="tomorrow"] { flex-grow: 9; }
  .date-option[data-value="weekend"] { flex-grow: 9; }
  .date-option[data-value="custom"] { flex-grow: 11; }
  
  .duration-option[data-value="2h"] { flex-grow: 3; }
  .duration-option[data-value="4h"] { flex-grow: 3; }
  .duration-option[data-value="day"] { flex-grow: 8; }
  .duration-option[data-value="custom"] { flex-grow: 11; }
  
  /* Label sizes */
  .selector-group label {
    font-size: 0.9rem;
  }
  
  /* Bike selector adjustments */
  .right-selector .bike-type-option {
    min-height: 180px;
  }
  
  .right-selector .bike-type-option .icon {
    font-size: 2.5rem;
    margin-bottom: 0.8rem;
  }
}

/* Medium Tablets (769px - 974px) */
@media (max-width: 974px) {
  /* Switch to single column layout with icon indicators */
  .selector-container {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }
  
  /* Adjust spacing */
  .left-selectors {
    gap: 1rem;
  }
  
  .right-selector {
    margin-top: 1rem;
  }
  
  /* Visual icon indicators with full text */
  .date-option[data-value="weekend"] span:before,
  .date-option[data-value="custom"] span:before,
  .duration-option[data-value="day"] span:before,
  .duration-option[data-value="custom"] span:before {
    margin-right: 4px;
    font-size: 0.9em;
  }
  
  /* Advanced layout - 2x2 grid for bike types */
  .right-selector .bike-type-select {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }
  
  .right-selector .bike-type-option {
    min-height: 120px;
  }
  
  .right-selector .bike-type-option .icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
  }
}

/* Mobile Landscape and Small Tablets (640px - 768px) */
@media (max-width: 768px) and (min-width: 641px) {
  /* Single column layout with spacing */
  .selector-container {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }
  
  /* Make buttons very compact but readable */
  .date-option,
  .duration-option,
  .quantity-option {
    padding: 0.35rem 0.4rem;
    font-size: 0.8rem;
    min-width: auto;
  }
  
  /* Make bike type options appear in a 2x2 grid */
  .right-selector .bike-type-select {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 0.75rem !important;
  }
  
  .right-selector .bike-type-option {
    min-height: 100px !important;
  }
  
  .right-selector .bike-type-option .icon {
    font-size: 1.8rem !important;
    margin-bottom: 0.4rem !important;
  }
}

/* FIX FOR PROBLEMATIC RANGE: 480px-630px - Two-row layout */
@media (max-width: 630px) and (min-width: 480px) {
  /* Fix containers to not overflow */
  #simple-booking,
  .smart-booking-container,
  .selector-container,
  .left-selectors,
  .right-selector,
  .selector-group {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
  }
  
  /* Use same two-row layout as mobile */
  .date-quick-select,
  .duration-quick-select,
  .quantity-quick-select {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  
  .date-option,
  .duration-option,
  .quantity-option {
    flex: 1 1 45%;
    justify-content: center;
    text-align: center;
    min-height: 44px;
    font-size: 0.85rem;
    padding: 0.6rem 0.5rem;
  }
  
  /* Keep all texts original - no need for abbreviations in two rows */
  .date-option[data-value="weekend"] span:before,
  .date-option[data-value="custom"] span:before,
  .duration-option[data-value="day"] span:before,
  .duration-option[data-value="custom"] span:before {
    display: none;
  }
}

/* Mobile Devices (Portrait) - Under 480px */
@media (max-width: 480px) {
  /* Very compact single column layout */
  .selector-container {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }
  
  /* Fix containers to not overflow */
  #simple-booking,
  .smart-booking-container,
  .selector-container,
  .left-selectors,
  .right-selector,
  .selector-group {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
  }
  
  /* Full width buttons for smaller phones */
  .date-quick-select,
  .duration-quick-select,
  .quantity-quick-select {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  
  .date-option,
  .duration-option,
  .quantity-option {
    flex: 1 1 45%;
    justify-content: center;
    text-align: center;
    min-height: 44px;
  }
  
  /* Bike type options in a 2x2 grid that properly fit */
  .right-selector .bike-type-select {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 0.5rem !important;
  }
}

/* App-like Mobile Experience */
@media (max-width: 767px) {
  /* Selector container becomes app-like cards */
  .selector-container {
    grid-template-columns: 1fr;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
  }
  
  /* Ensure proper spacing on all selectors */
  .selector-group {
    margin-bottom: 0.75rem;
  }
  
  /* Make bike type options a grid */
  .right-selector .bike-type-select {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 0.75rem !important;
    padding: 0.5rem 0 !important;
  }
  
  .right-selector .bike-type-option {
    min-height: 100px !important;
    border-radius: 12px !important;
    padding: 0.75rem 0.5rem !important;
    margin: 0 !important;
    justify-content: center;
  }
  
  .right-selector .bike-type-option .icon {
    font-size: 2rem !important;
    margin-bottom: 0.5rem !important;
  }
  
  .right-selector .bike-type-option span:not(.icon) {
    font-size: 0.9rem !important;
  }
  
  /* Ensure all buttons have proper touch targets */
  .date-option,
  .duration-option,
  .quantity-option {
    min-height: 44px;
    border-radius: 10px !important;
  }
  
  /* Show bikes button gets more emphasis */
  #showBikes {
    width: 100%;
    margin-top: 1rem;
    padding: 1rem;
    font-size: 1rem;
    border-radius: 10px;
    min-height: 50px;
  }
  
  /* Ensure buttons lay out properly */
  .date-quick-select,
  .duration-quick-select,
  .quantity-quick-select {
    display: flex;
    justify-content: space-between;
    width: 100%;
  }
}