@import url('https://fonts.googleapis.com/css2?family=Prompt:wght@300;400;500;600;700&display=swap');

body {
  font-family: 'Prompt', 'Segoe UI', sans-serif;
}

/* ---------- Layout primitives ---------- */
.card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 0.9rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 1px rgba(15, 23, 42, 0.03);
}
.card-pad { padding: 1.5rem; }
.card-warning { background: #fffbeb; border-color: #fde68a; }
.card-success { background: #ecfdf5; border-color: #a7f3d0; }

.section-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: #0f172a;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.section-sub { font-size: 0.8125rem; color: #64748b; margin-top: 0.125rem; }

.icon-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 0.6rem;
  font-size: 1.05rem;
  background: #f1f5f9;
  flex-shrink: 0;
}
.icon-badge-lg {
  width: 3rem;
  height: 3rem;
  border-radius: 0.75rem;
  font-size: 1.5rem;
}

.page-heading {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 0.5rem;
}
.page-heading h2 { font-size: 1.35rem; font-weight: 700; color: #0f172a; letter-spacing: -0.01em; }
.page-heading p { font-size: 0.8125rem; color: #64748b; margin-top: 0.1rem; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.pro-table { width: 100%; font-size: 0.875rem; text-align: left; border-collapse: collapse; }
table.pro-table thead th {
  background: #f8fafc;
  color: #64748b;
  text-transform: uppercase;
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  font-weight: 600;
  padding: 0.75rem 1rem;
  white-space: nowrap;
  border-bottom: 1px solid #e5e7eb;
}
table.pro-table tbody td {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
  vertical-align: middle;
}
table.pro-table tbody tr:last-child td { border-bottom: none; }
table.pro-table tbody tr:hover { background: #f8fafc; }
table.pro-table td.emphasis { font-weight: 600; color: #0f172a; }

/* ตารางเช็คชื่อการฝึกซ้อม: คอลัมน์เยอะกว่าตารางอื่นในระบบ (ผู้เล่น + สถานะ + คะแนน 4 ด้าน + เฉลี่ย) จึงมักต้อง
   เลื่อนแนวนอนบนจอ PC/แท็บเล็ต — ปักหมุดคอลัมน์ "ผู้เล่น" ไว้ซ้ายเสมอกันหลุดว่ากำลังให้คะแนนใคร และย่อปุ่ม
   สถานะ/คะแนนเฉพาะตารางนี้ให้เล็กลงเพื่อให้เห็นครบหลายด้านโดยไม่ต้องเลื่อนบ่อย (ครอบ min-width ไว้กันชนกับกฎ
   ขยายปุ่มให้ใหญ่สำหรับมือถือด้านล่าง ซึ่งต้อง "ชนะ" เสมอบนจอแคบเพราะมือถือต้องการพื้นที่แตะที่ใหญ่กว่า ไม่ใช่เล็กกว่า) */
@media (min-width: 641px) {
  #roster-wrap table.pro-table th:first-child,
  #roster-wrap table.pro-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background: #fff;
  }
  #roster-wrap table.pro-table thead th:first-child { background: #f8fafc; }
  #roster-wrap table.pro-table tbody tr:hover td:first-child { background: #f8fafc; }

  #roster-wrap .segmented-btn { min-width: 1.7rem; height: 1.7rem; padding: 0 0.3rem; font-size: 0.75rem; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: 0.55rem;
  padding: 0.55rem 1.1rem;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  cursor: pointer;
  border: 1px solid transparent;
}
.btn-block { width: 100%; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.75rem; border-radius: 0.45rem; }
.btn-primary { background: #0f172a; color: #fff; }
.btn-primary:hover { background: #1e293b; }
.btn-secondary { background: #fff; color: #334155; border-color: #e2e8f0; }
.btn-secondary:hover { background: #f8fafc; }
.btn-success { background: #059669; color: #fff; }
.btn-success:hover { background: #047857; }
.btn-danger-soft { background: #fef2f2; color: #b91c1c; }
.btn-danger-soft:hover { background: #fee2e2; }
.btn-warning-soft { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.btn-warning-soft:hover { background: #fef3c7; }
.btn-ghost { background: transparent; color: #64748b; padding-left: 0.25rem; padding-right: 0.25rem; }
.btn-ghost:hover { color: #0f172a; }
.btn-ghost-danger { background: transparent; color: #dc2626; padding-left: 0.25rem; padding-right: 0.25rem; }
.btn-ghost-danger:hover { color: #991b1b; }

/* ---------- Segmented control (สถานะ/คะแนน แบบกดเลือกค่าเดียว) ---------- */
.segmented {
  display: inline-flex;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  overflow: hidden;
  background: #fff;
  vertical-align: middle;
}
.segmented-btn {
  min-width: 2.1rem;
  height: 2.1rem;
  padding: 0 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #475569;
  background: transparent;
  border: none;
  border-right: 1px solid #e2e8f0;
  transition: background-color 0.15s ease, color 0.15s ease;
  cursor: pointer;
}
.segmented-btn:last-child { border-right: none; }
.segmented-btn:hover { background: #f1f5f9; }
.segmented-btn.active { background: #0f172a; color: #fff; }
.segmented-btn.active:hover { background: #0f172a; }
.segmented-readonly {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #475569;
}

/* ---------- Chip toggle (เลือกได้หลายค่าพร้อมกัน แบบตัวเลือกจำนวนมากที่ต้องขึ้นบรรทัดใหม่ได้) ---------- */
.chip-toggle-group { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip-toggle {
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  border: 1px solid #e2e8f0;
  background: #fff;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #475569;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.chip-toggle:hover { background: #f1f5f9; }
.chip-toggle.active { background: #0f172a; border-color: #0f172a; color: #fff; }
.chip-toggle.active:hover { background: #0f172a; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 0.2rem 0.65rem;
  border-radius: 9999px;
  white-space: nowrap;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #e0e7ff; color: #3730a3; }
.badge-neutral { background: #f1f5f9; color: #475569; }
.badge-danger { background: #fee2e2; color: #b91c1c; }

/* ---------- Inputs ---------- */
.field-label { display: block; font-size: 0.8125rem; font-weight: 500; color: #475569; margin-bottom: 0.35rem; }
.field-input {
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 0.55rem;
  padding: 0.55rem 0.75rem;
  font-size: 0.875rem;
  color: #0f172a;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field-input:focus {
  outline: none;
  border-color: #0f172a;
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.08);
}

/* ---------- Tabs ---------- */
.tab-btn {
  padding-bottom: 0.6rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-bottom: 2px solid transparent;
  color: #94a3b8;
}
.tab-btn:hover { color: #475569; }
.tab-btn-active { color: #0f172a; border-bottom-color: #0f172a; }

/* ---------- App shell ---------- */
.app-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}
.stat-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 0.9rem;
  padding: 1.25rem 1.4rem;
}
.stat-label { font-size: 0.8125rem; color: #64748b; }
.stat-value { font-size: 1.7rem; font-weight: 700; color: #0f172a; margin-top: 0.25rem; letter-spacing: -0.02em; }

.app-footer {
  border-top: 1px solid #e5e7eb;
  padding: 1.5rem 0;
  text-align: center;
  font-size: 0.75rem;
  color: #94a3b8;
}

/* ---------- ปุ่มไอคอนบน header เข้ม (☰ เปิดเมนู, 🔔 แจ้งเตือน) ---------- */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.55rem;
  background: transparent;
  color: #e2e8f0;
  font-size: 1.15rem;
  border: none;
  cursor: pointer;
  transition: background-color 0.15s ease;
  flex-shrink: 0;
}
.btn-icon:hover { background: rgba(255, 255, 255, 0.1); }
.hamburger-lines {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 1.15rem;
}
.hamburger-lines span {
  display: block;
  height: 2px;
  width: 100%;
  background: currentColor;
  border-radius: 1px;
}

/* ---------- เมนูนำทางแบบเลื่อนออกจากด้านซ้าย (nav drawer) ---------- */
#nav-drawer {
  transition: transform 0.22s ease;
}
#nav-drawer.nav-drawer-hidden { transform: translateX(-100%); }
#nav-drawer:not(.nav-drawer-hidden) { transform: translateX(0); }
#nav-drawer-overlay { transition: opacity 0.22s ease; }

.drawer-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  text-align: left;
  padding: 0.7rem 1.1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #334155;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.drawer-item:hover { background: #f1f5f9; }
.drawer-item.active { background: #eef2ff; color: #3730a3; font-weight: 600; }
.drawer-item .drawer-item-icon { font-size: 1.05rem; width: 1.5rem; text-align: center; flex-shrink: 0; }
.drawer-section-label {
  padding: 0.85rem 1.1rem 0.35rem;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #94a3b8;
}
.drawer-divider { height: 1px; background: #f1f5f9; margin: 0.4rem 0; }

/* ==========================================================================
   โหมดมือถือ (iOS / Android) — คงหน้าตาแบบ PC ไว้เหมือนเดิม ปรับเฉพาะจอแคบ
   ใช้ media query ตามความกว้างจอแทนการเช็ค user-agent (แนวทางมาตรฐาน
   responsive design ที่ครอบคลุมมือถือทุกยี่ห้อโดยไม่กระทบ PC)
   ========================================================================== */
@media (max-width: 640px) {
  /* Header: ย่อขนาด ลดช่องไฟ ให้พอดีจอแคบ */
  .app-header .max-w-6xl,
  .app-header .max-w-5xl {
    padding-left: 1rem;
    padding-right: 1rem;
    padding-top: 0.85rem;
    padding-bottom: 0.85rem;
  }
  .app-header h1 { font-size: 1rem; }
  .app-header p { font-size: 0.7rem; }
  .app-header img { width: 2rem; height: 2rem; }
  .app-header .btn { padding: 0.45rem 0.75rem; font-size: 0.75rem; }

  main { padding-left: 1rem; padding-right: 1rem; }
  .card-pad { padding: 1.1rem; }

  /* หัวข้อหน้า: ไอคอนเล็กลง ระยะห่างแน่นขึ้น */
  .page-heading { gap: 0.6rem; }
  .icon-badge-lg { width: 2.25rem; height: 2.25rem; font-size: 1.15rem; border-radius: 0.6rem; }
  .page-heading h2 { font-size: 1.05rem; }
  .page-heading p { font-size: 0.75rem; }

  /* ปุ่ม/ปุ่มกดสถานะ: ขยายพื้นที่แตะให้เหมาะกับนิ้ว (ตามแนวทาง touch target ของ iOS/Android) */
  .btn { padding: 0.65rem 1.1rem; font-size: 0.875rem; }
  .btn-sm { padding: 0.5rem 0.85rem; font-size: 0.8125rem; }
  .segmented-btn { min-width: 2.6rem; height: 2.6rem; font-size: 0.9375rem; }
  .field-input { padding: 0.65rem 0.85rem; font-size: 1rem; } /* 16px ป้องกัน iOS ซูมอัตโนมัติตอนโฟกัส input */

  /* สถิติภาพรวม: การ์ดสถิติเรียงคอลัมน์เดียวให้อ่านง่าย */
  #overview-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.65rem; }
  .stat-card { padding: 1rem; }
  .stat-value { font-size: 1.35rem; }

  /* ตาราง: แปลงเป็นรูปแบบการ์ดสไตล์มือถือ อ่านง่ายกว่าเลื่อนแนวนอน */
  table.pro-table thead { display: none; }
  table.pro-table, table.pro-table tbody, table.pro-table tr, table.pro-table td {
    display: block;
    width: 100%;
  }
  table.pro-table tbody tr {
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    margin: 0.65rem;
    overflow: hidden;
  }
  table.pro-table tbody tr:hover { background: transparent; }
  table.pro-table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.6rem 0.9rem;
    border-bottom: 1px solid #f1f5f9;
    text-align: right;
  }
  table.pro-table tr td:last-child { border-bottom: none; }
  table.pro-table td[data-label]::before {
    content: attr(data-label);
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #94a3b8;
    text-align: left;
    flex-shrink: 0;
  }
  /* เซลล์ที่เป็นปุ่มกดสถานะ/คะแนน หลายปุ่มในแถวเดียว ให้ห่อบรรทัดและชิดซ้ายแทน */
  table.pro-table td.space-x-2 {
    flex-wrap: wrap;
    justify-content: flex-start;
  }
}
