/*
  Mobile Version — คณะทันตแพทยศาสตร์ มข.
  ต้องโหลดต่อจาก tokens.css และ components.css
  ส่วนที่ 1 คัดมาจาก src/views/mobile/MobileApp.vue (โครงแอป)
  ส่วนที่ 2 คือรูปแบบที่ใช้ซ้ำในหน้าย่อยของมือถือ รวมเป็นคลาสกลางชุดเดียว
*/

/* ================= ส่วนที่ 1: โครงแอป ================= */
/* ธีมม่วง = สีเดียวกับเมนูด้านข้างของเดสก์ท็อป (#8645AA) — override เฉพาะในแอปมือถือ */
.m-app {
  --primary: #8645aa;
  --primary-hover: #74399a;
  --primary-active: #632f85;
  --primary-subtle: color-mix(in srgb, #8645aa 12%, white);
  --primary-ink: #ffffff;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  max-width: 560px;
  margin: 0 auto;
  position: relative;
}
.m-head { position: sticky; top: 0; z-index: 30; background: var(--sidebar-bg); box-shadow: 0 2px 8px rgba(15, 23, 42, 0.25); }
.m-top { display: flex; align-items: center; gap: 10px; padding: 10px 14px 12px; color: var(--sidebar-ink); }
.m-top__logo { height: 30px; width: auto; flex-shrink: 0; }
.m-top__txt { flex: 1; min-width: 0; }
.m-top__title { font-weight: 700; font-size: 0.98rem; line-height: 1.2; }
.m-top__sub { font-size: 0.7rem; opacity: 0.9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-top__img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 50%; }
.m-top__avatar { overflow: hidden; padding: 0; width: 36px; height: 36px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.6); background: rgba(255, 255, 255, 0.18); color: #fff; font-weight: 700; font-size: 0.95rem; cursor: pointer; font-family: inherit; flex-shrink: 0; }
/* เมนู header (แนวเดียวกับ e-MAR): แถบชื่อระบบสีม่วง + แผงเมนูสีม่วงอ่อน ขอบล่างโค้ง ไอคอนเส้นสีม่วงเข้ม ไม่มีกล่อง */
.m-head { background: #8645aa; border-radius: 0 0 24px 24px; }
.m-hmenu { position: relative; z-index: 1; background: linear-gradient(180deg, #f1e6f8 0%, #e6d5f2 100%); border-radius: 0 0 24px 24px; padding: 10px 8px 14px; box-shadow: 0 6px 14px rgba(70, 25, 100, 0.25); }
.m-hmenu__grid { display: grid; gap: 2px; }
.m-hm { position: relative; display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 5px 2px; border: 0; background: transparent; color: #5e2f7c; cursor: pointer; font-family: inherit; border-radius: 12px; }
.m-hm__ico { position: relative; display: inline-flex; line-height: 1; }
.m-hm__l { font-size: 0.66rem; line-height: 1.25; text-align: center; font-weight: 700; max-width: 76px; }
.m-hm:active { background: rgba(134, 69, 170, 0.14); }
.m-hm--on { background: rgba(134, 69, 170, 0.16); color: #4a2266; }
.m-hm .m-badge { top: -5px; right: -9px; box-shadow: 0 0 0 2px #ecdff6; }
.m-body { flex: 1; padding: 16px 12px 96px; display: flex; flex-direction: column; gap: 12px; }
/* เมนูล่าง: 5 ปุ่ม ปุ่มสแกน QR อยู่กลางและนูนขึ้น */
.m-tabs { position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 560px; z-index: 30; display: flex; align-items: flex-end; justify-content: space-around; background: var(--surface); border-top: 1px solid var(--border); border-radius: 18px 18px 0 0; box-shadow: 0 -4px 14px rgba(15, 23, 42, 0.1); padding: 4px 4px calc(6px + env(safe-area-inset-bottom, 0px)); }
.m-tabs__i { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 2px 3px; border: 0; background: transparent; color: var(--muted); font-size: 0.66rem; font-weight: 500; cursor: pointer; font-family: inherit; border-radius: 12px; }
.m-tabs__i--on { color: var(--primary); font-weight: 700; }
.m-tabs__ico { position: relative; display: inline-flex; line-height: 1; }
.m-tabs__scan { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; border: 0; background: transparent; cursor: pointer; font-family: inherit; padding: 0 2px 3px; margin-top: -26px; }
.m-tabs__scanbtn { width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--primary); color: #fff; border: 4px solid var(--surface); box-shadow: 0 4px 12px rgba(134, 69, 170, 0.45); }
.m-tabs__scanl { font-size: 0.66rem; font-weight: 700; color: var(--primary); }
.m-badge { position: absolute; top: -4px; right: -6px; min-width: 17px; padding: 0 4px; border-radius: 9px; background: #991b1b; color: #fff; font-size: 0.64rem; font-weight: 700; line-height: 17px; text-align: center; box-shadow: 0 0 0 2px #fff; }
.m-sheet-bg { position: fixed; inset: 0; z-index: 60; background: rgba(15, 23, 42, 0.5); display: flex; align-items: flex-end; justify-content: center; }
.m-sheet { width: 100%; max-width: 560px; background: var(--surface); border-radius: 16px 16px 0 0; padding: 14px 14px 22px; max-height: 88vh; overflow-y: auto; }
.m-sheet__h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.m-app .mbtn { width: 100%; justify-content: center; padding: 11px 14px; font-size: 0.92rem; }
.m-app .m-sec { font-weight: 700; font-size: 0.86rem; color: var(--ink); margin: 2px 2px -4px; }
.m-app .m-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.m-app .m-seg { display: flex; gap: 6px; flex-wrap: wrap; }
.m-app .m-seg__i { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); font-size: 0.8rem; cursor: pointer; color: var(--ink-soft); }
.m-app .m-seg__i--on { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }

/* ================= ส่วนที่ 2: รูปแบบที่ใช้ซ้ำในหน้าย่อย ================= */

/* การ์ดเด่น (hero) ไล่เฉดม่วง — ใช้ได้หน้าละ 1 ใบ บนสุดของหน้า */
.m-hero { display: flex; align-items: center; gap: 12px; background: linear-gradient(135deg, #8645aa, #6b3589); color: #fff; border-radius: 16px; padding: 14px 16px; box-shadow: 0 4px 14px rgba(134, 69, 170, 0.3); }
.m-hero__ico { width: 46px; height: 46px; border-radius: 14px; background: rgba(255, 255, 255, 0.22); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.m-hero__main { flex: 1; min-width: 0; }
.m-hero__t { font-weight: 800; font-size: 1rem; }
.m-hero__s { font-size: 0.72rem; opacity: 0.92; margin-top: 2px; line-height: 1.4; }
.m-hero__n { font-size: 1.8rem; font-weight: 800; line-height: 1; }
.m-hero__pill { background: rgba(255, 255, 255, 0.2); padding: 2px 10px; border-radius: 999px; font-size: 0.7rem; font-weight: 600; }

/* ตัวเลขสรุป (KPI) */
.m-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.m-kpi { text-align: center; cursor: pointer; padding: 10px 6px; }
.m-kpi__n { font-size: 1.5rem; font-weight: 800; color: var(--primary); line-height: 1.1; }
.m-kpi__n--hot { color: #991b1b; }
.m-kpi__l { font-size: 0.7rem; color: var(--muted); margin-top: 3px; }

/* แท็บแบบเม็ดยา (ตัวกรองในหน้า) */
.m-pills { display: flex; gap: 4px; background: var(--primary-subtle); border-radius: 999px; padding: 3px; width: fit-content; max-width: 100%; overflow-x: auto; }
.m-pill { border: 0; background: transparent; padding: 6px 12px; border-radius: 999px; font-family: inherit; font-size: 0.72rem; font-weight: 600; color: var(--primary); cursor: pointer; display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.m-pill--on { background: var(--primary); color: #fff; box-shadow: 0 2px 6px rgba(134, 69, 170, 0.35); }
.m-pill__n { font-size: 0.62rem; background: rgba(134, 69, 170, 0.18); border-radius: 9px; padding: 0 6px; line-height: 15px; }
.m-pill--on .m-pill__n { background: rgba(255, 255, 255, 0.28); }

/* รายการเอกสาร/แจ้งเตือน — แถบสีซ้ายและไอคอนบอกประเภทด้วย --acc / --acc-bg */
.m-item { --acc: #8645aa; --acc-bg: #f0e4f7; text-align: left; font-family: inherit; width: 100%; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--acc); border-radius: 16px; padding: 12px 14px; cursor: pointer; display: flex; flex-direction: column; gap: 9px; box-shadow: 0 2px 10px rgba(70, 25, 100, 0.07); }
.m-item:active { background: var(--primary-subtle); }
.m-item--blue { --acc: #1d4ed8; --acc-bg: #dbeafe; }   /* เบิกวัสดุ */
.m-item--amber { --acc: #d97706; --acc-bg: #fef3c7; }  /* ซื้อ/จ้าง */
.m-item--green { --acc: #15803d; --acc-bg: #dcfce7; }  /* รับของ / อนุมัติ */
.m-item__top { display: flex; align-items: center; gap: 10px; }
.m-item__ico { width: 38px; height: 38px; border-radius: 12px; background: var(--acc-bg); color: var(--acc); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.m-item__id { flex: 1; min-width: 0; }
.m-item__no { font-weight: 800; font-size: 0.96rem; color: var(--ink); line-height: 1.2; }
.m-item__kind { font-size: 0.68rem; color: var(--muted); }
.m-item__foot { display: flex; justify-content: space-between; gap: 8px; border-top: 1px dashed var(--border); padding-top: 7px; font-size: 0.7rem; color: var(--muted); }

/* สถานะว่าง */
.m-empty { text-align: center; color: var(--muted); font-size: 0.86rem; padding: 34px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; }

/* ช่องกรอกและปุ่มใน bottom sheet — เป้าสัมผัสสูง 42-44px */
.m-app .m-sheet .inp, .m-sheet .inp { height: 42px; font-size: 0.9rem; border-radius: 12px; width: 100%; }
.m-sheet__foot { display: grid; grid-template-columns: 1fr 1.7fr; gap: 10px; padding-top: 12px; }
.m-sheet__foot .btn { height: 44px; font-size: 0.92rem; font-weight: 700; border-radius: 12px; }
.m-sheet__foot .btn--p { background: linear-gradient(135deg, #8645aa, #6b3589); border-color: #8645aa; box-shadow: 0 4px 12px rgba(134, 69, 170, 0.35); }

/* ตัวปรับจำนวน */
.m-step { display: inline-flex; align-items: center; background: var(--primary-subtle); border-radius: 999px; padding: 2px; }
.m-step__b { width: 28px; height: 28px; border-radius: 50%; border: 0; background: var(--primary); color: #fff; font-size: 1.05rem; font-weight: 700; line-height: 1; cursor: pointer; }
.m-step__n { width: 40px; border: 0; background: transparent; text-align: center; font-family: inherit; font-weight: 800; font-size: 0.9rem; color: var(--ink); appearance: textfield; -moz-appearance: textfield; }
.m-step__n::-webkit-outer-spin-button, .m-step__n::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
