/**
 * Address Suggestion Styles
 *
 * Styling for city and zipcode autocomplete dropdowns in checkout.
 *
 * @package Nf\Platform
 * @since 1.0.0
 */

/* Ensure parent field has relative positioning for absolute dropdown */
#billing_city_field,
#shipping_city_field,
#billing_postcode_field,
#shipping_postcode_field {
    position: relative !important;
}

/* The JS sets position:relative on .woocommerce-input-wrapper (a <span>).
   Make it block-level so it serves as a proper containing block for
   both .nf-address-suggestions and .nf-field-hint. */
#billing_city_field .woocommerce-input-wrapper,
#shipping_city_field .woocommerce-input-wrapper,
#billing_postcode_field .woocommerce-input-wrapper,
#shipping_postcode_field .woocommerce-input-wrapper {
    display: block;
    width: 100%;
}

/* Autocomplete dropdown container */
.nf-address-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 250px;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 9999;
    margin-top: -1px;
}

/* Suggestion item */
.nf-address-suggestion-item {
    padding: 10px 14px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    line-height: 1.5;
    font-size: 14px;
    color: #333;
    border-bottom: 1px solid #f0f0f0;
}

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

/* Hover and active states */
.nf-address-suggestion-item:hover,
.nf-address-suggestion-item.active {
    background-color: #f5f5f5;
}

/* Zipcode/City display in suggestions */
.nf-address-suggestion-item .zipcode,
.nf-address-suggestion-item .city {
    color: #888;
    font-size: 0.9em;
    margin-left: 4px;
}

/* Scrollbar styling for dropdown */
.nf-address-suggestions::-webkit-scrollbar {
    width: 8px;
}

.nf-address-suggestions::-webkit-scrollbar-track {
    background: #f9f9f9;
}

.nf-address-suggestions::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.nf-address-suggestions::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Loading state (optional) */
.nf-address-suggestions.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .nf-address-suggestions {
        max-height: 200px;
        font-size: 16px; /* Prevent zoom on iOS */
    }

    .nf-address-suggestion-item {
        padding: 12px 16px;
        font-size: 16px;
    }
}

/* High DPI/Retina displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .nf-address-suggestions {
        border-width: 0.5px;
    }
}

/* Dark mode support (optional - matches system preference) */
@media (prefers-color-scheme: dark) {
    .nf-address-suggestions {
        background: #2a2a2a;
        border-color: #444;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    }

    .nf-address-suggestion-item {
        color: #e0e0e0;
        border-bottom-color: #333;
    }

    .nf-address-suggestion-item:hover,
    .nf-address-suggestion-item.active {
        background-color: #333;
    }

    .nf-address-suggestion-item .zipcode,
    .nf-address-suggestion-item .city {
        color: #999;
    }

    .nf-address-suggestions::-webkit-scrollbar-track {
        background: #222;
    }

    .nf-address-suggestions::-webkit-scrollbar-thumb {
        background: #555;
    }

    .nf-address-suggestions::-webkit-scrollbar-thumb:hover {
        background: #666;
    }
}

/* Accessibility - focus visible styles */
.nf-address-suggestion-item:focus-visible {
    outline: 2px solid #007cba;
    outline-offset: -2px;
}

/* Animation for dropdown appearance */
@keyframes nf-dropdown-slide {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.nf-address-suggestions {
    animation: nf-dropdown-slide 0.15s ease-out;
}
