/* ===== Todo PWA — โทนสว่าง สะอาด ใช้งานบนมือถือได้ ===== */

:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #1f2933;
  --muted: #7b8794;
  --accent: #3b82f6;
  --accent-dark: #2563eb;
  --accent-soft: #eaf2fe;
  --check: #22c55e;
  --danger: #ef4444;
  --danger-soft: #fdeaea;
  --border: #e3e8ef;
  --shadow: 0 2px 10px rgba(31, 41, 51, 0.07);
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Noto Sans Thai", "Sarabun", "Helvetica Neue", Arial, sans-serif;
  display: flex;
  justify-content: center;
  padding: 32px 16px 56px;
  -webkit-tap-highlight-color: transparent;
}

.app { width: 100%; max-width: 520px; }

/* ---------- ส่วนหัว ---------- */
.app-header { text-align: center; margin-bottom: 20px; }

.app-header h1 {
  margin: 0 0 6px;
  font-size: 28px;
  letter-spacing: -0.5px;
}

.subtitle { margin: 0; color: var(--muted); font-size: 14px; }

/* ---------- ฟอร์มเพิ่มงาน ---------- */
.todo-form { display: flex; gap: 10px; margin-bottom: 18px; }

.todo-input {
  flex: 1;
  min-width: 0;
  font-size: 16px; /* ป้องกัน Safari บนมือถือซูมหน้าตอนโฟกัส */
  font-family: inherit;
  padding: 13px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.todo-input::placeholder { color: #a3adba; }

.todo-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* กรณีพยายามเพิ่มงานว่าง ๆ ให้ช่องกระพือเตือน */
.todo-input.shake {
  animation: shake 0.3s ease;
  border-color: var(--danger);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.add-btn {
  padding: 0 20px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.add-btn:hover { background: var(--accent-dark); }
.add-btn:active { transform: scale(0.97); }

/* ---------- รายการงาน ---------- */
.todo-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.todo-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: opacity 0.2s ease, border-color 0.15s ease, transform 0.16s ease;
  animation: pop-in 0.18s ease;
}

@keyframes pop-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.todo-item:hover { border-color: #c9d4e0; }

/* วงกลมติ๊กด้านซ้าย */
.check {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 2px solid #c4cdd6;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.check svg {
  width: 14px;
  height: 14px;
  stroke: #fff;
  fill: none;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.todo-item:hover .check { border-color: var(--accent); }

/* ข้อความงาน */
.todo-text {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  line-height: 1.45;
  word-break: break-word;
  transition: color 0.15s ease;
}

/* ปุ่มลบด้านขวา */
.delete {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #b0bac6;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}

.delete svg { width: 18px; height: 18px; }

.delete:hover,
.delete:focus-visible {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ---------- งานที่เสร็จแล้ว: ขีดฆ่า + จางลง ---------- */
.todo-item.done { opacity: 0.62; }

.todo-item.done .check {
  background: var(--check);
  border-color: var(--check);
}

.todo-item.done .check svg { opacity: 1; transform: scale(1); }

.todo-item.done .todo-text {
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
  color: var(--muted);
}

/* ตอนกำลังลบ เฟดออกไปทางขวา */
.todo-item.removing {
  opacity: 0;
  transform: translateX(12px);
}

/* ---------- สถานะว่าง / แถบสรุป ---------- */
.empty-state {
  margin: 26px 0;
  text-align: center;
  color: var(--muted);
  font-size: 14.5px;
}

.app-footer {
  margin-top: 18px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}

/* โฟกัสด้วยคีย์บอร์ด */
.check:focus-visible,
.delete:focus-visible,
.add-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- จอมือถือ ---------- */
@media (max-width: 480px) {
  body { padding: 20px 12px 40px; }
  .app-header h1 { font-size: 24px; }
  .delete { width: 40px; height: 40px; } /* เป้าแตะใหญ่ขึ้นบนจอสัมผัส */
}
