/* SUGO Deep Research - Search Overlay */
:root {
    --sugo-search-bg: #ffffff;
    --sugo-search-border: #dcdcde;
    --sugo-search-accent: #2271b1;
    /* WordPress Blue */
    --sugo-search-radius: 4px;
    --sugo-input-height: 48px;
}

/* --- Search Bar Container --- */
.sugo-search-container {
    display: inline-flex;
    /* Fix: Evitar que sea bloque y tire el carrito */
    align-items: center;
    max-width: 100%;
    vertical-align: middle;
    /* Alinear con otros elementos del header */
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    box-sizing: border-box;
}


form.sugo-search-form {
    width: 100%;
}

.sugo-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: #fff;
    border: 1px solid var(--sugo-search-border);
    border-radius: var(--sugo-search-radius);
    transition: box-shadow 0.2s, border-color 0.2s;
    width: 100%;
    /* Llenar el contenedor */
}

.sugo-input-wrapper:focus-within {
    border-color: var(--sugo-search-accent);
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

.sugo-search-field {
    width: 100%;
    height: var(--sugo-input-height);
    padding: 0 50px 0 16px !important;
    /* Space for icon */
    border: none !important;
    background: transparent !important;
    font-size: 16px !important;
    color: #333 !important;
    /* Force dark text color for visibility */
    outline: none !important;
    box-shadow: none !important;
    margin: 0 !important;
}

.sugo-search-field::placeholder {
    color: #999;
    opacity: 1;
}

.sugo-search-submit {
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    width: 50px;
    background: none;
    border: none;
    cursor: pointer;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    padding: 0;
    margin: 0;
}

.sugo-search-submit:hover {
    color: var(--sugo-search-accent);
}

.sugo-search-overlay {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: var(--sugo-search-bg);
    border: 1px solid var(--sugo-search-border);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 99999;
    border-radius: 0 0 4px 4px;
    display: none;
    overflow-y: auto;
}

.sugo-search-overlay.is-active {
    display: block;
}

/* --- Scrollbar Styling --- */
.sugo-results-list::-webkit-scrollbar {
    width: 6px;
}

.sugo-results-list::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.sugo-results-list::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.sugo-results-list::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

/* --- Search Items --- */
/* Increased specificity to override theme nav styles (0-2-1 vs 0-3-0) */
.sugo-search-overlay .sugo-results-list .sugo-search-item {
    display: flex;
    flex-direction: row;
    /* Ensure row layout */
    align-items: center;
    /* Centered vertically for compact look */
    padding: 8px 12px;
    /* Reduced padding */
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.1s;
    text-decoration: none !important;
    gap: 10px;
    /* Reduced gap */
    background: #fff;
    margin: 0;
    /* Reset margins */
}

.sugo-search-overlay .sugo-results-list .sugo-search-item:hover,
.sugo-search-overlay .sugo-results-list .sugo-search-item.is-active {
    background: var(--sugo-search-bg-hover);
    /* Light grey highlight like reference */
    border-left: 3px solid var(--sugo-search-accent);
    padding-left: 9px;
    /* Compensate padding */
}

.sugo-search-thumb {
    width: 64px;
    height: 64px;
    min-width: 64px;
    border-radius: 4px;
    overflow: hidden;
    background: #fff;
    border: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sugo-search-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    margin: 0;
    padding: 2px;
}


.sugo-search-content {
    flex-grow: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.sugo-search-title {
    font-size: 14px;
    font-weight: 500;
    margin: 0 0 2px 0;
    line-height: 1.3;
    /* Removed hardcoded color to allow variable override */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.sugo-search-meta {
    font-size: 12px;
    color: #646970;
    display: flex;
    flex-wrap: wrap;
    /* Allow wrapping */
    gap: 8px;
    align-items: center;
}

.sugo-search-sku {
    background: #eee;
    padding: 2px 4px;
    border-radius: 3px;
    font-family: monospace;
}

.sugo-search-price {
    font-weight: 700;
    color: var(--sugo-search-price);
}

.sugo-search-footer {
    padding: 8px;
    text-align: center;
    background: #f9f9f9;
    font-size: 12px;
    color: #888;
    border-top: 1px solid var(--sugo-search-border);
}

.sugo-search-no-results {
    padding: 20px;
    text-align: center;
    color: #888;
}

/* Loader */
.sugo-search-loader {
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--sugo-search-accent);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: sugo-spin 1s linear infinite;
    margin: 10px auto;
}

@keyframes sugo-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* --- Two Column Layout (New) --- */
.sugo-results-grid {
    display: flex;
    min-height: 300px;
    /* Altura mínima para que se vea bien la preview */
}

.sugo-results-list {
    flex: 1;
    /* Ocupa espacio disponible */
    max-width: 60%;
    /* Ajustable */
    border-right: 1px solid #eee;
    overflow-y: auto;
    max-height: 500px;
    background: var(--sugo-search-bg-list);
}

.sugo-results-preview {
    flex: 0 0 40%;
    /* Ancho fijo para preview */
    background: var(--sugo-search-bg-preview);
    padding: 10px;
    /* Reduced from 20px for compactness */
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

/* Added .sugo-preview-content class */
.sugo-preview-content {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Adjust overlay width for 2-col layout */
.sugo-search-overlay {
    min-width: 600px !important;
    /* Necesitamos ancho para 2 columnas */
    max-width: 900px !important;
}

@media (max-width: 768px) {
    .sugo-search-container {
        width: 100% !important;
    }

    .sugo-search-overlay {
        min-width: 100% !important;
    }

    .sugo-results-preview {
        display: none !important;
        /* Ocultar preview en móvil */
    }

    .sugo-results-list {
        max-width: 100%;
        border-right: none;
    }
}

/* List Item Active State */
.sugo-search-item.is-active,
.sugo-search-item:hover {
    background: #f0f6fa;
    border-left: 3px solid var(--sugo-search-accent);
    padding-left: 7px;
    /* Compensar borde */
}

/* View All Link */
.sugo-search-overlay .sugo-results-list .sugo-search-view-all {
    justify-content: center;
    background: #e5e5e5;
    color: var(--sugo-search-title-color) !important;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 13px;
    padding: 12px;
    border-top: 1px solid #ddd;
}

.sugo-search-overlay .sugo-results-list .sugo-search-view-all:hover {
    background: #dcdcdc;
    color: #000 !important;
    border-left: none !important;
    /* No accent border for this special link */
    padding-left: 12px !important;
}

/* Preview Styles */
/* Preview Styles - Compact Mode */
.sugo-preview-image {
    width: 100%;
    height: 150px;
    background: #f9f9f9;
    margin-bottom: 5px;
    /* Reduced from 10px to save space */
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 4px;
    padding: 5px;
}

.sugo-preview-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}


/* Update List Items Colors as well for consistency */
.sugo-search-title {
    color: var(--sugo-search-title-color);
}

.sugo-search-price {
    color: var(--sugo-search-price-color);
}

.sugo-preview-title {
    font-size: var(--sugo-search-title-size);
    /* 14px default */
    font-weight: 600;
    margin: 0 0 5px 0;
    line-height: 1.3;
    color: var(--sugo-search-title-color);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    /* Standard property */
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.sugo-preview-sku {
    font-size: 11px;
    color: #999;
    margin-bottom: 5px;
    font-family: monospace;
    text-transform: uppercase;
}

.sugo-preview-price {
    font-size: var(--sugo-search-price-size);
    /* 16px default */
    font-weight: bold;
    color: var(--sugo-search-price-color);
    margin-bottom: 10px;
}

.sugo-preview-desc {
    display: -webkit-box;
    -webkit-line-clamp: 6;
    /* Show more lines */
    line-clamp: 6;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: var(--sugo-search-desc-size);
    /* 14px default */
    color: var(--sugo-search-desc-color);
    line-height: 1.4;
    margin-bottom: 20px;
    /* Specific spacing below text */
    /* Removed flex-grow to let button push away */
}

.sugo-preview-btn {
    display: block;
    width: 100%;
    text-align: center;
    background: var(--sugo-search-accent);
    color: #fff;
    padding: 10px;
    /* Reduced padding */
    text-decoration: none;
    border-radius: 4px;
    font-weight: 600;
    margin-top: auto;
    /* Push to bottom if space permits, or just after price */
    transition: filter 0.2s;
    font-size: 13px;
}

.sugo-preview-btn:hover {
    filter: brightness(0.8);
}