/* Polish Postal Code Autofill for Contact Form 7 - Styles */

/* Autocomplete dropdown container */
.postal-suggestions,
.city-suggestions {
    position: relative;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    max-height: 300px;
    overflow-y: auto;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    width: 100%;
    box-sizing: border-box;
    margin-top: 2px;
}

/* Individual suggestion item */
.suggestion-item {
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.suggestion-item:hover,
.suggestion-item.selected {
    background-color: #f8f9fa;
}

.suggestion-item:last-child {
    border-bottom: none;
}

/* Suggestion content */
.suggestion-item .suggestion-main {
    font-weight: 500;
    color: #333;
    font-size: 14px;
}

.suggestion-item .suggestion-details {
    font-size: 12px;
    color: #666;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.suggestion-item .suggestion-details span {
    background: #e9ecef;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
}

/* Highlighted text in suggestions */
.postal-autofill-suggestion .highlight {
    background-color: #fff3cd;
    padding: 1px 2px;
    border-radius: 2px;
    font-weight: 600;
}

/* Loading state */
.loading {
    padding: 15px;
    text-align: center;
    color: #666;
    font-style: italic;
}

.loading::after {
    content: "...";
    animation: dots 1.5s infinite;
}

@keyframes dots {
    0%, 20% { content: "..."; }
    40% { content: "...."; }
    60% { content: "....."; }
    80%, 100% { content: "......"; }
}

/* Error state */
.error {
    padding: 15px;
    text-align: center;
    color: #dc3545;
    font-size: 13px;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    margin: 5px;
}

/* Input field enhancements */
.postal-autofill-field {
    position: relative;
}

/* Ensure parent containers are positioned relatively for absolute dropdowns */
.wpcf7-form input[name="postal-code"],
.wpcf7-form input[name="city"] {
    position: relative;
}

.wpcf7-form .wpcf7-form-control-wrap {
    position: relative;
}

/* Position suggestion containers relative to their input fields */
.wpcf7-form .postal-suggestions,
.wpcf7-form .city-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 9999;
    width: 100%;
    box-sizing: border-box;
}

/* Ensure the parent div of form control wrap is positioned relatively */
.wpcf7-form .col-md-3,
.wpcf7-form .wpcf7-form-control-wrap {
    position: relative;
}

.postal-autofill-field input:focus {
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.2);
}

/* Responsive design */
@media (max-width: 768px) {
    .postal-autofill-suggestions {
        max-height: 250px;
    }
    
    .postal-autofill-suggestion {
        padding: 10px 12px;
    }
    
    .postal-autofill-suggestion .suggestion-details {
        font-size: 11px;
    }
}

/* Integration with Contact Form 7 */
.wpcf7-form .postal-autofill-field {
    margin-bottom: 1rem;
}

.wpcf7-form .postal-suggestions,
.wpcf7-form .city-suggestions {
    font-family: inherit;
}

/* Custom styling for BUDOKRUSZ theme */
.row.pt-5 .postal-suggestions,
.row.pt-5 .city-suggestions {
    background: #fff;
    border: 2px solid #f8e114;
    border-top: none;
    box-shadow: 0 4px 12px rgba(248, 225, 20, 0.3);
}

.row.pt-5 .suggestion-item:hover,
.row.pt-5 .suggestion-item.selected {
    background-color: #f8e114;
    color: #333;
}

.row.pt-5 .suggestion-item .suggestion-details span {
    background: rgba(248, 225, 20, 0.2);
    color: #333;
}