/* ================================================
   XI WOO SEARCH - FRONTEND STYLES (COMBINED)
   ================================================ */

/* ========================================
   1. SEARCH CONTAINER & FORM
   ======================================== */
.xi-search-container {
  max-width: 100%;
  margin: 0 0 30px 0;
  position: relative;
  clear: both;
  float: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  /* box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); */
  border-radius: 8px;
  padding: 5px;
}

.xi-search-form {
  width: 100%;
  position: relative;
}

.xi-search-input-wrapper {
  position: relative;
  width: 100%;
}

.xi-search-input {
  width: 100%;
  padding: 14px 45px 14px 20px;
  font-size: 16px;
  border: 2px solid rgba(251, 115, 5, 1);
  border-radius: 10px;
  transition: all 0.3s ease;
  box-sizing: border-box;
  background: #f8f9fa;
  color: #333;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
}

.xi-search-input:focus {
  outline: none;
  border-color: #2196f3;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

/* ========================================
   2. LOADING STATES & ANIMATIONS  
   ======================================== */
.searchloader {
  width: 100%;
  height: 4.8px;
  display: block;
  position: relative;
  background: rgba(251, 115, 5, 0.15);
  overflow: hidden;
  margin: 10px 0;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.searchloader::after {
  content: "";
  width: 96px;
  height: 4.8px;
  background: #fb7305;
  position: absolute;
  top: 0;
  left: 0;
  box-sizing: border-box;
  animation: hitZak 1s linear infinite alternate;
}

@keyframes hitZak {
  0% {
    left: 0;
    transform: translateX(-1%);
  }
  100% {
    left: 100%;
    transform: translateX(-99%);
  }
}

.searchloader.active {
  opacity: 1;
}

@keyframes rotation {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* ========================================
   3. RESULTS CONTAINER
   ======================================== */
.xi-search-results {
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  position: relative;
  width: 100%;
  z-index: 90;
  background: #f9f9f9;
  padding: 10px;
  border-radius: 10px;
}

.xi-results-header {
  padding: 10px 15px;
  background: #f8f9fa;
  border-bottom: 1px solid #e9ecef;
  border-radius: 10px 10px 0 0;
  margin-bottom: 10px;
}

.xi-results-count-text {
  color: #6c757d;
  font-size: 14px;
  font-weight: 500;
}

.xi-no-results {
  padding: 20px;
  text-align: center;
  color: #6c757d;
  font-style: italic;
}

/* ========================================
   4. LAYOUT TOGGLE CONTROLS
   ======================================== */
.xi-layout-toggle {
  margin-bottom: 15px;
  text-align: center;
}

.xi-layout-btn {
  padding: 8px 16px;
  margin: 0 5px;
  border: 2px solid #0073aa;
  background: #fff;
  color: #0073aa;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s ease;
}

.xi-layout-btn:hover {
  background: #f0f8ff;
}

.xi-layout-btn.active {
  background: #0073aa;
  color: #fff;
}

/* ========================================
   5. BASE PRODUCT COMPONENTS
   ======================================== */
.xi-product-image {
  overflow: hidden;
  position: relative;
}

.xi-product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.xi-product-name {
  font-weight: bold;
  color: #333;
  line-height: 1.4;
}

.xi-product-price {
  color: #0073aa;
  font-weight: 600;
}

.xi-product-price .amount {
  color: #0073aa;
}

.xi-product-stock {
  margin-top: auto;
}

.xi-product-stock .button {
  transition: all 0.3s ease;
  width: 100%;
  text-align: center;
  padding: 10px;
  font-size: 14px;
  border-radius: 4px;
  background-color: #fb7305;
  color: #fff;
  border: none;
  cursor: pointer;
}

.xi-product-stock .button:hover {
  background-color: #e6690a;
}

.xi-product-stock .out-of-stock {
  text-align: center;
  color: #ffffff;
  padding: 10px;
  border-radius: 4px;
  background-color: #dc3545;
  font-weight: 500;
  display: inline-block;
}

/* Loading State */
.xi-product-stock .button.loading {
  opacity: 0.5;
  padding-right: 2.618em;
  position: relative;
}

.xi-product-stock .button.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 0.5em;
  width: 1em;
  height: 1em;
  margin-top: -0.5em;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-right-color: transparent;
  border-radius: 50%;
  animation: rotation 0.8s infinite linear;
}

/* Added State */
.xi-product-stock .added {
  display: none !important;
}

.xi-product-stock .button.added + .added_to_cart {
  display: inline-block !important;
  background-color: #4caf50;
  color: white;
  padding: 0.5em 1em;
  border-radius: 4px;
  text-decoration: none;
  transition: background-color 0.3s ease;
}

.xi-product-stock .button.added + .added_to_cart:hover {
  background-color: #45a049;
}

/* ========================================
   6. ROWS LAYOUT
   ======================================== */
.xi-results-rows {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.product-row {
  background-color: white;
  display: grid;
  grid-template-columns: 100px 2fr 1fr 1fr; /* Image | Title | Price | Action */
  align-items: center;
  gap: 20px;
  padding: 15px;
  border-bottom: 1px solid #b7b7b7;
  margin-bottom: 4px;
  filter: drop-shadow(0px 2px 6px 2px rgba(77, 77, 77, 0.5));
  border-radius: 10px;
}

/* EXPLICIT COLUMN POSITIONING - ENSURES CORRECT ORDER */
.product-row .product-image {
  grid-column: 1; /* First column - Image */
  order: 1;
}

.product-row .product-image img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 4px;
}

.product-row .product-title {
  grid-column: 2; /* Second column - Product Name */
  order: 2;
  font-weight: bold;
}

.product-row .product-title a {
  text-decoration: none;
  color: inherit;
}

.product-row .product-title a:hover {
  color: #fe7d04;
  text-decoration: underline;
}

.product-row .product-price {
  grid-column: 3;
  order: 3;
  font-weight: bold;
  font-size: 2rem;
  color: #0073aa;
  text-align: center;
}

.product-row .product-action {
  grid-column: 4; /* Fourth column - Add to Cart */
  order: 4;
  text-align: center;
}

.product-row .product-action .button {
  display: inline-block;
  padding: 8px 16px;
  background-color: #fb7305;
  color: #fff;
  text-decoration: none;
  border-radius: 4px;
  border: none;
  cursor: pointer;
}

.product-row .product-action .out-of-stock {
  text-align: center;
  color: #ffffff;
  padding: 8px 16px;
  border-radius: 4px;
  background-color: #dc3545;
  font-weight: 500;
  display: inline-block;
}

/* LEGACY SUPPORT - Keep for backward compatibility */
.xi-results-rows .xi-result-item {
  background-color: white;
  display: grid;
  grid-template-columns: 100px 1fr auto;
  align-items: center;
  gap: 20px;
  padding: 15px;
  border-bottom: 1px solid #b7b7b7;
  margin-bottom: 4px;
  filter: drop-shadow(0px 2px 6px 2px rgba(77, 77, 77, 0.5));
  border-radius: 10px;
}

.xi-results-rows .xi-product-image {
  width: 100px;
  height: 80px;
  overflow: hidden;
  border-radius: 4px;
}

.xi-results-rows .xi-product-image img {
  width: 80px;
  height: 80px;
  object-fit: cover;
}

.xi-results-rows .xi-product-info {
  grid-column: 2;
  gap: 8px;
  align-self: center !important;
}

.xi-results-rows .xi-product-info a {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.xi-results-rows .xi-product-name:hover,
.xi-results-rows .xi-product-info a:hover .xi-product-name {
  color: #fe7d04;
  text-decoration: underline;
}

.xi-results-rows .xi-product-price {
  font-weight: bold;
  font-size: 2rem;
  color: #0073aa;
}

.xi-results-rows .xi-product-stock {
  grid-column: 3;
  width: 100%;
  text-align: center;
}

.xi-results-rows .xi-product-stock .button {
  display: inline-block;
  padding: 8px 16px;
  background-color: #fb7305;
  color: #fff;
  text-decoration: none;
  border-radius: 4px;
  border: none;
  cursor: pointer;
}

.xi-results-rows .xi-product-stock .out-of-stock {
  text-align: center;
  color: #ffffff;
  padding: 4px 6px;
  border-radius: 10px;
  background-color: #dc3545;
  font-weight: 500;
}

/* ========================================
   7. GRID LAYOUT  
   ======================================== */
.xi-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

/* NEW: PRODUCT-CARD STYLES FOR CLEAN SEPARATION */
.product-card {
  background-color: white;
  border-radius: 10px;
  padding: 20px;
  text-align: center;
  filter: drop-shadow(0px 2px 6px 2px rgba(77, 77, 77, 0.5));
  transition: transform 0.2s ease;
  border: 1px solid #ebebeb;
  min-height: 400px;
  display: flex;
  flex-direction: column;
}

.product-card:hover {
  transform: translateY(-2px);
}

.product-card .product-image {
  margin-bottom: 15px;
}

.product-card .product-image img {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 8px;
}

.product-card .product-title {
  font-weight: bold;
  font-size: 1.5rem;
  margin-bottom: 10px;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-grow: 1;
}

.product-card .product-title a {
  text-decoration: none;
  color: inherit;
}

.product-card .product-title a:hover {
  color: #fe7d04;
  text-decoration: underline;
}

.product-card .product-price {
  font-weight: bold;
  font-size: 1.8rem;
  margin-bottom: 15px;
}

span.woocommerce-Price-amount.amount {
  color: #0073aa !important;
}

.product-card .product-action {
  width: 200px;
  margin-top: auto;
  place-self: center;
}

.product-card .product-action .button {
  display: inline-block;
  width: auto;
  padding: 12px 24px;
  text-align: center;
  font-size: 1.4rem;
  background-color: #fb7305;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  min-width: 140px;
}

.product-card .product-action .out-of-stock {
  display: inline-block;
  width: auto;
  padding: 12px 24px;
  font-size: 1.2rem;
  text-align: center;
  color: #ffffff;
  border-radius: 10px;
  background-color: #dc3545;
  font-weight: 500;
  min-width: 140px;
}

/* LEGACY GRID SUPPORT - Keep for backward compatibility */
.xi-results-grid .xi-result-item {
  background-color: white;
  border-radius: 10px;
  padding: 20px;
  text-align: center;
  filter: drop-shadow(0px 2px 6px 2px rgba(77, 77, 77, 0.5));
  transition: transform 0.2s ease;
  border: 1px solid #ebebeb;
  min-height: 400px;
}

.xi-results-grid .xi-result-item:hover {
  transform: translateY(-2px);
}

.xi-results-grid .xi-product-image {
  margin-bottom: 15px;
  height: 140px;
}

.xi-results-grid .xi-product-image img {
  width: 120px;
  height: 120px;
  object-fit: contain;
  border-radius: 8px;
}

.xi-results-grid .xi-product-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 15px;
}

.xi-results-grid .xi-product-info a {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.xi-results-grid .xi-product-name {
  font-weight: bold;
  font-size: 14px;
  margin-bottom: 10px;
  min-height: 2.8em;
  display: flex;
  align-items: center;
  justify-content: center;
}

.xi-results-grid .xi-product-name a:hover,
.xi-results-grid .xi-product-info a:hover .xi-product-name {
  color: #fe7d04;
  text-decoration: underline;
}

.xi-results-grid .xi-product-price {
  font-weight: bold;
  font-size: 16px;
  color: #0073aa;
  margin-bottom: 15px;
}

.xi-results-grid .xi-product-stock {
  width: 100%;
  margin-top: auto;
}

.xi-results-grid .xi-product-stock .button {
  display: inline-block;
  width: auto;
  padding: 12px 24px;
  text-align: center;
  font-size: 1.4rem;
  background-color: #fb7305;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  min-width: 140px;
}

.xi-results-grid .xi-product-stock .out-of-stock {
  display: inline-block;
  width: auto;
  padding: 12px 24px;
  font-size: 1.2rem;
  text-align: center;
  color: #ffffff;
  border-radius: 10px;
  background-color: #dc3545;
  font-weight: 500;
  min-width: 140px;
}

/* ========================================
   8. MOBILE RESPONSIVE (576px and below)
   ======================================== */
@media screen and (max-width: 576px) {
  /* GRID - Mobile Default (2 columns) */
  .xi-results-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
  }

  /* GRID - Mobile 1 column when specifically set */
  .xi-results-grid.mobile-1-col {
    grid-template-columns: 1fr !important;
  }

  /* NEW: PRODUCT-CARD MOBILE STYLES */
  .product-card {
    min-height: 350px;
    padding: 15px;
  }

  .product-card .product-image img {
    width: 100px;
    height: 100px;
  }

  .product-card .product-title {
    font-size: 1.4rem;
    min-height: 42px;
  }

  .product-card .product-price {
    font-size: 1.6rem;
  }

  .product-card .product-action .button {
    padding: 10px 16px;
    font-size: 1.2rem;
    min-width: 120px;
  }

  /* Enhanced styling for single column mobile */
  .product-card.mobile-1-col {
    max-width: 400px;
    margin: 0 auto;
    min-height: 400px;
    padding: 20px;
  }

  .product-card.mobile-1-col .product-image img {
    width: 150px;
    height: 150px;
  }

  .product-card.mobile-1-col .product-title {
    font-size: 1.8rem;
    min-height: 54px;
  }

  .product-card.mobile-1-col .product-price {
    font-size: 2rem;
  }

  .product-card.mobile-1-col .product-action .button {
    font-size: 1.6rem;
    padding: 14px 24px;
    min-width: 160px;
  }

  /* NEW: PRODUCT-ROW MOBILE STYLES */
  .product-row {
    grid-template-columns: 80px 1fr;
    gap: 15px;
    padding: 15px;
  }

  .product-row .product-image {
    grid-column: 1;
    grid-row: 1;
  }

  .product-row .product-image img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 4px;
  }

  .product-row .product-title {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    font-size: 1.4rem;
  }

  .product-row .product-price {
    grid-column: 2;
    grid-row: 2;
    font-size: 1.5rem;
    margin-top: 5px;
  }

  .product-row .product-action {
    grid-column: 1 / -1;
    grid-row: 3;
    margin-top: 10px;
    width: 200px;
    justify-self: center;
  }

  .product-row .product-action .button {
    width: 100%;
    padding: 12px;
    font-size: 1.4rem;
  }

  /* LEGACY ROWS - Mobile */
  .xi-results-rows .xi-result-item {
    grid-template-columns: 80px 1fr;
    gap: 15px;
    padding: 15px;
  }

  .xi-results-rows .xi-product-image {
    width: 80px;
    height: 80px;
  }

  .xi-results-rows .xi-product-info {
    grid-column: 2;
    display: flex;
    flex-direction: column;
    gap: 5px;
  }

  .xi-results-rows .xi-product-info a {
    display: flex;
    flex-direction: column;
    gap: 5px;
  }

  .xi-results-rows .xi-product-stock {
    grid-column: 1 / -1;
    grid-row: 3;
    width: 100%;
    margin-top: 10px;
  }

  .xi-results-rows .xi-product-stock .button {
    width: 100%;
    padding: 10px;
  }
}

/* ========================================
   9. VERY SMALL MOBILE (480px and below)
   ======================================== */
@media screen and (max-width: 480px) {
  .xi-results-grid.mobile-1-col {
    grid-template-columns: 1fr !important;
  }

  /* NEW: PRODUCT-CARD VERY SMALL MOBILE */
  .product-card {
    padding: 12px;
    min-height: 320px;
  }

  .product-card .product-image img {
    width: 80px;
    height: 80px;
  }

  .product-card .product-title {
    font-size: 1.5rem !important;
    min-height: 36px;
  }

  .product-card .product-price {
    font-size: 1.4rem;
  }

  .product-card .product-action .button {
    width: 100%;
    font-size: 1.4rem;
    padding: 12px;
  }

  span.woocommerce-Price-amount.amount {
    font-size: 2rem !important;
  }
  /* Single column styling for very small screens when explicitly set */
  .product-card.mobile-1-col {
    max-width: 100%;
    padding: 16px;
    min-height: 380px;
  }

  .product-card.mobile-1-col .product-image img {
    width: 120px;
    height: 120px;
  }

  .product-card.mobile-1-col .product-title {
    font-size: 1.6rem;
    min-height: 48px;
  }

  .product-card.mobile-1-col .product-price {
    font-size: 1.8rem;
  }

  .product-card.mobile-1-col .product-action .button {
    font-size: 1.4rem;
    padding: 12px 20px;
    min-width: 140px;
  }

  /* NEW: PRODUCT-ROW VERY SMALL MOBILE */
  .product-row {
    padding: 12px;
    gap: 12px;
    background: #ffffff !important;
  }

  .product-row .product-title {
    font-size: 1.5rem !important;
  }

  .product-row .product-price {
    font-size: 2rem !important;
    margin-left: 80px;
  }
}

/* ========================================
   10. TABLET RESPONSIVE (577px - 1024px)
   ======================================== */
@media screen and (min-width: 577px) and (max-width: 1024px) {
  .xi-results-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  }

  .product-row {
    gap: 18px;
  }

  .product-row .product-price {
    font-size: 1.8rem;
  }
}

/* ========================================
   11. DESKTOP OPTIMIZATIONS (769px+)
   ======================================== */
@media (min-width: 769px) {
  /* === ROW VIEW (DESKTOP): one-line info + centered button === */
  /* Image | Info | Button */
  .xi-results-rows .xi-result-item {
    grid-template-columns: 100px 1fr auto !important;
    align-items: center !important; /* vertical center for all three cells */
  }

  /* Make the link a 2-column grid: name (flex) | price (auto) */
  .xi-results-rows .xi-product-info {
    align-self: center !important;
  }

  .xi-results-rows .xi-product-info a {
    display: grid !important;
    grid-template-columns: 1fr auto !important; /* name ..... price */
    align-items: center !important; /* same vertical level */
    column-gap: 12px !important; /* space between name & price */
    text-decoration: none;
  }

  /* Keep name on one line so price never drops */
  .xi-results-rows .xi-product-name {
    margin: 0 !important;
    line-height: 1.25 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  .xi-results-rows .xi-product-price {
    line-height: 1.25 !important;
    margin: 0 100px;
  }

  /* Button: compact and vertically centered; left side in RTL via `end` */
  .xi-results-rows .xi-product-stock {
    margin-top: 0 !important; /* override global pushing down */
    align-self: center !important;
    justify-self: end !important; /* right in LTR, left in RTL */
    text-align: inherit !important;
  }

  .xi-results-rows .xi-product-stock .button {
    width: auto !important; /* override global 100% */
    display: inline-block !important;
    white-space: nowrap !important;
    min-width: 120px;
    padding: 8px 14px;
  }
}

@media screen and (min-width: 1025px) {
  .xi-results-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}
