/**
 * ICS Address Autocomplete - Checkout Styles
 */

/* Wrapper for positioning */
.ics-aac-wrapper {
    position: relative;
    width: 100%;
}

/* Dropdown */
.ics-aac-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 9999;
    margin: 2px 0 0 0;
    padding: 0;
    list-style: none;
    background: #fff;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    max-height: 260px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Individual result item */
.ics-aac-item {
    display: flex;
    flex-direction: column;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.15s ease;
}

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

.ics-aac-item:hover,
.ics-aac-item.ics-aac-active {
    background-color: #f0f4ff;
}

.ics-aac-item-primary {
    font-size: 14px;
    font-weight: 500;
    color: #1a1a1a;
    line-height: 1.4;
}

.ics-aac-item-secondary {
    font-size: 12px;
    color: #666;
    line-height: 1.4;
    margin-top: 2px;
}

/* Loading state */
.ics-aac-loading,
.ics-aac-no-results,
.ics-aac-error {
    padding: 12px 14px;
    font-size: 13px;
    color: #888;
    text-align: center;
    cursor: default;
}

.ics-aac-error {
    color: #cc3333;
}

/* Spinner */
.ics-aac-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #ddd;
    border-top-color: #4a90d9;
    border-radius: 50%;
    animation: ics-aac-spin 0.6s linear infinite;
    vertical-align: middle;
}

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

/* Status bar (geolocation feedback) */
.ics-aac-status {
    display: none;
    padding: 6px 10px;
    margin-top: 4px;
    font-size: 12px;
    border-radius: 3px;
    line-height: 1.4;
}

.ics-aac-status-locating {
    color: #666;
}

.ics-aac-status-success {
    color: #2e7d32;
}

.ics-aac-status-warn {
    color: #e65100;
}

/* Field fill animation */
.ics-aac-filled {
    animation: ics-aac-flash 1.2s ease;
}

@keyframes ics-aac-flash {
    0% {
        background-color: inherit;
    }
    15% {
        background-color: #e8f5e9;
        box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.25);
    }
    100% {
        background-color: inherit;
        box-shadow: none;
    }
}

/* Mobile / Touch improvements */
@media (max-width: 768px) {
    .ics-aac-dropdown {
        max-height: 220px;
    }

    .ics-aac-item {
        padding: 12px 14px;
        min-height: 44px; /* Touch-friendly tap target */
    }

    .ics-aac-item-primary {
        font-size: 15px;
    }

    .ics-aac-item-secondary {
        font-size: 13px;
    }
}

/* Accessibility: focus visible */
.ics-aac-item:focus-visible {
    outline: 2px solid #4a90d9;
    outline-offset: -2px;
}

/* Cart shipping calculator: injected address field */
#calc_shipping_address_field {
    margin-bottom: 10px;
}

#calc_shipping_address_field label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    font-size: 14px;
}

#calc_shipping_address {
    width: 100%;
    box-sizing: border-box;
}

/* Ensure dropdown works inside the cart calculator */
.shipping-calculator-form .ics-aac-wrapper {
    position: relative;
    width: 100%;
}

.shipping-calculator-form .ics-aac-dropdown {
    z-index: 99999;
}

/* Cart shipping calculator - injected address field */
#calc_shipping_address_field {
    margin-bottom: 10px;
}

#calc_shipping_address_field label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    font-size: 14px;
}

#ics_calc_shipping_address {
    width: 100%;
    box-sizing: border-box;
}

/* Make sure the dropdown appears above the calculate button */
.woocommerce-shipping-calculator .ics-aac-wrapper {
    position: relative;
}

.woocommerce-shipping-calculator .ics-aac-dropdown {
    z-index: 10000;
}

/* Prefilled notice on checkout */
.ics-aac-prefill-notice {
    padding: 8px 12px;
    margin-bottom: 12px;
    background: #e8f5e9;
    border-left: 3px solid #4caf50;
    border-radius: 3px;
    font-size: 13px;
    color: #2e7d32;
}

/* Dark mode support (if theme uses prefers-color-scheme) */
@media (prefers-color-scheme: dark) {
    .ics-aac-dropdown {
        background: #2a2a2a;
        border-color: #444;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    }

    .ics-aac-item {
        border-bottom-color: #383838;
    }

    .ics-aac-item:hover,
    .ics-aac-item.ics-aac-active {
        background-color: #363650;
    }

    .ics-aac-item-primary {
        color: #e8e8e8;
    }

    .ics-aac-item-secondary {
        color: #999;
    }
}
