/* ตัวแปรสีกลางของศูนย์ควบคุม (ชุด C ใน design/system/palette.json) · เพิ่มเฉพาะชื่อ --color-* ไม่ทับตัวแปรเดิมของแต่ละหน้า */
:root {
  --color-primary: #8b5cf6;
  --color-primary-rgb: 139, 92, 246; /* ใช้ทำสีโปร่งใส: rgba(var(--color-primary-rgb), .16) · แก้คู่กับ --color-primary */
  --color-secondary: #16a34a;
  --color-accent: #00d9c0;
  --color-bg-light: #f1eff8;
  --color-bg-dark: #0b0918;
  --color-text-light: #111114;
  --color-text-dark: #f4f1ff;
  --color-primary-text: #6d28d9;
  --color-ok: #16a34a;
  --color-warn: #f59e0b;
  --color-bad: #dc2626;
  --color-icon: var(--color-primary-text);
}
:root[data-theme="dark"] { --color-icon: #c4b5fd; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --color-icon: #c4b5fd; } }

/* ตัวแปรโหมดสว่าง/มืดกลาง (--tm-*) · หน้าที่ยังใช้สีฮาร์ดโค้ดผูกด้วย var(--tm-bg, สีเดิม) ได้ */
:root, :root[data-theme="light"] { --tm-bg: var(--color-bg-light); --tm-text: var(--color-text-light); --tm-card: rgba(255,255,255,.92); --tm-line: rgba(27,22,64,.12); }
:root[data-theme="dark"] { --tm-bg: var(--color-bg-dark); --tm-text: var(--color-text-dark); --tm-card: rgba(30,28,44,.92); --tm-line: rgba(255,255,255,.14); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --tm-bg: var(--color-bg-dark); --tm-text: var(--color-text-dark); --tm-card: rgba(30,28,44,.92); --tm-line: rgba(255,255,255,.14); } }

/* ปุ่มสลับโหมดลอยมุมขวาล่าง (ใส่ให้อัตโนมัติโดย theme.js เฉพาะหน้าที่ยังไม่มีปุ่ม #theme-btn) */
.tm-fab { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 60; width: 44px; height: 44px; display: grid; place-items: center; padding: 0; border-radius: 999px; border: 1px solid var(--tm-line); background: var(--tm-card); color: var(--tm-text); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: 0 6px 18px rgba(0,0,0,.18); cursor: pointer; }
.tm-fab:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.tm-fab .icon { stroke: currentColor; width: 22px; height: 22px; }
@media (prefers-reduced-motion: no-preference) {
  .tm-fab { transition: transform .15s ease; }
  .tm-fab:active { transform: scale(.92); }
  .tm-fab.tm-swap .icon { animation: tm-swap .45s cubic-bezier(.34,1.4,.64,1); }
}
@keyframes tm-swap { from { transform: rotate(-90deg) scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }

/* FAB สลับธีมแบบเต็ม (theme.js ใส่คลาส theme-toggle-fab ให้ปุ่มที่สร้างเอง): 48px พื้นไล่เฉดม่วง-เขียว ไอคอนขาว ripple ตอนกด หมุน 180° ตอนสลับ */
.tm-fab.theme-toggle-fab { width: 48px; height: 48px; overflow: hidden; border: 0; background: linear-gradient(135deg, #7c3aed, var(--color-primary) 55%, #0f9b8e); color: #fff; box-shadow: 0 8px 22px rgba(var(--color-primary-rgb), .42); touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.tm-fab.theme-toggle-fab .icon { position: relative; stroke: #fff; }
.tm-fab.theme-toggle-fab::after { content: ""; position: absolute; left: var(--rx, 50%); top: var(--ry, 50%); width: 96px; height: 96px; margin: -48px 0 0 -48px; border-radius: 50%; background: rgba(255,255,255,.45); transform: scale(0); opacity: 0; pointer-events: none; }
@media (prefers-reduced-motion: no-preference) {
  .tm-fab.theme-toggle-fab.tm-swap .icon { animation: tm-spin180 .5s cubic-bezier(.34,1.4,.64,1); }
  .tm-fab.theme-toggle-fab.tm-rip::after { animation: tm-ripple .55s ease-out; }
}
@keyframes tm-spin180 { from { transform: rotate(-180deg) scale(.5); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes tm-ripple { from { transform: scale(0); opacity: .9; } to { transform: scale(1.6); opacity: 0; } }

/* tooltip บอกโหมดปัจจุบัน (ข้อความจาก data-tip ที่ theme.js ตั้งให้ปุ่มธีมลอย #theme-fab / .tm-fab) · โชว์ตอนชี้หรือโฟกัสด้วยคีย์บอร์ด */
.tooltip-fab { position: fixed; z-index: 62; right: 16px; bottom: 70px; padding: 6px 10px; border-radius: 12px; border: 1px solid var(--tm-line); background: var(--tm-card); color: var(--tm-text); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: 0 6px 18px rgba(0,0,0,.18); font: 500 12px/1.4 'Noto Sans Thai', sans-serif; white-space: nowrap; pointer-events: none; opacity: 0; visibility: hidden; }
.tooltip-fab.show { opacity: 1; visibility: visible; }
@media (prefers-reduced-motion: no-preference) { .tooltip-fab { transition: opacity .15s ease, visibility .15s; } }
@media print { .tooltip-fab { display: none; } }

/* สลับธีมแบบนุ่ม: เปิดคลาส tm-anim แค่ ~0.4 วินาทีตอนกดสลับ (theme.js) ไม่ทำให้หน้ากระตุกตอนใช้งานปกติ */
@media (prefers-reduced-motion: no-preference) {
  html.tm-anim, html.tm-anim *:not(canvas) { transition: background-color .3s ease, color .3s ease, border-color .3s ease, fill .3s ease, stroke .3s ease !important; }
}

/* มินิแมปผังออฟฟิศ (office-iso) */
#miniMap { position: fixed; left: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 6; width: 150px; height: 100px; border-radius: 16px; border: 1px solid var(--tm-line); background: var(--tm-card); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: 0 6px 18px rgba(0,0,0,.18); touch-action: none; cursor: pointer; }
@media (min-width: 900px) { #miniMap { width: 210px; height: 140px; } }

/* ไอคอน SVG เส้นเดียวสีเดียว แทนอีโมจิสี */
.icon { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; fill: none; stroke: var(--color-icon); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
