/* ========================================
   WCMLIM Address Management Styles
   Header integration - uses theme colors
   ======================================== */

/* Header Address Selector */
.wcmlim-address-header {
    position: relative;
    display: inline-block;
    z-index: 9999;
    font-family: inherit;
}

.wcmlim-address-trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: transparent;
    color: inherit;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 400;
    transition: opacity 0.2s ease;
}

.wcmlim-address-trigger:hover {
    opacity: 0.7;
}

.wcmlim-address-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.wcmlim-address-text {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wcmlim-address-arrow {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.wcmlim-address-trigger.active .wcmlim-address-arrow {
    transform: rotate(180deg);
}

/* Dropdown Menu */
.wcmlim-address-dropdown {
    position: absolute;
    top: calc(100% + 5px);
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    max-height: 500px;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.25s ease;
    overflow: hidden;
}

/* Widget specific adjustments */
.widget .wcmlim-address-dropdown {
    right: auto;
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
}

.widget .wcmlim-address-dropdown.show {
    transform: translateX(-50%) translateY(0);
}

/* Small screen adjustments */
@media (max-width: 480px) {
    .wcmlim-address-dropdown {
        width: 100%;
        max-width: calc(100vw - 20px);
        left: 50%;
        right: auto;
        transform: translateX(-50%) translateY(-10px);
    }
    
    .wcmlim-address-dropdown.show {
        transform: translateX(-50%) translateY(0);
    }
}

.wcmlim-address-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.wcmlim-address-dropdown-header {
    padding: 15px 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f9f9f9;
}

.wcmlim-address-dropdown-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.wcmlim-add-address-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    background: #333;
    color: #fff;
    border: none;
    border-radius: 3px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
}

.wcmlim-add-address-btn:hover {
    background: #555;
}

.wcmlim-address-list {
    max-height: 350px;
    overflow-y: auto;
    padding: 10px;
}

.wcmlim-address-list::-webkit-scrollbar {
    width: 6px;
}

.wcmlim-address-list::-webkit-scrollbar-track {
    background: #f5f5f5;
}

.wcmlim-address-list::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.wcmlim-address-list::-webkit-scrollbar-thumb:hover {
    background: #999;
}

.wcmlim-address-item {
    padding: 12px;
    margin-bottom: 8px;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.wcmlim-address-item:hover {
    background: #f0f0f0;
    border-color: #999;
}

.wcmlim-address-item.selected {
    background: #e8f4f8;
    border-color: #333;
}

.wcmlim-address-item.selected::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #333;
    border-radius: 4px 0 0 4px;
}

.wcmlim-address-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.wcmlim-address-label-icon {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.wcmlim-address-label-text {
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.wcmlim-address-default-badge {
    display: inline-block;
    padding: 2px 8px;
    background: #0073aa;
    color: white;
    font-size: 10px;
    font-weight: 600;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.wcmlim-address-details {
    font-size: 13px;
    color: #666;
    line-height: 1.6;
    margin-bottom: 10px;
}

.wcmlim-address-actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.wcmlim-address-action-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.wcmlim-address-edit-btn {
    background: #e8f0fe;
    color: #1967d2;
}

.wcmlim-address-edit-btn:hover {
    background: #d2e3fc;
}

.wcmlim-address-delete-btn {
    background: #fce8e6;
    color: #d93025;
}

.wcmlim-address-delete-btn:hover {
    background: #fad2cf;
}

.wcmlim-address-default-btn {
    background: #e6f4ea;
    color: #137333;
}

.wcmlim-address-default-btn:hover {
    background: #ceead6;
}

.wcmlim-no-address {
    text-align: center;
    padding: 40px 20px;
    color: #999;
}

.wcmlim-no-address-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 16px;
    opacity: 0.3;
}

.wcmlim-no-address-text {
    font-size: 14px;
    margin-bottom: 20px;
}

/* Modal Styles */
.wcmlim-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.wcmlim-modal-overlay.show {
    opacity: 1;
    visibility: visible;
    /* Themes with Bootstrap 3 ship ".show { display: block !important; }", which kills the
       flex centring and drops the popup into the top-left corner. More specific wins. */
    display: flex !important;
}

.wcmlim-modal {
    width: 90%;
    max-width: 700px;
    max-height: 90vh;
    background: white;
    border-radius: 20px;
    overflow: hidden;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.wcmlim-modal-overlay.show .wcmlim-modal {
    transform: scale(1);
}

.wcmlim-modal-header {
    padding: 24px 28px;
    background: #f5f5f5;
    color: #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e0e0e0;
}

.wcmlim-modal-title {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
}

.wcmlim-modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: #e0e0e0;
    color: #333;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 20px;
    line-height: 1;
}

.wcmlim-modal-close:hover {
    background: #ccc;
    transform: rotate(90deg);
}

.wcmlim-modal-body {
    padding: 28px;
    max-height: calc(90vh - 180px);
    overflow-y: auto;
}

.wcmlim-modal-body::-webkit-scrollbar {
    width: 6px;
}

.wcmlim-modal-body::-webkit-scrollbar-track {
    background: #f5f5f5;
}

.wcmlim-modal-body::-webkit-scrollbar-thumb {
    background: #d0d0d0;
    border-radius: 10px;
}

.wcmlim-form-group {
    margin-bottom: 20px;
}

.wcmlim-form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin-bottom: 8px;
}

.wcmlim-form-label.required::after {
    content: '*';
    color: #d93025;
    margin-left: 4px;
}

.wcmlim-form-input,
.wcmlim-form-select,
.wcmlim-form-textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.wcmlim-form-input:focus,
.wcmlim-form-select:focus,
.wcmlim-form-textarea:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

.wcmlim-form-textarea {
    resize: vertical;
    min-height: 80px;
}

.wcmlim-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.wcmlim-map-container {
    width: 100%;
    height: 300px;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 20px;
    border: 2px solid #e0e0e0;
}

.wcmlim-map-info {
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    font-size: 13px;
    color: #666;
    margin-bottom: 20px;
}

.wcmlim-modal-footer {
    padding: 20px 28px;
    background: #f8f9fa;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.wcmlim-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.wcmlim-btn-primary {
    background: #0073aa;
    color: white;
}

.wcmlim-btn-primary:hover {
    background: #005a87;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 115, 170, 0.3);
}

.wcmlim-btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.wcmlim-btn-secondary {
    background: #e0e0e0;
    color: #333;
}

.wcmlim-btn-secondary:hover {
    background: #d0d0d0;
}

/* Loading Spinner */
.wcmlim-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: wcmlim-spin 0.6s linear infinite;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .wcmlim-address-header {
        top: 10px;
        right: 10px;
    }

    .wcmlim-address-dropdown {
        width: calc(100vw - 20px);
        max-width: 380px;
    }

    .wcmlim-modal {
        width: 95%;
        max-height: 95vh;
    }

    .wcmlim-form-row {
        grid-template-columns: 1fr;
    }

    .wcmlim-address-trigger {
        padding: 8px 12px;
        font-size: 13px;
    }

    .wcmlim-address-text {
        max-width: 100px;
    }
}

@media (max-width: 480px) {
    .wcmlim-address-text {
        display: none;
    }

    .wcmlim-address-trigger {
        border-radius: 50%;
        width: 44px;
        height: 44px;
        padding: 0;
        justify-content: center;
    }

    .wcmlim-address-arrow {
        display: none;
    }
}

/* Animation classes */
.wcmlim-fade-in {
    animation: wcmlim-fadeIn 0.3s ease;
}

@keyframes wcmlim-fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Success message */
.wcmlim-success-message {
    padding: 12px 16px;
    background: #e6f4ea;
    color: #137333;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.wcmlim-error-message {
    padding: 12px 16px;
    background: #fce8e6;
    color: #d93025;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Map search box in the address form */
.wcmlim-map-search {
    margin-bottom: 8px;
}

.wcmlim-map-search-status {
    font-size: 12px;
    color: #d93025;
    min-height: 16px;
    margin-bottom: 6px;
}

/* Map search suggestions (rendered by our own code, in the normal flow under the box) */
.wcmlim-map-suggestions {
    display: none;
    list-style: none;
    margin: -4px 0 8px;
    padding: 4px 0;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.wcmlim-map-suggestion {
    padding: 10px 16px;
    font-size: 14px;
    cursor: pointer;
}

.wcmlim-map-suggestion:hover {
    background: #f1f7fb;
}

/* Google's own suggestion list (legacy Autocomplete) must sit above the address modal
   (z-index 10000); "body" beats wcmlim-public.css, which also sets it with !important. */
body .pac-container {
    z-index: 10001 !important;
}

/* Mandatory "Add Your Location" popup (setting "Show Popup To Enter User Location"):
   no close button until the customer has saved an address. */
.wcmlim-modal-overlay.wcmlim-location-required .wcmlim-modal-close {
    display: none;
}

/* "Use my current location" (form button + button inside the map) */
.wcmlim-use-current-location {
    width: 100%;
    margin-bottom: 6px;
}

.wcmlim-locate-status {
    font-size: 12px;
    color: #d93025;
    min-height: 16px;
    margin-bottom: 6px;
}

.wcmlim-map-locate-btn {
    margin: 0 10px 10px 0;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 2px;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    font-size: 20px;
    line-height: 40px;
    color: #1a73e8;
    cursor: pointer;
}
