/* Styles for the Members App */
#members-app {
    font-family: 'DM Sans', sans-serif;
    color: #555555;
    line-height: 1.5;
    background-color: transparent; /* Inherit global background or set explicitly */
    margin: 0;
    padding: 20px;
    width: 100%;
    box-sizing: border-box;
}

/* Reset global paragraph constraints from main style.css */
#members-app p {
    width: 100%;
    max-width: none;
    margin: 0;
}

#members-app .container {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
}

#members-app h1 {
    font-family: 'DM Sans', sans-serif;
    font-size: 32px;
    font-weight: 700;
    color: #333333;
    margin: 40px 8px 24px;
    text-align: center;
}
#members-app h1:first-of-type { margin-top: 0; }

#members-app .members-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 30px;
    margin-top: 30px;
}

#members-app .current-members-grid {
    grid-template-columns: repeat(2, 1fr);
}

#members-app .member-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 25px;
    text-align: left;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    display: block; /* Remove flex to allow text wrapping around floated elements */
    overflow: hidden; /* Clearfix for floated photo */
}

.admin-container {
    max-width: 1000px;
    margin: 20px auto;
    padding: 20px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.admin-header h1 {
    margin: 0;
    text-align: left; /* Override global center */
    font-family: 'DM Sans', sans-serif; /* Use main site font */
    font-size: 32px; /* Use main site h1 size */
    font-weight: 700;
    color: #333333; /* Use main site h1 color */
}
.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}
.admin-table th, .admin-table td {
    border: 1px solid #e5e7eb;
    padding: 10px;
    text-align: left;
    vertical-align: top;
}
.admin-table th {
    background-color: #f8fafc;
    font-weight: 600;
    color: #333;
}
.admin-table td input[type="text"],
.admin-table td input[type="number"],
.admin-table td input[type="email"],
.admin-table td select,
.admin-table td textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; /* Consistent font */
    font-size: 0.9rem;
}
.admin-table td textarea {
    min-height: 60px;
    resize: vertical;
}
.admin-table .member-photo-col {
    width: 100px;
    text-align: center;
}
.admin-table .member-photo {
    width: 80px;
    height: 100px; /* 4:5 aspect ratio */
    object-fit: cover;
    border-radius: 4px;
    display: block;
    margin: 0 auto 5px;
    background-color: #f0f0f0; /* Placeholder background */
}
.admin-table .actions-col {
    width: 180px;
    text-align: center;
}
.admin-table .action-buttons {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.admin-table .action-buttons button,
.admin-table .action-buttons label {
    padding: 8px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s;
    text-align: center;
    display: block;
    width: 100%;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; /* Consistent font */
}
.admin-table .action-buttons .btn-save {
    background-color: #10b981; /* Accent green */
    color: white;
}
.admin-table .action-buttons .btn-save:hover {
    background-color: #059669;
}
.admin-table .action-buttons .btn-update-photo {
    background-color: #0055b3; /* Primary blue */
    color: white;
}
.admin-table .action-buttons .btn-update-photo:hover {
    background-color: #004494;
}
.admin-table .action-buttons .btn-remove {
    background-color: #ef4444; /* Red */
    color: white;
}
.admin-table .action-buttons .btn-remove:hover {
    background-color: #dc2626;
}
.add-member-btn {
    background-color: #0055b3;
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.2s;
    margin-bottom: 15px;
    font-family: 'DM Sans', sans-serif; /* Consistent font */
}
.add-member-btn:hover {
    background-color: #004494;
}
.drag-handle {
    cursor: grab;
    padding: 5px;
    margin-right: 5px;
    background-color: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 3px;
    display: inline-block;
}
.sortable-ghost {
    opacity: 0.4;
    background-color: #fcfcfc;
}
.member-row.new-member-row {
    background-color: #e6ffed; /* Light green for new rows */
}
.member-row.new-member-row input, .member-row.new-member-row select, .member-row.new-member-row textarea {
    border-color: #34d399;
}
.file-input-wrapper {
    position: relative;
    overflow: hidden;
    display: inline-block;
    width: 100%;
}
.file-input-wrapper input[type=file] {
    font-size: 100px;
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0;
    cursor: pointer;
}
/* Default profile image */
.member-photo[src$="default_profile.png"] {
    background-color: #e0e0e0; /* Light grey background for default image */
    border: 1px solid #ccc;
}

/* New styles for field wrappers and save feedback */
.field-wrapper {
    position: relative; /* Crucial for positioning the feedback span */
    margin-bottom: 4px; /* Reduced space */
    flex: 1;
    min-width: 120px;
}

.field-wrapper label {
    display: none; /* Hide labels to save space; using placeholders instead */
}

.field-wrapper input,
.field-wrapper select,
.field-wrapper textarea {
    width: 100%;
    padding: 6px 8px;
    font-size: 0.85rem;
    background-color: #fcfcfc;
}

.field-group {
    display: flex;
    gap: 8px;
    margin-bottom: 4px;
}

.field-group .field-wrapper {
    margin-bottom: 0;
}

.save-feedback {
    padding: 2px 8px; /* Add padding to the badge */
}

/* Cropping Modal Styles */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1000; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgba(0,0,0,0.7); /* Black w/ opacity */
    /* Ensure modal is a flex container and centers its content */
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: #fefefe;
    margin: 2% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 90%; /* Could be more responsive */
    max-width: 700px; /* Max width for larger screens */
    border-radius: 8px;
    z-index: 1001; /* Ensure it's above the modal background */
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    position: relative;
    max-height: 95vh;
    overflow-y: auto;
}

.modal-content h2 {
    text-align: center;
    margin-top: 0;
    color: #333;
    font-size: 1.5rem;
}

.modal .close-button {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    right: 15px;
    top: 10px;
}

.modal .close-button:hover,
.modal .close-button:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

.modal .img-container {
    width: 100%;
    max-height: 500px; /* Limit height for cropping area */
    overflow: hidden;
    min-height: 300px; /* Ensure it has a minimum height for cropper to render */
    margin-bottom: 20px;
    background-color: #f0f0f0;
    display: flex; /* Use flex to center image if it's smaller */
    justify-content: center;
    align-items: center;
}

/* Style the Croppie zoomer to ensure it's visible and not overlapped */
.cr-slider-wrap {
    margin: 20px auto !important;
    z-index: 10;
}

.modal .img-container img {
    max-width: 100%; /* Ensure image fits container */
    display: block; /* Ensure image is a block element */
    height: auto; /* Maintain aspect ratio */
}

.modal-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.file-input-wrapper input[type=file] {
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0; /* Ensure it's hidden */
    font-size: 100px; /* Large hit area for click */
    cursor: pointer;
}

/* Ensure Cropper.js elements are visible */
.cropper-view-box,
.cropper-face,
.cropper-line,
.cropper-point {
    opacity: 1 !important;
    z-index: 9999 !important; /* Ensure it's above other modal content */
}
/* Ensure the image itself is visible within the cropper */
.cropper-canvas,
.cropper-crop-box,
.cropper-wrap-box {
    box-sizing: border-box !important;
}


/* Profile photo container and image */
#members-app .member-photo-container {
    width: 160px;
    height: 200px; /* Explicit height for float wrapping */
    float: left; /* Allow text to wrap around the photo */
    margin: 0 25px 10px 0;
    padding-bottom: 0;
    position: static;
    overflow: hidden;
    border-radius: 8px; /* Slightly rounded corners for the photo */
    background-color: #e0e0e0; /* Placeholder background */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 700;
    color: #666; /* Color for initials placeholder */
}
#members-app .member-photo-container img {
    position: static;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#members-app .member-self-intro {
    font-size: 0.95rem;
    color: #4b5563;
    margin-top: 10px;
    line-height: 1.6;
    text-align: left;
    max-width: none; /* Override global paragraph constraints */
}

#members-app .member-name-prominent {
    font-size: 1.8rem; /* Larger font size for name */
    font-weight: 700;
    margin-top: 0;
    margin-bottom: 2px;
    color: #1e293b;
    text-align: left;
}

#members-app .member-title {
    font-size: 1rem;
    color: #64748b;
    margin-bottom: 10px;
    text-align: left;
    max-width: none;
}

#members-app .member-divider {
    width: 50px;
    height: 2px;
    background-color: #e5e7eb;
    margin: 15px 0;
}

#members-app .member-birthday-info,
#members-app .member-animals-info,
#members-app .alumni-affiliation {
    font-size: 0.85rem;
    color: #4b5563;
    margin-bottom: 5px;
}

/* Login Modal Overlay Styles */
#members-app .login-modal {
    display: none; /* Hidden by default, shown via JS as flex */
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    justify-content: center;
    align-items: center;
}

#members-app .login-modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    position: relative;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

#members-app .close-login {
    position: absolute;
    right: 15px;
    top: 10px;
    font-size: 24px;
    cursor: pointer;
    color: #999;
}

#members-app .login-modal h3 {
    margin-top: 0;
    color: #333;
}

#members-app .login-modal input {
    width: 100%;
    padding: 12px;
    margin: 15px 0;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-sizing: border-box;
    font-size: 16px;
    text-align: center;
}

#members-app .login-btn {
    background: #0055b3;
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 6px;
    cursor: pointer;
    width: 100%;
    font-weight: 700;
}

#members-app .login-error {
    color: #ef4444;
    font-size: 14px;
    margin-top: 10px;
}

#members-app .clickable-photo {
    cursor: pointer;
    transition: transform 0.2s;
}

#members-app .clickable-photo:hover {
    transform: scale(1.02);
}

/* Mobile Responsive Adjustments */
@media (max-width: 768px) {
    #members-app {
        padding: 8px; /* Minimum margin on screen edges */
    }
    #members-app .members-grid,
    #members-app .current-members-grid {
        grid-template-columns: 1fr; /* 1 card per row on mobile */
        gap: 20px;
    }
    #members-app .member-card {
        padding: 20px 20px; /* Reduced side padding to 12px for more text width */
    }
    #members-app .member-photo-container {
        margin-right: 15px; /* Reduced gap between photo and text on mobile */
        width: 140px; /* Slightly smaller photo to give text more breathing room */
    }
}