
/* Modal Overlays & Content */
.fm-modal-overlay {
    display: none;
    position: fixed;
    z-index: 999999999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
  }

  .fm-modal-content {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    min-height: 85vh;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    z-index: 9999999;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .fm-close {
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 1.5rem;
    cursor: pointer;
  }


/* Base modal styles */
.fm-modal {
    display: none;
    position: fixed;
    z-index: 100000000; /* Much higher than WordPress header */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: rgba(0,0,0,0.6);
}


/* Section styling */
.modal-section {
    margin-bottom: 30px;
    background-color: #fff;
    border-radius: 6px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    min-height: 85vh;
}

/* Heading styles */
.modal-section h4 {
    color: #03045e;
    font-size: 1.2em;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #03045e;
}

/* Table styles */
.modal-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    border: 1px solid #ddd;
}

.modal-table thead {
    background-color: #fcb904;
}

.modal-table th {
    color: #03045e;
    padding: 12px;
    text-align: left;
    font-weight: bold;
}

.modal-table td {
    padding: 10px;
    border: 1px solid #ddd;
}

.modal-table tr:nth-child(even) {
    background-color: #f8f9fa;
}

/* Close button */
.fm-close {
    background-color: #fcb904;
    color: #03045e;
    float: right;
    padding: 8px 16px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    margin-bottom: 10px;
    border: none;
    border-radius: 4px;
    text-transform: uppercase;
}

.fm-close:hover,
.fm-close:focus {
    background-color: #e3a704;
    text-decoration: none;
}

/* Loading indicator */
.loading {
    text-align: center;
    padding: 20px;
    color: #03045e;
    font-weight: bold;
}

/* Responsive adjustments */
@media screen and (max-width: 768px) {
    .fm-modal-content {
        width: 95%;
        margin: 10% auto;
        padding: 15px;
    }

    .modal-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    .modal-section {
        padding: 15px;
    }
}

/* Animation */
.fm-modal.show {
    animation: fadeIn 0.3s ease-in-out;
}

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

/* Primary Details Section specific styling */
.modal-section:first-child {
    border-top: 4px solid #03045e;
}

/* Field labels in tables */
.modal-table th[scope="row"] {
    background-color: #fcb904;
    color: #03045e;
    width: 30%;
}

/* Status indicators */
.status-active {
    color: #28a745;
    font-weight: bold;
}

.status-inactive {
    color: #dc3545;
    font-weight: bold;
}

/* Dependent Modal Styles */
.dependent-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 999999999;
}

.dependent-modal-content {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #fefefe;
    width: 90%;
    max-width: 1900px;
    max-height: 85vh;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
}

.dependent-modal-close {
    position: sticky;
    top: 0;
    float: right;
    background-color: #fcb904;
    color: #03045e;
    padding: 8px 16px;
    font-size: 16px;
    font-weight: bold;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-transform: uppercase;
    margin-bottom: 10px;
    z-index: 9999999999;
}

.dependent-modal-close:hover {
    background-color: #e3a704;
}

/* Ensure modal displays properly on mobile */
@media screen and (max-width: 768px) {
    .dependent-modal-content {
        width: 95%;
        max-height: 90vh;
    }
}

/* Adjust modal positioning for mobile */
@media screen and (max-width: 768px) {
    .fm-modal-content {
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        transform: none;
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        min-height: 85vh;
        border-radius: 0;
        display: flex;
        flex-direction: column;
    }

    /* Make close button sticky at top */
    .fm-close {
        position: sticky;
        top: 0;
        background: #fff;
        padding: 10px;
        margin: -20px -20px 10px -20px;
        border-bottom: 1px solid #ddd;
        text-align: right;
        z-index: 1;
    }

    /* Make form content scrollable */
    #myDataEditFormContainer,
    #dependentDetailsFormContainer,
    #householdEditFormContainer,
    #rankModalContent {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 10px 0;
    }
}

/* Enhanced mobile styles */
@media screen and (max-width: 768px) {
    .fm-modal-content {
        /* Position at top of screen instead of center */
        top: 0;
        left: 0;
        right: 0;
        transform: none;
        width: 100%;
        height: auto; /* Remove fixed height */
        max-height: 100%; /* Allow content to determine height */
        border-radius: 0;
        margin: 0;
        display: flex;
        flex-direction: column;
        padding: 0; /* Remove padding, will add it to inner elements */
    }

    /* Sticky header section */
    .fm-modal-header {
        position: sticky;
        top: 0;
        background: #fff;
        padding: 10px 20px;
        border-bottom: 1px solid #ddd;
        z-index: 2;
    }

    /* Close button styling */
    .fm-close {
        position: relative; /* Change from sticky to relative */
        float: right;
        padding: 10px;
        margin: 0;
        background: transparent;
    }

    /* Content area */
    .fm-modal-body {
        flex: 1;
        padding: 20px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Form containers */
    #myDataEditFormContainer,
    #dependentDetailsFormContainer,
    #householdEditFormContainer,
    #rankModalContent {
        padding: 0 20px 20px;
    }

    /* Table adjustments for mobile */
    .modal-table {
        width: 100%;
        margin: 0;
    }

    .modal-table th,
    .modal-table td {
        padding: 8px;
    }
}

/* Additional adjustments for very small screens */
@media screen and (max-width: 480px) {
    .fm-modal-content {
        /* Ensure modal doesn't exceed viewport */
        max-height: calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    }
}

/* Mobile styles */
@media screen and (max-width: 768px) {
    .fm-modal-content {
        position: fixed;
        top: 5vh; /* Start 5% from top */
        left: 0;
        right: 0;
        bottom: 5vh; /* End 5% from bottom */
        transform: none;
        width: 100%;
        height: 90vh; /* Take up 90% of viewport height */
        max-height: 90vh;
        margin: 0;
        border-radius: 0;
        display: flex;
        flex-direction: column;
    }

    .fm-modal-header {
        position: sticky;
        top: 0;
        background: #fff;
        padding: 15px;
        border-bottom: 1px solid #ddd;
        z-index: 2;
    }

    .fm-modal-body {
        flex: 1;
        overflow-y: auto;
        padding: 15px;
        -webkit-overflow-scrolling: touch;
    }

    /* Ensure form containers take full height */
    #myDataEditFormContainer,
    #dependentDetailsFormContainer,
    #householdEditFormContainer,
    #rankModalContent {
        min-height: calc(85vh - 60px); /* Subtract header height */
        padding-bottom: 30px;
    }
}

/* Ensure proper height on iOS devices */
@supports (-webkit-touch-callout: none) {
    .fm-modal-content {
        height: -webkit-fill-available;
        max-height: -webkit-fill-available;
    }
}






