/*!
 * CrewShop Search Widget — Stiluri v2.0.0
 * Prefix: .cssearch-
 * Design: panel lateral stânga 90%, slide-in animation
 */

/* =========================================================================
   CSS Custom Properties
   ========================================================================= */

.cssearch-backdrop {
  --cssearch-color-base:    #00001A;
  --cssearch-gray-100:      #f3f4f6;
  --cssearch-gray-200:      #e5e7eb;
  --cssearch-gray-400:      #9ca3af;
  --cssearch-white:         #ffffff;
  --cssearch-overlay-bg:    #ffffff;
  --cssearch-backdrop-bg:   rgba(0, 0, 0, 0.35);
  --cssearch-font-size:     14px;
  --cssearch-z-index:       9999;
  --cssearch-transition:    0.35s cubic-bezier(0.4, 0, 0.2, 1);
  --cssearch-sidebar-w:     180px;
}

/* =========================================================================
   Backdrop — full screen dark overlay
   ========================================================================= */

.cssearch-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: var(--cssearch-z-index);
  background: var(--cssearch-backdrop-bg);
  justify-content: flex-start;
  align-items: stretch;
  opacity: 0;
  transition: opacity var(--cssearch-transition);
}

.cssearch-backdrop.cssearch-visible {
  opacity: 1;
}

/* =========================================================================
   Overlay — panel lateral stânga, 90% width, slide from left
   ========================================================================= */

.cssearch-overlay {
  background: var(--cssearch-overlay-bg);
  width: 90%;
  max-width: none;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateX(-100%);
  transition: transform var(--cssearch-transition);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: var(--cssearch-font-size);
  color: var(--cssearch-color-base);
  border-radius: 0;
  box-shadow: 4px 0 40px rgba(0, 0, 0, 0.12);
}

.cssearch-backdrop.cssearch-visible .cssearch-overlay {
  transform: translateX(0);
}

/* =========================================================================
   Header: icon search + input + close
   ========================================================================= */

.cssearch-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 32px;
  border-bottom: 1px solid var(--cssearch-gray-200);
  flex-shrink: 0;
}

.cssearch-input-wrap {
  display: flex;
  align-items: center;
  flex: 1;
  background: transparent;
  border: none;
  padding: 0;
  gap: 12px;
}

.cssearch-input-wrap:focus-within {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.cssearch-icon-search {
  width: 22px;
  height: 22px;
  color: var(--cssearch-color-base);
  flex-shrink: 0;
  stroke-width: 2;
}

.cssearch-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 16px;
  color: var(--cssearch-color-base);
  padding: 8px 0;
  min-width: 0;
}

.cssearch-input::placeholder {
  color: var(--cssearch-gray-400);
}

.cssearch-input::-webkit-search-cancel-button { display: none; }

.cssearch-input-clear {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--cssearch-gray-400);
  display: flex;
  align-items: center;
  transition: color 0.15s;
}

.cssearch-input-clear:hover {
  color: var(--cssearch-color-base);
}

.cssearch-input-clear svg {
  width: 16px;
  height: 16px;
}

.cssearch-hidden {
  display: none !important;
}

.cssearch-close {
  background: none;
  border: none;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cssearch-color-base);
  flex-shrink: 0;
  transition: opacity 0.2s;
  padding: 0;
  border-radius: 0;
}

.cssearch-close:hover {
  opacity: 0.5;
  background: transparent;
}

.cssearch-close svg {
  width: 20px;
  height: 20px;
}

/* =========================================================================
   Body — sidebar (tags) + results (produse)
   ========================================================================= */

.cssearch-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* Sidebar stânga — tag-uri pills vertical */
.cssearch-sidebar {
  width: var(--cssearch-sidebar-w);
  flex-shrink: 0;
  padding: 24px 20px;
  overflow-y: auto;
}

/* Zona dreapta — rezultate */
.cssearch-results {
  flex: 1;
  overflow-y: auto;
  padding: 0 32px;
  min-width: 0;
}

/* =========================================================================
   Tags — pills cu border (sidebar)
   ========================================================================= */

.cssearch-section-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--cssearch-gray-400);
  margin: 0 0 12px;
}

.cssearch-tags-list,
.cssearch-categories-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cssearch-tag,
.cssearch-category {
  display: inline-flex;
  align-items: center;
  background: transparent;
  border: 1px solid var(--cssearch-color-base);
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 13px;
  color: var(--cssearch-color-base);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
  text-align: left;
  gap: 6px;
}

.cssearch-tag:hover,
.cssearch-category:hover {
  background: var(--cssearch-color-base);
  color: var(--cssearch-white);
}

.cssearch-category::before {
  display: none;
}

.cssearch-category.active {
  background: var(--cssearch-color-base);
  border-color: var(--cssearch-color-base);
  color: var(--cssearch-white);
}

.cssearch-cat-count {
  margin-left: auto;
  font-size: 11px;
  opacity: 0.5;
}

.cssearch-category.active .cssearch-cat-count {
  color: rgba(255, 255, 255, 0.7);
}

.cssearch-categories-section {
  margin-top: 20px;
}

.cssearch-dynamic-section .cssearch-section-label {
  color: var(--cssearch-color-base);
}

.cssearch-btn-notify-done {
  opacity: 0.6;
  cursor: default;
}

/* =========================================================================
   Lista de produse
   ========================================================================= */

.cssearch-product-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

/* Card produs — grid: image | info | price | button */
.cssearch-product-card {
  display: grid;
  grid-template-columns: 80px 1fr auto auto;
  align-items: center;
  gap: 0 24px;
  padding: 20px 0;
  border-bottom: 1px solid var(--cssearch-gray-200);
  cursor: pointer;
  outline: none;
  transition: opacity 0.15s;
}

.cssearch-product-card:last-child {
  border-bottom: none;
}

.cssearch-product-card:hover {
  opacity: 0.7;
}

/* Imagine produs */
.cssearch-product-img {
  width: 80px;
  height: 90px;
  flex-shrink: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border-radius: 0;
}

.cssearch-product-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.cssearch-img-placeholder {
  font-size: 28px;
  line-height: 1;
  color: var(--cssearch-gray-400);
}

/* Info produs (brand + name + type) */
.cssearch-product-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.cssearch-product-brand {
  font-size: 14px;
  font-weight: 500;
  color: var(--cssearch-color-base);
  text-transform: uppercase;
  letter-spacing: 0;
}

.cssearch-product-name {
  font-size: 14px;
  font-weight: 400;
  color: var(--cssearch-color-base);
  line-height: 1.4;
}

.cssearch-product-type {
  font-size: 14px;
  font-weight: 300;
  color: var(--cssearch-color-base);
}

/* Preț — coloană separată */
.cssearch-product-price-col {
  font-size: 14px;
  font-weight: 400;
  color: var(--cssearch-color-base);
  white-space: nowrap;
  text-align: right;
}

/* Badge / discount — ascunse în design-ul nou */
.cssearch-badge,
.cssearch-discount,
.cssearch-price-old {
  display: none;
}

/* Out of stock */
.cssearch-product-card.cssearch-oos {
  opacity: 0.5;
}

.cssearch-out-of-stock {
  font-size: 11px;
  font-weight: 500;
  color: #999;
  margin-top: 2px;
}

/* Buton acțiune — bordered, fără fill */
.cssearch-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--cssearch-color-base);
  border-radius: 0;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 400;
  color: var(--cssearch-color-base);
  background: transparent;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
  margin: 0;
  text-transform: none;
  letter-spacing: 0;
}

.cssearch-btn:hover {
  background: var(--cssearch-color-base);
  color: var(--cssearch-white);
}

.cssearch-btn:active {
  transform: none;
}

.cssearch-btn-cart {
  background: transparent;
  color: var(--cssearch-color-base);
}

.cssearch-btn-notify {
  background: transparent;
  color: var(--cssearch-gray-400);
  border-color: var(--cssearch-gray-400);
}

.cssearch-btn-notify:hover {
  background: var(--cssearch-gray-400);
  color: var(--cssearch-white);
}

.cssearch-btn-notify:disabled {
  opacity: 0.5;
  cursor: default;
}

/* =========================================================================
   Price row (compatibilitate cu cod vechi)
   ========================================================================= */

.cssearch-product-price-row {
  display: none;
}

.cssearch-price {
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
}

/* =========================================================================
   Highlight query în text
   ========================================================================= */

.cssearch-highlight {
  background: transparent;
  color: inherit;
  font-weight: 600;
  border-radius: 0;
  padding: 0;
}

/* =========================================================================
   Loading / Empty / Error states
   ========================================================================= */

.cssearch-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px 20px;
  color: var(--cssearch-gray-400);
  font-size: 14px;
}

.cssearch-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--cssearch-gray-200);
  border-top-color: var(--cssearch-color-base);
  border-radius: 50%;
  animation: cssearch-spin 0.7s linear infinite;
}

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

.cssearch-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 24px;
  gap: 8px;
}

.cssearch-empty-icon {
  font-size: 32px;
  line-height: 1;
}

.cssearch-empty-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--cssearch-color-base);
  margin: 0;
}

.cssearch-empty-sub {
  font-size: 13px;
  color: var(--cssearch-gray-400);
  margin: 0;
}

/* =========================================================================
   Istoric produse vizualizate
   ========================================================================= */

.cssearch-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding: 16px 0 0;
}

.cssearch-history-header .cssearch-section-label {
  margin: 0;
}

.cssearch-history-clear {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 11px;
  color: var(--cssearch-gray-400);
  text-decoration: underline;
  padding: 0;
  transition: color 0.2s;
}

.cssearch-history-clear:hover {
  color: var(--cssearch-color-base);
}

/* =========================================================================
   Mobile — full width, tags scroll orizontal
   ========================================================================= */

@media (max-width: 768px) {
  .cssearch-overlay {
    width: 100%;
    box-shadow: none;
  }

  .cssearch-header {
    padding: 16px 20px;
    gap: 12px;
  }

  /* Body: coloană unică pe mobile */
  .cssearch-body {
    flex-direction: column;
  }

  .cssearch-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--cssearch-gray-200);
    padding: 12px 20px;
    overflow-x: auto;
    overflow-y: hidden;
    flex-shrink: 0;
  }

  /* Tags pe mobile: scroll orizontal */
  .cssearch-tags-list,
  .cssearch-categories-list {
    flex-direction: row;
    gap: 8px;
    flex-wrap: nowrap;
    min-width: max-content;
  }

  .cssearch-results {
    padding: 0 20px;
  }

  /* Product card: image left + info stacked right */
  .cssearch-product-card {
    grid-template-columns: 70px 1fr;
    grid-template-rows: auto auto auto;
    gap: 4px 16px;
    padding: 16px 0;
  }

  .cssearch-product-img {
    grid-row: 1 / span 3;
    width: 70px;
    height: 80px;
    align-self: start;
  }

  .cssearch-product-info {
    grid-column: 2;
  }

  .cssearch-product-price-col {
    grid-column: 2;
    text-align: left;
    margin-top: 4px;
  }

  .cssearch-btn {
    grid-column: 2;
    justify-self: start;
    padding: 8px 16px;
    font-size: 12px;
    margin-top: 4px;
  }
}

/* =========================================================================
   Scrollbar custom (Webkit)
   ========================================================================= */

.cssearch-sidebar::-webkit-scrollbar,
.cssearch-results::-webkit-scrollbar {
  width: 3px;
  height: 3px;
}

.cssearch-sidebar::-webkit-scrollbar-track,
.cssearch-results::-webkit-scrollbar-track {
  background: transparent;
}

.cssearch-sidebar::-webkit-scrollbar-thumb,
.cssearch-results::-webkit-scrollbar-thumb {
  background: var(--cssearch-gray-200);
  border-radius: 3px;
}
