/* WP Busca Distribuidores - Estilos Premium */

/* Reset e variáveis */
.wpbd-container {
    --wpbd-primary: #080808;
    --wpbd-primary-dark: #080808;
    --wpbd-secondary: #64748b;
    --wpbd-success: #10b981;
    --wpbd-border: #e2e8f0;
    --wpbd-bg-light: #f8fafc;
    --wpbd-text: #1e293b;
    --wpbd-text-muted: #64748b;
    --wpbd-shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --wpbd-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --wpbd-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --wpbd-radius: 12px;
    
    max-width: 100%;
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.wpbd-container * {
    box-sizing: border-box;
}

/* Formulário de busca premium */
.wpbd-search-wrapper {
    padding: 3rem 1.5rem;
    margin: -1.5rem -1.5rem 2rem;
    position: relative;
    overflow: visible !important; /* CORRIGIDO para autocomplete */
}



.wpbd-search-inner {
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.wpbd-search-title {
    padding-left: 30px;
    padding-right: 30px;
    color: white;
    font-size: 2rem;
    font-weight: 700;
    margin: 0 0 2rem;
    text-align: center;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.wpbd-search-form {
    background: #f7f7f7;
    border-radius: var(--wpbd-radius);
    padding: 1.5rem;
    box-shadow: var(--wpbd-shadow-lg);
    overflow: visible !important; /* CORRIGIDO para autocomplete */
}

#wpbd-busca-input {
    padding-left: 45px;
    border-radius: 7px 7px 7px 7px !important;
}

.wpbd-search-grid {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 1rem;
    align-items: end;
}

.wpbd-search-field {
    position: relative;
}

.wpbd-field-busca {
    grid-column: 1;
    position: relative; /* IMPORTANTE para o autocomplete */
}

/* Campo de busca com ícone */
.wpbd-search-field input[type="text"] {
    width: 100%;
    padding: 0.875rem 1rem 0.875rem 3rem;
    border: 2px solid var(--wpbd-border);
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: all 0.2s;
    background: white;
}

.wpbd-search-field input[type="text"]:focus {
    outline: none;
    border-color: var(--wpbd-primary);
    box-shadow: 0 0 0 3px rgba(8, 8, 8, 0.1);
}

.wpbd-search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--wpbd-text-muted);
    pointer-events: none;
}

/* Select customizado */
.wpbd-search-field select {
    width: 100%;
    padding: 0.875rem 2.5rem 0.875rem 1rem;
    border: 2px solid var(--wpbd-border);
    border-radius: 0.5rem;
    font-size: 1rem;
    background: white;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M10.293 3.293L6 7.586 1.707 3.293A1 1 0 00.293 4.707l5 5a1 1 0 001.414 0l5-5a1 1 0 10-1.414-1.414z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    appearance: none;
    cursor: pointer;
    transition: all 0.2s;
}

.wpbd-search-field select:focus {
    outline: none;
    border-color: var(--wpbd-primary);
    box-shadow: 0 0 0 3px rgba(8, 8, 8, 0.1);
}

/* Botão de busca */
.wpbd-search-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 2rem;
    background: var(--wpbd-primary);
    color: white !important;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.wpbd-search-button:hover {
    background: var(--wpbd-primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--wpbd-shadow);
}

.wpbd-search-button:active {
    transform: translateY(0);
}

.wpbd-search-button svg {
    transition: transform 0.2s;
}

.wpbd-search-button:hover svg {
    transform: translateX(2px);
}

/* Autocomplete - CORRIGIDO */
.wpbd-autocomplete {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    margin-top: 0.25rem;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    display: none;
    z-index: 9999; /* AUMENTADO para garantir que fique acima */
    max-height: 300px;
    overflow-y: auto;
}

.wpbd-autocomplete.show {
    display: block;
}

.wpbd-autocomplete-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background 0.1s;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.wpbd-autocomplete-item:last-child {
    border-bottom: none;
}

.wpbd-autocomplete-item:hover,
.wpbd-autocomplete-item.active {
    background: #f8fafc;
}

.wpbd-autocomplete-label {
    flex: 1;
    font-size: 0.875rem;
    color: #1e293b;
}

.wpbd-autocomplete-type {
    font-size: 0.75rem;
    color: #64748b;
    background: #f1f5f9;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    margin-left: 0.5rem;
}

.wpbd-autocomplete-loading,
.wpbd-autocomplete-empty {
    padding: 1rem;
    text-align: center;
    color: #64748b;
    font-size: 0.875rem;
}

/* Não mostra mensagem vazia para CEPs */
.wpbd-autocomplete-empty.is-cep {
    display: none;
}

.wpbd-autocomplete-loading::after {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-left: 0.5rem;
    border: 2px solid #e2e8f0;
    border-top-color: var(--wpbd-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
}

/* Destaque no campo quando tem sugestões */
.wpbd-field-busca.has-suggestions input {
    border-color: var(--wpbd-primary);
}

/* Contador de resultados */
.wpbd-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 0 0.5rem;
}

.wpbd-results-count {
    font-size: 1.125rem !important;
    color: var(--wpbd-text);
    margin: 0;
    font-weight: 600;
}

.wpbd-clear-search {
    color: var(--wpbd-primary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: color 0.2s;
}

.wpbd-clear-search:hover {
    color: var(--wpbd-primary-dark);
    text-decoration: underline;
}

/* Mapa - ALTURA AUMENTADA */
.wpbd-map-container {
    margin-bottom: 2rem;
    border-radius: var(--wpbd-radius);
    overflow: hidden;
    box-shadow: var(--wpbd-shadow);
}

#wpbd-map {
    width: 100%;
    height: 600px; /* AUMENTADO de 500px para 600px */
    min-height: 400px;
}

/* Grid de cards */
.wpbd-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

/* Card de distribuidor */
.wpbd-card {
    background: white;
    border: 1px solid var(--wpbd-border);
    border-radius: var(--wpbd-radius);
    overflow: hidden;
    transition: all 0.2s;
    cursor: pointer;
}

.wpbd-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--wpbd-shadow-lg);
    border-color: var(--wpbd-primary);
}

.wpbd-card.destacado {
    border-color: var(--wpbd-primary);
    box-shadow: 0 0 0 3px rgba(8, 8, 8, 0.1);
}

.wpbd-card-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--wpbd-bg-light);
    display: flex;
    justify-content: space-between;
    align-items: start;
}

.wpbd-card-header h4 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--wpbd-text);
    line-height: 1.4;
}

.wpbd-card-code {
    font-size: 0.75rem;
    color: var(--wpbd-text-muted);
    background: var(--wpbd-bg-light);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    white-space: nowrap;
}

.wpbd-card-body {
    padding: 1.25rem;
    overflow-wrap: break-word; /* CORRIGIDO para mobile */
    word-wrap: break-word;
}

.wpbd-card-info {
    display: flex;
    align-items: start;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    color: var(--wpbd-text-muted);
    font-size: 0.875rem;
    line-height: 1.5;
}

.wpbd-card-info:last-child {
    margin-bottom: 0;
}

.wpbd-card-info svg {
    flex-shrink: 0;
    margin-top: 0.125rem;
    color: var(--wpbd-secondary);
}

.wpbd-card-info span {
    word-break: break-word; /* CORRIGIDO para mobile */
}

.wpbd-card-phone a {
    color: var(--wpbd-primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.wpbd-card-phone a:hover {
    color: var(--wpbd-primary-dark);
    text-decoration: underline;
}

.wpbd-card-footer {
    padding: 1rem 1.25rem;
    background: var(--wpbd-bg-light);
    border-top: 1px solid var(--wpbd-border);
}

.wpbd-card-map-btn {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    background: white;
    color: var(--wpbd-primary);
    border: 1px solid var(--wpbd-primary);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.wpbd-card-map-btn:hover {
    background: var(--wpbd-primary);
    color: white;
}

/* Estados vazios */
.wpbd-no-results,
.wpbd-welcome {
    text-align: center;
    padding: 2rem 2rem;
    color: var(--wpbd-text-muted);
}

.wpbd-no-results svg,
.wpbd-welcome svg {
    margin-bottom: 1.5rem;
    opacity: 0.3;
}

.wpbd-no-results h3,
.wpbd-welcome h3 {
    font-size: 1.5rem;
    color: var(--wpbd-text);
    margin: 0 0 0.5rem;
}

.wpbd-no-results p,
.wpbd-welcome p {
    font-size: 1rem;
    margin: 0 0 1.5rem;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.wpbd-no-results .wpbd-search-button {
    margin-top: 1rem;
    border-radius: 7px 7px 7px 7px !important;
    padding: 17px 30px 18px 30px !important;
}

.wpbd-search-button {
    border-radius: 7px 7px 7px 7px !important;
    padding: 17px 30px 18px 30px !important;
}

/* InfoWindow do mapa */
.wpbd-info-window {
    padding: 0.5rem;
    min-width: 200px;
}

.wpbd-info-window h4 {
    margin: 0 0 0.5rem;
    font-size: 1rem;
    color: var(--wpbd-text);
}

.wpbd-info-window p {
    margin: 0.25rem 0;
    font-size: 0.875rem;
    color: var(--wpbd-text-muted);
}

/* Responsividade */
@media (max-width: 1024px) {
    .wpbd-search-grid {
        grid-template-columns: 1fr auto;
        gap: 0.75rem;
    }
    
    .wpbd-field-busca {
        grid-column: 1 / -1;
    }
    
    #wpbd-map {
        height: 500px; /* Reduz um pouco em tablets */
    }
}

@media (max-width: 768px) {
    .wpbd-search-wrapper {
        padding: 2rem 1rem;
        margin: -1rem -1rem 1.5rem;
    }
    
    .wpbd-search-title {
        font-size: 1.5rem;
        margin-bottom: 1.5rem;
    }
    
    .wpbd-search-form {
        padding: 1rem;
    }
    
    .wpbd-search-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .wpbd-field-estado,
    .wpbd-field-submit {
        grid-column: 1;
    }
    
    .wpbd-search-button {
        width: 100%;
        justify-content: center;
    }
    
    #wpbd-map {
        height: 400px; /* Menor no mobile mas ainda proporcional */
    }
    
    .wpbd-cards-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .wpbd-results-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .wpbd-card-header {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .wpbd-card-code {
        align-self: flex-start;
    }
    
    /* Autocomplete no mobile - flutuante */
    .wpbd-autocomplete {
        position: fixed;
        left: 1rem;
        right: 1rem;
        top: auto;
        bottom: 1rem;
        max-height: 50vh;
        border-radius: 1rem;
        z-index: 99999;
    }
    
    .wpbd-autocomplete-item {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .wpbd-search-wrapper {
        padding: 1.5rem 0.75rem;
        margin: -0.75rem -0.75rem 1rem;
    }
    
    .wpbd-search-title {
        font-size: 1.25rem;
    }
    
    .wpbd-search-form {
        padding: 0.75rem;
        border-radius: 0.75rem;
    }
    
    .wpbd-card {
        border-radius: 0.75rem;
    }
    
    .wpbd-card-header,
    .wpbd-card-body {
        padding: 1rem;
    }
    
    .wpbd-card-footer {
        padding: 0.75rem 1rem;
    }
    
    .wpbd-no-results,
    .wpbd-welcome {
        padding: 1rem 1.5rem;
    }
    
    #wpbd-map {
        height: 350px;
    }
}

/* Animações */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wpbd-card {
    animation: fadeIn 0.3s ease-out;
    animation-fill-mode: both;
}

.wpbd-card:nth-child(1) { animation-delay: 0.05s; }
.wpbd-card:nth-child(2) { animation-delay: 0.1s; }
.wpbd-card:nth-child(3) { animation-delay: 0.15s; }
.wpbd-card:nth-child(4) { animation-delay: 0.2s; }
.wpbd-card:nth-child(5) { animation-delay: 0.25s; }
.wpbd-card:nth-child(6) { animation-delay: 0.3s; }

/* Loading */
.wpbd-loading {
    display: flex;
    justify-content: center;
    padding: 3rem;
}

.wpbd-loading::after {
    content: '';
    width: 40px;
    height: 40px;
    border: 3px solid var(--wpbd-border);
    border-top-color: var(--wpbd-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Print styles */
@media print {
    .wpbd-search-wrapper,
    .wpbd-card-footer,
    .wpbd-clear-search,
    #wpbd-map {
        display: none !important;
    }
    
    .wpbd-cards-grid {
        grid-template-columns: 1fr;
    }
    
    .wpbd-card {
        break-inside: avoid;
        border: 1px solid #000;
        margin-bottom: 1rem;
    }
}


