/* ==========================================
   1. CORE VARIABLES & BASE STYLES
   ========================================== */
:root {
    --bg: #fdfbf7;
    --txt: #1a1a1a;
    --card-bg: #ffffff;
    --primary: #2c3e50; 
    --accent: #e74c3c;  /* Dynamic: Overridden by JS */
    --muted: #999999;
    --border: #eeeeee;
    --shadow: 0 4px 20px rgba(0,0,0,0.05);
}

* { 
    box-sizing: border-box; 
    -webkit-tap-highlight-color: transparent; 
    outline: none !important;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    margin: 0; 
    padding: 0; 
    color: var(--txt);
    overflow-x: hidden;
}

/* Bulma Mobile Grid Fix */
.columns.is-mobile > .column.is-6-mobile { width: 50%; }

/* ==========================================
   2. SPLASH SCREEN
   ========================================== */
#splash {
    position: fixed; inset: 0; background: #fff; z-index: 9999;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    transition: opacity 0.8s ease-out;
}
.splash-logo {
    width: 130px; height: 130px; object-fit: contain;
    animation: PulseZoom 2s infinite ease-in-out alternate;
    display: none;
}
.loading-txt { 
    margin-top: 25px; font-size: 0.7rem; letter-spacing: 2.5px; 
    color: var(--muted); font-weight: 700; text-transform: uppercase;
}
@keyframes PulseZoom { 
    0% { transform: scale(0.95); opacity: 0.8; } 
    100% { transform: scale(1.05); opacity: 1; } 
}

/* ==========================================
   3. PORTAL UI & HEADER
   ========================================== */
.view { display: none; padding-bottom: 140px; opacity: 0; transition: opacity 0.6s; }
.view.is-active { display: block; opacity: 1; }

.ph { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: 1rem 1.5rem;
    position: relative;
}
.ph-spacer { width: 45px; } 

.top-logo { 
    height: 65px; width: 65px; object-fit: contain; 
    background: #fff; padding: 5px; border: 1px solid var(--border); border-radius: 12px; 
}

.ph-icon {
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 1rem;
    line-height: 1;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    cursor: pointer;
    transition: 0.2s;
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 100;
}

.ph-icon i {
    display: flex;
    align-items: center;
    justify-content: center;
}
.ph-icon:active { transform: scale(0.9); background: #f5f5f5; }
.ph-icon.is-active { background: var(--primary); color: #fff; border-color: var(--primary); }

.mh { text-align: center; padding: 0 1rem; }
.cw { 
    width: 145px; height: 145px; margin: 0 auto; 
    border-radius: 20%; overflow: hidden; 
    background: #f4f4f4; box-shadow: 0 10px 30px rgba(0,0,0,0.1); 
    border: 4px solid #fff;
}
.cw img { width: 100%; height: 100%; object-fit: cover; }

.leader-name { font-size: 1.35rem; font-weight: 800; margin-top: 1.2rem; color: var(--primary); }
.leader-title { 
    font-size: 0.65rem; color: var(--muted); font-weight: 700; 
    text-transform: uppercase; letter-spacing: 1.5px; margin-top: 5px;
}

.acts { display: flex; justify-content: center; gap: 20px; margin-top: 25px; flex-wrap: wrap; }
.act-btn { display: flex; flex-direction: column; align-items: center; cursor: pointer; transition: 0.2s; width: 60px; }
.act-btn:active { transform: scale(0.9); }
.act-btn i { font-size: 1.5rem; color: var(--primary); margin-bottom: 8px; }
.act-btn span { font-size: 0.5rem; font-weight: 800; color: #666; letter-spacing: 1px; text-transform: uppercase; }

.sep-line { width: 100%; height: 1px; background: var(--border); margin: 2.5rem 0; }

/* ==========================================
   4. ASSOCIATE CARDS
   ========================================== */
.card-base {
    background: var(--card-bg); border-radius: 24px; padding: 1.2rem 0.8rem;
    display: flex; flex-direction: column; align-items: center;
    border: 1px solid #f0f0f0; box-shadow: var(--shadow);
    height: 100%; cursor: pointer; transition: transform 0.2s;
    position: relative;
}
.card-base:active { transform: scale(0.96); background-color: #f9f9f9; }

.aa { 
    width: 100px; height: 100px; border-radius: 20%; overflow: hidden; 
    background: #f8f8f8; margin-bottom: 0.8rem; object-fit: cover;
    border: 3px solid #fff; box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.ln { font-size: 0.85rem; font-weight: 700; color: #1a1a1a; margin-bottom: 4px; text-align: center; }
.branch-info { text-align: center; margin-bottom: 12px; }
.b-name { display: block; font-size: 0.6rem; font-weight: 600; color: #4a4a4a; }
.b-loc { display: block; font-size: 0.55rem; color: var(--muted); }

.sm-acts { display: flex; gap: 10px; margin-top: auto; color: var(--muted); opacity: 0.4; }
.sm-acts i { font-size: 0.8rem; }

/* ==========================================
   5. DRAWERS & MODALS
   ========================================== */
.oc { 
    position: fixed; top: 0; left: 0; width: 100%; height: 100dvh; 
    background: rgba(255,255,255,0.98); z-index: 6000; 
    opacity: 0; pointer-events: none; transition: opacity .3s ease; 
    display: flex; align-items: center; justify-content: center;
}
.oc.is-open { opacity: 1; pointer-events: auto; }
.occ { width: 100%; max-width: 450px; padding: 2.5rem; position: relative; max-height: 90vh; overflow-y: auto; }

.c-btn-x { 
    position: absolute; top: 15px; right: 15px;
    border: none; background: #f5f5f5; width: 35px; height: 35px; border-radius: 50%;
    font-size: 1rem; cursor: pointer; z-index: 10; display: flex; align-items: center; justify-content: center;
}

.drawer-header { text-align: center; margin-bottom: 2rem; }
.drawer-user-name { font-weight: 800; font-size: 1.1rem; margin-top: 10px; color: var(--primary); }
.drawer-sub-label { font-size: 0.6rem; color: var(--muted); letter-spacing: 2px; font-weight: 700; text-transform: uppercase; }

.custom-input {
    border-radius: 12px !important;
    border: 1.5px solid var(--border) !important;
    padding: 25px 15px !important;
    font-weight: 600;
}
.custom-select-wrap select {
    border-radius: 12px !important;
    height: 50px !important;
    border: 1.5px solid var(--border) !important;
    font-weight: 600;
}

.custom-select { 
    position: relative; width: 100%; height: 52px; 
    background: #fff; border: 1.5px solid var(--border); border-radius: 14px; margin-bottom: 12px;
}
.custom-select select {
    width: 100%; height: 100%; padding: 0 15px; background: transparent;
    border: none; outline: none; font-size: 0.95rem; font-weight: 700; appearance: none;
    font-family: 'Courier New', Courier, monospace;
}
.custom-select .caret { position: absolute; right: 15px; top: 50%; transform: translateY(-50%); color: var(--primary); pointer-events: none; }

.s-btn { 
    width: 100%; padding: 18px; background: var(--primary); color: #fff; 
    font-weight: 800; text-transform: uppercase; border: none; border-radius: 14px; cursor: pointer;
    transition: 0.2s;
}
.s-btn:active { background: #000; transform: scale(0.98); }

.drawer-list { margin-top: 1rem; }
.vi { 
    padding: 14px 0; border-bottom: 1px solid #f9f9f9; cursor: pointer; 
    font-size: 0.95rem; transition: 0.2s;
}
.vi:active { background: #f5f5f5; }

.list-thumb { width: 50px; height: 50px; border-radius: 10px; object-fit: cover; background: #eee; }
.date-box { 
    width: 45px; height: 45px; background: #f8f8f8; border-radius: 10px; 
    display: flex; flex-direction: column; align-items: center; justify-content: center; border: 1px solid #eee;
}
.date-box span { font-size: 0.55rem; font-weight: 700; color: var(--muted); }
.date-box b { font-size: 0.95rem; }

/* ==========================================
   6. MEMBER CARD & SCANNER UI
   ========================================== */
.member-card-ui {
    background: linear-gradient(135deg, var(--primary) 0%, #000 100%);
    color: white;
    border-radius: 24px;
    padding: 2rem 1.5rem;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0,0,0,0.25);
    position: relative;
    overflow: hidden;
}
.member-card-ui::before {
    content: ''; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, transparent 70%);
}
.card-header { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 1.5rem; }
.card-logo-sm { height: 24px; filter: brightness(0) invert(1); }
.card-header span { font-size: 0.65rem; font-weight: 800; letter-spacing: 2px; text-transform: uppercase; }

.qr-placeholder {
    background: white;
    color: #000;
    width: 130px;
    height: 130px;
    margin: 0 auto 1.5rem;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}
.card-footer {
    margin-top: 1.5rem; font-size: 0.55rem; letter-spacing: 2px; font-weight: 700;
    border-top: 1px solid rgba(255,255,255,0.1); padding-top: 1rem; opacity: 0.5;
}

/* Scanner Logic UI */
.scan-trigger-container {
    display: flex; flex-direction: column; align-items: center;
    margin-bottom: 2rem; cursor: pointer;
}
.scan-btn-circle {
    width: 70px; height: 70px;
    background: linear-gradient(135deg, var(--accent) 0%, #ff7e5f 100%);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 1.8rem;
    box-shadow: 0 10px 25px rgba(231, 76, 60, 0.4);
    animation: PulseBtn 2s infinite;
    margin-bottom: 10px;
}
.scan-label {
    font-size: 0.7rem; font-weight: 800; letter-spacing: 1px;
    color: var(--primary);
}
@keyframes PulseBtn {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 15px rgba(231, 76, 60, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(231, 76, 60, 0); }
}

#scannerView { text-align: center; }
.scan-anim-icon {
    width: 50px; height: 50px; margin: 0 auto 10px;
    background: #f0f0f0; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #666;
}

/* ==========================================
   7. UNIFIED PLAYER OVERLAY
   ========================================== */
#pv { 
    position: fixed; inset: 0; background: #fff; z-index: 7000; 
    transform: translateY(100%); transition: transform .5s cubic-bezier(.19,1,.22,1); 
    display: flex; flex-direction: column; 
}
#pv.is-open { transform: translateY(0); }

.p-head { padding: 1rem 1.5rem; display: flex; justify-content: space-between; align-items: center; }
.p-mode-tag { font-size: 0.65rem; font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); }
.ib { border: none; background: none; font-size: 1.3rem; color: var(--primary); cursor: pointer; padding: 10px; }

.vl { flex: 1; overflow-y: auto; padding: 1.5rem 1.5rem 180px; font-family: 'Courier New', Courier, monospace; }
.vl .vi b { font-size: 0.7rem; vertical-align: super; margin-right: 10px; color: var(--muted); }
.vl .vi.is-active { color: #000; font-weight: 700; border-left: 4px solid var(--accent); padding-left: 12px; }

#bookStage { flex: 1; display: none; flex-direction: column; align-items: center; justify-content: center; padding-bottom: 80px; }
.book-cover-large { 
    width: 280px; height: 280px; object-fit: cover; 
    border-radius: 28px; box-shadow: 0 30px 60px rgba(0,0,0,0.15); 
}

#pv.mode-bible .vl { display: block; }
#pv.mode-bible #bookStage { display: none; }
#pv.mode-book .vl { display: none; }
#pv.mode-book #bookStage { display: flex; }

.p-foot { position: absolute; bottom: 0; width: 100%; background: #fff; box-shadow: 0 -10px 40px rgba(0,0,0,0.03); }
.sc-wrap { position: relative; height: 4px; background: #f0f0f0; width: 100%; }
.sc-prog { height: 100%; background: var(--accent); width: 0%; transition: width 0.1s linear; }
.sc-inp { position: absolute; top: -15px; left: 0; width: 100%; height: 35px; opacity: 0; cursor: pointer; }

.ctrl-row { display: flex; padding: 1.2rem 1.5rem 2.8rem; align-items: center; }
.foot-left { width: 75px; position: relative; }
.footer-art { 
    width: 70px; height: 70px; border-radius: 14px; object-fit: cover; 
    position: absolute; top: -48px; border: 3px solid #fff; 
    box-shadow: 0 8px 20px rgba(0,0,0,0.1); background:#eee; 
}
.foot-name { font-size: 0.5rem; font-weight: 800; margin-top: 35px; text-transform: uppercase; color: var(--muted); text-align: center; }

.foot-right { flex: 1; padding-left: 20px; }
.track-ref { font-size: 0.9rem; font-weight: 800; text-align: center; margin-bottom: 15px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;}
.btn-deck { display: flex; justify-content: space-between; align-items: center; }
.c-btn { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: #444; }
.speed-btn { font-size: 0.75rem; font-weight: 800; color: var(--muted); width: 35px; }
.play-btn { font-size: 2.2rem; color: var(--primary); }

/* ==========================================
   8. MINI PLAYER (STICKY)
   ========================================== */
#mp { 
    position: fixed; bottom: 0; width: 100%; height: 78px; 
    background: rgba(255,255,255,0.95); backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px);
    border-top: 1px solid var(--border); display: flex; align-items: center; 
    padding: 0 1.2rem; z-index: 5000; 
    transform: translateY(100%); transition: .3s ease-out; 
}
#mp.is-visible { transform: translateY(0); }
.ma { width: 48px; height: 48px; border-radius: 10px; margin-right: 15px; object-fit: cover; background: #eee; }
.m-tit { font-weight: 700; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-art { font-size: 0.65rem; color: var(--muted); margin-top: 2px; }

/* ==========================================
   9. DEVOTIONAL READER
   ========================================== */
.reader-container { 
    max-width: 650px !important; background: #fdfbf7 !important; 
    height: 100dvh; display: block !important; padding: 4rem 2rem !important; 
}
.reader-header { text-align: center; margin-bottom: 3rem; }
.reader-date { font-size: 0.7rem; color: var(--muted); letter-spacing: 2.5px; text-transform: uppercase; font-weight: 700; }
.reader-title { font-size: 1.8rem; font-weight: 800; margin: 15px 0; color: var(--primary); line-height: 1.2; }
.reader-sep { width: 45px; height: 4px; background: var(--accent); margin: 0 auto; border-radius: 2px; }

.reader-body { 
    font-family: 'Georgia', serif; font-size: 1.15rem; line-height: 1.95; 
    color: #222; padding-bottom: 140px; 
}

.scrip-link {
    display: inline-flex; align-items: center; color: var(--accent); 
    font-weight: 700; cursor: pointer; background: rgba(0,0,0,0.03); 
    padding: 2px 10px; border-radius: 8px; margin: 0 2px;
    font-family: 'Courier New', monospace; font-size: 0.85rem;
    border-bottom: 2px solid var(--accent);
}
.scrip-link i { margin-left: 8px; font-size: 0.7rem; opacity: 0.6; }

.hidden { display: none !important; }

/* Custom Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #eee; border-radius: 10px; }

/* ==========================================
   MEMBERSHIP CARD PAGE STYLES
   ========================================== */
.membership-container {
    max-width: 400px;
    margin: 0 auto;
    padding: 1.5rem;
    text-align: center;
    min-height: 100vh;
    background: var(--bg);
}

.mem-header {
    margin-bottom: 1.5rem;
    padding-top: 1rem;
}

.mem-header .church-logo {
    width: 70px;
    height: 70px;
    margin: 0 auto 0.8rem;
    border-radius: 50%;
    overflow: hidden;
    background: #f4f4f4;
    border: 3px solid var(--primary);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.mem-header .church-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mem-header h2 {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--primary);
    margin: 0;
}

.mem-subtitle {
    font-size: 0.65rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-top: 0.3rem;
    font-weight: 700;
}

/* Member Card */
.member-card {
    background: linear-gradient(145deg, var(--primary) 0%, #1a1a2e 50%, #16213e 100%);
    border-radius: 24px;
    padding: 1.8rem 1.3rem;
    color: white;
    position: relative;
    box-shadow: 0 25px 50px rgba(0,0,0,0.25);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.member-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.05) 0%, transparent 70%);
    pointer-events: none;
}

.card-badge {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 1px;
    border: 1px solid rgba(255,255,255,0.1);
}

.member-photo {
    width: 90px;
    height: 90px;
    margin: 0.5rem auto 1rem;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: rgba(255,255,255,0.7);
    border: 4px solid rgba(255,255,255,0.25);
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
}

#memName {
    font-size: 1.3rem;
    font-weight: 800;
    margin: 0 0 0.3rem;
    letter-spacing: 0.5px;
}

.mem-branch {
    font-size: 0.85rem;
    opacity: 0.85;
    margin: 0;
    font-weight: 500;
}

.mem-divider {
    width: 40px;
    height: 3px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    margin: 1.2rem auto;
    border-radius: 2px;
}

.mem-details {
    text-align: left;
    margin-bottom: 1.2rem;
    background: rgba(255,255,255,0.05);
    border-radius: 12px;
    padding: 1rem;
}

.mem-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.mem-row:last-child {
    border-bottom: none;
}

.mem-label {
    font-size: 0.75rem;
    opacity: 0.6;
    font-weight: 500;
}

.mem-value {
    font-size: 0.8rem;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    letter-spacing: 0.5px;
}

/* QR Section */
.qr-section {
    background: rgba(255,255,255,0.08);
    border-radius: 16px;
    padding: 1rem;
    margin-top: 0.5rem;
    border: 1px solid rgba(255,255,255,0.1);
}

.qr-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin: 0 0 0.8rem;
    opacity: 0.8;
    font-weight: 700;
}

.qr-code {
    width: 140px;
    height: 140px;
    margin: 0 auto;
    background: white;
    padding: 10px;
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

.qr-code img {
    width: 100%;
    height: 100%;
    display: block;
}

.qr-hint {
    font-size: 0.7rem;
    margin: 0.8rem 0 0;
    opacity: 0.5;
    font-weight: 500;
}

/* Action Buttons */
.mem-actions {
    display: flex;
    gap: 0.8rem;
    margin-bottom: 1rem;
}

.mem-btn {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
}

.mem-btn:active {
    transform: scale(0.96);
}

.mem-btn.primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 15px rgba(44,62,80,0.3);
}

.mem-btn.secondary {
    background: #f0f0f0;
    color: var(--primary);
}

.mem-btn.checkin {
    width: 100%;
    background: linear-gradient(135deg, var(--accent) 0%, #ff6b6b 100%);
    color: white;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    padding: 16px;
    box-shadow: 0 6px 20px rgba(231,76,60,0.3);
}

.mem-back {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 0.85rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    font-family: inherit;
    font-weight: 600;
    transition: color 0.2s;
}

.mem-back:hover {
    color: var(--primary);
}

.top-logo {
    height: 100px;
    width: 2000px;
    object-fit: contain;
    background: #fff;
    padding: 5px;
    border: 1px solid var(--border);
    border-radius: 12px;
}
.bb {
    width: 150px;
    height: 150px;
    border-radius: 20%;
    overflow: hidden;
    background: #f8f8f8;
    margin-bottom: 0.8rem;
    object-fit: contain;
    border: 3px solid #fff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}