/*
 * CM Collection - Location System Styles
 */

/* Trigger Button */
.cmc-location-trigger-wrapper {
    position: relative;
}

.cmc-open-location-modal {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.cmc-selected-address-display {
    color: var(--cmc-primary);
    font-size: 0.95rem;
}

/* Modal Core (Micromodal structure) */
.cmc-location-modal {
    display: none;
}

.cmc-location-modal.is-open {
    display: block;
}

/* Generic panel — ensures absolute close button works */
.cmc-modal {
    position: relative;
}

.cmc-modal__overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    padding: 1rem;
    backdrop-filter: blur(4px);
}

.cmc-modal__container {
    background-color: var(--cmc-white);
    padding: 2rem;
    max-width: 500px;
    width: 100%;
    border-radius: var(--cmc-radius-lg);
    box-shadow: var(--cmc-shadow-xl);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.cmc-modal__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--cmc-border);
}

.cmc-modal__title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--cmc-dark);
}

.cmc-modal__close {
    background: transparent;
    border: 0;
    cursor: pointer;
    padding: 0.375rem 0.5rem;
    font-size: 1.25rem;
    line-height: 1;
    color: var(--cmc-gray-500);
    transition: color var(--cmc-transition-fast), opacity var(--cmc-transition-fast);
    opacity: 0.7;
}

.cmc-modal__close:hover {
    color: var(--cmc-gray-300, #d1d5db);
    opacity: 1;
}

/* Quote Modal — close button override (SVG icon, positioned top-right) */
.cmc-quote-modal__close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.10);
    color: rgba(255, 255, 255, 0.55);
    padding: 0;
    opacity: 1;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    z-index: 10;
}

.cmc-quote-modal__close:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.9);
    opacity: 1;
}

.cmc-modal__content {
    overflow-y: auto;
    flex-grow: 1;
    padding-right: 0.5rem; /* For scrollbar */
}

/* Custom Scrollbar for Modal Content */
.cmc-modal__content::-webkit-scrollbar {
    width: 6px;
}
.cmc-modal__content::-webkit-scrollbar-track {
    background: var(--cmc-gray-100);
    border-radius: 4px;
}
.cmc-modal__content::-webkit-scrollbar-thumb {
    background: var(--cmc-gray-400);
    border-radius: 4px;
}

.cmc-modal__footer {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--cmc-border);
}

/* Search Autocomplete */
.cmc-search-wrapper {
    position: relative;
}

.cmc-autocomplete-results {
    list-style: none;
    margin: 0;
    padding: 0;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--cmc-white);
    border: 1px solid var(--cmc-border);
    border-top: none;
    border-radius: 0 0 var(--cmc-radius-md) var(--cmc-radius-md);
    box-shadow: var(--cmc-shadow-md);
    max-height: 200px;
    overflow-y: auto;
    z-index: 10;
    display: none; /* Shown by JS when there are results */
}

.cmc-autocomplete-results li {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--cmc-gray-100);
    color: var(--cmc-dark);
    font-size: 0.95rem;
    transition: background-color var(--cmc-transition-fast);
}

.cmc-autocomplete-results li:last-child {
    border-bottom: none;
}

.cmc-autocomplete-results li:hover {
    background-color: var(--cmc-gray-100);
}

/* Responsive Overrides */
@media (max-width: 767px) {
    .cmc-modal__container {
        padding: 1.5rem;
        border-radius: var(--cmc-radius-md);
    }
    
    .cmc-modal__overlay {
        padding: 0; /* Full screen touch */
    }
    
    .cmc-modal__container {
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
}
