/**
 * Smort WooCommerce Custom Search Styles
 *
 * @package Smort_WooCommerce_Custom_Search
 * @since 2.0
 */

/* Product Image Styles */
.swcs-product-image {
  position: relative;
  overflow: hidden;
}

.swcs-product-image img {
  width: 100%;
  height: auto;
  display: block;
}

/* Ultra Fast Loading Animations - Optimized for speed */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.swcs-loading-fast,
.swcs-loading-ultra-fast {
  animation: fadeIn 0.1s ease-in;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Performance optimizations */
.swcs-search-results-container {
  transition: all 0.2s ease-in-out;
  will-change: contents;
}

.swcs-product-card {
  transition: transform 0.15s ease-in-out;
  will-change: transform;
}

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

/* Result Count Styling */
.swcs-result-count {
  background: #f8f9fa;
  border-left: 3px solid var(--accentColor, #ad0000);
  margin-bottom: 15px;
  font-weight: 500;
}

/* Load More Button Styling */
.swcs-load-more-btn {
  background: var(--accentColor, #ad0000) !important;
  color: white !important;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.swcs-load-more-btn:hover {
  background: var(--accentColorDark, #8b0000) !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.swcs-load-more-btn:disabled {
  background: #ccc !important;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.swcs-load-more-container {
  animation: fadeIn 0.3s ease-in;
  text-align: center;
  padding: 20px;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Search Trigger Styles */
.swcs-search-trigger {
  display: inline-block;
  padding: 10px 15px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 16px;
  line-height: 1.5;
  box-sizing: border-box;
  width: 60%;
  font-family: "CustomContentFont";
  font-size: 14px;
}

/* Style 1 - Simple */
.swcs-search-trigger.swcs-trigger-style1 {
  background-color: transparent;
  border-bottom: 1px solid #000 !important;
  text-align: left;
  padding-left: 20px;
  background-color: transparent;
  border-top: 0;
  border-left:0;
  border-right: 0;
}

/* Style 2 - Bordered */
.swcs-search-trigger.swcs-trigger-style2 {
  background-color: transparent;
  border: 1px solid #000;
  border-radius: 4px;
  text-align: left;
  padding-left: 20px;
}

/* Style 3 - Button */
.swcs-search-trigger.swcs-trigger-style3 {
  background-color: #000; /* Kommer att ersättas av dynamisk CSS */
  color: #fff;
  border: none;
  border-radius: 4px; /* Kommer att ersättas av dynamisk CSS */
  text-align: center;
}

/* Style 4 - Icon Only */
.swcs-search-trigger.swcs-trigger-style4 {
  background-color: transparent;
  border: none;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.swcs-search-trigger.swcs-trigger-style4 svg {
  width: 32px;
  height: 32px;
  fill: #000;
}

/* Width Classes */
.swcs-search-trigger.swcs-width-25 {
  width: 25%;
}

.swcs-search-trigger.swcs-width-50 {
  width: 50%;
}

.swcs-search-trigger.swcs-width-75 {
  width: 75%;
}

.swcs-search-trigger.swcs-width-100 {
  width: 60%;
}

/* Search Overlay */
.swcs-search-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 1);
  z-index: 999999;
  display: none;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  overflow-y: auto;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.swcs-search-overlay.active {
  display: flex;
  opacity: 1;
}

/* Body class when overlay is open */
body.swcs-overlay-open {
  overflow: hidden;
}

/* Search Bar */
.swcs-search-bar {
  width: 100%;
  width: -moz-available;
  width: -webkit-fill-available;
  padding: 20px;
  background-color: black;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  border-bottom: 1px solid #000;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}


/* Search Input */
#swcs_search_input ,
#swcs_search_input_desktop,
#swcs_search_input_mobile {
  width: 80%;
  padding: 15px 20px;
  font-size: 20px;
  border: none;
  border-radius: 30px; /* Kommer att ersättas av dynamisk CSS */
  border-radius: 2px; 
  background-color: #fff;
  color: #333;
  transition: all 0.3s ease;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

#swcs_search_input:focus ,
#swcs_search_input_desktop:focus,
#swcs_search_input_mobile:focus {
  outline: none;
  box-shadow: 0 2px 15px rgba(0, 0, 0, 0.2);
  width: 77%;
}
@media (max-width: 388) {
  #swcs_search_input:focus ,
  #swcs_search_input_desktop:focus,
  #swcs_search_input_mobile:focus {
    outline: none;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.2);
    width: 70%;
  }
}
/* Close Button */
.swcs-search-close {
  position: absolute;
  top: 50%;
  right: 40px;
  transform: translateY(-50%);
  font-size: 30px;
  font-weight: bold;
  color: #fff;
  cursor: pointer;
  transition: all 0.3s ease;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.2);
}

.swcs-search-close:hover {
  color: #fff;
  background-color: #ad0000; /* Kommer att ersättas av dynamisk CSS */
}

/* Popular Searches */
.swcs-popular-searches {
  padding: 20px 15px;
  background-color: #fff;
  width: 100%;
  text-align: center;
  box-sizing: border-box;
  border-bottom: 1px solid #eee;
}

.swcs-popular-searches p {
  margin: 0;
  padding: 0;
}

.swcs-popular-search {
  display: inline-block;
  margin: 5px;
  padding: 8px 15px;
  border: 1px solid #000;
  border-radius: 20px; /* Kommer att ersättas av dynamisk CSS */
  color: #000;
  text-decoration: none;
  transition: all 0.3s ease;
  font-size: 14px;
}

.swcs-popular-search:hover {
  background-color: #000; /* Kommer att ersättas av dynamisk CSS */
  color: #fff;
}

/* Search Results */
.swcs-search-results {
  width: 100%;
  padding: 12px;
  background-color: #fff;
  box-sizing: border-box;
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

/* Loading Spinner */
.swcs-loading {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 50px 0;
}

.swcs-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(0, 0, 0, 0.1);
  border-radius: 50%;
  border-top-color: #000;
  animation: swcs-spin 1s ease-in-out infinite;
}

@keyframes swcs-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Search Results Container */
.swcs-search-results-container {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
  box-sizing: border-box;
  position: relative;
}

.swcs-search-results-container::after {
  content: "";
  display: table;
  clear: both;
}

/* Clearfix för att hantera flytande element */
.swcs-products-column::after {
  content: "";
  display: table;
  clear: both;
}

/* Category Filter */
.swcs-categories-column {
  width: 25%;
  float: left;
  background-color: #fff;
  max-height: 600px;
  overflow-y: auto;
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 20px;
  box-sizing: border-box;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.swcs-categories-column h3 {
  margin-top: 0;
  margin-bottom: 15px;
  font-size: 18px;
  color: #333;
  border-bottom: 2px solid #eee;
  padding-bottom: 10px;
}

.swcs-categories-list {
  margin-bottom: 20px;
}

.swcs-categories-list label {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 5px 0;
  flex-grow: 1;
}

.swcs-category-item {
  display: flex;
  flex-wrap: wrap;
  margin-bottom: 5px;
  position: relative;
}

.swcs-category-toggle {
  margin-left: 5px;
  cursor: pointer;
  font-weight: bold;
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background-color: #f0f0f0;
  font-size: 14px;
  line-height: 1;
}

.swcs-subcategories {
  width: 100%;
  padding-left: 10px;
}

.swcs-categories-list label:hover {
  color: #ad0000; /* Kommer att ersättas av dynamisk CSS */
}

.swcs-category-checkbox {
  margin-right: 10px;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid #ccc;
  border-radius: 3px;
  outline: none;
  transition: all 0.2s ease;
  position: relative;
  cursor: pointer;
}

.swcs-category-checkbox:checked {
  background-color: #ad0000; /* Kommer att ersättas av dynamisk CSS */
  border-color: #ad0000; /* Kommer att ersättas av dynamisk CSS */
}

.swcs-category-checkbox:checked:after {
  content: "";
  position: absolute;
  top: 2px;
  left: 6px;
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.swcs-clear-categories {
  background-color: transparent;
  border: 1px solid #ad0000; /* Kommer att ersättas av dynamisk CSS */
  color: #ad0000; /* Kommer att ersättas av dynamisk CSS */
  padding: 8px 15px;
  cursor: pointer;
  transition: all 0.3s ease;
  border-radius: 20px; /* Kommer att ersättas av dynamisk CSS */
  font-size: 14px;
  font-weight: 500;
  width: 100%; /* Täck hela bredden */
  text-align: center;
}

.swcs-clear-categories:hover {
  background-color: #ad0000; /* Kommer att ersättas av dynamisk CSS */
  color: #fff;
}

/* Products Column */
.swcs-products-column {
  width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-wrap: wrap;
  margin: 0; /* Kommer att ersättas av dynamisk CSS */
}

/* När kategorifiltret är aktivt */
.swcs-has-category-filter .swcs-products-column {
  width: 75%;
  padding-left: 20px;
}

/* No Products Message */
.swcs-no-products {
  width: 100%;
  padding: 50px 0;
  text-align: center;
  font-size: 18px;
  color: #666;
  background-color: #f9f9f9;
  border-radius: 8px;
  margin: 20px 0;
  box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.05);
}

/* Product Card - Grid Layout */
.swcs-layout-layout1 .swcs-product-card {
  width: calc(25% - 15px); /* Kommer att ersättas av dynamisk CSS */
  margin-bottom: 20px;
  box-sizing: border-box;
  float: left;
  padding: 0; /* Kommer att ersättas av dynamisk CSS */
  margin: 7.5px; /* Kommer att ersättas av dynamisk CSS */
}

/* Justera antalet produkter per rad när kategorifiltret är aktivt */
.swcs-has-category-filter .swcs-layout-layout1 .swcs-product-card {
  width: calc(33.333% - 15px); /* Kommer att ersättas av dynamisk CSS */
}

.swcs-product-grid {
  background-color: #fff;
  border: 1px solid #eee;
  border-radius: 8px; /* Kommer att ersättas av dynamisk CSS */
  overflow: hidden;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  height: 350px; /* Fixerad höjd för alla kort */
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.swcs-product-grid:hover {
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
  transform: translateY(-5px);
}

.swcs-product-grid a {
  display: flex;
  flex-direction: column;
  height: 100%;
  text-decoration: none;
  color: inherit;
}

.swcs-product-grid .swcs-product-image {
  height: 180px;
  overflow: hidden;
  background-color: #f9f9f9; /* Kommer att ersättas av dynamisk CSS */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
}

.swcs-product-grid .swcs-product-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 0.3s ease;
}

.swcs-product-grid:hover .swcs-product-image img {
  transform: scale(1.05);
}

.swcs-product-grid .swcs-product-content {
  padding: 15px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  background-color: #fff;
}

.swcs-product-grid .swcs-product-title h2 {
  font-size: 16px;
  font-weight: bold;
  margin: 0 0 10px;
  color: #333;
  line-height: 1.4;
  min-height: 45px;
  max-height: 45px;
  overflow: hidden;
  transition: color 0.3s ease;
}

.swcs-product-grid:hover .swcs-product-title h2 {
  color: #ad0000; /* Kommer att ersättas av dynamisk CSS */
}

.swcs-product-grid .swcs-product-sku {
  font-size: 12px;
  color: #666;
  margin-bottom: 10px;
}

.swcs-product-grid .swcs-product-price {
  margin-top: auto;
  font-weight: bold;
  color: #ad0000; /* Kommer att ersättas av dynamisk CSS */
  font-size: 18px;
}

/* Product Card - List Layout */
.swcs-layout-layout2 .swcs-product-card {
  width: 100%;
  margin-bottom: 20px;
  box-sizing: border-box;
}

.swcs-product-list {
  background-color: #fff;
  border: 1px solid #eee;
  border-radius: 4px;
  overflow: hidden;
  transition: all 0.3s ease;
  display: flex;
}

.swcs-product-list:hover {
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.swcs-product-list a {
  display: flex;
  width: 100%;
}

.swcs-product-list .swcs-product-image {
  width: 200px;
  min-width: 200px;
  height: 200px;
  overflow: hidden;
}

.swcs-product-list .swcs-product-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.swcs-product-list .swcs-product-content {
  padding: 15px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.swcs-product-list .swcs-product-title h2 {
  font-size: 18px;
  font-weight: bold;
  margin: 0 0 10px;
  color: #333;
  line-height: 1.4;
}

.swcs-product-list .swcs-product-sku {
  font-size: 12px;
  color: #666;
  margin-bottom: 10px;
}

.swcs-product-list .swcs-product-excerpt {
  font-size: 14px;
  color: #666;
  margin-bottom: 15px;
  line-height: 1.5;
}

.swcs-product-list .swcs-product-price {
  margin-top: auto;
  font-weight: bold;
  color: #ad0000; /* Kommer att ersättas av dynamisk CSS */
}

/* Product Card - Compact Layout */
.swcs-layout-layout3 .swcs-product-card {
  width: calc(33.33% - 14px);
  margin-bottom: 20px;
  box-sizing: border-box;
}

.swcs-product-compact {
  background-color: #fff;
  border: 1px solid #eee;
  border-radius: 4px;
  overflow: hidden;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
}

.swcs-product-compact:hover {
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  transform: translateY(-3px);
}

.swcs-product-compact .swcs-product-image {
  height: 150px;
  overflow: hidden;
}

.swcs-product-compact .swcs-product-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.swcs-product-compact .swcs-product-content {
  padding: 10px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.swcs-product-compact .swcs-product-title h2 {
  font-size: 14px;
  font-weight: bold;
  margin: 0 0 5px;
  color: #333;
  line-height: 1.3;
  min-height: 36px;
}

.swcs-product-compact .swcs-product-price {
  margin-top: auto;
  font-weight: bold;
  color: #ad0000; /* Kommer att ersättas av dynamisk CSS */
  font-size: 14px;
}

/* Responsive Styles */
@media (max-width: 1200px) {
  .swcs-layout-layout1 .swcs-product-card {
    width: calc(33.33% - 14px);
  }

  .swcs-layout-layout3 .swcs-product-card {
    width: calc(50% - 10px);
  }
}

@media (max-width: 992px) {
  .swcs-layout-layout1 .swcs-product-card {
    width: calc(50% - 10px);
  }

  .swcs-has-category-filter .swcs-layout-layout1 .swcs-product-card {
    width: calc(50% - 10px);
  }

  .swcs-categories-column {
    width: 30%;
  }

  .swcs-has-category-filter .swcs-products-column {
    width: 70%;
  }

  .swcs-product-list .swcs-product-image {
    width: 150px;
    min-width: 150px;
    height: 150px;
  }

  #swcs_search_input,#swcs_search_input_desktop, #swcs_search_input_mobile  {
    width: 75%;
  }
}

@media (max-width: 768px) {
  .swcs-layout-layout1 .swcs-product-card,
  .swcs-layout-layout3 .swcs-product-card,
  .swcs-has-category-filter .swcs-layout-layout1 .swcs-product-card {
    width: 100%;
  }

  .swcs-search-results-container {
    flex-direction: column;
    align-items: center;
  }

  .swcs-categories-column {
    width: 100%;
    float: none;
    max-height: none;
    margin-bottom: 20px;
  }

  .swcs-products-column,
  .swcs-has-category-filter .swcs-products-column {
    width: 100%;
    float: none;
    padding-left: 0;
  }

  .swcs-product-list a {
    flex-direction: column;
  }

  .swcs-product-list .swcs-product-image {
    width: 100%;
    height: 200px;
  }

  #swcs_search_input,#swcs_search_input_desktop, #swcs_search_input_mobile  {
    width: 60%;
    font-size: 16px;
    padding: 12px 15px;
  }

  /* Kompakt layout för tablets */
  .swcs-product-grid {
    height: auto;
    margin-bottom: 10px;
  }

  .swcs-product-grid .swcs-product-image {
    height: 120px;
    padding: 8px;
  }

  .swcs-product-grid .swcs-product-content {
    padding: 10px;
  }

  .swcs-product-grid .swcs-product-title h2 {
    font-size: 15px;
    line-height: 1.3;
    margin-bottom: 6px;
    min-height: unset;
    max-height: unset;
  }

  .swcs-product-grid .swcs-product-sku {
    font-size: 11px;
    margin-bottom: 6px;
  }

  .swcs-product-grid .swcs-product-price {
    font-size: 16px;
  }

  .swcs-search-close {
    right: 15px;
    width: 35px;
    height: 35px;
    font-size: 24px;
  }

  .swcs-search-bar {
    padding: 15px;
  }

  .swcs-popular-searches {
    padding: 15px 10px;
  }

  .swcs-popular-search {
    padding: 6px 12px;
    font-size: 13px;
    margin: 3px;
  }
  .swcs-search-results {
    .swcs-products-column {
      flex-direction: column;
      flex-wrap: nowrap;
      scroll-behavior: smooth;
      scroll-snap-type: x mandatory;

      .swcs-product-grid {
        height: auto;
        margin-bottom: 8px; /* Minska avstånd mellan kort */
      }

      .swcs-product-grid .swcs-product-title h2 {
        min-height: unset;
        height: auto;
        max-height: unset;
        font-size: 14px; /* Mindre text */
        line-height: 1.2;
        margin-bottom: 4px;
      }

      .swcs-product-card {
        .swcs-product-content {
          flex-direction: column;
          align-items: flex-start;
          padding: 8px; /* Mindre padding */

          .swcs-product-sku {
            margin: 0;
            font-size: 11px; /* Mindre SKU-text */
            margin-bottom: 4px;
          }
          .swcs-product-price {
            margin: 0;
            font-size: 14px; /* Mindre pristext */
          }
        }

        & > a {
          flex-direction: row;
          min-height: 80px; /* Mycket lägre höjd */
        }

        .swcs-product-image {
          width: 35%; /* Mindre bildarea */
          height: 80px; /* Lägre höjd */
          padding: 4px; /* Mindre padding */

          img {
            object-fit: contain;
          }
        }

        .swcs-product-content {
          width: 65%; /* Mer plats för text */
          height: 80px; /* Samma höjd som bilden */
          display: flex;
          flex-direction: column;
          justify-content: space-between;
          align-items: flex-start;
          padding: 8px;

          .swcs-product-sku {
            justify-self: flex-start;
            margin-bottom: auto;
          }
        }
      }
    }
  }

  
}

@media (max-width: 480px) {
  #swcs_search_input,#swcs_search_input_desktop, #swcs_search_input_mobile {
    width: 70%;
    font-size: 16px;
  }

  .swcs-search-close {
    right: 10px;
    width: 30px;
    height: 30px;
    font-size: 20px;
  }

  /* Extra kompakt för mycket små skärmar */
  .swcs-search-results .swcs-products-column .swcs-product-card {
    margin-bottom: 6px;

    & > a {
      min-height: 70px; /* Ännu lägre höjd */
    }

    .swcs-product-image {
      width: 30%; /* Ännu mindre bildarea */
      height: 70px;
      padding: 2px;
    }

    .swcs-product-content {
      width: 70%;
      height: 70px;
      padding: 6px;

      .swcs-product-title h2 {
        font-size: 13px;
        line-height: 1.1;
        margin-bottom: 2px;
      }

      .swcs-product-sku {
        font-size: 10px;
        margin-bottom: 2px;
      }

      .swcs-product-price {
        font-size: 13px;
      }
    }
  }

  .swcs-categories-column {
    padding: 15px;
  }

  .swcs-categories-column h3 {
    font-size: 16px;
  }


}
