/* ============================================================================
   MURIEL SMART SEARCH - ESTILOS
   Búsqueda avanzada y responsive para WooCommerce
   ============================================================================ */

:root {
    --mss-primary: #007bff;
    --mss-primary-dark: #0056b3;
    --mss-accent: #FFA500;
    --mss-dark: #000000;
    --mss-text: #222222;
    --mss-text-light: #555555;
    --mss-bg: #ffffff;
    --mss-bg-light: #f9f9f9;
    --mss-border: #e0e0e0;
    --mss-shadow-sm: 0 2px 10px rgba(0,0,0,0.05);
    --mss-shadow-md: 0 8px 20px rgba(0,0,0,0.1);
    --mss-shadow-lg: 0 12px 30px rgba(0,0,0,0.15);
    --mss-radius: 10px;
    --mss-transition: all 0.3s ease;
}

/* ===== CONTENEDOR PRINCIPAL ===== */
.muriel-search-container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    position: relative;
    z-index: 1000;
    background: transparent !important;
    padding: 0 !important;
}

/* ===== FORMULARIO ===== */
.muriel-search-form {
    width: 100%;
    position: relative;
}

/* ===== WRAPPER DE BÚSQUEDA ===== */
.muriel-search-wrapper {
    display: flex;
    align-items: center;
    position: relative;
    background: var(--mss-bg);
    border: 2px solid var(--mss-border);
    border-radius: var(--mss-radius);
    overflow: hidden;
    transition: var(--mss-transition);
    box-shadow: var(--mss-shadow-sm);
}

.muriel-search-wrapper:focus-within {
    border-color: var(--mss-primary);
    box-shadow: 0 0 0 4px rgba(0,123,255,0.1);
}

/* ===== INPUT DE BÚSQUEDA ===== */
.muriel-search-input {
    flex: 1;
    border: none;
    padding: 1rem 1.5rem;
    font-size: 1rem;
    color: var(--mss-text);
    background: transparent;
    outline: none;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.muriel-search-input::placeholder {
    color: var(--mss-text-light);
}

/* ===== BOTÓN DE BÚSQUEDA ===== */
.muriel-search-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--mss-primary);
    color: var(--mss-bg);
    border: none;
    padding: 1rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--mss-transition);
    white-space: nowrap;
}

.muriel-search-button:hover {
    background: var(--mss-primary-dark);
}

.muriel-search-button svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* ===== LOADING SPINNER ===== */
.muriel-search-loading {
    position: absolute;
    right: 140px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
}

.muriel-search-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--mss-border);
    border-top-color: var(--mss-primary);
    border-radius: 50%;
    animation: muriel-spin 0.8s linear infinite;
}

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

/* ===== RESULTADOS ===== */
.muriel-search-results {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    right: 0;
    background: var(--mss-bg);
    border-radius: var(--mss-radius);
    box-shadow: var(--mss-shadow-lg);
    max-height: 500px;
    overflow-y: auto;
    z-index: 9999;
    animation: muriel-fadeInDown 0.3s ease;
}

@keyframes muriel-fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Scrollbar personalizada */
.muriel-search-results::-webkit-scrollbar {
    width: 8px;
}

.muriel-search-results::-webkit-scrollbar-track {
    background: var(--mss-bg-light);
    border-radius: 4px;
}

.muriel-search-results::-webkit-scrollbar-thumb {
    background: var(--mss-border);
    border-radius: 4px;
}

.muriel-search-results::-webkit-scrollbar-thumb:hover {
    background: var(--mss-text-light);
}

/* ===== MENSAJE DE ESTADO ===== */
.muriel-search-message {
    padding: 2rem;
    text-align: center;
    color: var(--mss-text-light);
    font-size: 1rem;
}

.muriel-search-message.no-results {
    color: var(--mss-text);
}

/* ===== ITEM DE RESULTADO ===== */
.muriel-search-results .muriel-search-item {
    display: grid !important;
    grid-template-columns: 70px 1fr auto !important;
    grid-template-areas: "image content price" !important;
    gap: 1rem !important;
    padding: 1rem !important;
    border-bottom: 1px solid var(--mss-border);
    transition: var(--mss-transition);
    cursor: pointer;
    text-decoration: none !important;
    color: inherit;
    align-items: center !important;
    writing-mode: horizontal-tb !important;
    direction: ltr !important;
    text-orientation: mixed !important;
}

/* Sobrescribir cualquier flex heredado */
.muriel-search-results .muriel-search-item,
.muriel-search-results .muriel-search-item * {
    box-sizing: border-box !important;
}

.muriel-search-results .muriel-search-item:last-child {
    border-bottom: none;
}

.muriel-search-results .muriel-search-item:hover {
    background: var(--mss-bg-light);
}

/* ===== IMAGEN DEL PRODUCTO ===== */
.muriel-search-results .muriel-search-item .muriel-search-item-image {
    grid-area: image !important;
    width: 70px !important;
    height: 70px !important;
    border-radius: 8px;
    overflow: hidden;
    background: var(--mss-bg-light);
    flex-shrink: 0 !important;
}

.muriel-search-results .muriel-search-item .muriel-search-item-image img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
}

/* ===== CONTENIDO DEL ITEM ===== */
.muriel-search-results .muriel-search-item .muriel-search-item-content {
    grid-area: content !important;
    display: block !important;
    min-width: 0 !important;
}

.muriel-search-results .muriel-search-item .muriel-search-item-title {
    font-size: 1rem !important;
    font-weight: 600 !important;
    color: var(--mss-text) !important;
    margin: 0 0 0.5rem 0 !important;
    padding: 0 !important;
    line-height: 1.4 !important;
    display: block !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    writing-mode: horizontal-tb !important;
    direction: ltr !important;
    white-space: normal !important;
}

.muriel-search-results .muriel-search-item .muriel-search-item-meta {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 0.75rem !important;
    flex-wrap: wrap !important;
    font-size: 0.85rem !important;
    color: var(--mss-text-light) !important;
    margin: 0 !important;
    padding: 0 !important;
    writing-mode: horizontal-tb !important;
    direction: ltr !important;
}

.muriel-search-results .muriel-search-item .muriel-search-item-meta > * {
    display: inline-block !important;
    margin: 0 !important;
    writing-mode: horizontal-tb !important;
    white-space: nowrap !important;
}

.muriel-search-results .muriel-search-item .muriel-search-item-sku {
    white-space: nowrap !important;
}

.muriel-search-results .muriel-search-item .muriel-search-item-sku::before {
    content: "SKU: " !important;
    font-weight: 600 !important;
}

.muriel-search-results .muriel-search-item .muriel-search-item-category {
    color: var(--mss-primary) !important;
    white-space: nowrap !important;
}

.muriel-search-results .muriel-search-item .muriel-search-item-stock {
    padding: 0.25rem 0.5rem !important;
    border-radius: 4px !important;
    font-size: 0.75rem !important;
    font-weight: 600 !important;
    white-space: nowrap !important;
}

.muriel-search-results .muriel-search-item .muriel-search-item-stock.in-stock {
    background: #d4edda !important;
    color: #155724 !important;
}

.muriel-search-results .muriel-search-item .muriel-search-item-stock.out-of-stock {
    background: #f8d7da !important;
    color: #721c24 !important;
}

.muriel-search-results .muriel-search-item .muriel-search-item-stock::before {
    content: "● " !important;
    font-size: 0.6rem !important;
}

/* ===== PRECIO ===== */
.muriel-search-results .muriel-search-item .muriel-search-item-price {
    grid-area: price !important;
    font-size: 1.125rem !important;
    font-weight: 700 !important;
    color: var(--mss-primary) !important;
    text-align: right !important;
    white-space: nowrap !important;
    min-width: 100px !important;
}

.muriel-search-results .muriel-search-item .muriel-search-item-price * {
    color: inherit !important;
}

.muriel-search-results .muriel-search-item .muriel-search-item-price span,
.muriel-search-results .muriel-search-item .muriel-search-item-price bdi {
    display: inline !important;
}

.muriel-search-results .muriel-search-item .muriel-search-item-price del {
    display: block !important;
    font-size: 0.875rem !important;
    color: var(--mss-text-light) !important;
    font-weight: 400 !important;
    margin-bottom: 0.25rem !important;
    opacity: 0.7 !important;
}

.muriel-search-results .muriel-search-item .muriel-search-item-price ins {
    text-decoration: none !important;
    color: #e74c3c !important;
    font-weight: 700 !important;
    display: inline !important;
}

/* ===== VER TODOS LOS RESULTADOS ===== */
.muriel-search-view-all {
    display: block;
    padding: 1rem;
    text-align: center;
    background: var(--mss-bg-light);
    color: var(--mss-primary);
    font-weight: 600;
    text-decoration: none;
    border-top: 1px solid var(--mss-border);
    transition: var(--mss-transition);
}

.muriel-search-view-all:hover {
    background: var(--mss-primary);
    color: var(--mss-bg);
}

/* ===== RESPONSIVE - TABLET ===== */
@media (max-width: 768px) {
    .muriel-search-container {
        max-width: 100%;
    }
    
    .muriel-search-input {
        padding: 0.875rem 1rem;
        font-size: 0.95rem;
    }
    
    .muriel-search-button {
        padding: 0.875rem 1rem;
    }
    
    .muriel-search-button-text {
        display: none;
    }
    
    .muriel-search-loading {
        right: 60px;
    }
    
    .muriel-search-results .muriel-search-item {
        grid-template-columns: 60px 1fr auto !important;
        gap: 0.75rem !important;
        padding: 0.875rem !important;
    }
    
    .muriel-search-results .muriel-search-item .muriel-search-item-image {
        width: 60px !important;
        height: 60px !important;
    }
    
    .muriel-search-results .muriel-search-item .muriel-search-item-title {
        font-size: 0.9rem !important;
    }
    
    .muriel-search-results .muriel-search-item .muriel-search-item-meta {
        font-size: 0.8rem !important;
        gap: 0.5rem !important;
    }
    
    .muriel-search-results .muriel-search-item .muriel-search-item-price {
        font-size: 1rem !important;
    }
}

/* ===== RESPONSIVE - MÓVIL ===== */
@media (max-width: 480px) {
    .muriel-search-wrapper {
        border-radius: 8px;
    }
    
    .muriel-search-input {
        padding: 0.75rem;
        font-size: 0.9rem;
    }
    
    .muriel-search-button {
        padding: 0.75rem;
    }
    
    .muriel-search-loading {
        right: 50px;
    }
    
    .muriel-search-spinner {
        width: 20px;
        height: 20px;
        border-width: 2px;
    }
    
    .muriel-search-results {
        max-height: 400px;
        border-radius: 8px;
    }
    
    .muriel-search-results .muriel-search-item {
        grid-template-columns: 1fr !important;
        grid-template-areas: 
            "image"
            "content"
            "price" !important;
        gap: 0.75rem !important;
        padding: 1rem !important;
    }
    
    .muriel-search-results .muriel-search-item .muriel-search-item-image {
        width: 100% !important;
        height: 150px !important;
        border-radius: 6px;
    }
    
    .muriel-search-results .muriel-search-item .muriel-search-item-content {
        width: 100%;
    }
    
    .muriel-search-results .muriel-search-item .muriel-search-item-title {
        white-space: normal !important;
        line-height: 1.4 !important;
    }
    
    .muriel-search-results .muriel-search-item .muriel-search-item-meta {
        flex-wrap: wrap;
    }
    
    .muriel-search-results .muriel-search-item .muriel-search-item-price {
        width: 100% !important;
        text-align: left !important;
        font-size: 1.25rem !important;
    }
    
    .muriel-search-view-all {
        padding: 0.875rem;
        font-size: 0.9rem;
    }
}

/* ===== WIDGET EN SIDEBAR ===== */
.widget .muriel-search-container {
    max-width: 100%;
}

.widget .muriel-search-input {
    font-size: 0.9rem;
}

.widget .muriel-search-button {
    padding: 0.875rem 1rem;
}

.widget .muriel-search-button-text {
    display: none;
}

/* ===== ACCESIBILIDAD ===== */
.muriel-search-input:focus,
.muriel-search-button:focus {
    outline: 3px solid rgba(0,123,255,0.3);
    outline-offset: 2px;
}

.muriel-search-item:focus {
    outline: 2px solid var(--mss-primary);
    outline-offset: -2px;
    background: var(--mss-bg-light);
}

/* ===== TEMA OSCURO (OPCIONAL) ===== */
@media (prefers-color-scheme: dark) {
    .muriel-search-wrapper,
    .muriel-search-results {
        background: #1a1a1a;
        border-color: #333;
    }
    
    .muriel-search-input {
        color: #fff;
    }
    
    .muriel-search-item:hover {
        background: #2a2a2a;
    }
    
    .muriel-search-item-title {
        color: #fff;
    }
    
    .muriel-search-view-all {
        background: #2a2a2a;
        border-color: #333;
    }
}

/* ===== ANIMACIONES ===== */
@keyframes muriel-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.muriel-search-loading.active .muriel-search-spinner {
    animation: muriel-spin 0.8s linear infinite;
}

/* ===== RESET Y PROTECCIÓN CONTRA CONFLICTOS DE TEMA ===== */
/* Máxima especificidad para sobrescribir cualquier tema */

/* Reset completo de todos los elementos */
.muriel-search-results,
.muriel-search-results *,
.muriel-search-results *::before,
.muriel-search-results *::after {
    writing-mode: horizontal-tb !important;
    text-orientation: mixed !important;
    direction: ltr !important;
    box-sizing: border-box !important;
}

/* Prevenir flex heredado problemático */
.muriel-search-results .muriel-search-item,
.muriel-search-results .muriel-search-item * {
    flex-direction: row !important;
    -webkit-writing-mode: horizontal-tb !important;
    -ms-writing-mode: lr-tb !important;
}

/* Forzar display y orientación en elementos de texto */
.muriel-search-results .muriel-search-item-title,
.muriel-search-results .muriel-search-item-title *,
.muriel-search-results .muriel-search-item-sku,
.muriel-search-results .muriel-search-item-sku *,
.muriel-search-results .muriel-search-item-category,
.muriel-search-results .muriel-search-item-category *,
.muriel-search-results .muriel-search-item-stock,
.muriel-search-results .muriel-search-item-stock *,
.muriel-search-results .muriel-search-item-price,
.muriel-search-results .muriel-search-item-price * {
    display: inline !important;
    white-space: normal !important;
    writing-mode: horizontal-tb !important;
    text-orientation: mixed !important;
    direction: ltr !important;
    vertical-align: baseline !important;
}

/* El título debe ser block */
.muriel-search-results .muriel-search-item-title {
    display: block !important;
}

/* Asegurar que el meta use flex correctamente con máxima especificidad */
.muriel-search-results .muriel-search-item .muriel-search-item-meta {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    writing-mode: horizontal-tb !important;
    align-items: center !important;
}

.muriel-search-results .muriel-search-item .muriel-search-item-meta > span,
.muriel-search-results .muriel-search-item .muriel-search-item-meta > * {
    display: inline-block !important;
    flex-direction: row !important;
    white-space: nowrap !important;
    writing-mode: horizontal-tb !important;
    direction: ltr !important;
}

/* Sobrescribir estilos de Astra específicamente */
.ast-container .muriel-search-results .muriel-search-item,
.site-content .muriel-search-results .muriel-search-item,
.entry-content .muriel-search-results .muriel-search-item {
    display: grid !important;
    writing-mode: horizontal-tb !important;
}

/* Evitar que los selectores universales del tema afecten */
.muriel-search-results .muriel-search-item-content > *,
.muriel-search-results .muriel-search-item-content div,
.muriel-search-results .muriel-search-item-content span {
    writing-mode: horizontal-tb !important;
    direction: ltr !important;
    text-orientation: mixed !important;
}
