/* Modal base styles */
.required{color:red;}

.mafwc-modal {
    display: none; 
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    
}

/* Prevent body scroll when modal is open */
body.mafwc-modal-open {
    overflow: hidden;
}

/* Modal content styles */
#mafwc-modal-content,
#mafwc-view-modal-content {
    background-color: #fefefe;
    /* margin: 2% auto; <- Removed; flex handles centering */
    padding: 20px; /* Increased for better form spacing */
    border: 1px solid #888;
    width: fit-content; /* Flexible width based on form content */
    max-width: 90vw; /* Prevents overflow on small screens */
    min-width: 300px; /* Ensures usability on narrow views; adjust as needed */
    max-height: 80vh; /* Caps height; triggers internal scroll for long forms */
    overflow-y: auto; /* Internal vertical scroll */
    box-sizing: border-box;
    position: relative;
    
    /* Optional enhancements for form-friendly modal */
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

/* Close buttons */
#mafwc-close, #mafwc-view-close {
    color: #000;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

#mafwc-close:hover, #mafwc-close:focus,
#mafwc-view-close:hover, #mafwc-view-close:focus {
    color: #aaa;
    text-decoration: none;
}

/* Address form styles */
#mafwc-address-form .form-row {
    margin-bottom: 1em;
    position: relative;
}

#mafwc-address-form label {
    display: block;
    margin-bottom: 5px;
}

#mafwc-address-form input,
#mafwc-address-form select {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* Ensure Select2 dropdown is contained within modal */
#mafwc-modal .select2-container {
    z-index: 1004 !important;
    position: relative;
}

#mafwc-modal .select2-dropdown {
    z-index: 1004 !important;
    position: absolute;
    top: auto;
    bottom: auto;
    max-height: 200px;
    overflow-y: auto;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* Style for Save and Save and Use buttons */

#mafwc-address-form button[type="submit"],
#mafwc-address-form .mafwc-save-and-use {
    margin-right: 10px;
    padding: 12px 18px;
    font-size: 14px;
    border-radius: 4px;
    cursor: pointer;
    background-color: #0073aa;
    color: #fff;
    border: none;
    transition: background-color 0.2s;
}

#mafwc-address-form button[type="submit"]:hover,
#mafwc-address-form .mafwc-save-and-use:hover {
    background-color: #005177;
}

#mafwc-address-form select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12"><path fill="%23333" d="M6 9L2 5h8z"/></svg>') no-repeat right 10px center;
    background-size: 12px;
}

#mafwc-address-form .form-row label.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: auto;
}

#mafwc-address-form .form-row label.checkbox input.input-checkbox {
    width: auto;
    margin: 0;
}

/* View container */
#mafwc-view-container {
    line-height: 1.6;
}

#mafwc-view-container p {
    margin: 5px 0;
}

#mafwc-view-container strong {
    display: inline-block;
    width: 150px;
}

/* Form sections */
.mafwc-form-section {
    /* Any shared styles, e.g., padding if needed */
}

/* When modal opens, ensure forms are full-width */
#mafwc-modal:visible .mafwc-form-section {
    display: block;  /* But JS handles show/hide */
}



.mafwc-success-message {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #4CAF50;
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    z-index: 1000;
}

#mafwc-view-modal {  /* Or whatever your outer modal wrapper selector is */
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;  /* Horizontal center */
    align-items: center;      /* Vertical center */
    z-index: 9999;            /* Ensures it overlays everything */
    background-color: rgba(0, 0, 0, 0.5);  /* Optional: Semi-transparent backdrop */
}

#mafwc-view-modal-content {
    width: fit-content !important;
    max-width: 90vw;
    min-width: 25vw;
    padding: 20px; 
    box-sizing: border-box; /* Ensures padding doesn't add to width */
    
    /* Optional: Add these for better modal feel */
    background-color: #fff;  /* White background if not already set */
    border-radius: 8px;      /* Rounded corners */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15); /* Subtle shadow */
}

/* Optional: If you want the address details left-aligned inside (common for addresses) */
#mafwc-view-modal-content .mafwc-address-card {
    text-align: left; /* Overrides any parent centering if needed */
}

#mafwc-view-container h3, #mafwc-form-container h3{margin-bottom:20px;}

/* Responsive styles for modals */
@media screen and (max-width: 768px) {
    #mafwc-modal-content, #mafwc-view-modal-content {
        width: 95%;
        /*max-height: 85vh; */
        margin: 5% auto;
    }
}