/**
 * Estilos para o Sistema de Busca Inteligente de Produtos
 * Design moderno e responsivo inspirado em interfaces premium
 */

/* Não aplica estilos no editor visual do BeTheme */
body.mfn-live-builder .mfn-product-search-container,
body.mfn-visual-builder .mfn-product-search-container,
body.mfn-vb .mfn-product-search-container,
.mfn-live-builder .mfn-product-search-container {
    display: none !important;
}

/* ===== CONTAINER PRINCIPAL ===== */
.mfn-product-search-container {
    position: relative;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    z-index: 9999;
}

/* ===== FORMULÁRIO DE BUSCA ===== */
.mfn-product-search-form {
    position: relative;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: all 0.3s ease;
}

.mfn-product-search-form:focus-within {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

/* ===== INPUT E BOTÃO ===== */
.mfn-search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: #fff;
}

.mfn-product-search-input {
    width: 100%;
    padding: 16px 20px;
    padding-right: 60px;
    border: none;
    outline: none;
    font-size: 16px;
    font-weight: 400;
    color: #333;
    background: transparent;
    border-radius: 12px;
    margin: 0 !important;
    margin-bottom: 0 !important;
    transition: all 0.3s ease;
}

.mfn-product-search-input::placeholder {
    color: #999;
    font-weight: 300;
}

.mfn-product-search-input:focus::placeholder {
    color: #ccc;
}

.mfn-search-submit {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    color: #fff;
}

.mfn-search-submit:hover {
    background: linear-gradient(135deg, #5a67d8 0%, #6b46c1 100%);
    transform: translateY(-50%) scale(1.05);
}

.mfn-search-submit svg {
    width: 18px !important;
    height: 18px !important;
    stroke: currentColor;
    fill: none;
    transition: transform 0.3s ease;
    flex-shrink: 0;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.mfn-search-submit:hover svg {
    transform: scale(1.1);
}

/* ===== FILTROS ===== */
.mfn-search-filters {
    padding: 12px 20px;
    border-top: 1px solid #f0f0f0;
    background: #fafafa;
}

.mfn-search-category-filter {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
    outline: none;
    transition: border-color 0.3s ease;
}

.mfn-search-category-filter:focus {
    border-color: #667eea;
}

/* ===== RESULTADOS - LAYOUT MODERNO ===== */
.mfn-search-results {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    overflow: hidden;
    z-index: 9998; /* Abaixo do footer sticky menu (9999) */
    margin: 0;
    border-radius: 0;
    display: none;
    transform: scale(0.95);
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 0.4s ease;
}

/* Overlay escuro atrás dos resultados */
.mfn-search-results::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    z-index: -1;
    backdrop-filter: blur(8px) saturate(180%);
    -webkit-backdrop-filter: blur(8px) saturate(180%);
}

/* Quando os resultados estão visíveis */
.mfn-search-results.mfn-show {
    display: block !important;
    opacity: 1;
    transform: scale(1);
}

/* Bloqueia scroll do body quando fullscreen está ativo */
body.mfn-search-fullscreen-active {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* ===== TOPO COMPACTO DOS RESULTADOS ===== */
.mfn-search-results-top {
    padding: 16px 12px 12px;
    background: #ffffff;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
    position: relative;
    z-index: 1;
}

.mfn-search-input-wrapper-fullscreen {
    position: relative;
    width: 100%;
    max-height: 40px;
    margin-bottom: 0;
}

.mfn-product-search-input-fullscreen {
    width: 100%;
    height: 40px;
    padding: 0 50px 0 16px;
    border: none;
    outline: none;
    font-size: 16px;
    font-weight: 500;
    color: #1e293b;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 20px;
    letter-spacing: 0.025em;
    margin: 0 !important;
    margin-bottom: 0 !important;
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.1),
        0 2px 6px rgba(0, 0, 0, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(148, 163, 184, 0.2);
    transition: all 0.3s ease;
}

.mfn-product-search-input-fullscreen:focus {
    box-shadow: 
        0 6px 20px rgba(99, 102, 241, 0.15),
        0 3px 8px rgba(99, 102, 241, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
    border-color: rgba(99, 102, 241, 0.4);
    outline: none;
}

.mfn-product-search-input-fullscreen::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

.mfn-search-close {
    position: absolute;
    right: 3px;
    top: 50%;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    min-width: 34px;
    min-height: 34px;
    border: none;
    background: #64748b;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    font-weight: 400;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
    box-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.1),
        0 1px 2px rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.2);
    z-index: 10;
    line-height: 1;
}

.mfn-search-close:hover {
    background: #475569;
    transform: translateY(-50%) scale(1.05);
    box-shadow: 
        0 4px 8px rgba(0, 0, 0, 0.15),
        0 2px 4px rgba(0, 0, 0, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

.mfn-search-close:active {
    transform: translateY(-50%) scale(0.98);
}

/* ===== CONTEÚDO DOS RESULTADOS - LISTA COMPACTA ===== */
.mfn-search-results-content {
    height: calc(100vh - 90px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.3) transparent;
    padding: 8px 12px 60px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #ffffff;
}

/* Container da lista de produtos - mais compacto */
.mfn-search-results-content > * {
    width: 100%;
    max-width: 700px;
    margin: 0 auto;
}

.mfn-search-results-content::-webkit-scrollbar {
    width: 6px;
}

.mfn-search-results-content::-webkit-scrollbar-track {
    background: transparent;
}

.mfn-search-results-content::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.mfn-search-results-content::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* ===== ITEM DE PRODUTO - DESIGN COMPACTO ===== */
.mfn-search-product-item {
    display: grid;
    grid-template-columns: 70px 1fr;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 6px;
    background: #ffffff;
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
    position: relative;
    border: 1px solid rgba(148, 163, 184, 0.15);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.mfn-search-product-item:hover {
    background: #ffffff;
    transform: translateY(-1px);
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.12),
        0 2px 6px rgba(0, 0, 0, 0.08);
    border-color: rgba(99, 102, 241, 0.2);
}

.mfn-search-product-item:last-child {
    margin-bottom: 0;
}

/* Coluna 1 - Foto Compacta */
.mfn-search-product-image {
    width: 70px;
    height: 70px;
    border-radius: 6px;
    overflow: hidden;
    background: #f8fafc;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border: 1px solid rgba(148, 163, 184, 0.1);
}

.mfn-search-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.mfn-search-product-image.mfn-no-image {
    color: #94a3b8;
}

.mfn-search-product-item:hover .mfn-search-product-image {
    transform: scale(1.02);
}

.mfn-search-product-item:hover .mfn-search-product-image img {
    transform: scale(1.05);
}

.mfn-search-product-item:hover .mfn-search-product-title {
    color: #3b82f6;
}

/* Coluna 2 - Info Compacta */
.mfn-search-product-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    padding: 0;
}

/* Linha 1 - Nome compacto */
.mfn-search-product-title {
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.3s ease;
}

/* Linha 2 - Preço compacto */
.mfn-search-product-price {
    font-size: 15px;
    font-weight: 700;
    color: #059669;
    margin: 0;
}

.mfn-search-product-price .woocommerce-Price-amount {
    font-weight: inherit;
}

.mfn-search-product-price del {
    color: #94a3b8;
    font-weight: 400;
    font-size: 15px;
    margin-right: 8px;
    text-decoration: line-through;
    opacity: 0.8;
    -webkit-text-fill-color: #94a3b8;
    background: none;
}

/* Linha 3 - Botão compacto */
.mfn-search-add-to-cart {
    padding: 8px 16px;
    background: #059669;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    align-self: flex-start;
    min-width: 100px;
    height: 32px;
}

.mfn-search-add-to-cart:hover {
    background: #047857;
    transform: translateY(-1px);
    color: #ffffff;
}

.mfn-search-add-to-cart:active {
    transform: translateY(0);
}

/* Botão fora de estoque */
.mfn-search-add-to-cart.out-of-stock {
    background: #64748b;
    cursor: not-allowed;
    opacity: 0.7;
}

.mfn-search-add-to-cart.out-of-stock:hover {
    background: #64748b;
    transform: none;
}

/* ===== ESTADOS DE LOADING ===== */
.mfn-search-loading {
    padding: 40px 20px;
    text-align: center;
    color: #666;
}

.mfn-search-loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: mfn-spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes mfn-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.mfn-search-no-results {
    padding: 40px 20px;
    text-align: center;
    color: #666;
}

.mfn-search-no-results p {
    margin: 0;
    font-size: 14px;
    color: #64748b;
}

.mfn-search-no-results-icon {
    font-size: 48px;
    color: #ddd;
    margin-bottom: 16px;
}

.mfn-search-no-results h4 {
    margin: 0 0 8px 0;
    color: #333;
    font-weight: 600;
}

.mfn-search-no-results p {
    margin: 0;
    font-size: 14px;
}

/* ===== SUGESTÕES ===== */
.mfn-search-suggestions {
    padding: 16px 20px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
}

.mfn-search-suggestions h5 {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: #666;
}

.mfn-search-suggestion-item {
    display: inline-block;
    margin: 0 8px 8px 0;
    padding: 6px 12px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 12px;
    color: #666;
    text-decoration: none;
    transition: all 0.3s ease;
}

.mfn-search-suggestion-item:hover {
    background: #667eea;
    border-color: #667eea;
    color: #fff;
}

/* ===== RESPONSIVO ===== */
@media (max-width: 768px) {
    .mfn-product-search-container {
        max-width: 100%;
    }
    
    .mfn-product-search-input {
        font-size: 16px; /* Previne zoom no iOS */
        padding: 14px 16px;
        padding-right: 56px;
    }
    
    .mfn-search-submit {
        width: 40px;
        height: 40px;
        right: 6px;
    }
    
    .mfn-search-product-item {
        grid-template-columns: 60px 1fr;
        gap: 10px;
        padding: 10px 12px;
    }
    
    .mfn-search-product-image {
        width: 60px;
        height: 60px;
    }
    
    .mfn-search-product-title {
        font-size: 13px;
        line-height: 1.3;
    }
    
    .mfn-search-product-price {
        font-size: 14px;
    }
    
    .mfn-search-add-to-cart {
        padding: 6px 12px;
        font-size: 11px;
        min-width: 90px;
        height: 28px;
    }
    
    .mfn-search-results-content {
        height: calc(100vh - 80px);
        padding: 6px 8px 60px 8px;
    }
    
    .mfn-search-results-content > * {
        max-width: 100%;
    }
    
    .mfn-search-results-top {
        padding: 12px 8px 8px;
    }
    
    .mfn-product-search-input-fullscreen {
        font-size: 16px; /* Previne zoom no iOS */
        height: 40px;
        padding: 0 45px 0 14px;
    }
    
    .mfn-search-close {
        width: 32px;
        height: 32px;
        font-size: 14px;
        right: 4px;
    }
}

@media (max-width: 480px) {
    .mfn-search-product-item {
        grid-template-columns: 50px 1fr;
        gap: 8px;
        padding: 8px 12px;
    }
    
    .mfn-search-product-image {
        width: 50px;
        height: 50px;
    }
    
    .mfn-search-product-title {
        font-size: 12px;
        -webkit-line-clamp: 2;
        line-height: 1.2;
    }
    
    .mfn-search-product-price {
        font-size: 13px;
    }
    
    .mfn-search-add-to-cart {
        padding: 5px 10px;
        font-size: 10px;
        min-width: 80px;
        height: 26px;
    }
}

/* ===== ANIMAÇÕES ===== */
/* Animações agora controladas pelo CSS transition na classe .mfn-search-results */

/* ===== DESTAQUE DOS TERMOS ===== */
.mfn-search-highlight {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    padding: 1px 2px;
    border-radius: 2px;
    font-weight: 600;
}

/* ===== RATING ===== */
.mfn-search-product-rating {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
}

.mfn-search-rating-stars {
    color: #ffc107;
    font-size: 12px;
}

.mfn-search-rating-count {
    font-size: 11px;
    color: #999;
}

/* ===== ESTILO MODAL (OPCIONAL) ===== */
.mfn-product-search-container[data-style="modal"] .mfn-search-results {
    position: fixed;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 600px;
    border-radius: 12px;
    z-index: 999999;
}

.mfn-product-search-container[data-style="modal"] .mfn-search-results::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: -1;
}

/* ===== ACESSIBILIDADE ===== */
.mfn-product-search-input:focus,
.mfn-search-submit:focus,
.mfn-search-category-filter:focus,
.mfn-search-product-item:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.mfn-search-product-item[aria-selected="true"] {
    background: #e3f2fd;
    border-left: 4px solid #667eea;
}

/* ===== NOTIFICAÇÕES ===== */
.mfn-search-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 8px;
    color: #fff;
    font-weight: 500;
    z-index: 999999;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    animation: mfn-slideInRight 0.3s ease-out;
    max-width: 300px;
}

.mfn-search-notification-success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
}

.mfn-search-notification-error {
    background: linear-gradient(135deg, #dc3545 0%, #e74c3c 100%);
}

.mfn-search-notification-info {
    background: linear-gradient(135deg, #17a2b8 0%, #6610f2 100%);
}

@keyframes mfn-slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ===== COMPATIBILIDADE COM TEMA PAI ===== */
.mfn-product-search-container * {
    box-sizing: border-box;
}

/* Reset para evitar conflitos */
.mfn-product-search-container button {
    font-family: inherit;
    cursor: pointer;
}

.mfn-product-search-container input {
    font-family: inherit;
    margin: 0 !important;
    margin-bottom: 0 !important;
}

/* Garante que nossos estilos tenham prioridade */
.mfn-product-search-container .mfn-search-results {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 9998 !important;
    margin: 0 !important;
    border-radius: 0 !important;
}

/* Force o ícone da lupa no botão */
.mfn-product-search-container .mfn-search-submit svg {
    width: 18px !important;
    height: 18px !important;
    stroke: #ffffff !important;
    fill: none !important;
    stroke-width: 2 !important;
    stroke-linecap: round !important;
    stroke-linejoin: round !important;
    display: block !important;
    visibility: visible !important;
}

/* Force o layout do input fullscreen */
.mfn-product-search-container .mfn-search-input-wrapper-fullscreen {
    position: relative !important;
    width: 100% !important;
    max-height: 40px !important;
    margin-bottom: 0 !important;
}

.mfn-product-search-container .mfn-product-search-input-fullscreen {
    width: 100% !important;
    height: 40px !important;
    padding: 0 50px 0 16px !important;
    background: rgba(255, 255, 255, 0.98) !important;
    border-radius: 20px !important;
    border: 1px solid rgba(148, 163, 184, 0.2) !important;
}

.mfn-product-search-container .mfn-search-close {
    position: absolute !important;
    right: 3px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    min-height: 34px !important;
    background: #64748b !important;
    border-radius: 50% !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: #ffffff !important;
    z-index: 10 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 18px !important;
    font-weight: 400 !important;
    line-height: 1 !important;
    flex-shrink: 0 !important;
}

/* Força exibição quando ativo - regra super específica */
body .mfn-product-search-container .mfn-search-results.mfn-show,
.mfn-product-search-container .mfn-search-results.mfn-show {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* ===== FOOTER DOS RESULTADOS ===== */
.mfn-search-results-footer {
    padding: 15px 20px;
    text-align: center;
    border-top: 1px solid #eee;
    background: #fafafa;
    margin-top: 10px;
}

.mfn-results-count {
    font-size: 11px;
    color: #666;
    margin: 0 0 10px 0;
    font-weight: 400;
    letter-spacing: 0.3px;
}

.mfn-view-all-btn {
    background: #0073aa;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
    min-width: 160px;
}

.mfn-view-all-btn:hover {
    background: #005177;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    color: white;
}

.mfn-view-all-btn:active {
    transform: translateY(0);
}

/* Mobile para footer */
@media (max-width: 768px) {
    .mfn-search-results-footer {
        padding: 12px 15px;
    }
    
    .mfn-view-all-btn {
        width: 100%;
        max-width: 250px;
        padding: 10px 16px;
        font-size: 13px;
    }
}

/* ===== MODO ESCURO (OPCIONAL) ===== */
@media (prefers-color-scheme: dark) {
    .mfn-product-search-form {
        background: #2d3748;
        color: #e2e8f0;
    }
    
    .mfn-product-search-input {
        color: #e2e8f0;
        background: transparent;
    }
    
    .mfn-product-search-input::placeholder {
        color: #a0aec0;
    }
    
    .mfn-search-results {
        background: #2d3748;
        color: #e2e8f0;
    }
    
    .mfn-search-product-item {
        border-color: #4a5568;
    }
    
    .mfn-search-product-item:hover {
        background: #4a5568;
    }
    
    .mfn-search-results-footer {
        background: #1a202c;
        border-color: #4a5568;
    }
    
    .mfn-results-count {
        color: #a0aec0;
    }
}