/* ============================================================
   WC Ajax Product Search — search.css
   ============================================================ */

:root {
  --wcas-accent:        #e63946;
  --wcas-bg:            #ffffff;
  --wcas-border:        rgba(0,0,0,.12);
  --wcas-text:          #1a1a2e;
  --wcas-muted:         #6b7280;
  --wcas-radius:        10px;
  --wcas-shadow:        0 8px 32px rgba(0,0,0,.14);
  --wcas-hover:         #f8f9fa;
  --wcas-input-h:       46px;
  --wcas-transition:    .18s ease;
}

/* Wrapper ---------------------------------------------------- */
.wcas-wrapper {
  position: relative;
  width: 100%;
  max-width: 520px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.4;
  box-sizing: border-box;
}

.wcas-wrapper *,
.wcas-wrapper *::before,
.wcas-wrapper *::after {
  box-sizing: inherit;
}

/* Input row -------------------------------------------------- */
.wcas-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--wcas-bg);
  border: 1.5px solid var(--wcas-border);
  border-radius: var(--wcas-radius);
  transition: border-color var(--wcas-transition),
              box-shadow  var(--wcas-transition);
  overflow: hidden;
}

.wcas-input-wrap:focus-within {
  border-color: var(--wcas-accent);
  box-shadow: 0 0 0 3px rgba(230,57,70,.12);
}

/* Search icon */
.wcas-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  color: var(--wcas-muted);
  pointer-events: none;
}

.wcas-icon svg {
  width: 18px;
  height: 18px;
}

/* Input field */
.wcas-input {
  flex: 1;
  height: var(--wcas-input-h);
  border: none !important;
  outline: none !important;
  background: transparent !important;
  color: var(--wcas-text);
  font-size: 15px;
  padding: 0 4px;
  margin: 0 !important;
  box-shadow: none !important;
}

.wcas-input::placeholder {
  color: var(--wcas-muted);
}

/* Clear button */
.wcas-clear {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin-right: 5px;
  background: none;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: var(--wcas-muted);
  transition: background var(--wcas-transition), color var(--wcas-transition);
  padding: 0;
}

.wcas-clear:hover {
  background: var(--wcas-hover);
  color: var(--wcas-text);
}

.wcas-clear svg {
  width: 14px;
  height: 14px;
}

/* Spinner */
.wcas-spinner {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-right: 12px;
  border: 2px solid var(--wcas-border);
  border-top-color: var(--wcas-accent);
  border-radius: 50%;
  animation: wcas-spin .65s linear infinite;
}

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

/* Dropdown --------------------------------------------------- */
.wcas-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--wcas-bg);
  border: 1.5px solid var(--wcas-border);
  border-radius: var(--wcas-radius);
  box-shadow: var(--wcas-shadow);
  overflow: hidden;
  z-index: 99999;
  animation: wcas-slide-in .15s ease both;
}

@keyframes wcas-slide-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0);    }
}

/* Individual result item */
.wcas-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  text-decoration: none !important;
  color: inherit !important;
  border-bottom: 1px solid var(--wcas-border);
  transition: background var(--wcas-transition);
  cursor: pointer;
}

.wcas-item:last-child {
  border-bottom: none;
}

.wcas-item:hover,
.wcas-item:focus,
.wcas-item.wcas-focused {
  background: var(--wcas-hover);
  outline: none;
}

/* Product image (left) */
.wcas-item-img {
  flex-shrink: 0;
  width: 62px;
  height: 62px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--wcas-hover);
  border: 1px solid var(--wcas-border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.wcas-item-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Product info (right of image) */
.wcas-item-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.wcas-item-title {
  font-weight: 600;
  color: var(--wcas-text);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wcas-item-desc {
  font-size: 12.5px;
  color: var(--wcas-muted);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.wcas-item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
}

.wcas-item-price {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--wcas-accent);
}

/* Override WooCommerce price styles inside dropdown */
.wcas-item-price del {
  color: var(--wcas-muted);
  font-weight: 400;
  font-size: 12px;
  margin-right: 4px;
}

.wcas-item-price ins {
  text-decoration: none;
}

/* Badges */
.wcas-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1.4;
}

.wcas-badge--sale {
  background: #fff3cd;
  color: #92630a;
}

.wcas-badge--stock {
  background: #d1fae5;
  color: #065f46;
}

.wcas-badge--no-stock {
  background: #fee2e2;
  color: #991b1b;
}

/* No results / messages */
.wcas-message {
  padding: 18px 14px;
  text-align: center;
  color: var(--wcas-muted);
  font-size: 13.5px;
}

/* View all results link */
.wcas-view-all {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 14px;
  background: var(--wcas-hover);
  color: var(--wcas-accent) !important;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none !important;
  border-top: 1px solid var(--wcas-border);
  transition: background var(--wcas-transition);
}

.wcas-view-all:hover {
  background: #fff0f1;
}

/* Dark header adaptation — agrega class "wcas-dark" al shortcode
   wrapper o al header de Elementor con custom CSS */
.wcas-dark .wcas-input-wrap {
  background: rgba(255,255,255,.1);
  border-color: rgba(255,255,255,.2);
}

.wcas-dark .wcas-input {
  color: #fff;
}

.wcas-dark .wcas-input::placeholder {
  color: rgba(255,255,255,.6);
}

.wcas-dark .wcas-icon,
.wcas-dark .wcas-clear {
  color: rgba(255,255,255,.7);
}

.wcas-dark .wcas-input-wrap:focus-within {
  border-color: var(--wcas-accent);
  box-shadow: 0 0 0 3px rgba(230,57,70,.2);
}

/* Responsive */
@media (max-width: 480px) {
  .wcas-item-img {
    width: 50px;
    height: 50px;
  }
  .wcas-item-title {
    font-size: 13px;
  }
}
