/* ════════════════════════════════════════════════════════════
   AliceLium UI Kit — คอมโพเนนต์ (มือถือมาก่อน)

   ★ ห้ามมีค่าสีในไฟล์นี้ ★ ทุกสีต้องมาจาก css/tokens.css
   ถ้าต้องการสีใหม่ ให้ไปเพิ่มโทเคน ไม่ใช่เขียน hex ตรงนี้

   ชุดนี้ตัดมาเฉพาะของที่มินิแอปใน Telegram ใช้จริง — ไม่ได้ยก theme.css
   ทั้ง 2,000 บรรทัดของ AliceLium มา เพราะครึ่งหนึ่งเป็นของเว็บเดสก์ท็อป
   (แถบบน ฟุตเตอร์ ตารางราคา) ซึ่งมินิแอปไม่มี
   ════════════════════════════════════════════════════════════ */

/* ─── Reset ────────────────────────────────────────────────── */
* { box-sizing: border-box; }

/* ★★ hidden ต้องชนะเสมอ ★★ กฎที่แพงที่สุดในไฟล์นี้ — อย่าลบ
   เบราว์เซอร์ตั้ง [hidden] { display: none } ไว้ในสไตล์ชีตของตัวเอง ซึ่ง **แพ้**
   ทุกคลาสของเราที่ตั้ง display (.card .row .alert .btn ล้วนตั้ง flex)
   ผลคือ el.hidden = true ไม่ทำอะไรเลยกับของพวกนั้น

   ⚠️ ไม่ใช่ทฤษฎี ⚠️ AliceLium เจอของจริง: หน้าที่ควรโชว์ 26 รายการโชว์ครบ 61
   พร้อมกล่อง "ไม่พบรายการ" ขึ้นมาพร้อมกันขัดกันเอง — และก่อนหน้านั้นถูกแก้
   แบบรายคลาสมาแล้วสี่รอบ ทุกรอบแก้เฉพาะคลาสที่เพิ่งพัง
   ต้องมี !important เพราะ [hidden] จำเพาะเท่าคลาส (0,1,0) จึงแพ้ <style>
   ของแต่ละหน้าที่โหลดทีหลัง */
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  /* กันหน้าเด้งซ้ายขวาในเว็บวิวของ Telegram */
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: 'Prompt', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--color-text);
  /* ★ ต้องระบุพื้นเสมอ ★ พื้นโปร่งใสจะไปยืมสีพื้นของเว็บวิว ซึ่งเป็นคนละโหมดกับเรา */
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  /* ที่ว่างของขอบจอมือถือ (รอยบาก/แถบล่าง) — ค่ามาจาก js/tg.js หรือ env() */
  padding-bottom: var(--safe-bottom, 0px);
}

h1, h2, h3 { color: var(--color-ink); margin: 0 0 8px; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -.2px; }
h2 { font-size: 18px; font-weight: 600; }
h3 { font-size: 16px; font-weight: 600; }
p  { margin: 0 0 12px; }
a  { color: var(--color-link); text-decoration: none; }
small, .text-muted { color: var(--color-muted); font-size: 13px; }

/* ─── โครงหน้า ─────────────────────────────────────────────── */
.app { max-width: 560px; margin: 0 auto; padding: 14px 14px 20px; }
.stack   { display: flex; flex-direction: column; gap: 12px; }
.stack-s { display: flex; flex-direction: column; gap: 8px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; margin: 18px 0 8px; }
.section-title h2 { margin: 0; }

/* ─── ปุ่ม ──────────────────────────────────────────────────
   ★ สูงอย่างน้อย 44px ★ เกณฑ์พื้นที่แตะบนมือถือ — ปุ่มที่เตี้ยกว่านี้
   คนนิ้วใหญ่กดพลาดเป็นประจำ และในเว็บวิวไม่มีเมาส์ให้เล็งแทน */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border: 1px solid var(--line);
  border-radius: 999px; background: var(--color-surface); color: var(--color-text);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  transition: transform .12s, box-shadow .15s, background .15s, border-color .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary {
  background: var(--color-primary); border-color: transparent;
  color: var(--color-on-primary); box-shadow: var(--shadow-soft);
}
.btn.primary:active { background: var(--color-primary-hover); }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.danger { background: transparent; border-color: rgba(var(--rgb-danger), .35);
  color: var(--color-danger-text); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn:focus-visible, a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--color-link); outline-offset: 2px;
}

/* ─── การ์ด ────────────────────────────────────────────────── */
.card {
  padding: 14px; border-radius: var(--r16); background: var(--color-surface);
  border: 1px solid var(--line); box-shadow: var(--shadow-soft);
}
.card-flat { box-shadow: none; }

/* ─── ไทล์แอป — ชิ้นที่เป็นตัวตนของชุดนี้ ─────────────────────
   ★ สีมาจากที่เดียว ★ คลาส t-<ตระกูล> ตั้งค่า --tile-a/b/fg ไว้ที่ตัวการ์ด
   แล้วไอคอนข้างในหยิบไปใช้ — เพิ่มทรงใหม่ = เพิ่ม selector ในกฎทาสีข้างล่าง
   ไม่ใช่เขียนกฎสีชุดใหม่ (ไม่งั้นวันที่ปรับโทน จะมีทรงที่ไม่ขยับตามเงียบ ๆ) */
.tile, .rowcard { --tile-a: var(--tile-blue-a); --tile-b: var(--tile-blue-b);
  --tile-fg: var(--tile-ink); }
.tile.t-blue,   .rowcard.t-blue   { --tile-a: var(--tile-blue-a);   --tile-b: var(--tile-blue-b); }
.tile.t-green,  .rowcard.t-green  { --tile-a: var(--tile-green-a);  --tile-b: var(--tile-green-b); }
.tile.t-violet, .rowcard.t-violet { --tile-a: var(--tile-violet-a); --tile-b: var(--tile-violet-b); }
.tile.t-teal,   .rowcard.t-teal   { --tile-a: var(--tile-teal-a);   --tile-b: var(--tile-teal-b); }
.tile.t-rose,   .rowcard.t-rose   { --tile-a: var(--tile-rose-a);   --tile-b: var(--tile-rose-b); }
.tile.t-indigo, .rowcard.t-indigo { --tile-a: var(--tile-indigo-a); --tile-b: var(--tile-indigo-b); }
.tile.t-gold,   .rowcard.t-gold   { --tile-a: var(--tile-gold-a);   --tile-b: var(--tile-gold-b);
  --tile-fg: var(--tile-ink-gold); }

/* กฎเดียวที่ทาสีให้ทุกทรง */
.tile .tile-ic, .rowcard .rowcard-ic {
  background: linear-gradient(140deg, var(--tile-a), var(--tile-b));
  color: var(--tile-fg);
  box-shadow: 0 5px 12px -4px rgba(var(--rgb-shadow-deep), .42);
}

/* ทรงที่ 1 — ตารางไอคอนแอป */
.tile-grid { display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.tile {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 14px 8px; border-radius: var(--r16); text-decoration: none;
  background: var(--color-surface); border: 1px solid var(--line);
  box-shadow: var(--shadow-soft); color: var(--color-text);
  transition: transform .12s;
}
.tile:active { transform: scale(.96); }
.tile .tile-ic { width: 46px; height: 46px; border-radius: 14px;
  display: grid; place-items: center; flex: none; }
.tile .tile-ic .icon { font-size: 24px; color: inherit; }
.tile .tile-t { font-size: 12.5px; font-weight: 600; text-align: center;
  line-height: 1.35; color: var(--color-ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; }

/* ทรงที่ 2 — แถวรายการ (เมนู / การตั้งค่า) */
.rowcard {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 9px 10px; border: 0; border-radius: var(--r16);
  background: transparent; color: var(--color-text); font: inherit;
  font-weight: 600; text-align: left; text-decoration: none; cursor: pointer;
}
.rowcard:active { background: rgba(var(--rgb-primary), .10); }
.rowcard .rowcard-ic { width: 36px; height: 36px; border-radius: 11px; flex: none;
  display: grid; place-items: center; }
.rowcard .rowcard-ic .icon { font-size: 20px; color: inherit; }
.rowcard .rowcard-tx { min-width: 0; flex: 1; }
.rowcard .rowcard-sub { display: block; font-weight: 400; font-size: 12.5px;
  color: var(--color-muted); line-height: 1.4; }
.rowcard .rowcard-go { margin-left: auto; flex: none; color: var(--color-muted); }
.rowlist { display: flex; flex-direction: column; }
.rowlist .sep { height: 1px; background: var(--line); margin: 6px 0; }

/* ─── กล่องสถานะ ───────────────────────────────────────────── */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: var(--r12); font-size: 14px;
  background: rgba(var(--rgb-primary), .08); color: var(--color-text);
  border: 1px solid rgba(var(--rgb-primary), .20);
}
.alert .icon { flex: none; margin-top: 1px; }
.alert.success { background: rgba(var(--rgb-success), .10);
  border-color: rgba(var(--rgb-success), .28); color: var(--color-success-text); }
.alert.warning { background: rgba(var(--rgb-warning), .12);
  border-color: rgba(var(--rgb-warning), .32); color: var(--color-warning-text); }
.alert.danger  { background: rgba(var(--rgb-danger), .10);
  border-color: rgba(var(--rgb-danger), .28); color: var(--color-danger-text); }

/* ─── ป้าย / ชิป ───────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
  background: rgba(var(--rgb-primary), .12); color: var(--color-link);
}
.badge.success { background: rgba(var(--rgb-success), .14); color: var(--color-success-text); }
.badge.warning { background: rgba(var(--rgb-warning), .16); color: var(--color-warning-text); }
.badge.danger  { background: rgba(var(--rgb-danger), .12);  color: var(--color-danger-text); }

/* ─── แท่งความคืบหน้า ──────────────────────────────────────── */
.progress { height: 8px; border-radius: 999px; overflow: hidden;
  background: rgba(var(--rgb-ink), .08); }
.progress > i { display: block; height: 100%; border-radius: inherit;
  background: linear-gradient(90deg, var(--tile-blue-a), var(--color-primary)); }

/* ─── ฟอร์ม ────────────────────────────────────────────────
   ⚠️ font-size ห้ามต่ำกว่า 16px ⚠️ iOS ซูมหน้าเข้าเองตอนแตะช่องกรอก
      ที่ตัวอักษรเล็กกว่านั้น แล้วผู้ใช้ต้องซูมออกเองทุกครั้ง */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 13px; font-weight: 600; color: var(--color-muted); }
input[type="text"], input[type="number"], input[type="search"], textarea, select {
  width: 100%; min-height: 44px; padding: 10px 14px; font: inherit; font-size: 16px;
  color: var(--color-text); background: var(--color-surface);
  border: 1px solid var(--line); border-radius: var(--r12);
}
textarea { min-height: 96px; resize: vertical; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: rgba(var(--rgb-primary), .55);
  box-shadow: 0 0 0 3px rgba(var(--rgb-primary), .16);
}

/* ─── แถบปุ่มติดขอบล่าง ────────────────────────────────────
   ทางเลือกของ MainButton ที่ Telegram มีให้ — ใช้ตัวนี้เมื่ออยากคุมหน้าตาเอง
   หรือเมื่อต้องมีปุ่มมากกว่าหนึ่ง (MainButton มีได้ปุ่มเดียว)
   ⚠️ ต้องเผื่อ safe-area ⚠️ ไม่งั้นปุ่มจะไปอยู่ใต้แถบลากปิดของ iPhone */
.actionbar {
  position: sticky; bottom: 0; z-index: 10;
  display: flex; gap: 10px;
  margin: 16px -14px 0; padding: 12px 14px;
  padding-bottom: calc(12px + var(--safe-bottom, 0px));
  background: color-mix(in srgb, var(--color-bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.actionbar .btn { flex: 1; }

/* ─── ตัวช่วยเล็ก ๆ ─────────────────────────────────────────── */
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 18px; }
.center { text-align: center; }
.spinner {
  width: 18px; height: 18px; border-radius: 50%; flex: none;
  border: 2px solid rgba(var(--rgb-primary), .25);
  border-top-color: var(--color-primary);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* เคารพคนที่ปิดภาพเคลื่อนไหวในระบบ — ไม่ใช่ทางเลือก เป็นการตั้งค่าเพื่อสุขภาพ
   ของคนที่เวียนหัวกับการเคลื่อนไหว (vestibular disorder) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
}
