/* ========================================
   Woo Dynamic Search - Estilos
   ======================================== */

/* Contenedor principal */
.woo-dynamic-search-wrap {
    position: relative;
    width: 100%;
    max-width: 500px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.woo-search-container {
    position: relative;
    display: flex;
    align-items: center;
    background: #fff;
    border: 2px solid #e0e0e0;
    border-radius: 24px;
    padding: 0 16px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.woo-search-container:focus-within {
    border-color: #2271b1;
    box-shadow: 0 2px 12px rgba(34,113,177,0.15);
}

/* Icono de búsqueda */
.woo-search-icon {
    display: flex;
    align-items: center;
    color: #999;
    margin-right: 8px;
    flex-shrink: 0;
}

.woo-search-container:focus-within .woo-search-icon {
    color: #2271b1;
}

/* Input */
.woo-search-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 16px;
    padding: 14px 8px;
    background: transparent;
    color: #333;
}

.woo-search-input::placeholder {
    color: #999;
}

/* Spinner */
.woo-search-spinner {
    display: flex;
    align-items: center;
    margin-left: 8px;
}

.woo-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e0e0e0;
    border-top-color: #2271b1;
    border-radius: 50%;
    animation: woo-spin 0.6s linear infinite;
}

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

/* Botón limpiar */
.woo-search-clear {
    background: none;
    border: none;
    font-size: 22px;
    color: #999;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.2s;
}

.woo-search-clear:hover {
    color: #d63638;
}

/* ========================================
   Panel de Resultados
   ======================================== */
.woo-search-results {
    background: #fff;
    border: 1px solid #e0e0e0;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
    z-index: 99999;
    max-height: 480px;
    overflow-y: auto;
    padding: 12px;
    animation: woo-fade-in 0.2s ease;
}

@keyframes woo-fade-in {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Sin resultados */
.woo-search-no-results {
    text-align: center;
    padding: 24px 16px;
    color: #666;
}

.woo-search-no-results svg {
    margin-bottom: 8px;
    opacity: 0.4;
}

/* ========================================
   Grid de Cards (vista grilla)
   ======================================== */
.woo-search-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

/* Card individual */
.woo-search-card {
    display: block;
    text-decoration: none;
    color: inherit;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.2s ease;
    background: #fafafa;
    border: 1px solid #f0f0f0;
}

.woo-search-card:hover,
.woo-search-card.woo-card-active {
    background: #f0f7ff;
    border-color: #2271b1;
    box-shadow: 0 2px 8px rgba(34,113,177,0.1);
    transform: translateY(-1px);
}

/* Imagen del producto */
.woo-search-card-img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    display: block;
    background: #f5f5f5;
}

/* Info de la card */
.woo-search-card-info {
    padding: 10px 12px;
}

.woo-search-card-title {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    margin: 0 0 4px 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.woo-search-card-price {
    font-size: 14px;
    font-weight: 700;
    color: #2271b1;
    margin: 0;
}

.woo-search-card-category {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
}

/* ========================================
   Header injection styles
   ======================================== */
.woo-dynamic-search-menu-item {
    display: flex;
    align-items: center;
}

.woo-dynamic-search-menu-item .woo-dynamic-search-wrap {
    max-width: 280px;
}

.woo-dynamic-search-menu-item .woo-search-input {
    padding: 10px 8px;
    font-size: 14px;
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
    .woo-dynamic-search-wrap {
        max-width: 100%;
    }

    .woo-search-results {
        max-height: calc(100vh - 120px);
        /* border-radius removed */
    }

    .woo-search-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
}

@media (max-width: 480px) {
    .woo-search-grid {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   Enhancer Mode - wrapper inside form
   ======================================== */
form .woo-dynamic-search-wrap {
    max-width: none;
}

form .woo-search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
}

/* ========================================
   Vista Lista (horizontal)
   ======================================== */
.woo-search-results-list .woo-search-grid {
    grid-template-columns: 1fr;
    gap: 4px;
}

.woo-search-results-list .woo-search-card {
    display: flex;
    flex-direction: row;
    align-items: center;
}

.woo-search-results-list .woo-search-card-img {
    width: 64px;
    height: 64px;
    aspect-ratio: 1 / 1;
    flex-shrink: 0;
    border-radius: 8px 0 0 8px;
}

.woo-search-results-list .woo-search-card-info {
    flex: 1;
    padding: 8px 12px;
    min-width: 0;
}

.woo-search-results-list .woo-search-card-title {
    font-size: 13px;
    -webkit-line-clamp: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.woo-search-results-list .woo-search-card-price {
    font-size: 13px;
    margin-top: 2px;
}

.woo-search-results-list .woo-search-card-category {
    font-size: 11px;
    margin-top: 2px;
}

/* Vista lista en mobile */
@media (max-width: 480px) {
    .woo-search-results-list .woo-search-card-img {
        width: 56px;
        height: 56px;
    }
}
