/**
 * Livriz ElasticSearch Plugin Styles
 * Unified Responsive Version 2.0.1
 */

/* ========== SEARCH CONTAINER ========== */
.livriz-search-container {
  width: 100%;
  min-width: 280px;
  max-width: 600px;
  position: relative;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

@media (min-width: 768px) {
  .livriz-search-container {
    min-width: 400px;
  }
}

/* ========== SEARCH INPUT WRAPPER ========== */
.livriz-search-wrapper {
  position: relative;
  width: 100%;
}

.livriz-search-input {
  width: 100%;
  padding: 12px 20px;
  border-radius: 26px;
  border: 1px solid #d0d0d0;
  background-color: #ffffff !important;
  color: #333333 !important;
  font-size: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
  transition: all 0.3s ease;
  outline: none;
}

.livriz-search-input:focus {
  border-color: #999;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.1) !important;
}

.livriz-search-input::placeholder {
  color: #666666;
}

@media (max-width: 767px) {
  .livriz-search-input {
    font-size: 16px; /* Prevent zoom on iOS */
    padding: 10px 16px;
  }
}

/* ========== LOADER / SPINNER ========== */
.livriz-loader {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1001;
}

.livriz-spinner {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 4px solid rgba(51, 51, 51, 0.2);
  border-top-color: #333;
  animation: livriz-spin 0.8s linear infinite;
}

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

@media (max-width: 767px) {
  .livriz-loader {
    margin-top: 5px;
  }
  
  .livriz-spinner {
    width: 24px;
    height: 24px;
    border-width: 3px;
  }
}

/* ========== FILTER CHECKBOXES ========== */
.livriz-checks-container {
  display: none;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 16px;
  background-color: #0a0a0a;
  border-radius: 8px;
  margin-top: 8px;
  position: relative;
  z-index: 100;
}

.livriz-checks-container.show {
  display: flex;
}

.livriz-filter-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.livriz-checkbox {
  margin: 0;
  cursor: pointer;
  width: 16px;
  height: 16px;
  accent-color: #fff;
}

.livriz-checkbox:focus {
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: 2px;
}

.livriz-filter-item label {
  margin: 0;
  color: #fff;
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
  user-select: none;
}

@media (max-width: 767px) {
  .livriz-checks-container {
    gap: 8px;
    padding: 10px 12px;
  }
  
  .livriz-filter-item label {
    font-size: 13px;
  }
}

/* ========== RESULTS CONTAINER ========== */
.livriz-results-container {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  max-height: 500px;
  overflow-y: auto;
  background-color: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border-radius: 8px;
  margin-top: 4px;
  z-index: 999;
}

@media (max-width: 767px) {
  .livriz-results-container {
    max-height: 400px;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    width: 100%;
    margin-top: 4px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  }
}

/* Custom scrollbar */
.livriz-results-container::-webkit-scrollbar {
  width: 8px;
}

.livriz-results-container::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.livriz-results-container::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 4px;
}

.livriz-results-container::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* ========== LATEST SEARCHES ========== */
.livriz-latest-searches {
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.livriz-search-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.livriz-search-item:hover {
  background-color: rgba(0, 0, 0, 0.04);
}

.livriz-search-item i {
  color: #666;
  font-size: 14px;
  width: 16px;
  flex-shrink: 0;
}

.livriz-search-item p {
  margin: 0;
  color: #333;
  font-size: 14px;
  line-height: 1.4;
}

@media (max-width: 767px) {
  .livriz-search-item {
    padding: 10px 12px;
  }
  
  .livriz-search-item i {
    font-size: 13px;
  }
  
  .livriz-search-item p {
    font-size: 13px;
  }
}

/* ========== PRODUCTS LIST ========== */
.livriz-products-list {
  padding: 0;
}

.livriz-no-results,
.livriz-error {
  padding: 24px 16px;
  text-align: center;
  color: #666;
  font-size: 14px;
}

.livriz-error {
  color: #d32f2f;
}

/* ========== PRODUCT ITEM ========== */
.livriz-product-link {
  display: block;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  transition: background-color 0.2s ease;
}

.livriz-product-link:hover {
  background-color: rgba(0, 0, 0, 0.04);
}

.livriz-product-link:last-child {
  border-bottom: none;
}

.livriz-product-box {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
}

@media (max-width: 767px) {
  .livriz-product-box {
    gap: 10px;
    padding: 10px 12px;
  }
}

/* ========== PRODUCT IMAGE ========== */
.livriz-product-image {
  width: 62px;
  height: 91px;
  object-fit: cover;
  flex-shrink: 0;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

@media (max-width: 767px) {
  .livriz-product-image {
    width: 50px;
    height: 73px;
  }
}

/* ========== PRODUCT CONTENT ========== */
.livriz-product-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0; /* Allow text truncation */
}

.livriz-product-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: #1a1a1a;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}

.livriz-product-author,
.livriz-product-editorial,
.livriz-product-categories {
  margin: 0;
  font-size: 13px;
  color: #666;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.livriz-clickable {
  cursor: pointer;
  transition: color 0.2s ease;
}

.livriz-clickable:hover {
  color: #1a1a1a;
  text-decoration: underline;
}

@media (max-width: 767px) {
  .livriz-product-title {
    font-size: 14px;
  }
  
  .livriz-product-author,
  .livriz-product-editorial,
  .livriz-product-categories {
    font-size: 12px;
  }
}

/* ========== PRODUCT PRICES ========== */
.livriz-product-prices {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.livriz-price-regular,
.livriz-price-sale {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: #1a1a1a;
  line-height: 1;
}

.livriz-price-strikethrough {
  text-decoration: line-through;
  color: #999;
  font-weight: 400;
  font-size: 14px;
}

.livriz-price-sale {
  color: #d32f2f;
}

@media (max-width: 767px) {
  .livriz-price-regular,
  .livriz-price-sale {
    font-size: 14px;
  }
  
  .livriz-price-strikethrough {
    font-size: 13px;
  }
}

/* ========== ACCESSIBILITY ========== */
.livriz-search-container *:focus-visible {
  outline: 2px solid #4a90e2;
  outline-offset: 2px;
}

/* ========== PRINT STYLES ========== */
@media print {
  .livriz-search-container {
    display: none;
  }
}

/* ========== HIGH CONTRAST MODE ========== */
@media (prefers-contrast: high) {
  .livriz-search-input {
    border: 2px solid #fff;
  }
  
  .livriz-product-link:hover {
    background-color: rgba(0, 0, 0, 0.1);
  }
}

/* ========== DARK MODE SUPPORT ========== */
@media (prefers-color-scheme: dark) {
  .livriz-results-container {
    background-color: #1a1a1a;
    color: #fff;
  }
  
  .livriz-product-title {
    color: #fff;
  }
  
  .livriz-product-author,
  .livriz-product-editorial,
  .livriz-product-categories {
    color: #bbb;
  }
  
  .livriz-clickable:hover {
    color: #fff;
  }
  
  .livriz-price-regular,
  .livriz-price-sale {
    color: #fff;
  }
  
  .livriz-search-item p {
    color: #fff;
  }
  
  .livriz-product-link:hover {
    background-color: rgba(255, 255, 255, 0.08);
  }
  
  .livriz-search-item:hover {
    background-color: rgba(255, 255, 255, 0.06);
  }
  
  .livriz-latest-searches,
  .livriz-product-link {
    border-bottom-color: rgba(255, 255, 255, 0.1);
  }
}

/* ========== LEGACY COMPATIBILITY ========== */
/* 
 * Note: Old class names from v2.0 are no longer supported.
 * If you had custom CSS using these classes, update to the new naming:
 * - .container-search → .livriz-search-container
 * - #container-checks → .livriz-checks-container
 * - .products-filter → .livriz-results-container
 */
