/* ============================================================
   Usagroparts Advanced Search – Estilos
   ============================================================ */

/* ── Variables ────────────────────────────────────────────── */
.usagro-search-wrapper {
    --usagro-accent:        #1a3a5c;
    --usagro-accent-dark:   #122840;
    --usagro-bg:            #ffffff;
    --usagro-bg-hover:      #f8f8f6;
    --usagro-border:        #d1d5db;
    --usagro-border-focus:  #E8B400;
    --usagro-text:          #1a1a1a;
    --usagro-text-muted:    #6b7280;
    --usagro-dropdown-bg:   #ffffff;
    --usagro-shadow:        0 8px 32px rgba(0,0,0,0.12);
    --usagro-radius:        10px;
    --usagro-font:          -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    position: relative;
    width: 100%;
    font-family: var(--usagro-font);
    z-index: 9999;
}

/* Dark theme */
.usagro-search-wrapper.usagro-theme-dark {
    --usagro-bg:            #1e2124;
    --usagro-bg-hover:      #2a2d31;
    --usagro-border:        #3a3d42;
    --usagro-text:          #f0f0f0;
    --usagro-text-muted:    #9ca3af;
    --usagro-dropdown-bg:   #1e2124;
    --usagro-shadow:        0 8px 32px rgba(0,0,0,0.4);
}

/* ── Input Wrapper ────────────────────────────────────────── */
.usagro-search-inner {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--usagro-bg);
    border: 2px solid var(--usagro-border);
    border-radius: var(--usagro-radius);
    padding: 10px 16px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.usagro-search-inner:focus-within {
    border-color: var(--usagro-border-focus);
    box-shadow: 0 0 0 3px rgba(26, 58, 92, 0.18);
}

/* ── Ícono de búsqueda ────────────────────────────────────── */
.usagro-search-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    color: var(--usagro-text-muted);
}

.usagro-search-icon svg {
    width: 18px;
    height: 18px;
    stroke: var(--usagro-text-muted);
    transition: stroke 0.2s;
}

.usagro-search-inner:focus-within .usagro-search-icon svg {
    stroke: var(--usagro-accent);
}

/* ── Input ────────────────────────────────────────────────── */
.usagro-search-input {
    flex: 1;
    border: none !important;
    outline: none !important;
    background: transparent !important;
    color: var(--usagro-text) !important;
    font-size: 15px !important;
    font-family: var(--usagro-font) !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    min-width: 0;
}

.usagro-search-input::placeholder {
    color: var(--usagro-text-muted);
    opacity: 1;
}

/* ── Spinner ──────────────────────────────────────────────── */
.usagro-search-spinner {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    border: 2px solid var(--usagro-border);
    border-top-color: var(--usagro-accent);
    border-radius: 50%;
    display: none;
    animation: usagro-spin 0.7s linear infinite;
}

.usagro-search-wrapper.usagro-loading .usagro-search-spinner {
    display: block;
}

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

/* ── Botón limpiar ────────────────────────────────────────── */
.usagro-search-clear {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
    color: var(--usagro-text-muted);
    transition: color 0.2s;
}

.usagro-search-clear:hover { color: var(--usagro-text); }
.usagro-search-clear svg   { width: 16px; height: 16px; stroke: currentColor; }

/* ── Dropdown ─────────────────────────────────────────────── */
.usagro-search-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--usagro-dropdown-bg);
    border: 1px solid var(--usagro-border);
    border-radius: var(--usagro-radius);
    box-shadow: var(--usagro-shadow);
    max-height: 520px;
    overflow-y: auto;
    display: none;
    z-index: 99999;
    scroll-behavior: smooth;
}

.usagro-search-dropdown.usagro-open {
    display: block;
    animation: usagro-fade-in 0.15s ease;
}

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

/* Scrollbar bonito */
.usagro-search-dropdown::-webkit-scrollbar { width: 5px; }
.usagro-search-dropdown::-webkit-scrollbar-track { background: transparent; }
.usagro-search-dropdown::-webkit-scrollbar-thumb {
    background: var(--usagro-border);
    border-radius: 99px;
}

/* ── Grupos ───────────────────────────────────────────────── */
.usagro-group {
    padding: 8px 0;
    border-bottom: 1px solid var(--usagro-border);
}

.usagro-group:last-child { border-bottom: none; }

.usagro-group-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--usagro-text-muted);
    padding: 6px 16px 4px;
}

.usagro-group-title svg {
    width: 13px;
    height: 13px;
    stroke: currentColor;
}

/* ── Item genérico ────────────────────────────────────────── */
.usagro-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 16px;
    text-decoration: none !important;
    color: var(--usagro-text) !important;
    border-left: 3px solid transparent;
    transition: background 0.15s, border-color 0.15s;
    cursor: pointer;
}

.usagro-item:hover {
    background: var(--usagro-bg-hover);
    border-left-color: var(--usagro-accent);
    text-decoration: none !important;
}

/* ── Item producto ────────────────────────────────────────── */
.usagro-item-thumb {
    width: 46px;
    height: 46px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--usagro-bg-hover);
    border: 1px solid var(--usagro-border);
}

.usagro-item-thumb-placeholder {
    width: 46px;
    height: 46px;
    border-radius: 6px;
    background: var(--usagro-bg-hover);
    border: 1px solid var(--usagro-border);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.usagro-item-thumb-placeholder svg {
    width: 20px;
    height: 20px;
    stroke: var(--usagro-text-muted);
    opacity: 0.5;
}

.usagro-item-info {
    flex: 1;
    min-width: 0;
}

.usagro-item-title {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--usagro-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

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

.usagro-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--usagro-accent);
    color: #ffffff;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.usagro-item-pn {
    font-size: 11px;
    color: var(--usagro-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.usagro-item-compat {
    font-size: 11px;
    color: var(--usagro-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.usagro-item-price {
    flex-shrink: 0;
    font-size: 14px;
    font-weight: 700;
    color: var(--usagro-accent-dark);
    text-align: right;
}

.usagro-item-price .woocommerce-Price-amount { color: inherit; }

/* ── Item categoría / marca ───────────────────────────────── */
.usagro-tax-icon {
    width: 32px;
    height: 32px;
    background: var(--usagro-bg-hover);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.usagro-tax-icon svg {
    width: 16px;
    height: 16px;
    stroke: var(--usagro-accent);
}

.usagro-tax-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--usagro-text);
}

.usagro-tax-count {
    font-size: 12px;
    color: var(--usagro-text-muted);
}

/* ── Ver todos los resultados ─────────────────────────────── */
.usagro-see-all {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--usagro-accent-dark) !important;
    text-decoration: none !important;
    transition: background 0.15s;
    border-top: 1px solid var(--usagro-border);
}

.usagro-see-all:hover {
    background: var(--usagro-bg-hover);
    text-decoration: none !important;
}

.usagro-see-all svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
}

/* ── Estado vacío / sin resultados ───────────────────────── */
.usagro-empty {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 24px 20px;
    gap: 10px;
    color: var(--usagro-text-muted);
}

.usagro-empty svg {
    width: 32px;
    height: 32px;
    stroke: #1a3a5c;
    opacity: 0.7;
    margin-bottom: 4px;
}

.usagro-empty-text {
    font-size: 15px;
    font-weight: 700;
    color: var(--usagro-text);
    line-height: 1.3;
}

.usagro-empty-sub {
    font-size: 13px;
    color: var(--usagro-text-muted);
    line-height: 1.6;
}

.usagro-empty-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.usagro-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 18px;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none !important;
    transition: opacity 0.15s, transform 0.1s;
    white-space: nowrap;
    cursor: pointer;
}

.usagro-btn:hover {
    opacity: 0.88;
    transform: translateY(-1px);
    text-decoration: none !important;
}

.usagro-btn svg {
    width: 15px;
    height: 15px;
    stroke: currentColor;
    flex-shrink: 0;
}

.usagro-btn-primary {
    background: #1a3a5c;
    color: #ffffff !important;
}

.usagro-btn-outline {
    background: transparent;
    color: #1a3a5c !important;
    border: 2px solid #1a3a5c;
}

/* ============================================================
   Usagroparts Results Page — [usagro_results] shortcode
   ============================================================ */

.usagro-results-page {
    width: 100%;
}

.usagro-results-header {
    margin-bottom: 28px;
}

.usagro-results-title {
    font-size: 1.5em;
    margin: 0 0 6px;
    color: #1a1a1a;
}

.usagro-results-title em {
    font-style: italic;
    color: #1a3a5c;
}

.usagro-results-count {
    color: #6b7280;
    font-size: 14px;
    margin: 0;
}

/* ── Product Grid ─────────────────────────────────────────── */
.usagro-product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 24px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.usagro-product-card {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    transition: box-shadow 0.2s, transform 0.15s;
}

.usagro-product-card:hover {
    box-shadow: 0 6px 24px rgba(0,0,0,0.10);
    transform: translateY(-2px);
}

.usagro-product-link {
    display: block;
    text-decoration: none !important;
    color: inherit !important;
    height: 100%;
}

.usagro-product-img-wrap {
    width: 100%;
    height: 200px;
    background: #f9f9f9;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-bottom: 1px solid #f0f0f0;
}

.usagro-product-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 12px;
    box-sizing: border-box;
}

.usagro-product-img-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f0f0;
}

.usagro-product-img-placeholder svg {
    width: 48px;
    height: 48px;
    stroke: #ccc;
}

.usagro-product-body {
    padding: 16px;
}

.usagro-product-title {
    font-weight: 700;
    font-size: 14px;
    margin: 0 0 8px;
    line-height: 1.35;
    color: #1a1a1a;
}

.usagro-product-meta {
    font-size: 12px;
    color: #6b7280;
    margin: 0 0 4px;
}

.usagro-product-price {
    font-size: 16px;
    font-weight: 700;
    color: #1a3a5c;
    margin: 10px 0 0;
}

.usagro-product-price .woocommerce-Price-amount { color: inherit; }

/* ── No Results Box (page version) ───────────────────────── */
.usagro-noresults-box {
    background: #f8f9fa;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 40px 36px;
    max-width: 680px;
}

.usagro-noresults-icon {
    width: 40px;
    height: 40px;
    stroke: #1a3a5c;
    opacity: 0.7;
    display: block;
    margin-bottom: 18px;
}

.usagro-noresults-title {
    font-size: 1.2em;
    margin: 0 0 12px;
    color: #1a1a1a;
}

.usagro-noresults-text {
    color: #4b5563;
    line-height: 1.7;
    margin: 0 0 28px;
    font-size: 15px;
}

.usagro-noresults-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.usagro-noresults-actions .usagro-btn svg {
    width: 16px;
    height: 16px;
}

/* ── Elementor container fix ──────────────────────────────── */
.elementor-widget-usagroparts_search {
    width: 100%;
}

.elementor-widget-usagroparts_search .elementor-widget-container {
    width: 100%;
}

.elementor-widget-usagroparts_search .usagro-search-wrapper {
    width: 100%;
    box-sizing: border-box;
}
