/* assets/css/dark.css
   โหมดมืด (เปิดจากเมนูบัญชี → โหมดมืด) ใช้ html[data-theme="dark"]
   ปรับตัวแปรสีหลัก + พื้นผิวที่ใช้สีขาวตรง ๆ ในหน้าที่ใช้บ่อยบนมือถือ */
html[data-theme="dark"] {
    color-scheme: dark;
    --bg-main: #0b1220;
    --card-bg: #111a2b;
    --card-border: #1f2b40;
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --text-light: #64748b;
    --input-text: #bae6fd;
    --input-placeholder: #64748b;
    --primary-light: #0c2a43;
    --success-light: #0f2f25;
    --warning-light: #3a2a0a;
    --danger-light: #3b1515;
    --purple-light: #2a2145;
    --dk-surface: #111a2b;
    --dk-surface-2: #16223a;
    --dk-line: #1f2b40;
}

html[data-theme="dark"] body { background: var(--bg-main); color: var(--text-main); }

/* ---------- พื้นผิวหลัก ---------- */
html[data-theme="dark"] :is(.card, .settings-card, .sidebar, .top-bar, .stat-card, .catalog-dialog, .user-selector-wrapper,
    .inbox-item, .inbox-empty, .schedule-shift, .schedule-mine, .schedule-day, .schedule-stat, .schedule-nav-btn, .schedule-nav-label,
    .swap-card, .push-status, .m-sheet-list, .m-sheet-item, .m-more-item, .m-sheet-danger, .m-ptr, .pwa-install-banner, .travel-hospital, .travel-trip) {
    background: var(--dk-surface) !important;
    border-color: var(--dk-line) !important;
    color: var(--text-main);
}
html[data-theme="dark"] :is(.swap-flow > div, .schedule-day-names span, .inbox-step, .m-sheet-icon, .schedule-badge, .swap-status, .travel-bar) { background: var(--dk-surface-2); color: var(--text-muted); }
html[data-theme="dark"] [style*="background:#ffffff"], html[data-theme="dark"] [style*="background: #ffffff"],
html[data-theme="dark"] [style*="background:#fff;"], html[data-theme="dark"] [style*="background: #fff;"] { background: var(--dk-surface) !important; }
html[data-theme="dark"] [style*="color:var(--text-main)"] { color: var(--text-main) !important; }

/* ---------- ฟอร์ม/ปุ่ม/ตาราง ---------- */
html[data-theme="dark"] :is(.form-control, .form-select, input, select, textarea) { background: var(--dk-surface-2) !important; border-color: var(--dk-line) !important; color: var(--text-main) !important; }
html[data-theme="dark"] .btn-outline { background: transparent; border-color: #334155; color: var(--text-main); }
html[data-theme="dark"] .btn-outline:hover { background: var(--dk-surface-2); }
html[data-theme="dark"] .custom-table th { background: var(--dk-surface-2); color: var(--text-muted); border-color: var(--dk-line); }
html[data-theme="dark"] .custom-table td { border-color: var(--dk-line); }
html[data-theme="dark"] .custom-table tr:hover td { background: var(--dk-surface-2); }
html[data-theme="dark"] .m-cards tbody tr { background: var(--dk-surface); border-color: var(--dk-line); }
html[data-theme="dark"] .m-cards tbody td + td { border-top-color: var(--dk-line) !important; }
html[data-theme="dark"] .inbox-tabs, html[data-theme="dark"] .guide-tabs { background: #0f1a2c; }
html[data-theme="dark"] .inbox-tab.active { background: var(--dk-surface-2); color: #7dd3fc; }
html[data-theme="dark"] .inbox-tab { color: var(--text-muted); }

/* ---------- เปลือกแอปมือถือ ---------- */
html[data-theme="dark"] .m-appbar, html[data-theme="dark"] .m-tabbar { background: rgb(11 18 32 / 86%); border-color: var(--dk-line); }
html[data-theme="dark"] .m-tab.active { color: #7dd3fc; }
html[data-theme="dark"] .m-tab.active .m-tab-icon { background: #0c2a43; }
html[data-theme="dark"] .m-sheet[open] { background: #0b1220; }
html[data-theme="dark"] .m-sheet-close { background: var(--dk-surface-2); color: var(--text-main); }
html[data-theme="dark"] .m-avatar { box-shadow: 0 0 0 3px #0b1220, 0 0 0 4px rgb(56 189 248 / 35%); }
html[data-theme="dark"] .m-appbar-logo { background: #fff; }

/* ---------- รายละเอียดเฉพาะหน้า ---------- */
html[data-theme="dark"] .inbox-item.unread { background: #0c2238 !important; border-color: #0e4a6e !important; }
html[data-theme="dark"] .inbox-item-text, html[data-theme="dark"] .swap-reason, html[data-theme="dark"] .travel-hospital-stats { color: #cbd5e1; }
html[data-theme="dark"] .schedule-person.me { background: color-mix(in srgb, var(--sch) 22%, #111a2b); }
html[data-theme="dark"] .schedule-person-avatar, html[data-theme="dark"] .schedule-shift-icon { background: color-mix(in srgb, var(--sch) 25%, #111a2b); }
html[data-theme="dark"] .schedule-next { background: #3a2a0a; color: #fcd34d; }
html[data-theme="dark"] .schedule-day-names span.me { background: var(--sch); color: #fff; }
html[data-theme="dark"] .swap-card.actionable { box-shadow: 0 0 0 2px #0e4a6e; }
html[data-theme="dark"] .swap-status.wait { background: #3a2a0a; color: #fcd34d; }
html[data-theme="dark"] .swap-status.ok, html[data-theme="dark"] .inbox-step.done, html[data-theme="dark"] .schedule-badge.on { background: #0f2f25; color: #6ee7b7; }
html[data-theme="dark"] .swap-status.no, html[data-theme="dark"] .inbox-step.fail { background: #3b1515; color: #fca5a5; }
html[data-theme="dark"] .travel-map { background: #0c2a43; color: #7dd3fc; }
html[data-theme="dark"] .settings-message { background: var(--dk-surface-2); }
html[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #334155; }
