/* ธีม "Midnight & Champagne" – ดำลึก + ทองแชมเปญ (มืด/สว่างสลับได้)
   ปิดธีม: ลบบรรทัด <link ... theme.css> ใน index.html  */

:root {
  color-scheme: dark;
  --bg: #0c0e13; --surface: #14171f; --surface2: #1b1f2a; --track: rgba(255,255,255,.09);
  --line: rgba(255,255,255,.09); --line-strong: rgba(255,255,255,.18);
  --text: #f1ede4; --muted: #9aa0ab; --muted2: #6f7581;
  --accent: #cdb07a; --accent-h: #dcc391; --on-accent: #15120a; --accent-bg: rgba(205,176,122,.13);
  --header: #090b0f;
  --danger: #ef8b82; --ok: #7fcaa2; --warn: #e8b86a; --info: #9db4e8;
  --danger-bg: rgba(239,139,130,.14); --ok-bg: rgba(127,202,162,.14); --warn-bg: rgba(232,184,106,.15); --info-bg: rgba(157,180,232,.13);
  --danger-solid: #c9534a; --ok-solid: #3e8f6a;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) { color-scheme: light; --bg:#f5f2ec; --surface:#ffffff; --surface2:#f0ece3; --track:#e6e1d5; --line:#e4dfd3; --line-strong:#cfc8b8;
    --text:#181a20; --muted:#666b76; --muted2:#8d919b; --accent:#9c7a35; --accent-h:#876829; --on-accent:#ffffff; --accent-bg:rgba(156,122,53,.11);
    --danger:#b9473f; --ok:#2f7d59; --warn:#9a6410; --info:#3b5fa8;
    --danger-bg:rgba(185,71,63,.10); --ok-bg:rgba(47,125,89,.10); --warn-bg:rgba(154,100,16,.11); --info-bg:rgba(59,95,168,.09);
    --danger-solid:#b9473f; --ok-solid:#2f7d59; --shadow:0 1px 2px rgba(20,22,28,.06), 0 8px 24px -12px rgba(20,22,28,.12); }
}
:root[data-theme="light"] { color-scheme: light; --bg:#f5f2ec; --surface:#ffffff; --surface2:#f0ece3; --track:#e6e1d5; --line:#e4dfd3; --line-strong:#cfc8b8;
  --text:#181a20; --muted:#666b76; --muted2:#8d919b; --accent:#9c7a35; --accent-h:#876829; --on-accent:#ffffff; --accent-bg:rgba(156,122,53,.11);
  --danger:#b9473f; --ok:#2f7d59; --warn:#9a6410; --info:#3b5fa8;
  --danger-bg:rgba(185,71,63,.10); --ok-bg:rgba(47,125,89,.10); --warn-bg:rgba(154,100,16,.11); --info-bg:rgba(59,95,168,.09);
  --danger-solid:#b9473f; --ok-solid:#2f7d59; --shadow:0 1px 2px rgba(20,22,28,.06), 0 8px 24px -12px rgba(20,22,28,.12); }

/* ---------- พื้นฐาน ---------- */
html body { font-family: 'IBM Plex Sans Thai', 'Noto Sans Thai', system-ui, sans-serif; letter-spacing: .005em; }
html body.bg-slate-100 { background: var(--bg); color: var(--text); }
body * { border-color: var(--line); }
body h1, body h2, body h3, body .text-2xl, body .text-xl, body .text-lg { font-family: 'Prompt', 'IBM Plex Sans Thai', sans-serif; letter-spacing: .01em; }
body h1, body h2, body h3 { font-weight: 400; }
body .text-2xl { font-weight: 300; font-size: 1.9rem; line-height: 1.15; letter-spacing: -.01em; }
body .font-bold, body b { font-weight: 500; }
body ::selection { background: var(--accent); color: var(--on-accent); }
body ::-webkit-scrollbar { width: 10px; height: 10px; }
body ::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 10px; }

/* ---------- พื้นผิว / การ์ด ---------- */
body .bg-white { background: var(--surface); color: var(--text); }
body .bg-slate-50, body .hover\:bg-slate-50:hover { background: var(--surface2); }
body .bg-slate-100 { background: var(--track); }
body .bg-slate-200 { background: var(--line-strong); color: var(--text); }
body .shadow { box-shadow: var(--shadow); border: 1px solid var(--line); }
body .rounded-xl { border-radius: 18px; }
body .rounded-lg { border-radius: 14px; }
body .rounded { border-radius: 10px; }
body .border { border-color: var(--line); }
body .border-b, body .border-t { border-color: var(--line); }
body .divide-y > * + * { border-color: var(--line); }
body table thead { background: transparent; }
body .text-slate-500 { color: var(--muted); }

/* ---------- ฟอร์ม ---------- */
body input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=range]), body select, body textarea {
  background: var(--surface2); color: var(--text); border: 1px solid var(--line); border-radius: 10px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
body input::placeholder, body textarea::placeholder { color: var(--muted2); }
body input:focus, body select:focus, body textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
body input[type=checkbox], body input[type=radio] { accent-color: var(--accent); }
body input:disabled, body select:disabled, body textarea:disabled, body .disabled\:bg-slate-100:disabled { background: var(--track); color: var(--muted2); }
body input[type=file]::file-selector-button { background: var(--surface2); color: var(--text); border: 1px solid var(--line-strong); border-radius: 999px; padding: 4px 12px; margin-right: 10px; }

/* ---------- ปุ่ม ---------- */
body button { transition: background-color .15s, transform .08s, opacity .15s; }
body button:active:not(:disabled) { transform: scale(.98); }
body .bg-blue-600, body .bg-blue-700 { background: var(--accent); color: var(--on-accent); font-weight: 500; }
body .bg-blue-600:hover:not(:disabled) { background: var(--accent-h); }
body .bg-green-600 { background: var(--ok-solid); color: #fff; }
body .bg-red-600 { background: var(--danger-solid); color: #fff; }
body .bg-slate-600 { background: var(--surface2); color: var(--text); border: 1px solid var(--line-strong); }
body .bg-yellow-500 { background: var(--warn); color: #15120a; }
body .bg-orange-500 { background: var(--warn); color: #15120a; }
body button.rounded.px-2, body button.rounded.px-3, body button.rounded.px-4 { border-radius: 999px; }
body button:disabled { opacity: .45; cursor: not-allowed; }
body .text-blue-700, body .text-blue-800 { color: var(--accent); }
body a { color: var(--accent); }

/* ---------- แถบหัว/เมนู ---------- */
body header, body header.bg-blue-700 { background: var(--header); color: #f1ede4; border-bottom: 1px solid rgba(255,255,255,.08); }
body header .font-bold { font-family: 'Prompt', sans-serif; font-weight: 300; letter-spacing: .22em; text-transform: uppercase; }
body header select { background: rgba(255,255,255,.07); color: #f1ede4; border-color: rgba(255,255,255,.14); color-scheme: dark; }
body header select option { background: #14171f; color: #f1ede4; }
body header button.bg-blue-600 { background: transparent; color: #a8adb8; }
body header button.bg-blue-600:hover { color: #f1ede4; background: rgba(255,255,255,.06); }
body header button.bg-white { background: var(--accent); color: var(--on-accent); font-weight: 500; }
body header nav button { border-radius: 999px; padding-left: 14px; padding-right: 14px; }
body header a, body header .underline { color: #cdb07a; }

@media (max-width: 520px) {
  body header select { max-width: 7.5rem; }
  body header .font-bold { letter-spacing: .08em; font-size: .8rem; }
  body header .theme-toggle { width: 30px; height: 30px; }
}

/* ---------- ป้ายสถานะ / สีเชิงความหมาย (ปรับโทนให้นุ่ม) ---------- */
body .text-red-600, body .text-red-700, body .text-red-800 { color: var(--danger); }
body .text-green-600, body .text-green-700 { color: var(--ok); }
body .text-orange-600, body .text-orange-700, body .text-orange-800 { color: var(--warn); }
body .text-yellow-500, body .text-yellow-600 { color: var(--accent); }
body .text-sky-800 { color: var(--info); }
body .text-slate-300 { color: var(--line-strong); }
body .text-slate-400 { color: var(--muted2); }
body .text-slate-600 { color: var(--muted); }
body .text-slate-800 { color: var(--text); }
body .text-white { color: #fff; }

body .bg-red-50, body .bg-red-100, body .bg-red-200 { background: var(--danger-bg); color: var(--danger); }
body .bg-orange-50, body .bg-orange-100 { background: var(--warn-bg); color: var(--warn); }
body .bg-amber-50, body .bg-yellow-100 { background: var(--warn-bg); }
body .bg-green-50, body .bg-green-100 { background: var(--ok-bg); color: var(--ok); }
body .bg-blue-50, body .bg-blue-100 { background: var(--info-bg); color: var(--info); }
body .bg-indigo-100 { background: var(--accent-bg); color: var(--accent); }
body .bg-sky-50, body .bg-sky-100 { background: var(--info-bg); color: var(--info); }
body .border-amber-200, body .border-sky-200, body .border-blue-200, body .border-green-200 { border-color: var(--line-strong); }
body .border-blue-300, body .border-blue-600 { border-color: var(--accent); }
body .hover\:ring-2:hover, body .ring-blue-300 { --tw-ring-color: var(--accent); }
body .bg-red-200.text-red-800 { background: var(--danger-bg); }

/* แท่งกราฟ */
body .bg-blue-500 { background: var(--accent); }
body .bg-green-500 { background: var(--ok); }
body .bg-red-500 { background: var(--danger); }
body .bg-indigo-500 { background: #8f95b5; }

/* กล่องประเด็นที่ควรดู (พื้นเหลือง) ให้เป็นการ์ดทองอ่อน */
body .bg-amber-50.border { background: var(--accent-bg); border-color: var(--accent); }
body .bg-amber-50 li { color: var(--text); }

/* แถบแจ้งข้อผิดพลาดลอย */
body .fixed.bg-red-600 { background: var(--danger-solid); box-shadow: 0 12px 30px -10px rgba(0,0,0,.5); border-radius: 14px; }

/* หน้าล็อกอิน */
body form.bg-white.max-w-sm { border-radius: 24px; padding: 34px 30px; }
body form.bg-white.max-w-sm h1 { font-weight: 300; letter-spacing: .08em; font-size: 1.4rem; }

/* รูปโปรไฟล์/รูปแนบ */
body img.rounded-full, body img.rounded { border-color: var(--line-strong); }

/* ภาษา: ปุ่มเลือก / ฟอนต์พม่า */
body .lang-btn { background: var(--accent); color: var(--on-accent); border: 0; cursor: pointer; }
body .lang-btn:hover { background: var(--accent-h); }
body .lang-switch button { font-size: .8rem; padding: .25rem .8rem; border-radius: 999px; border: 1px solid var(--line-strong); background: transparent; color: var(--muted); cursor: pointer; }
body .lang-switch button.on { background: var(--accent-bg); color: var(--accent); border-color: var(--accent); }
body .lang-select { background: rgba(255,255,255,.07); color: #f1ede4; border: 1px solid rgba(255,255,255,.14); border-radius: 999px; padding: .2rem .6rem; color-scheme: dark; }
body .lang-select option { background: #14171f; color: #f1ede4; }
html[lang="my"] body, html[lang="my"] body * { font-family: 'Noto Sans Myanmar', 'Myanmar Text', 'Padauk', sans-serif; letter-spacing: 0; }
html[lang="my"] body { line-height: 1.75; }
html[lang="my"] body header .font-bold, html[lang="my"] body .pomec-word { font-family: 'Prompt', sans-serif; letter-spacing: .3em; }

/* โลโก้ POMEC */
body .pomec-mark { color: var(--accent); }
body header .pomec-mark { color: #cdb07a; }
body form.bg-white.max-w-sm h1.pomec-word { font-family: 'Prompt', sans-serif; font-weight: 300; font-size: 1.7rem; letter-spacing: .42em; margin-left: .42em; line-height: 1.2; }
body .pomec-sub { font-size: .66rem; letter-spacing: .12em; color: var(--muted); white-space: nowrap; }

/* โลโก้ภาพ (ป้ายวงกลมแจ้งซ่อม) */
body .app-badge { width: 150px; height: 150px; object-fit: contain; filter: drop-shadow(0 6px 14px rgba(0,0,0,.35)); }
body .app-badge-sm { width: 40px; height: 40px; object-fit: contain; }

/* ปุ่มสลับธีม */
body .theme-toggle { width: 34px; height: 34px; border-radius: 50%; border: 1px solid rgba(255,255,255,.18); background: transparent; color: #f1ede4; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
body .theme-toggle:hover { background: rgba(255,255,255,.08); }

/* ---------- ระบบฝึกอบรม: ธีมเขียวมรกต + แถบเตือนส้ม เพื่อไม่ให้สับสนกับระบบจริง (สีทองแชมเปญ) ---------- */
:root[data-mode="training"] { --accent: #4fd1a5; --accent-h: #6fe0b9; --on-accent: #04140e; --accent-bg: rgba(79,209,165,.14); --header: #06261c; }
:root[data-mode="training"][data-theme="light"] { --accent: #0f8a68; --accent-h: #0b7156; --on-accent: #ffffff; --accent-bg: rgba(15,138,104,.11); --header: #0b3d2e; --bg: #eef5f1; --surface2: #e6efe9; }
@media (prefers-color-scheme: light) {
  :root[data-mode="training"]:not([data-theme]) { --accent: #0f8a68; --accent-h: #0b7156; --on-accent: #ffffff; --accent-bg: rgba(15,138,104,.11); --header: #0b3d2e; --bg: #eef5f1; --surface2: #e6efe9; }
}
html[data-mode="training"] body header.bg-indigo-700 { background: #0a3b47; } /* โหมด IT ของระบบฝึกอบรม = เขียวน้ำเงิน (ต่างจากม่วงครามของระบบจริง) */
html[data-mode="training"] body header a, html[data-mode="training"] body header .underline { color: #8ee8c6; }
html[data-mode="training"] body::before {
  content: '🎓 ระบบฝึกอบรม — ข้อมูลตัวอย่าง ไม่ใช่ข้อมูลจริง · ไม่มีการส่งอีเมล/Telegram';
  display: block; text-align: center; font-weight: 600; font-size: .8rem; letter-spacing: .02em; padding: 5px 8px; color: #1a1200;
  background: repeating-linear-gradient(45deg, #f5b942, #f5b942 14px, #e0a02a 14px, #e0a02a 28px);
}

/* ---------- หน้ารายการงาน 2 ฝั่ง: พื้นหลังต่างสีแบบบาง ๆ ให้แยกแจ้งซ่อม (ฟ้า) กับ PM วันนี้ (เหลืองอำพัน) ชัดเจน ---------- */
body .col-panel { border-radius: 20px; padding: 14px; border: 1px solid transparent; border-top-width: 3px; }
body .col-repair { background: rgba(96,150,235,.08); border-color: rgba(96,150,235,.22); border-top-color: rgba(96,150,235,.75); }
body .col-pm     { background: rgba(240,170,60,.08);  border-color: rgba(240,170,60,.24);  border-top-color: rgba(240,170,60,.80); }
body .col-repair .col-title { color: #7fa8f0; }
body .col-pm .col-title     { color: #eab25a; }
:root[data-theme="light"] body .col-repair { background: rgba(60,110,210,.07); }
:root[data-theme="light"] body .col-pm     { background: rgba(214,140,20,.09); }
:root[data-theme="light"] body .col-repair .col-title { color: #2f5fc0; }
:root[data-theme="light"] body .col-pm .col-title     { color: #a86a08; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) body .col-repair { background: rgba(60,110,210,.07); }
  :root:not([data-theme]) body .col-pm     { background: rgba(214,140,20,.09); }
  :root:not([data-theme]) body .col-repair .col-title { color: #2f5fc0; }
  :root:not([data-theme]) body .col-pm .col-title     { color: #a86a08; }
}
