/**
 * Location Selector Component Styles
 * Responsive design for mobile and desktop views
 */

/* ==================== Mobile View ==================== */
.location-selector-mobile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #fff;
    border-bottom: 1px solid #e5e5e5;
    gap: 12px;
}

.location-display {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.location-icon {
    flex-shrink: 0;
    color: #333;
}

.location-text {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 4px;
}

.location-label {
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #515567;
    font-weight: 400;
    line-height: 20px;
}

.location-pincode {
    font-size: 12px;
    color: #666;
}

.location-update-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: transparent;
    border: none;
    color: #0062B8;
    font-size: 14px;
    font-weight: 400;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity 0.2s;
    line-height: 20px;
}

.location-update-btn:hover {
    opacity: 0.8;
}

.location-update-btn:active {
    opacity: 0.6;
}

.update-text {
    font-size: 14px;
    color: #0062B8;
    line-height: 20px;
    font-weight: 400;
}

/* ==================== Desktop View ==================== */
.location-selector-desktop {
    display: none; /* Hidden by default, shown only in header on desktop */
}

/* Show desktop view on larger screens */
@media screen and (min-width: 768px) {
    .location-selector-desktop {
        display: block;
    }
    
    /* Hide mobile view in header on desktop */
    header .location-selector-mobile {
        display: none;
    }
}

@media screen and (min-width: 1200px) {
    .location-selector-mobile{
        display: none !important;
    }
}

.location-display-desktop {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 16px;
    background: #fff;
    border: 1.5px solid #0066cc;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.location-display-desktop:hover {
    background: #f8f9ff;
    border-color: #0052a3;
}

.location-display-desktop:active {
    background: #f0f4ff;
}

.location-text-desktop {
    display: flex;
    align-items: center;
    flex: 1;
}

.location-label-desktop {
    font-size: 14px;
    font-weight: 400;
    color: #333;
    line-height: 24px;
}

.location-display-desktop .location-icon {
    color: #0066cc;
    flex-shrink: 0;
}

.update-location-text {
    font-size: 14px;
    color: #0066cc;
    font-weight: 400;
    margin-left: auto;
    line-height: 24px;
}

.edit-icon {
    flex-shrink: 0;
    margin-left: 4px;
}

.dropdown-icon {
    color: #0066cc;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.location-display-desktop:hover .dropdown-icon {
    transform: rotate(180deg);
}

/* ==================== Modal / Bottom Sheet ==================== */
.location-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 999999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    isolation: isolate;
    transform: translateZ(0);
}

.location-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Mobile Bottom Sheet */
.location-modal {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 16px 16px 0 0;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.location-modal-overlay.active .location-modal {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 4px 16px !important;
    border-bottom: none;
    margin-bottom: 0 !important;
}

.modal-title {
    font-size: 16px !important;
    font-weight: 700 !important;
    color: #20253C !important;
    margin: 0 !important;
    line-height: 24px !important;
}

.modal-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: #666;
    transition: background 0.2s;
    padding: 0;
}

.modal-close-btn:hover {
    background: #f0f0f0;
}

.modal-close-btn:active {
    background: #e0e0e0;
}

.modal-body {
    padding: 0 20px 20px 20px !important;
    position: relative;
}

.pincode-label {
    position: absolute;
    top: 50%;
    left: 48px;
    transform: translateY(-50%);
    font-size: 15px;
    color: #999;
    background: transparent;
    padding: 0;
    font-weight: 400;
    z-index: 1;
    pointer-events: none;
    transition: all 0.2s ease;
}

.pincode-input-wrapper:focus-within .pincode-label,
.pincode-input-wrapper.has-value .pincode-label {
    top: -10px;
    left: 12px;
    transform: translateY(0);
    font-size: 12px;
    color: #0066cc;
    background: #fff;
    padding: 0 4px;
    font-weight: 500;
}

.pincode-input-wrapper.error-state .pincode-label {
    color: #B81800;
}

.required-asterisk {
    color: #d32f2f;
    opacity: 0;
    transition: opacity 0.2s;
}

.pincode-input-wrapper:focus-within .required-asterisk,
.pincode-input-wrapper.has-value .required-asterisk {
    opacity: 1;
}

.modal-description {
    font-size: 12px !important;
        color: #515567 !important;
    margin: 0 0 16px 0;
    line-height: 20px !important;
    font-weight: 400 !important;
}
.modal-description p{
}
.pincode-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    border: 0.4px solid #CDCED3 !important;
    border-radius: 8px;
    padding: 14px;
    background: #fff;
    transition: all 0.2s;
    margin-top: 12px;
}

.pincode-input-wrapper:focus-within {
    border-radius: 8px;
    border: 1px solid #0062B8 !important;
}

.pincode-input-wrapper.success {
    border: 1px solid #0062B8 !important;
}

.pincode-input-wrapper.error-state {
    border: 1px solid #B81800 !important;
}

.search-icon {
    flex-shrink: 0;
     width: 16px;
    height: 16px;
    transition: opacity 0.2s;
}

.pincode-input-wrapper:focus-within .search-icon,
.pincode-input-wrapper.has-value .search-icon {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.pincode-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 14px;
    color: #20253C !important;
    min-width: 0;
    font-weight: 400;
}

.pincode-input::placeholder {
    color: transparent;
}

.pincode-input:focus::placeholder {
    color: transparent;
}

.pincode-input.error {
    color: #d32f2f;
}

.apply-btn {
    padding: 0;
    background: transparent;
    color: #828592;
    border: none;
    font-size: 14px;
    font-weight: 400;
    cursor: pointer;
    transition: opacity 0.2s;
    white-space: nowrap;
}

.apply-btn:hover {
    opacity: 0.8;
}

.apply-btn:active {
    opacity: 0.6;
}

.apply-btn:disabled {
    opacity: 1;
    cursor: not-allowed;
}

.apply-btn.active {
    color: #0062B8;
}

.apply-btn.loading {
    pointer-events: none;
}

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 4px solid #0062B8;
    border-top-color: transparent;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.apply-btn.error-state {
    color: #B81800;
}

.error-message {
    margin-top: 12px;
    font-size: 13px;
    color: #B81800;
    display: none;
}

.error-message.show {
    display: block;
}

/* ==================== Responsive Media Queries ==================== */
@media screen and (min-width: 768px) {
    /* Keep mobile visible on mobile pages (like plp.ftl) */
    /* Desktop header will handle showing/hiding appropriately */
    .location-selector-desktop {
        display: block;
        margin-left: 24px;
    }
    
    /* Mobile bottom sheet becomes centered dialog on larger screens */
    .location-modal {
        position: absolute;
        top: 50%;
        left: 50%;
        right: auto;
        bottom: auto;
        transform: translate(-50%, -50%) scale(0.9);
        border-radius: 12px;
        width: 90%;
        max-width: 480px;
        max-height: 85vh;
        box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
    }

    .location-modal-overlay.active .location-modal {
        transform: translate(-50%, -50%) scale(1);
    }

    .modal-title {
        font-size: 20px;
    }

    .modal-body {
        padding: 24px;
    }

    .modal-description {
        font-size: 14px !important;
        margin-bottom: 24px;
    }

    .pincode-input-wrapper {
        padding: 14px 18px;
    }

    .pincode-input {
        font-size: 16px;
    }

    .apply-btn {
        padding: 10px 24px;
        font-size: 14px;
    }
}

/* ==================== Desktop Large (1024px+) ==================== */
@media screen and (min-width: 1024px) {
    .location-modal {
        max-width: 520px;
    }

    .modal-header {
        padding: 20px 24px;
    }

    .modal-body {
        padding: 28px;
    }
}

/* ==================== Animation Keyframes ==================== */
@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ==================== Accessibility ==================== */
.location-update-btn:focus,
.location-display-desktop:focus,
.modal-close-btn:focus,
.apply-btn:focus,
.modal-close-btn-desktop:focus,
.apply-btn-desktop:focus {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
}

.pincode-input:focus,
.pincode-input-desktop:focus {
    outline: none;
}

/* ==================== Desktop Modal Styles ==================== */

/* Hide search popup when location modal is active */
.location-modal-overlay.active ~ .searchPopupWrapper,
.location-modal-overlay-desktop.active ~ .searchPopupWrapper,
body:has(.location-modal-overlay.active) .searchPopupWrapper,
body:has(.location-modal-overlay-desktop.active) .searchPopupWrapper {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Force search wrapper to lower z-index when location modal is active */
.location-modal-overlay.active ~ header .searchWrapper,
.location-modal-overlay-desktop.active ~ header .searchWrapper,
body:has(.location-modal-overlay.active) header .searchWrapper,
body:has(.location-modal-overlay-desktop.active) header .searchWrapper {
    z-index: 2 !important;
}

.location-modal-overlay-desktop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 4;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    isolation: isolate;
    transform: translateZ(0);
}

.location-modal-overlay-desktop.active {
    opacity: 1;
    visibility: visible;
}

.location-modal-desktop {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    border-radius: 12px;
    width: 90%;
    max-width: 420px;
    max-height: 85vh;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
    background: #fff;
    overflow-y: auto;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.location-modal-overlay-desktop.active .location-modal-desktop {
    transform: translate(-50%, -50%) scale(1);
}

.modal-header-desktop {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 8px 20px;
    border-bottom: none;
}

.modal-title-desktop {
    font-size: 18px;
    font-weight: 600;
    color: #20253C;
    margin: 0;
    line-height: 24px;
}

.modal-close-btn-desktop {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: #666;
    transition: background 0.2s;
    padding: 0;
}

.modal-close-btn-desktop:hover {
    background: #f0f0f0;
}

.modal-close-btn-desktop:active {
    background: #e0e0e0;
}

.modal-body-desktop {
    padding: 0 20px 20px 20px;
    position: relative;
}

.modal-description-desktop {
    font-size: 14px !important;
    color: #515567 !important;
    margin: 0 0 16px 0;
    line-height: 20px !important;
    font-weight: 400 !important;
}

.pincode-input-wrapper-desktop {
    position: relative;
    display: flex;
    align-items: center;
    border: 1px solid #d0d0d0;
    border-radius: 8px;
    padding: 14px 16px;
    background: #fff;
    transition: all 0.2s;
    margin-top: 12px;
}

.pincode-input-wrapper-desktop:focus-within {
    border-radius: 8px;
    border: 1px solid #0062B8 !important;
}

.pincode-input-wrapper-desktop.success {
    border: 1px solid #0062B8 !important;
}

.pincode-input-wrapper-desktop.error-state {
    border: 1px solid #B81800 !important;
}

.search-icon-desktop {
    flex-shrink: 0;
    color: #999;
    width: 20px;
    height: 20px;
    transition: opacity 0.2s;
}

.pincode-input-wrapper-desktop:focus-within .search-icon-desktop,
.pincode-input-wrapper-desktop.has-value .search-icon-desktop {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.pincode-label-desktop-input {
    position: absolute;
    top: 50%;
    left: 48px;
    transform: translateY(-50%);
    font-size: 15px;
    color: #999;
    background: transparent;
    padding: 0;
    font-weight: 400;
    z-index: 1;
    pointer-events: none;
    transition: all 0.2s ease;
}

.pincode-input-wrapper-desktop:focus-within .pincode-label-desktop-input,
.pincode-input-wrapper-desktop.has-value .pincode-label-desktop-input {
    top: -10px;
    left: 12px;
    transform: translateY(0);
    font-size: 12px;
    color: #0066cc;
    background: #fff;
    padding: 0 4px;
    font-weight: 500;
}

.pincode-input-wrapper-desktop.error-state .pincode-label-desktop-input {
    color: #B81800;
}

.pincode-input-wrapper-desktop:focus-within .required-asterisk,
.pincode-input-wrapper-desktop.has-value .required-asterisk {
    opacity: 1;
}

.pincode-input-desktop {
    flex: 1;
    border: none;
    outline: none;
    font-size: 16px;
    color: #000;
    background: transparent;
    min-width: 0;
    font-weight: 400;
}

.pincode-input-desktop::placeholder {
    color: transparent;
}

.pincode-input-desktop:focus::placeholder {
    color: transparent;
}

.pincode-input-desktop.error {
    color: #d32f2f;
}

.apply-btn-desktop {
    padding: 0;
    background: transparent;
    color: #828592;
    border: none;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s;
    white-space: nowrap;
}

.apply-btn-desktop:hover {
    opacity: 0.8;
}

.apply-btn-desktop:active {
    opacity: 0.6;
}

.apply-btn-desktop:disabled {
    opacity: 1;
    cursor: not-allowed;
}

.apply-btn-desktop.active {
    color: #0062B8;
}

.apply-btn-desktop.loading {
    pointer-events: none;
}

.apply-btn-desktop.error-state {
    color: #B81800;
}

.error-message-desktop {
    margin-top: 12px;
    font-size: 13px;
    color: #B81800;
    display: none;
}

.error-message-desktop.show {
    display: block;
}

/* ==================== Non-Serviceable Tooltip ==================== */
/* Hide tooltip on desktop, show only on mobile */
@media (min-width: 769px) {
    #non-serviceable-tooltip {
        display: none !important;
    }
}

/* ==================== Cart Iframe Active State ==================== */
body.cart-iframe-active .location-selector-mobile,
body.cart-iframe-active .location-selector-desktop {
    display: none !important;
}

/* ==================== Print Styles ==================== */
@media print {
    .location-modal-overlay,
    .location-modal-overlay-desktop,
    .location-update-btn {
        display: none !important;
    }
}
