/* =========================================================
   🎨 style-shared.css: ศูนย์กลาง Design System (Shared UI)
   ใช้ร่วมกันทั้งฝั่งสมาชิกและแอดมิน (Mobile / Tablet / Desktop)
   ========================================================= */

:root { 
    --primary-dark: #0F172A; 
    --primary-main: #2563EB; 
    --success-main: #10B981; 
    --danger-main: #EF4444; 
    --warning-main: #F59E0B; 
    --bg-light: #F4F6F9; 
    --app-bg: #F4F6F9;
    --white: #FFFFFF;
    --text-main: #1E293B;
    --text-muted: #64748B; 
    --card-border: #E2E8F0;
    --card-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 12px;
    --bottom-nav-height: 75px;
}

* { 
    box-sizing: border-box; 
    -webkit-tap-highlight-color: transparent; 
}

/* แยกฟอนต์ออกจากสีพื้นหลัง เพื่อไม่ให้ input/button ติดสีเทา */
body, input, button, select, textarea, .offcanvas, .modal, .swal2-container { 
    font-family: 'Prompt', sans-serif !important; 
}

/* ====== [จุดเริ่มแก้ไข 1.1 ใน assets/css/style-shared.css (แทนที่บรรทัด 27 - 35)] ====== */
body { 
    background-color: var(--bg-light); 
    color: var(--text-main);
    margin: 0;
    padding: 0;
    padding-bottom: calc(95px + env(safe-area-inset-bottom, 16px)) !important;
    overflow-x: hidden; 
    line-height: 1.5;
}
/* ====== [จุดจบแก้ไข 1.1 ใน assets/css/style-shared.css] ====== */

h1, h2, h3, h4, p { margin: 0; }

/* =========================================================
   📐 1. GLOBAL LAYOUT & GRID UTILITIES
   ========================================================= */
.app-container {
    width: 100%;
    max-width: 100vw;
    margin: 0 auto;
    background-color: var(--bg-light);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

.content-grid {
    display: flex;
    flex-direction: column;
    width: 100%;
    position: relative;
    z-index: 10;
}

.stat-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    width: 100%;
}
.stat-row > * {
    flex: 1;
    min-width: 135px;
}

.quick-actions,
.quick-actions-bar {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    width: 100%;
    padding: 2px 0 0 0;
    position: relative;
    z-index: 10;
}

.desktop-chart-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    width: 100%;
}

.info-grid-2col {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    width: 100%;
}

/* =========================================================
   🧩 2. SHARED COMPONENTS (Icons, Inputs, Cards, Animations)
   ========================================================= */
.icon-box { 
    width: 44px; 
    height: 44px; 
    border-radius: 14px; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    font-size: 1.2rem; 
    flex-shrink: 0;
}

.cursor-pointer { cursor: pointer; }

/* ฟอร์ม Input มาตรฐาน FinTech */
.form-control-modern, .form-select-modern { 
    background-color: #F1F5F9; 
    border: 2px solid transparent; 
    border-radius: var(--radius-md); 
    padding: 0.75rem 1.2rem; 
    font-weight: 500; 
    color: #334155; 
    transition: all 0.25s ease; 
}
.form-control-modern:focus, .form-select-modern:focus { 
    background-color: #FFFFFF; 
    border-color: var(--primary-main); 
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12) !important; 
    outline: none;
}

/* การ์ดกระเป๋าเงินสีเข้ม (ใช้ทั้งหน้าสมาชิกและแอดมิน) */
.wallet-card { 
    background: linear-gradient(135deg, #0F172A 0%, #1E293B 100%); 
    border-radius: var(--radius-lg); 
    padding: 24px; 
    color: white; 
    box-shadow: 0 20px 25px -5px rgba(15, 23, 42, 0.35), 0 8px 10px -6px rgba(15, 23, 42, 0.2); 
    position: relative; 
    overflow: hidden; 
    border: 1px solid rgba(255,255,255,0.1); 
    z-index: 1; 
    margin-bottom: 1.5rem;
}
.wallet-card::before { 
    content: ''; position: absolute; top: -50px; right: -30px; width: 150px; height: 150px; 
    background: linear-gradient(135deg, rgba(37,99,235,0.4) 0%, rgba(16,185,129,0.4) 100%); 
    border-radius: 50%; filter: blur(30px); z-index: -1; 
}
.wallet-card::after { 
    content: ''; position: absolute; bottom: -30px; left: -20px; width: 100px; height: 100px; 
    background: linear-gradient(135deg, rgba(245,158,11,0.2) 0%, rgba(239,68,68,0.2) 100%); 
    border-radius: 50%; filter: blur(20px); z-index: -1; 
}

/* แอนิเมชันเสริม UX */
@keyframes blinkWarning { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
.blink-anim { animation: blinkWarning 1.5s infinite; }

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.fade-in-up { animation: fadeInUp 0.28s ease-out forwards; }

/* =========================================================
   ⏳ 3. SYSTEM 3D LOADER (รองรับโครงสร้าง <use href="#swMainPath">)
   ========================================================= */
#systemLoading { 
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: rgba(255, 255, 255, 0.96); z-index: 9999; 
    display: flex; flex-direction: column; justify-content: center; 
    align-items: center; backdrop-filter: blur(10px); 
    transition: opacity 0.3s ease;
}
.loading-container { 
    display: flex; flex-direction: column; align-items: center; 
    justify-content: center; gap: 16px; 
}
.sw-logo-svg { 
    width: 190px; max-width: 60vw; height: auto; 
    filter: drop-shadow(0 15px 25px rgba(5, 150, 105, 0.22)); 
    animation: floatLogo 3s ease-in-out infinite; 
}
@keyframes floatLogo { 
    0%, 100% { transform: translateY(0px); } 
    50% { transform: translateY(-10px); } 
}

.loading-text-glow { 
    font-size: 1.65rem; font-weight: 700; margin: 0; 
    background: linear-gradient(90deg, #059669, #2563EB); 
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; 
    animation: pulseTextGlow 1.5s ease-in-out infinite; 
}
#systemLoadingText {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}
@keyframes pulseTextGlow { 
    0%, 100% { opacity: 0.65; transform: scale(0.98); } 
    50% { opacity: 1; transform: scale(1); } 
}

/* =========================================================
   💻 5. GLOBAL RESPONSIVE BREAKPOINTS (Tablet & Desktop)
   ========================================================= */
@media (min-width: 600px) and (max-width: 899px) {
    body {
        background-color: #E2E8F0;
        display: flex;
        justify-content: center;
    }
    .app-container,
    #adminApp {
        max-width: 680px;
        width: 100%;
        margin: 0 auto;
        background-color: var(--bg-light);
        box-shadow: 0 0 40px rgba(15, 23, 42, 0.12);
        min-height: 100vh;
    }
    .bottom-nav {
        max-width: 680px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
    }
}

@media (min-width: 900px) {
    body {
        background-color: #E2E8F0;
        display: flex;
        justify-content: center;
        padding: 25px 20px 100px 20px;
    }
    .app-container,
    #adminApp {
        max-width: 960px;
        width: 100%;
        margin: 0 auto;
        background-color: var(--bg-light);
        border-radius: 32px;
        box-shadow: 0 20px 50px rgba(15, 23, 42, 0.12);
        overflow: hidden;
        min-height: calc(100vh - 120px);
        padding-bottom: 35px;
    }
    .desktop-chart-grid {
        grid-template-columns: repeat(2, 1fr);
        align-items: stretch;
    }
    .bottom-nav {
        max-width: 560px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        bottom: 15px !important;
        border-radius: 24px !important;
        border: 1px solid rgba(226, 232, 240, 0.9) !important;
        box-shadow: 0 12px 32px rgba(15, 23, 42, 0.15) !important;
        padding-bottom: 12px !important;
    }
}

/* ====== [จุดเริ่มแทรก 1.2 ท้ายไฟล์ assets/css/style-shared.css (ต่อจากบรรทัด 274)] ====== */
/* =========================================================
   🛡️ 6. ZERO-OVERLAP STICKY SYSTEM & ELDERLY ERGONOMICS
   ========================================================= */
.members-sticky-dock,
.sw-sticky-subtab-bar,
.admin-inbox-sticky-bar {
    position: sticky !important;
    top: 0 !important;
    z-index: 1020 !important;
    background: rgba(244, 246, 249, 0.96) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding-top: 8px !important;
    padding-bottom: 8px !important;
    margin-bottom: 12px !important;
    border-bottom: 1px solid rgba(226, 232, 240, 0.85);
    box-shadow: 0 6px 16px -6px rgba(15, 23, 42, 0.06);
}

/* ยกระดับขนาดปุ่มและตัวอักษรให้เหมาะกับชาวบ้านและผู้สูงอายุ (Thumb-Driven Ergonomics) */
.btn,
.btn-fintech,
.btn-modern-action,
.inbox-toggle-btn {
    min-height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

#btnSubtabMain,
#btnSubtabCommunity {
    min-height: 44px !important;
    font-size: 0.88rem !important;
    font-weight: 700 !important;
    letter-spacing: -0.2px;
}

.bottom-nav .nav-item {
    font-size: 0.72rem !important;
    min-height: 48px;
}

/* สถานะล็อกปุ่มป้องกันการกดซ้ำรัวๆ (Double Submission Lock) */
button[disabled],
.btn-submitting-lock {
    opacity: 0.68 !important;
    pointer-events: none !important;
    cursor: not-allowed !important;
}
/* ====== [จุดจบแทรก 1.2 ท้ายไฟล์ assets/css/style-shared.css] ====== */

/* =========================================================
   📱 UNIFIED BOTTOM NAVIGATION (แก้ไขการแสดงผลเมนูด้านล่าง)
   ========================================================= */
.bottom-nav { 
    position: fixed; 
    bottom: 0; 
    left: 0; 
    width: 100%; 
    min-height: 75px;
    background: rgba(255, 255, 255, 0.96); 
    backdrop-filter: blur(12px); 
    box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.08); 
    display: flex; 
    justify-content: space-around; 
    align-items: flex-end;
    padding: 10px 10px calc(14px + env(safe-area-inset-bottom, 10px)) 10px; 
    z-index: 1030; 
    border-radius: 24px 24px 0 0; 
}

.bottom-nav .nav-item { 
    flex: 1;
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: flex-end;
    text-decoration: none; 
    color: #94A3B8; 
    font-size: 0.65rem; 
    font-weight: 600; 
    background: none; 
    border: none; 
    position: relative;
    transition: all 0.2s ease; 
    cursor: pointer; 
    white-space: nowrap; 
    padding: 0;
}

.bottom-nav .nav-item i { 
    font-size: 1.3rem; 
    margin-bottom: 4px; 
    display: block; 
    transition: transform 0.2s; 
}

.bottom-nav .nav-item.active { 
    color: #0F172A; 
    font-weight: 700; 
    transform: translateY(-2px); 
}

.bottom-nav .nav-item:active i { 
    transform: scale(0.9); 
}

/* ปุ่มสแกน QR ลอยตัวตรงกลาง */
.nav-item-scan-wrapper { 
    position: relative; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: flex-end;
    flex: 1; 
    cursor: pointer; 
    white-space: nowrap;
}

.nav-item-scan { 
    position: absolute; 
    top: -52px;
    background: linear-gradient(135deg, #10B981 0%, #059669 100%); 
    width: 60px; 
    height: 60px; 
    border-radius: 50%; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    color: #FFFFFF; 
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.38); 
    border: 4px solid #F8FAFC; 
    font-size: 1.55rem; 
    transition: transform 0.2s ease; 
}

.nav-item-scan-wrapper:active .nav-item-scan { 
    transform: scale(0.94); 
}

.nav-item-scan-text { 
    margin-top: 15px; 
    color: #059669; 
    font-size: 0.68rem; 
    font-weight: 700; 
}