/* ============================================
   Family Page Styles
   ============================================ */

.family-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.family-header h1 {
    margin-bottom: 0;
}

/* --- Family members grid --- */
.family-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.family-member {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 24px;
    position: relative;
    transition: box-shadow 0.2s;
}
.family-member:hover {
    box-shadow: var(--shadow-lg);
}

.family-member-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 12px;
}
.family-member-info {
    display: flex;
    align-items: center;
    gap: 12px;
}
.family-member-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: #fff;
    font-weight: 700;
    flex-shrink: 0;
}
.avatar-father { background: var(--tl-blue); }
.avatar-mother { background: #7B1FA2; }
.avatar-grandfather { background: var(--brown); }
.avatar-grandmother { background: #7B1FA2; }
.avatar-grandparent { background: var(--brown); }
.avatar-otherMale { background: var(--clay); }
.avatar-otherFemale { background: #7B1FA2; }
.avatar-trailman { background: #2D5E2A; }

.family-member-name {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--brown-dark);
}
.family-member-role {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--gray-500);
}
.family-self-badge {
    display: inline-block;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 1px 7px;
    border-radius: 10px;
    background: var(--tl-blue);
    color: #fff;
    vertical-align: middle;
    margin-left: 6px;
}

.family-member-actions {
    display: flex;
    gap: 4px;
}
.family-member-actions .btn-icon {
    background: none;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    opacity: 0.4;
    /* Buttons don't inherit text color — without this the ✎/🗑 glyphs render
       UA-default black, which disappears on the dark-mode card background. */
    color: inherit;
    transition: opacity 0.2s, background 0.2s;
}
.family-member-actions .btn-icon:hover {
    opacity: 1;
    background: var(--gray-100);
}
.family-member-actions .btn-delete:hover {
    color: var(--crimson);
}

.family-member-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-left: 56px;
}
.family-member-detail {
    font-size: 0.8rem;
    color: var(--gray-500);
}
/* A boy who isn't 5 yet — say when he can join instead of letting the family
   wonder why his dues and registration are greyed out. */
.family-member-pending {
    color: #876237;
    font-weight: 600;
}

/* Hint under the Birthday field: the 5-year-old minimum, or the specific
   "he turns 5 on <date>" message once a too-young date is entered. */
.field-hint {
    font-size: 0.78rem;
    line-height: 1.5;
    color: var(--gray-500);
    margin: 6px 0 0;
}
.field-hint.is-error {
    color: #BA272C;
    font-weight: 600;
}

/* --- Dues block (per-trailman pay status) --- */
.family-dues-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    margin: 10px 0 0 56px;
    border-radius: 8px;
    font-size: 0.9rem;
    flex-wrap: wrap;
}
.family-dues-paid {
    background: #DBEDD9;
    color: #2D5E2A;
    font-weight: 600;
}
.family-dues-paid .family-dues-icon {
    font-weight: 700;
    margin-right: 6px;
}
.family-dues-unpaid {
    background: #FFF1D6;
    color: #876237;
}
.family-dues-processing {
    background: #DDE9F4;
    color: #004B87;
}
.family-dues-pending {
    background: var(--gray-100);
    color: var(--gray-500);
    font-style: italic;
}
.family-dues-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px;
}
.family-dues-amount {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--brown-dark);
    font-family: var(--font-heading);
}
.family-dues-year {
    font-size: 0.85rem;
    color: var(--gray-700);
}
.family-dues-pay {
    font-size: 0.85rem;
    padding: 8px 16px;
    flex-shrink: 0;
}
.family-dues-discount-line {
    width: 100%;
    margin-top: 4px;
    font-size: 0.78rem;
    color: #5A2B7A;
    background: #F3E5F5;
    padding: 4px 10px;
    border-radius: 4px;
}
.family-dues-discount-line strong { font-weight: 700; }
.family-dues-scholarship-note {
    margin: 6px 0 0 56px;
    padding: 0 14px;
    font-size: 0.82rem;
    color: var(--gray-700);
    font-style: italic;
}
.family-dues-scholarship-note a {
    color: var(--brand-green, #2D5E2A);
    text-decoration: underline;
}
@media (max-width: 600px) {
    .family-dues-scholarship-note {
        margin-left: 0;
    }
}
.dues-success-banner {
    background: #DBEDD9;
    color: #2D5E2A;
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 18px;
    font-size: 0.95rem;
}
@media (max-width: 600px) {
    .family-dues-row {
        margin-left: 0;
    }
}

/* Dark mode — the dues status boxes use hardcoded light pastels above, and the
   text inside them uses theme vars that flip light in dark mode. Darken the
   boxes so the flipped text stays readable. */
[data-theme="dark"] .family-dues-paid {
    background: #1E2F1C;
    color: #9CCB96;
}
[data-theme="dark"] .family-dues-unpaid {
    background: #33290F;
    color: #D8B778;
}
[data-theme="dark"] .family-dues-processing {
    background: #16293A;
    color: #7FB7E8;
}
[data-theme="dark"] .family-dues-discount-line {
    background: #2A1F33;
    color: #C9A3E0;
}
[data-theme="dark"] .dues-success-banner {
    background: #1E2F1C;
    color: #9CCB96;
}

/* --- Modal (reuse events modal pattern) --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
}
.modal-content {
    position: relative;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 32px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}
.modal-header h2 {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--brown-dark);
}
.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--gray-500);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.modal-close:hover {
    color: var(--gray-900);
}

/* --- Form --- */
.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gray-700);
    margin-bottom: 6px;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--gray-900);
    background: var(--white);
    transition: border-color 0.2s;
}
.form-group textarea {
    resize: vertical;
    min-height: 72px;
    line-height: 1.4;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--tl-blue);
}

.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 8px;
}

.btn {
    display: inline-block;
    font-family: var(--font-heading);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    padding: 10px 20px;
    font-size: 0.9rem;
}
.btn:active { transform: scale(0.98); }
.btn-primary { color: #fff; background: var(--crimson); }
.btn-primary:hover { background: var(--crimson-dark); }
.btn-primary:disabled { background: var(--gray-500); cursor: not-allowed; }
.btn-secondary { color: var(--gray-700); background: var(--gray-100); }
.btn-secondary:hover { background: var(--gray-200); }

.btn-add {
    padding: 10px 20px;
    font-size: 0.9rem;
    white-space: nowrap;
}

/* --- Messages --- */
.member-message {
    margin-top: 12px;
    font-size: 0.85rem;
    border-radius: var(--radius);
}
.member-message:empty { display: none; }
.member-message.error {
    display: block;
    padding: 10px 14px;
    background: #fdf0f0;
    color: var(--crimson);
    border: 1px solid rgba(186,39,44,0.15);
}
.member-message.success {
    display: block;
    padding: 10px 14px;
    background: #f0fdf4;
    color: #2D5E2A;
    border: 1px solid rgba(45,94,42,0.15);
}

.family-empty,
.family-loading {
    font-size: 0.9rem;
    color: var(--gray-500);
    text-align: center;
    padding: 48px 0;
    grid-column: 1 / -1;
}

/* --- Responsive --- */
@media (max-width: 600px) {
    .family-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .form-row-2 {
        grid-template-columns: 1fr;
    }
    .family-member-details {
        padding-left: 0;
    }
}


/* === Dark mode (audit #85, added 2026-08-05) ============================== */
[data-theme="dark"] .scholarship-note a { color: #81C784; }
