/*
 * WP Family Tree - Modal Styles
 * (Overlays, Comments Modal, Freeform Bio Modal, Image Enlarge Modal)
 */

/* --- Modal Overlays --- */
.wpft-modal-overlay {
    display: none;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    cursor: pointer;
    z-index: 10007; /* Base z-index for overlays */
}
/* Specific overlays for different modals - ensure they are above their content but below higher modals */
div[id^="wpft-search-modal-overlay-"] { z-index: 10014 !important; } /* For search popups */
div[id^="wpft-general-modal-overlay-"] { z-index: 10014 !important; } /* For purchasable panel */
div[id^="wpft-comments-modal-overlay-"] { z-index: 10018 !important; } /* For comments modal */
div[id^="wpft-freeform-bio-overlay-"] { z-index: 10018 !important; } /* For freeform bio modal */

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

/* --- Comments Modal Styles --- */
.wpft-comments-modal {
    display: none;
    position: fixed;
    width: 90%;
    max-width: 700px;
    max-height: 85vh;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    z-index: 10020; /* Highest for modals */
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.wpft-modal-header { padding: 15px 20px; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
.wpft-modal-header h3 { margin: 0; font-size: 1.2em; color: #333; }
.wpft-modal-close { background: none; border: none; font-size: 1.8em; line-height: 1; color: #888; cursor: pointer; padding: 0 5px; font-weight: bold; }
.wpft-modal-close:hover { color: #333; }
.wpft-modal-body { padding: 20px; overflow-y: auto; flex-grow: 1; -webkit-overflow-scrolling: touch; }
#wpft-comments-modal-body { background-color: #f9f9f9; }
#wpft-comments-form-placeholder { padding: 15px; background-color: #fff; border: 1px solid #eee; border-radius: 4px; margin-bottom: 20px; }
#wpft-modal-respond .comment-form-comment label { font-size: 1em; color: #444; }
#wpft-modal-comment { border: 1px solid #ddd !important; box-shadow: inset 0 1px 2px rgba(0,0,0,.07); }
#wpft-modal-comment-message { padding: 8px; border-radius: 3px; text-align: center; }
#wpft-modal-comment-message.error { background-color: #f2dede; color: #a94442; border: 1px solid #ebccd1; }
#wpft-modal-comment-message.success { background-color: #dff0d8; color: #3c763d; border: 1px solid #d6e9c6; }
.wpft-comments-history-title { border-bottom: 1px solid #eee; padding-bottom: 8px; }
#wpft-comments-history-placeholder { padding: 15px; background-color: #fff; border: 1px solid #eee; border-radius: 4px; }
#wpft-comments-history-placeholder .commentlist { list-style: none; padding: 0; margin: 0; }
#wpft-comments-history-placeholder .commentlist li.comment { padding: 10px 0; border-bottom: 1px dotted #eee; }
#wpft-comments-history-placeholder .commentlist li.comment:last-child { border-bottom: none; }
#wpft-comments-history-placeholder .commentlist .comt-avatar { float: left; margin-right: 10px; }
#wpft-comments-history-placeholder .commentlist .comt-avatar img { border-radius: 50%; max-width: 40px; height: auto; }
#wpft-comments-history-placeholder .commentlist .comt-main { overflow: hidden; }
#wpft-comments-history-placeholder .commentlist .comt-meta { font-size: 0.85em; color: #888; margin-top: 5px; }
#wpft-comments-history-placeholder .commentlist .comt-author { font-weight: bold; color: #555; margin-right: 5px; }
#wpft-comments-history-placeholder .commentlist .comment-reply-link { margin-left: 10px; font-size: 0.9em; }

/* --- Freeform Biography Modal Styles --- */
.wpft-freeform-bio-modal {
    display: none;
    position: fixed !important;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    z-index: 10019 !important;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.wpft-freeform-bio-modal .wpft-modal-header { /* Uses .wpft-modal-header */ }
.wpft-freeform-bio-modal .wpft-modal-header h3 { /* Uses .wpft-modal-header h3 */ }
.wpft-freeform-bio-modal .wpft-modal-close { /* Uses .wpft-modal-close */ }
.wpft-freeform-bio-modal .wpft-modal-body { /* Uses .wpft-modal-body */ }
.wpft-ff-bio-content .wpft-ff-bio-photos {
    text-align: center;
    margin-bottom: 15px;
}
.wpft-ff-bio-content .wpft-ff-bio-avatar {
    max-width: 120px;
    max-height: 120px;
    border-radius: 50%;
    margin-bottom: 10px;
    display: block;
    margin-left: auto;
    margin-right: auto;
    border: 2px solid #eee;
}
.wpft-ff-bio-content .wpft-ff-bio-life-photos-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-bottom: 15px;
}
.wpft-ff-bio-content .wpft-ff-bio-life-photos-gallery img {
    max-width: 80px;
    max-height: 80px;
    object-fit: cover;
    border: 1px solid #ddd;
    border-radius: 4px;
}
.wpft-ff-bio-content .wpft-ff-bio-name {
    text-align: center;
    margin-bottom: 5px;
    font-size: 1.3em;
    font-weight: bold;
}
.wpft-ff-bio-content .wpft-ff-bio-dates {
    text-align: center;
    font-size: 0.9em;
    color: #666;
    margin-bottom: 15px;
}
.wpft-ff-bio-content .wpft-ff-bio-text {
    line-height: 1.6;
    text-align: justify;
    font-size: 0.95em;
    color: #444;
}
/* Freeform Biography Modal EDIT FORM Styles */
.wpft-ff-bio-edit-form .wpft-form-group { /* Uses .wpft-form-group from style-core.css */
    margin-bottom: 15px;
}
.wpft-ff-bio-edit-form .wpft-form-group label { /* Uses .wpft-form-group label */
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    font-size: 0.9em;
}
.wpft-ff-bio-edit-form input[type="file"] { /* Uses .wpft-form-group input */
    padding: 5px;
    border: 1px solid #ccc;
    border-radius: 3px;
}
.wpft-current-life-photos-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px;
    border: 1px solid #eee;
    background-color: #f9f9f9;
    margin-bottom: 10px;
    min-height: 50px;
}
.wpft-current-photo-item {
    position: relative;
    border: 1px solid #ddd;
    padding: 2px;
    background-color: white;
}
.wpft-current-photo-item img {
    display: block;
    width: 70px;
    height: 70px;
    object-fit: cover;
}
.wpft-delete-current-photo {
    position: absolute;
    top: -5px;
    right: -5px;
    background: red;
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    line-height: 18px;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 0 5px rgba(0,0,0,0.3);
}
.wpft-delete-current-photo:hover {
    background: darkred;
}
#wpft_edit_ff_life_photos_new_preview img {
    width: 70px;
    height: 70px;
    object-fit: cover;
    border: 1px solid #ddd;
    margin: 3px;
}
.wpft-ff-bio-edit-form .wpft-form-group input[type="text"],
.wpft-ff-bio-edit-form .wpft-form-group input[type="date"],
.wpft-ff-bio-edit-form .wpft-form-group textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 3px;
    box-sizing: border-box;
}

/* --- Image Enlarge Modal Styles --- */
#wpft-image-enlarge-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.85);
    z-index: 10025;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    cursor: zoom-out;
    padding: 20px;
    box-sizing: border-box;
}
#wpft-enlarged-image {
    max-width: 90%;
    max-height: 80%;
    object-fit: contain;
    border-radius: 5px;
    box-shadow: 0 0 30px rgba(0,0,0,0.6);
    display: block;
}
#wpft-close-enlarge-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2.5em;
    color: white;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 5px;
    line-height: 1;
    text-shadow: 0 0 5px black;
}
#wpft-image-enlarge-caption {
    color: white;
    margin-top: 15px;
    font-size: 1em;
    text-align: center;
    max-width: 80%;
}

/* --- New Dynamic Menu Styles --- */
.popup-menu {
    position: fixed;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    width: 280px;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: opacity 0.25s ease-out, transform 0.25s ease-out;
    z-index: 10017;
    visibility: hidden;
}
.popup-menu[aria-hidden="false"] { opacity: 1; transform: translateY(0) scale(1); visibility: visible; }
.menu-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid #eee; }
.menu-header h3 { margin: 0; font-size: 1.1em; color: #333; }
.close-btn { background: none; border: none; padding: 8px; cursor: pointer; color: #888; font-size: 1.2em; line-height: 1; }
.close-btn:hover { color: #333; }
.menu-list { list-style: none; margin: 0; padding: 8px; max-height: 60vh; overflow-y: auto; }
.menu-list li { position: relative; }
.menu-list a { display: block; padding: 10px 15px; color: #333; text-decoration: none; transition: background-color 0.2s ease, color 0.2s ease; border-radius: 6px; font-size: 0.95em; white-space: nowrap; }
.menu-list a:hover { background-color: #f0f5fa; color: #0056b3; }
.menu-list a[aria-current="page"] { background-color: #e7f3ff; color: #0056b3; font-weight: 500; }

/* Responsive adjustments for modals */
@media screen and (max-width: 768px) {
    .wpft-comments-modal, .wpft-freeform-bio-modal { width: 95%; max-width: none; left: 2.5% !important; right: 2.5% !important; top: 5% !important; max-height: 90vh; transform: none !important; }
    .wpft-freeform-bio-modal .wpft-modal-body { padding: 15px; }
    .wpft-ff-bio-content .wpft-ff-bio-avatar { max-width: 100px; max-height: 100px; }
    .wpft-ff-bio-content .wpft-ff-bio-life-photos-gallery img { max-width: 70px; max-height: 70px; }
    .popup-menu { width: calc(100% - 40px); } /* Make dynamic menu wider on small screens */
    .menu-list a { padding: 8px 12px; font-size: 0.9em; }
}
@media screen and (max-width: 480px) {
    .popup-menu { width: calc(100% - 20px); }
}