/**
 * Members Chamber – minimal overrides only.
 * All layout, typography, buttons, cards, and footer use main site styles (../css/style.css).
 */

/* Clear fixed header (this page has no hero) */
main {
    padding-top: 80px;
}

/* Auth loading state: show until guard.js verifies user (members.html only) – visible on light background */
#members-main .auth-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 50vh;
    font-size: 1.1rem;
    color: var(--text-primary);
}

#members-main .auth-loading.auth-loading-hidden {
    display: none !important;
}

/* Hide members content until auth verified; guard.js removes this class */
#members-main .members-content-body.members-content-hidden {
    visibility: hidden;
    pointer-events: none;
}

#members-main .members-content-body:not(.members-content-hidden) {
    visibility: visible;
    pointer-events: auto;
}

/* Basic content protection: right-click disabled via JS; discourage selection in members area only */
#members-content-body {
    -webkit-user-select: none;
    user-select: none;
}

/* Upcoming Meetings: ensure event cards are always visible (override .fade-in from main site) */
#membersEventsGrid.events-grid,
#membersEventsGrid.events-grid .event-card {
    opacity: 1;
    transform: none;
}

/* Confidential note: muted, centered, readable line length */
.chamber-confidential-note {
    font-size: 0.95rem;
    color: var(--text-secondary-on-blue);
    max-width: 65ch;
    margin: 0 auto;
    line-height: 1.6;
}

/* Login page: center form within container */
.login-form-wrap {
    max-width: 28rem;
    margin: 0 auto;
}

.login-form-wrap .login-submit {
    width: 100%;
}

.login-back {
    margin-top: 1.5rem;
    text-align: center;
}

.login-back a {
    color: var(--primary-red);
    font-weight: 500;
}

.login-back a:hover {
    color: var(--red-alt);
}

/* Error message area (same pattern as .form-success, error state) */
.form-error {
    padding: 1rem;
    background: var(--primary-red);
    color: var(--white);
    border-radius: 4px;
    margin-bottom: 1rem;
    text-align: center;
    font-size: 0.95rem;
}

.form-error:empty {
    display: none;
}

/* Long message (e.g. file:// instructions) – wrap and keep readable */
.form-error.form-error-file-protocol {
    white-space: normal;
    text-align: left;
}

/* Auth in header (login page or fallback): email + logout */
.header-auth {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-right: 0.5rem;
}

.header-auth .auth-email {
    font-size: 0.9rem;
    color: var(--text-primary);
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-auth .auth-logout {
    padding: 0.4rem 0.75rem;
    font-size: 0.875rem;
}

/* Members intro: section is positioning context for auth (align with header right edge) */
.members-intro-section {
    position: relative;
    padding-bottom: clamp(1rem, 3vw, 1.5rem);
}

/* Auth block: top right of section, aligned with primary menu right edge */
.members-welcome-auth {
    position: absolute;
    top: clamp(3rem, 10vw, 80px);
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.75rem;
}

/* Welcome title + decoration: full width, properly centered */
.members-welcome-head {
    margin-bottom: 4rem;
}

.members-welcome-head .section-header {
    width: 100%;
    text-align: center;
    margin-bottom: 0;
}

.members-welcome-head .section-header .section-label,
.members-welcome-head .section-header .section-title {
    display: block;
    text-align: center;
}

.members-welcome-head .title-decoration {
    justify-content: center;
}

.members-welcome-auth .auth-email {
    font-size: 0.95rem;
    color: var(--text-on-blue);
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.members-welcome-auth .auth-logout {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    border-color: var(--white);
    color: var(--white);
    background: transparent;
}

.members-welcome-auth .auth-logout:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--white);
    color: var(--white);
}

/* Center intro text and Quick access button below the welcome head */
#members-content-body .intro-section .intro-content {
    display: block;
    text-align: center;
}

#members-content-body .intro-section .intro-content .intro-text {
    max-width: 65ch;
    margin-left: auto;
    margin-right: auto;
}

#members-content-body .intro-section .intro-content .intro-text .btn {
    margin-top: 0.5rem;
}

/* Profile section starts immediately after hero subtext (no Quick access button) */
.members-profile-follows-hero {
    padding-top: clamp(0.75rem, 2vw, 1.25rem);
}

@media (max-width: 768px) {
    .members-intro-section {
        display: flex;
        flex-direction: column;
    }
    .members-intro-section .container {
        order: 1;
    }
    .members-welcome-auth {
        position: static;
        order: 2;
        margin-top: 1.5rem;
        align-items: center;
    }
}

/* ============================================
   Profile section (Firestore) – modern card UI
   ============================================ */

.profile-loading {
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary-on-blue);
    font-size: 1.05rem;
}

.profile-error {
    padding: 1rem 1.5rem;
    background: var(--primary-red);
    color: var(--white);
    border-radius: 8px;
    margin-bottom: 1rem;
    text-align: center;
    font-size: 0.95rem;
    box-shadow: var(--shadow-sm);
}

/* Main profile card: white on blue section, red accent */
.profile-card {
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    position: relative;
}

.profile-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    background: var(--primary-red);
    z-index: 1;
}

/* Card header: name + craft title – flexbox so title and name are centered */
.profile-card-header {
    padding: 2rem 2rem 1.5rem;
    text-align: center;
    border-bottom: 1px solid var(--gray-medium);
    background: linear-gradient(180deg, rgba(245, 245, 245, 0.6) 0%, var(--white) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.profile-card-header .profile-card-badge,
.profile-card-header .profile-card-name,
.profile-card-header .profile-card-name-decoration {
    align-self: center;
}

.profile-card-badge {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--primary-red);
    margin-bottom: 0.35rem;
    text-align: center !important;
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Ensure title line is centered above name (override any inherited alignment) */
#profile-titles.profile-card-badge {
    text-align: center !important;
}

.profile-card-name {
    font-family: 'Playfair Display', serif;
    font-size: clamp(1.75rem, 4vw, 2.25rem);
    font-weight: 600;
    color: var(--blue);
    margin: 0;
    line-height: 1.2;
}

.profile-card-name-decoration {
    margin-top: 1rem;
    width: 48px;
    height: 3px;
    background: var(--primary-red);
    margin-left: auto;
    margin-right: auto;
    border-radius: 2px;
}

/* Card body: grouped sections */
.profile-card-body {
    padding: 1.5rem 2rem 2rem;
}

.profile-group {
    margin-bottom: 1.75rem;
}

.profile-group:last-child {
    margin-bottom: 0;
}

.profile-group-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--primary-red);
    margin-bottom: 0.75rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--gray-light);
    font-family: 'Inter', sans-serif;
}

.profile-content .profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.9rem 2rem;
}

.profile-field {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.profile-field-full {
    grid-column: 1 / -1;
}

.profile-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.profile-value {
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 500;
    line-height: 1.4;
}

/* Subscription badge in status field */
.profile-subscription-badge {
    display: inline-block;
    padding: 0.35rem 0.85rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85rem;
    width: fit-content;
    letter-spacing: 0.3px;
}

.profile-badge-paid {
    background: #0f7d40;
    color: var(--white);
}

.profile-badge-unpaid {
    background: var(--primary-red);
    color: var(--white);
}

/* Subscription section: 3 columns on larger screens */
.profile-grid-subscription {
    grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 768px) {
    .profile-card-header {
        padding: 1.5rem 1.25rem 1.25rem;
    }
    .profile-card-body {
        padding: 1.25rem 1.25rem 1.5rem;
    }
    .profile-content .profile-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem 1.25rem;
    }
    .profile-grid-subscription {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .profile-content .profile-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   Portal section (UGLE Membership Desktop)
   ============================================ */
.members-portal-section {
    background: var(--white);
    color: var(--text-primary);
}

.members-portal-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: clamp(2rem, 5vw, 4rem);
    align-items: center;
    max-width: 1100px;
    margin-left: auto;
    margin-right: auto;
}

.members-portal-content {
    order: 1;
}

.members-portal-brand {
    margin-bottom: 1.5rem;
    text-align: center;
}

.members-portal-logo {
    max-width: 200px;
    height: auto;
    display: block;
    margin-left: auto;
    margin-right: auto;
    object-fit: contain;
}

.members-portal-section .section-title {
    color: var(--text-primary);
}

.members-portal-section .title-decoration .decoration-line,
.members-portal-section .title-decoration .decoration-square {
    background: var(--primary-red);
}

.members-portal-header {
    text-align: center;
    margin-bottom: 1rem;
}

.members-portal-header .section-header {
    margin-bottom: 0;
}

.members-portal-header .section-title {
    display: block;
    text-align: center;
}

.members-portal-header .title-decoration {
    justify-content: center;
}

.members-portal-text {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 1.5rem;
    max-width: 42ch;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}

.members-portal-cta-wrap {
    text-align: center;
}

.members-portal-cta {
    display: inline-block;
    padding: 0.75rem 1.75rem;
    font-weight: 600;
    background: var(--primary-red);
    color: var(--white);
    border: 2px solid var(--primary-red);
    text-decoration: none;
    border-radius: 6px;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.members-portal-cta:hover {
    background: var(--red-alt);
    border-color: var(--red-alt);
    color: var(--white);
}

.members-portal-image-wrap {
    order: 2;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.members-portal-image {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
}

@media (max-width: 768px) {
    .members-portal-container {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    .members-portal-content {
        order: 1;
    }
    .members-portal-image-wrap {
        order: 2;
    }
    .members-portal-header,
    .members-portal-text {
        text-align: center;
    }
    .members-portal-text {
        margin-left: auto;
        margin-right: auto;
    }
    .members-portal-cta {
        display: block;
        text-align: center;
        max-width: 280px;
        margin: 0 auto;
    }
}
