/* --- SEARCH FORM MODERNIZATION --- */

.search-form-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 30px;
  padding: 20px;
  background-color: #f7f7f7;
  border-radius: 20px;
  align-items: center;
  margin-bottom: 30px;
}

.form-image-container {
  flex: 1 1 250px;
  min-width: 250px;
}

.tyre-info-image {
  width: 100%;
  max-width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  border-radius: 15px;
}

.form-container {
  flex: 3 1 60%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.custom-select-wrapper {
  position: relative;
  font-family: sans-serif;
  color: #333;
}

.custom-select-wrapper label {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  display: block;
  color: #555;
}

/* Hide original select */
.custom-select-wrapper select {
  display: none;
}

.custom-select {
  position: relative;
}

.custom-select-trigger {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 16px;
  font-weight: 500;
  color: #333;
  background: #ffffff;
  border-radius: 8px;
  border: 1px solid #ddd;
  cursor: pointer;
  transition: border-color 0.3s ease;
}

.custom-select-trigger:hover {
  border-color: #999;
}

.custom-select.open .custom-select-trigger {
  border-color: #777;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.06);
}

.custom-select-search {
  width: 100%;
  min-width: 0;
  padding: 12px 42px 12px 15px;
  border: 0;
  outline: 0;
  border-radius: 8px;
  background: transparent;
  color: #333;
  font: inherit;
  cursor: text;
}

.custom-select-search::placeholder {
  color: #777;
  opacity: 1;
}

.custom-select-trigger .arrow {
  position: absolute;
  right: 16px;
  top: 50%;
  height: 10px;
  width: 10px;
  border-left: 2px solid #555;
  border-bottom: 2px solid #555;
  transform: rotate(-45deg) translateY(-50%);
  transition: transform 0.3s ease;
  margin-top: -5px;
  pointer-events: none;
}

.custom-select.open .arrow {
  transform: rotate(135deg);
}

.custom-options {
  position: absolute;
  display: block;
  top: 100%;
  left: 0;
  right: 0;
  min-width: 100%;
  margin-top: 5px;
  background: #fff;
  border-radius: 8px;
  border: 1px solid #ddd;
  box-shadow: 0 5px 15px rgba(0,0,0,0.08);
  z-index: 10;
  max-height: 0;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transition: max-height 0.3s ease, opacity 0.3s ease, visibility 0.3s ease;
}

.custom-select.open .custom-options {
  max-height: 220px;
  opacity: 1;
  visibility: visible;
}

.custom-option {
  position: relative;
  display: block;
  padding: 12px 15px;
  font-size: 15px;
  color: #333;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.custom-option:hover,
.custom-option.selected {
  background-color: #f0f0f0;
}

.custom-no-results {
  padding: 12px 15px;
  color: #777;
  font-size: 14px;
}

.search-button-container {
  grid-column: 3 / 4; /* Place in the third column */
  align-self: end; /* Align to the bottom of the grid cell */
}

.ricerca-bottone {
  cursor: pointer;
  color: white !important;
  width: 100%;
  height: 50px;
  font-size: 16px;
  font-weight: 600;
  background: linear-gradient(45deg, rgb(20, 20, 20), rgb(0, 0, 0)) !important;
  border: none;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ricerca-bottone:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}


/* --- CARD & RESULTS STYLING --- */

.tyrestock-container {
  display: flex;
  flex-wrap: wrap; 
  gap: 16px; 
  justify-content: flex-start; 
  margin-top: 20px;
}

.card {
  flex: 0 1 calc((100% - 48px) / 4);
  max-width: calc((100% - 48px) / 4);
  box-sizing: border-box; 
  padding: 14px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  display: flex;
  flex-direction: column;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
}

.card .box {
  margin-bottom: 10px;
}
.card .box:last-child {
  margin-bottom: 0;
  margin-top: auto; /* Push to bottom */
}

.card .box img.imggomma {
  width: 100%;
  max-width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  border-radius: 10px;
  margin-bottom: 8px;
}
.card .box img.imgmarca {
  width: 68px;
  max-width: 68px;
  height: 34px;
  object-fit: contain;
}

.card .descrizione {
  color: #444;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.35;
  height: 61px;
  overflow: hidden;
  text-align: left;
}

.card .gomma {
  color: #222;
  font-size: 13px;
  margin: 10px 0;
  display: flex;
  align-items: center;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 7px;
}

.card .gomma img {
  vertical-align: middle;
}

.card .pfu {
  color: #888;
  font-size: 12px;
  margin-bottom: 8px;
}

.card .prezzo {
  color: #000;
  font-size: 21px;
  font-weight: bold;
  margin-bottom: 10px;
}

.button-add-To-Cart-tyrestock {
  cursor: pointer;
  color: white!important;
  width: 100%;
  height: 44px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  background: linear-gradient(45deg,rgb(20, 20, 20),rgb(0, 0, 0))!important;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.2s ease;
}
.button-add-To-Cart-tyrestock:hover {
  transform: scale(1.03);
}


/* --- PAGINATION --- */
#pagination-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px; 
  margin-top: 30px; 
}

.pagination-button-1 {
  cursor: pointer;
  color: white !important;
  width: 120px;
  height: 45px;
  font-size: 15px;
  font-weight: 600;
  background: linear-gradient(45deg, rgb(20, 20, 20), rgb(0, 0, 0)) !important;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
}

.pagination-button-1:hover {
  background: linear-gradient(45deg, rgb(50, 50, 50), rgb(30, 30, 30)) !important;
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

/* --- RESPONSIVE --- */

@media (max-width: 1199px) {
  .card {
    flex-basis: calc((100% - 32px) / 3);
    max-width: calc((100% - 32px) / 3);
  }
}

@media (max-width: 900px) {
  .card {
    flex-basis: calc((100% - 16px) / 2);
    max-width: calc((100% - 16px) / 2);
  }
}

@media (max-width: 992px) {
  .form-container {
    grid-template-columns: repeat(2, 1fr);
  }
  .search-button-container {
    grid-column: 1 / -1; /* Full width */
  }
}

@media (max-width: 768px) {
  .search-form-wrapper {
    flex-direction: column;
    align-items: stretch;
  }
  .form-container {
    grid-template-columns: 1fr;
  }
  .search-button-container {
    grid-column: 1 / -1; /* Ensure it stays full width */
  }
}

@media (max-width: 600px) {
  .card {
    flex-basis: 100%;
    max-width: 100%;
  }
}


.tyrestock-loader {
  grid-column: 1 / -1;
  text-align: center;
}

.tyrestock-spinner {
  width: 50px;
  height: 50px;
  margin: 0 auto;
  border: 4px solid #d8d8d8;
  border-top-color: #111;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .custom-select-trigger,
  .custom-select-trigger .arrow,
  .custom-options,
  .custom-option,
  .ricerca-bottone,
  .card,
  .button-add-To-Cart-tyrestock,
  .pagination-button-1 {
    transition: none !important;
  }

  .tyrestock-spinner {
    animation: none !important;
  }
}
