/* Shared styles */
button {
  color: white;
  border: none;
  display: flex;
  cursor: pointer;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  background: var(--kuida-main-color);
}

/* Search */
.search {
  display: flex;
  padding: 2rem 1rem;
  justify-content: center;
}

.search-wrapper {
  width: 100%;
  max-width: 960px;
  padding: 1.75rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  background: white;
  border-radius: 32px;
  box-shadow: var(--shadow);
  overflow: visible;
  position: relative;
}

.search-intro h2 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--kuida-main-color, #e04e53);
}

.search-intro p {
  margin: 0.4rem 0 0;
  color: #4a4a4a;
  font-size: 0.95rem;
}

.search-wrapper form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  width: 100%;
  min-width: 0;
  overflow: visible;
}

.search-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow: visible;
}

.search-field-with-button {
  grid-column: auto;
  min-width: 0;
  width: 100%;
  overflow: visible;
  box-sizing: border-box;
}

.search-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 0;
  width: 100%;
  position: relative;
  overflow: visible;
  z-index: 1;
}

.search-field:has(.autocomplete-suggestions) {
  z-index: 10002;
}

.search-field label {
  font-weight: 600;
  font-size: 0.9rem;
  color: #3d3d3d;
}

.input-wrapper {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.9rem;
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #f8f9ff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  min-width: 0;
  box-sizing: border-box;
  overflow: visible;
  min-height: 48px;
  height: 48px;
  position: relative;
}

.time-input-wrapper {
  overflow: visible;
}

.input-wrapper:focus-within {
  border-color: var(--kuida-main-color, #e04e53);
  box-shadow: 0 0 0 4px rgba(224, 78, 83, 0.12);
  background: #fff;
}

.input-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.search-input {
  border: none;
  background: transparent;
  outline: none;
  width: 100%;
  font-size: 1rem;
  color: #1f1f1f;
  min-width: 0;
  flex: 1;
  height: 100%;
  line-height: 1.5;
}

.search-input::placeholder {
  color: #8c8c8c;
}

.search-input::-webkit-calendar-picker-indicator {
  filter: invert(35%);
  cursor: pointer;
}

/* Custom time selector styles */
.time-input-wrapper {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: nowrap;
  width: 100%;
  overflow: visible;
  min-width: 0;
  flex: 1;
}

.time-selector {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex: 1;
  min-width: 0;
  flex-wrap: nowrap;
  width: 100%;
  height: 100%;
  max-width: 100%;
}

.time-hour-input {
  border: none;
  background: transparent;
  outline: none;
  flex: 1 1 auto;
  min-width: 40px;
  max-width: 60px;
  font-size: 1rem;
  color: #1f1f1f;
  text-align: left;
  padding: 0;
  -moz-appearance: textfield;
  height: 100%;
  line-height: 1.5;
}

.time-hour-input::-webkit-outer-spin-button,
.time-hour-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.ampm-buttons {
  display: flex;
  gap: 0.3rem;
  align-items: center;
  flex-shrink: 0;
  margin-left: 0;
}

.ampm-btn {
  border: 2px solid #e0e0e0;
  background: #f8f9fa;
  color: #666;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
  min-width: 38px;
  text-align: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  white-space: nowrap;
  flex-shrink: 0;
  height: auto;
  line-height: 1.2;
}

.ampm-btn:hover {
  background: #e9ecef;
  border-color: #adb5bd;
  color: #333;
  transform: translateY(-1px);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
}

.ampm-btn.active {
  background: var(--kuida-main-color, #26A69A);
  color: white;
  border-color: var(--kuida-main-color, #26A69A);
  box-shadow: 0 2px 8px rgba(38, 166, 154, 0.3);
  transform: translateY(-1px);
}

.ampm-btn.active:hover {
  background: #1e8a7f;
  border-color: #1e8a7f;
  box-shadow: 0 3px 10px rgba(38, 166, 154, 0.4);
}

.ampm-btn:focus {
  outline: 2px solid var(--kuida-main-color, #26A69A);
  outline-offset: 2px;
}

.search-field-with-button {
  min-width: 0;
}

.search-field--button-only {
  gap: 0;
  justify-content: flex-end;
  align-self: end;
  height: auto;
}

.search-field-with-button .input-button-wrapper {
  display: flex;
  gap: 0.75rem;
  align-items: stretch;
  width: 100%;
  height: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.input-button-wrapper--single {
  justify-content: flex-end;
  height: auto;
}

.input-button-wrapper--single {
  justify-content: flex-end;
  height: auto;
  width: 100%;
}

.input-button-wrapper--single .submit-btn {
  flex: 0 0 auto;
  width: auto;
  height: auto;
  min-height: 3.1rem;
  min-width: 3.5rem;
}

.search-field--button-only .submit-btn {
  padding: 0.65rem 1.25rem;
  height: auto;
}

.price-range-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1 1 0;
  min-width: 0;
}

.price-input-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
  padding: 0.65rem 0.9rem;
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #f8f9ff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.price-input-group:focus-within {
  border-color: var(--kuida-main-color, #e04e53);
  box-shadow: 0 0 0 4px rgba(224, 78, 83, 0.12);
  background: #fff;
}

.price-input-group .input-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.price-input-group .price-input {
  border: none;
  background: transparent;
  outline: none;
  width: 100%;
  font-size: 1rem;
  color: #1f1f1f;
  min-width: 0;
  flex: 1;
}

.price-input-group .price-input::placeholder {
  color: #8c8c8c;
}

.price-separator {
  color: #666;
  font-weight: 600;
  flex-shrink: 0;
  padding: 0 0.25rem;
}

.search-field-with-button .input-wrapper {
  flex: 1 1 0;
  min-width: 0;
  overflow: visible;
  box-sizing: border-box;
}

.search-field-with-button .submit-btn {
  flex-shrink: 1;
  flex-grow: 0;
  white-space: nowrap;
  align-self: stretch;
  min-width: 0;
  max-width: none;
  padding: 0.65rem 0.75rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  box-sizing: border-box;
}

.search-field-with-button .submit-btn .icon {
  font-size: 1.1rem;
  margin-right: 0.3rem;
}

.search-wrapper .submit-btn {
  height: 48px;
  min-height: 48px;
  border-radius: 14px;
  padding: 0.85rem 1.6rem;
  background: var(--kuida-main-color, #e04e53);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.01em;
  box-shadow: 0 10px 20px rgba(224, 78, 83, 0.22);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-field-with-button .submit-btn {
  width: auto;
}

.search-submit .submit-btn {
  width: 100%;
}

.search-wrapper .submit-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 28px rgba(224, 78, 83, 0.28);
}

.search-wrapper .submit-btn .icon {
  font-size: 1.1rem;
}

/* Override generic button defaults inside search wrapper */
.search-wrapper button:not(.submit-btn) {
  border-radius: 14px;
  width: auto;
  height: auto;
}

/* Autocomplete styles */
.autocomplete-suggestions {
  position: fixed;
  background: white;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 14px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  max-height: 200px;
  overflow-y: auto;
  z-index: 10001;
  margin-top: 0.4rem;
  box-sizing: border-box;
}

.autocomplete-item {
  padding: 0.75rem 0.9rem;
  cursor: pointer;
  font-size: 1rem;
  color: #1f1f1f;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  transition: background-color 0.2s ease;
}

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

.autocomplete-item:hover,
.autocomplete-item.autocomplete-active {
  background-color: #f8f9ff;
  color: var(--kuida-main-color, #e04e53);
}

.search-field {
  position: relative;
}

.input-wrapper {
  position: relative;
}

/* Tablet and Mobile */
@media (max-width: 768px) {
  .search {
    padding: 1rem;
    overflow: visible;
  }

  .search-wrapper {
    padding: 1.25rem 1rem;
    border-radius: 24px;
    gap: 1.25rem;
    overflow: visible;
  }

  .search-grid {
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .search-field {
    overflow: visible;
  }

  .autocomplete-suggestions {
    position: fixed;
    left: 1rem;
    right: 1rem;
    width: auto;
    max-width: calc(100vw - 2rem);
    margin-top: 0.5rem;
    z-index: 10001;
  }

  .search-wrapper.search-collapsed {
    gap: 0.9rem;
  }

  .search-wrapper.search-collapsed .search-intro h2 {
    font-size: 1.3rem;
  }

  .search-wrapper.search-collapsed .search-intro p {
    display: none;
  }

  .search-field-with-button {
    grid-column: span 1;
  }

  .search-field-with-button .input-button-wrapper {
    flex-direction: column;
    gap: 0.75rem;
  }

  .search-field-with-button .input-wrapper {
    width: 100%;
    flex: none;
  }

  .search-field-with-button .price-range-wrapper {
    flex-direction: row;
    width: 100%;
  }

  .search-field-with-button .price-input-group {
    flex: 1;
  }

  .search-field-with-button .submit-btn {
    width: 100%;
    max-width: 100%;
    flex-shrink: 0;
  }

  .search-wrapper.search-collapsed .search-grid {
    grid-template-columns: 1fr;
  }

  .search-wrapper.search-collapsed .search-field:not(:first-child) {
    display: none !important;
  }
  
  /* Ensure all fields are visible when not collapsed */
  .search-wrapper:not(.search-collapsed) .search-field {
    display: flex !important;
    visibility: visible !important;
  }

  /* Time selector responsive adjustments */
  .time-input-wrapper {
    overflow: visible;
  }
  
  .time-selector {
    flex-wrap: nowrap;
    gap: 0.25rem;
    width: 100%;
    min-width: 0;
    justify-content: space-between;
  }

  .time-hour-input {
    flex: 0 0 auto;
    min-width: 50px;
    max-width: 80px;
  }

  .ampm-buttons {
    flex-shrink: 0;
    gap: 0.25rem;
    margin-left: auto;
  }

  .ampm-btn {
    min-width: 35px;
    width: 35px;
    padding: 0.3rem 0.4rem;
    font-size: 0.7rem;
  }
}
