/* ==========================================================================
   ธีมมืด / สว่าง (2026-11-25)
   - ค่าเริ่มต้นคือธีมมืดเหมือนเดิม ธีมสว่างเปิดด้วย <html data-theme="light">
   - ส่วนกลาง (ui.css, ตาราง, SweetAlert, พื้นหลัง) เปลี่ยนผ่านตัวแปร CSS ในไฟล์นี้
   - สีที่เขียนตายตัวในแต่ละหน้า assets/js/theme.js จะปรับให้อัตโนมัติตอนเป็นธีมสว่าง
   - ส่วนที่ไม่ต้องการให้ปรับ ใส่ attribute data-theme-keep
   ========================================================================== */

:root {
    color-scheme: dark;
}

/* ---------- แก้สีไม่เข้ากัน (ทั้งสองธีม) ---------- */
/* index.php ทำ .table-responsive ทุกอันเป็นกล่องขาว แต่ตารางที่อยู่ในการ์ด ui-card ของหน้าใหม่ใช้ตัวหนังสือสีอ่อน
   จึงกลายเป็นกล่องขาวตัวหนังสือขาว (เช่น "รายได้ล่าสุด" หน้า /invite) ให้ตารางในการ์ดใช้พื้นของการ์ดแทน */
.ui-card .table-responsive,
.ui-section .table-responsive {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    border-radius: 0 !important;
    color: inherit !important;
}

/* ---------- ปุ่มสลับธีมบนแถบเมนู ---------- */
.pl-theme-toggle .pl-theme-ic-sun { display: none; }
html[data-theme="light"] .pl-theme-toggle .pl-theme-ic-sun { display: inline-block; }
html[data-theme="light"] .pl-theme-toggle .pl-theme-ic-moon { display: none; }
.pl-theme-toggle i { transition: transform .35s ease; }
.pl-theme-toggle:hover i { transform: rotate(-20deg); }

/* ==========================================================================
   ธีมสว่าง
   ========================================================================== */
html[data-theme="light"] {
    color-scheme: light;
    background-color: #eef2f7 !important;

    --ui-accent-ink: #1a1206;
    --ui-surface: rgba(255, 255, 255, 0.97);
    --ui-surface-2: rgba(15, 23, 42, 0.04);
    --ui-line: rgba(15, 23, 42, 0.10);
    --ui-line-strong: rgba(15, 23, 42, 0.18);
    --ui-text: #0f172a;
    --ui-muted: #475569;
    --ui-dim: #64748b;
    --ui-ok: #059669;
    --ui-warn: #b45309;
    --ui-danger: #dc2626;
    --ui-info: #2563eb;
    --ui-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    --clr-bg: #f8fafc;
}

/* ซ่อนหน้าแป๊บเดียวระหว่าง theme.js ปรับสี กันตัวหนังสือขาวบนพื้นขาวกระพริบ (index.php ปลดเองภายใน 1.5 วิ ถ้าสคริปต์ล่ม) */
html[data-theme="light"].pl-theme-pending body { opacity: 0 !important; }

/* พื้นหลังเว็บ: วอลเปเปอร์เดิมเป็นภาพมืด ใช้พื้นสว่างไล่สีอ่อนจากสีหลักของร้านแทน */
html[data-theme="light"] body::before {
    background:
        radial-gradient(1100px 620px at 8% -8%, color-mix(in srgb, var(--clr-neon, #ffa66b) 20%, transparent), transparent 62%),
        radial-gradient(900px 520px at 100% 0%, rgba(99, 102, 241, 0.10), transparent 60%),
        linear-gradient(180deg, #f6f8fb 0%, #eef2f7 100%) !important;
}

html[data-theme="light"] ::-webkit-scrollbar-track { background: #e2e8f0; }

/* SweetAlert */
html[data-theme="light"] div:where(.swal2-container) .swal2-popup {
    background: #ffffff !important;
    border: 1px solid rgba(15, 23, 42, 0.10) !important;
    color: #0f172a !important;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.18) !important;
}
html[data-theme="light"] div:where(.swal2-container) .swal2-title,
html[data-theme="light"] div:where(.swal2-container) .swal2-html-container { color: #0f172a !important; }
html[data-theme="light"] div:where(.swal2-container) .swal2-cancel { background: #e2e8f0 !important; color: #0f172a !important; }

/* ตัวหนังสือบนปุ่มสีของ Bootstrap ต้องเป็นสีขาวเสมอ */
html[data-theme="light"] :is(.btn-primary, .btn-success, .btn-danger, .btn-info, .btn-dark, .btn-secondary),
html[data-theme="light"] :is(.btn-primary, .btn-success, .btn-danger, .btn-info, .btn-dark, .btn-secondary) * { color: #fff !important; }

/* ฟอร์ม Bootstrap */
html[data-theme="light"] :is(.form-control, .form-select) {
    background-color: #ffffff;
    color: #0f172a;
    border-color: rgba(15, 23, 42, 0.18);
}
html[data-theme="light"] :is(.form-control, .form-select)::placeholder { color: #94a3b8; }
html[data-theme="light"] option { background: #fff; color: #0f172a; }

/* หน้าหลังบ้าน: admin.css บังคับกล่องและตารางเป็นสีมืด */
html[data-theme="light"] body.pl-admin .class-thxk,
html[data-theme="light"] body.pl-admin .class-thxk:has(table) {
    background: #ffffff !important;
    color: #0f172a !important;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08) !important;
}
html[data-theme="light"] body.pl-admin .class-thxk :is(h1, h2, h3, h4, h5, h6),
html[data-theme="light"] body.pl-admin .class-thxk:has(table) center * { color: #0f172a !important; }
html[data-theme="light"] body.pl-admin .class-thxk label,
html[data-theme="light"] body.pl-admin .form-check-label { color: #334155 !important; }
html[data-theme="light"] body.pl-admin table.dataTable,
html[data-theme="light"] body.pl-admin .table-responsive table.table,
html[data-theme="light"] body.pl-admin table.table { color: #0f172a !important; --bs-table-color: #0f172a; --bs-table-striped-color: #0f172a; }
html[data-theme="light"] body.pl-admin .table-responsive { color: #0f172a !important; }
html[data-theme="light"] body.pl-admin table.dataTable thead th,
html[data-theme="light"] body.pl-admin .table-responsive table.table thead th { background: #eef2f7 !important; color: #334155 !important; }
html[data-theme="light"] body.pl-admin table.dataTable tbody tr,
html[data-theme="light"] body.pl-admin .table-responsive table.table tbody tr { background: #f8fafc !important; }
html[data-theme="light"] body.pl-admin table.dataTable tbody tr:hover,
html[data-theme="light"] body.pl-admin .table-responsive table.table tbody tr:hover { background: #eef2f7 !important; }
html[data-theme="light"] body.pl-admin :is(table.dataTable, .table-responsive table.table, table.table) :is(td, th) { color: #0f172a !important; }
html[data-theme="light"] body.pl-admin .dataTables_wrapper :is(.dataTables_length, .dataTables_filter, .dataTables_info, .dataTables_paginate, label) { color: #475569 !important; }
html[data-theme="light"] body.pl-admin .dataTables_wrapper :is(.dataTables_length select, .dataTables_filter input) { background-color: #fff !important; color: #0f172a !important; }
html[data-theme="light"] body.pl-admin .dataTables_wrapper .dataTables_paginate .paginate_button { background: #fff !important; color: #0f172a !important; }
html[data-theme="light"] body.pl-admin .dataTables_wrapper .dataTables_paginate .paginate_button.current { background: #0f172a !important; color: #fff !important; }

/* ==========================================================================
   ธีมสว่าง: แถบเมนู เมนูล่างมือถือ และลิ้นชักเมนู (ใส่ data-theme-keep ไว้ใน navbar.php ให้ theme.js ไม่แตะ)
   ========================================================================== */
html[data-theme="light"] #pl-navbar-wrapper .nv-bar,
html[data-theme="light"] body.pl-ios-device #pl-navbar-wrapper .nv-bar {
    background: rgba(255, 255, 255, 0.94);
    border-color: rgba(15, 23, 42, 0.10);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}
html[data-theme="light"] #pl-navbar-wrapper.is-scrolled .nv-bar { background: #ffffff; box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12); }
html[data-theme="light"] .nv-brand-copy strong { color: #0f172a !important; }
html[data-theme="light"] #pl-navbar-wrapper .nv-link { color: #475569 !important; }
html[data-theme="light"] #pl-navbar-wrapper .nv-link:hover,
html[data-theme="light"] #pl-navbar-wrapper .nv-link[aria-expanded=true] { background: rgba(15, 23, 42, 0.05); color: #0f172a !important; }
html[data-theme="light"] #pl-navbar-wrapper .nv-link.active { background: var(--ui-accent-soft); color: color-mix(in srgb, var(--ui-accent) 55%, #000) !important; }
html[data-theme="light"] #pl-navbar-wrapper .dropdown-menu { background: #ffffff; border-color: rgba(15, 23, 42, 0.12); box-shadow: 0 20px 50px rgba(15, 23, 42, 0.14); }
html[data-theme="light"] .nv-item { color: #334155 !important; }
html[data-theme="light"] .nv-item > i:first-child { background: rgba(15, 23, 42, 0.05); color: #64748b !important; }
html[data-theme="light"] .nv-item:hover,
html[data-theme="light"] .nv-item.active { background: rgba(15, 23, 42, 0.05); color: #0f172a !important; }
html[data-theme="light"] .nv-item.active > i:first-child { background: var(--ui-accent-soft); color: color-mix(in srgb, var(--ui-accent) 55%, #000) !important; }
html[data-theme="light"] .nv-item.active > span { color: color-mix(in srgb, var(--ui-accent) 55%, #000) !important; }
html[data-theme="light"] .nv-item.danger,
html[data-theme="light"] .nv-item.danger > span,
html[data-theme="light"] .nv-item.danger > i:first-child { color: #dc2626 !important; }
html[data-theme="light"] :is(#pl-navbar-wrapper, #mobileMenu) .nv-tag { color: color-mix(in srgb, var(--ui-accent) 55%, #000) !important; }
html[data-theme="light"] #pl-navbar-wrapper :is(.nv-search, .nv-icon-btn, .nv-user) { background: rgba(15, 23, 42, 0.03); color: #334155; }
html[data-theme="light"] #pl-navbar-wrapper :is(.nv-search, .nv-icon-btn):hover { background: rgba(15, 23, 42, 0.07); }
html[data-theme="light"] #pl-navbar-wrapper .nv-search kbd { border-color: rgba(15, 23, 42, 0.15); color: #64748b; }
html[data-theme="light"] #pl-navbar-wrapper .nv-user,
html[data-theme="light"] #pl-navbar-wrapper .nv-user .meta b { color: #0f172a !important; }
html[data-theme="light"] #pl-navbar-wrapper :is(.nv-balance, .nv-mobile-login) { color: color-mix(in srgb, var(--ui-accent) 55%, #000) !important; }
html[data-theme="light"] #pl-navbar-wrapper .nv-rank i { color: #d97706; }
html[data-theme="light"] #pl-navbar-wrapper .nv-bell .nv-bell-count { box-shadow: 0 0 0 2px #ffffff; }
html[data-theme="light"] .pl-theme-toggle .pl-theme-ic-sun { color: #f59e0b; }
html[data-theme="light"] .pl-breadcrumb [aria-current=page] { color: #0f172a !important; }

/* เมนูล่างมือถือ */
html[data-theme="light"] .nv-tabbar { background: rgba(255, 255, 255, 0.97); border-color: rgba(15, 23, 42, 0.10); box-shadow: 0 10px 30px rgba(15, 23, 42, 0.14); }
html[data-theme="light"] .nv-tab { color: #64748b !important; }
html[data-theme="light"] .nv-tab.active,
html[data-theme="light"] .nv-tab[aria-expanded=true] { color: color-mix(in srgb, var(--ui-accent) 55%, #000) !important; }
html[data-theme="light"] .nv-tab:active { background: rgba(15, 23, 42, 0.06); }
html[data-theme="light"] .nv-tab-more { color: #334155 !important; }
html[data-theme="light"] .nv-tab-more .nv-more-icon { background: #eef2ff; border-color: rgba(99, 102, 241, 0.30); }

/* ลิ้นชักเมนู (มือถือ/แท็บเล็ต) */
html[data-theme="light"] #mobileMenu.nv-drawer { background: #ffffff; color: #0f172a; border-color: rgba(15, 23, 42, 0.10); box-shadow: 0 -16px 50px rgba(15, 23, 42, 0.18); }
html[data-theme="light"] #mobileMenu .offcanvas-header::before { background: #cbd5e1; }
html[data-theme="light"] #mobileMenu .nv-drawer-title-icon { color: #4c1d95; background: #ede9fe; border-color: rgba(124, 58, 237, 0.25); }
html[data-theme="light"] #mobileMenu .nv-drawer-heading h2,
html[data-theme="light"] #mobileMenu .nv-account b { color: #0f172a !important; }
html[data-theme="light"] #mobileMenu :is(.nv-drawer-close, .nv-search-m) { background: rgba(15, 23, 42, 0.03); color: #334155; }
html[data-theme="light"] #mobileMenu .nv-search-m span { color: #334155 !important; }
html[data-theme="light"] #mobileMenu .nv-account { background: linear-gradient(135deg, var(--ui-accent-soft), #ffffff); }
html[data-theme="light"] #mobileMenu .nv-account .bal { color: color-mix(in srgb, var(--ui-accent) 55%, #000) !important; }
html[data-theme="light"] #mobileMenu .nv-drawer-services .nv-section,
html[data-theme="light"] #mobileMenu .nv-drawer-account .nv-section { color: #334155 !important; }
html[data-theme="light"] .nv-drawer-main .nv-item,
html[data-theme="light"] #mobileMenu .nv-drawer-main .nv-item { background: #f8fafc; }
html[data-theme="light"] #mobileMenu .nv-drawer-main .nv-item > i:first-child { background: #eef2f7; }
html[data-theme="light"] #mobileMenu .nv-service-grid .nv-item { background: #f8fafc; }
html[data-theme="light"] #mobileMenu .nv-service-grid .nv-item > i:first-child { color: #7c3aed !important; }
html[data-theme="light"] #mobileMenu .nv-service-grid .nv-drawer-feature { background: #f5f3ff; border-color: rgba(124, 58, 237, 0.30); }
html[data-theme="light"] #mobileMenu .nv-drawer-feature > i:first-child { color: #6d28d9 !important; background: #ede9fe; }
html[data-theme="light"] #mobileMenu .nv-menu-group { background: #f8fafc; border-color: rgba(15, 23, 42, 0.10); }
html[data-theme="light"] .nv-menu-group summary { color: #1e293b; }
html[data-theme="light"] .nv-menu-group summary .nv-svg { color: #64748b; }

/* ตอน theme.js อ่านสี ปิดการเปลี่ยนสีแบบค่อยๆ ชั่วคราว ไม่ให้อ่านได้ค่ากลางทาง (เช่นแถบเมนูตอนเลื่อนจอ) */
html.pl-theme-measure *,
html.pl-theme-measure *::before,
html.pl-theme-measure *::after {
    transition-property: transform, opacity, visibility, width, height, max-height, top, right, bottom, left, translate, scale, rotate, clip-path !important;
}

/* index.php บังคับ span/p/a/h*/button เป็นสีตัวอักษรของร้าน (ขาว) ในแถบเมนูให้ใช้สีของกล่องแทน */
html[data-theme="light"] :is(#pl-navbar-wrapper, #mobileMenu, .nv-tabbar) { color: #334155; }
html[data-theme="light"] :is(#pl-navbar-wrapper, #mobileMenu, .nv-tabbar) :is(span, small, p, a, button, h1, h2, h3, h4, h5, h6):not([class*="count"]):not(.badge) { color: inherit; }

/* ปุ่มเปลี่ยนธีมในลิ้นชักเมนู (มือถือ) */
#mobileMenu .nv-theme-m { margin-top: 8px; }
.pl-theme-to-dark { display: none; }
html[data-theme="light"] .pl-theme-to-dark { display: inline; }
html[data-theme="light"] .pl-theme-to-light { display: none; }
.nv-theme-m .pl-theme-ic-moon { color: #c4b5fd; }

/* ปุ่มปิด (X) สีขาวของ Bootstrap มองไม่เห็นบนพื้นขาว */
html[data-theme="light"] .btn-close-white { filter: none; }

/* ปุ่ม "เพิ่มลงตะกร้า" ในหน้าต่างสินค้า (SweetAlert deny button) ไม่มีสไตล์ เลยเป็นปุ่มเปล่า (ทั้งสองธีม) */
.a2-product-dialog .swal2-deny {
    width: 100%; min-height: 46px; margin: 0; padding: 11px 16px; border-radius: 13px;
    font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
    color: #e7eaf1 !important; background: #ffffff0d !important; border: 1px solid var(--ui-accent-line, #ffffff2a);
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.a2-product-dialog .swal2-deny:hover { background: var(--ui-accent-soft, #ffffff16) !important; }
.a2-product-dialog .swal2-deny i { color: inherit !important; }
html[data-theme="light"] .a2-product-dialog .swal2-deny { color: #0f172a !important; background: #f8fafc !important; }
html[data-theme="light"] .a2-product-dialog .a2-product-close { color: #0f172a !important; background: #eef2f7 !important; border-color: rgba(15, 23, 42, 0.12); }

/* กรอบหน้าร้าน (layouts/public_shell.php): หน้าเว็บอยู่ใน iframe พื้นของกรอบโผล่ตอนเปลี่ยนหน้า */
html[data-theme="light"] body.pl-public-shell,
html[data-theme="light"] #pl-public-frame,
html[data-theme="light"] [data-pl-staged] { background: #eef2f7 !important; }

/* ==========================================================================
   ผลไล่เช็คความคมชัดทั้งเว็บ (2026-11-25)
   ========================================================================== */
/* ธีมมืด: ตัวหนังสือจาง (--ui-dim) จาง .42 อ่านไม่ถึงมาตรฐาน */
html:not([data-theme="light"]) { --ui-dim: rgba(255, 255, 255, 0.56); }
/* ธีมมืด: .text-muted ของ Bootstrap เป็นสีเทาเข้มบนพื้นมืด */
html:not([data-theme="light"]) { --bs-secondary-color: rgba(255, 255, 255, 0.62); }
/* ...ยกเว้นในกล่องตารางพื้นขาว */
body:not(.pl-admin) :is(.table-responsive, .class-thxk:has(table), .history-card-wrapper, .history-app-card, .history-social-card) { --bs-secondary-color: rgba(33, 37, 41, 0.75); }
.ui-card .table-responsive, .ui-section .table-responsive { --bs-secondary-color: inherit; }

/* ป้ายสถานะ ui-badge (สีพาสเทลสำหรับพื้นมืด) ที่อยู่ในกล่องตารางพื้นขาว */
body:not(.pl-admin) :is(.table-responsive, .class-thxk:has(table), .history-card-wrapper, .history-app-card, .history-social-card) { --ui-ok: #047857; --ui-warn: #b45309; --ui-danger: #b91c1c; --ui-info: #1d4ed8; }
:is(.ui-card, .ui-section) .table-responsive { --ui-ok: inherit; --ui-warn: inherit; --ui-danger: inherit; --ui-info: inherit; }

/* ประวัติบูสต์ดิสคอร์ด: กล่องประวัติตั้งใจเป็นพื้นมืด แต่กฎกล่องตารางขาวใน index.php ชนะ เลยเป็นตัวขาวบนพื้นขาว */
.dboost .db-list.class-thxk { background: rgba(15, 23, 42, 0.7) !important; border: 1px solid rgba(255, 255, 255, 0.08) !important; color: #fff !important; }

/* ธีมมืด: โค้ดตัวอย่าง (<code>) สีชมพูเข้มของ Bootstrap อ่านยากบนพื้นมืด */
html:not([data-theme="light"]) code { color: #f472b6; }
html:not([data-theme="light"]) body:not(.pl-admin) :is(.table-responsive, .class-thxk:has(table)) code { color: #d63384; }
/* ธีมมืด หลังบ้าน: แท็บและตัวหนังสือรองของ Bootstrap */
html:not([data-theme="light"]) body.pl-admin .nav-tabs .nav-link:not(.active) { color: #93b4ff; }
html:not([data-theme="light"]) body.pl-admin .text-secondary { color: rgba(255, 255, 255, 0.62) !important; }
html:not([data-theme="light"]) body.pl-admin .text-danger { color: #f87171 !important; }
/* ตัวหนังสือที่ไม่มีสีของตัวเองในการ์ด จะได้สีดำของ Bootstrap (body) ซึ่งมองไม่เห็นบนการ์ดมืด */
.ui-card, .ui-section { color: var(--ui-text); }
html:not([data-theme="light"]) body.pl-admin { color: #e5e7eb; }

/* ธีมสว่าง + ฉากเทศกาล (theme.js ใส่คลาส pl-theme-scene): เส้นทางหน้า (breadcrumb) วางบนฉากมืดโดยตรง ต้องเป็นตัวอ่อน */
html.pl-theme-scene .pl-breadcrumb,
html.pl-theme-scene .pl-breadcrumb :is(a, span, li) { color: rgba(255, 255, 255, 0.82) !important; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6); }
html.pl-theme-scene .pl-breadcrumb [aria-current=page] { color: #ffffff !important; }

/* ==========================================================================
   ธีมสว่าง: ของตกแต่งเทศกาลที่ลอยบนพื้นหลัง (หิมะคริสต์มาส ดาวปีใหม่ หยดน้ำสงกรานต์ ฯลฯ ใน layouts/loykrathong.php)
   สีเดิมเป็นสีอ่อน/ขาวสำหรับพื้นมืด บนพื้นสว่างเลยมองไม่เห็น: ทำให้สีเข้มขึ้นและมีเงาขอบ
   ตอนที่มีฉากเทศกาลเป็นพื้นหลัง (pl-theme-scene = ภาพมืด) ไม่ต้องปรับ
   ========================================================================== */
html[data-theme="light"]:not(.pl-theme-scene) .pl-festival-float svg {
    filter: brightness(0.78) saturate(1.5) drop-shadow(0 0 1px rgba(15, 23, 42, 0.55)) drop-shadow(0 2px 4px rgba(15, 23, 42, 0.3)) !important;
}
html[data-theme="light"]:not(.pl-theme-scene) .pl-festival-ember {
    filter: brightness(0.8) saturate(1.6);
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.22), 0 1px 5px rgba(15, 23, 42, 0.3);
}
/* หิมะคริสต์มาสเป็นเส้นสีขาวฟ้า ปรับเป็นฟ้าเข้มให้เห็นชัด */
html[data-theme="light"]:not(.pl-theme-scene) .pl-festival-float svg [stroke="#e3f6ff"] { stroke: #5b9bd5; }
html[data-theme="light"]:not(.pl-theme-scene)[data-pl-festival-theme="christmas"] { --pl-festival-accent: #7fb5e0 !important; }
