/* ============================================================================
   theme.css — ระบบสี ฟอนต์หัวมน ปุ่ม ช่องกรอก อวาตาร์ และแอนิเมชันกลาง (CocaCola CVS)
   ============================================================================ */
:root {
  /* โทนสีหลัก CocaCola CVS (แดงสดใสมีมิติ + พาสเทลนุ่มตา) */
  --brand: #e11d2f;
  --brand-2: #ff4757;
  --brand-dark: #b31220;
  --brand-soft: #fff0f2;
  --brand-ink: #88131d;

  /* โทนสี Sidebar ตัดกับสีแดงและพื้นขาวของเว็บ (Deep Petrol Ocean-Teal) */
  --side-bg-1: #133142;
  --side-bg-2: #0e2432;
  --side-bg-3: #121f33;
  --side-accent: #38bdf8;

  /* สีพื้นหลัง เส้นขอบ และตัวอักษร */
  --ink: #162033;
  --ink-2: #4b5870;
  --muted: #8b98ae;
  --line: #e6ebf3;
  --line-2: #cfd8e6;
  --bg: #f4f7fc;
  --card: #ffffff;
  --card-2: #f8fafd;

  /* สีสถานะ */
  --ok: #0d8a52;
  --ok-soft: #eafaf2;
  --ok-line: #b5ebd0;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --warn-line: #fde68a;
  --err: #c81e2b;
  --err-soft: #fff1f2;
  --err-line: #fecdd3;

  /* มุมโค้งมนทันสมัย ดูน่ารักเป็นมิตร */
  --r-sm: 12px;
  --r: 18px;
  --r-lg: 24px;
  --r-full: 999px;

  --sh-1: 0 2px 10px rgba(20, 34, 58, .05);
  --sh-2: 0 10px 28px rgba(20, 34, 58, .09);
  --sh-brand: 0 8px 20px rgba(225, 29, 47, .26);
  --sh-pop: 0 24px 56px rgba(15, 23, 42, .26);

  /* ฟอนต์หัวมนอ่านง่าย ทั้งตัวเลข รหัส และภาษาไทย */
  --font: "Nunito", "Prompt", "Segoe UI", Tahoma, sans-serif;
  --safetop: 0px;

  color-scheme: light;
}

@media (display-mode: standalone), (display-mode: minimal-ui), (display-mode: fullscreen) {
  :root { --safetop: env(safe-area-inset-top, 0px); }
}
html.is-app { --safetop: env(safe-area-inset-top, 0px); }
html.is-overlap { --safetop: max(36px, env(safe-area-inset-top, 0px)); }

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.58;
  color: var(--ink);
  background:
    radial-gradient(circle at 100% 0%, rgba(225, 29, 47, .05), transparent 36%),
    radial-gradient(circle at 0% 100%, rgba(56, 189, 248, .06), transparent 40%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; }
button, input, select, textarea { font: inherit; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- แอนิเมชันกลางนุ่มนวล ---------- */
@keyframes uiFadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes uiPopIn {
  0%   { opacity: 0; transform: scale(.92) translateY(8px); }
  70%  { opacity: 1; transform: scale(1.02) translateY(0); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes uiPulseDot {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(225, 29, 47, .45); }
  50%      { transform: scale(1.12); box-shadow: 0 0 0 5px rgba(225, 29, 47, 0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ---------- จุดวงกลมสีไฮไลท์ (แทนขีดเหลี่ยมแข็ง ๆ) ---------- */
.ui-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--dot-color, var(--brand));
  flex: 0 0 auto;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--dot-color, var(--brand)) 20%, transparent);
}

/* ---------- อวาตาร์วงกลมของผู้ใช้งาน ---------- */
.u-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  overflow: hidden;
  flex: 0 0 auto;
  border: 2px solid #fff;
  box-shadow: 0 3px 10px rgba(15, 23, 42, .12);
  background: var(--brand-soft);
}
.u-avatar svg { width: 82%; height: 82%; display: block; }
.u-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.u-avatar.is-sm { width: 38px; height: 38px; }
.u-avatar.is-lg { width: 76px; height: 76px; border-width: 3px; box-shadow: 0 8px 22px rgba(225, 29, 47, .18); }
.u-avatar.is-xl { width: 92px; height: 92px; border-width: 4px; box-shadow: 0 10px 26px rgba(225, 29, 47, .2); }

/* ---------- ปุ่มกดขนาดสัมผัสบนมือถือสบายนิ้ว (>= 44px) ---------- */
.ui-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--r-full);
  cursor: pointer;
  font-size: 14.5px;
  font-weight: 600;
  text-decoration: none;
  border: 1.5px solid var(--line-2);
  background: var(--card);
  color: var(--ink-2);
  box-shadow: 0 2px 6px rgba(15, 23, 42, .04);
  transition: background .18s, border-color .18s, color .18s, transform .14s cubic-bezier(.2, .9, .3, 1.3), box-shadow .18s;
}
.ui-btn:hover {
  background: var(--card-2);
  border-color: #a9b6ca;
  color: var(--ink);
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(15, 23, 42, .08);
}
.ui-btn:active { transform: scale(.97); }
.ui-btn[disabled] { opacity: .48; cursor: not-allowed; transform: none; box-shadow: none; }

.ui-btn-primary {
  background: linear-gradient(135deg, var(--brand-2) 0%, var(--brand) 65%, var(--brand-dark) 100%);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--sh-brand);
}
.ui-btn-primary:hover {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 10px 24px rgba(225, 29, 47, .34);
}

.ui-btn-dark {
  background: linear-gradient(135deg, #1b3b4e, #112634);
  border-color: transparent;
  color: #fff;
}
.ui-btn-dark:hover { background: linear-gradient(135deg, #21485f, #163142); color: #fff; }

.ui-btn-danger {
  color: var(--err);
  border-color: #f9b4bd;
  background: #fff;
}
.ui-btn-danger:hover { background: var(--err-soft); border-color: #f48a98; color: var(--err); }

.ui-btn-sm {
  min-height: 38px;
  padding: 0 14px;
  font-size: 13px;
}

.ui-btn-block { width: 100%; }

/* ---------- ช่องกรอกข้อมูล (font-size 16px บนมือถือ ป้องกัน iPhone ซูมจอเอง) ---------- */
.ui-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 15px;
}
.ui-label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}
.ui-hint {
  font-size: 12.5px;
  color: var(--ink-2);
}
.ui-input {
  width: 100%;
  min-height: 46px;
  padding: 10px 15px;
  font-size: 16px;
  color: var(--ink);
  background: var(--card);
  border: 1.5px solid var(--line-2);
  border-radius: var(--r-sm);
  transition: border-color .18s, box-shadow .18s, background .18s;
}
@media (min-width: 768px) {
  .ui-input { font-size: 14.5px; min-height: 44px; }
}
.ui-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(225, 29, 47, .14);
}

.pw-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.pw-wrap .ui-input { padding-right: 74px; }
.pw-toggle {
  position: absolute;
  right: 7px;
  height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--r-full);
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.pw-toggle:hover { background: #ffe0e4; color: var(--brand); }
.pw-toggle:active { transform: scale(.95); }

/* ---------- การ์ดและป้ายสถานะ ---------- */
.ui-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--sh-1);
  animation: uiFadeUp .32s cubic-bezier(.2, .8, .2, 1) both;
}

.ui-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.4;
  padding: 4px 11px;
  border-radius: var(--r-full);
  background: #edf2f9;
  color: var(--ink-2);
}
.ui-tag::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .75;
}
.ui-tag-ok { background: var(--ok-soft); color: var(--ok); border: 1px solid var(--ok-line); }
.ui-tag-red { background: var(--brand-soft); color: var(--brand); border: 1px solid #fecdd3; }
.ui-tag-warn { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn-line); }

/* ---------- กล่องแจ้งเตือน (Flash / Error / Info) ---------- */
.ui-alert {
  padding: 13px 16px;
  border-radius: var(--r-sm);
  margin-bottom: 14px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  animation: uiPopIn .25s ease-out both;
}
.ui-alert.is-ok { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok); }
.ui-alert.is-err { background: var(--err-soft); border-color: var(--err-line); color: var(--err); }
.ui-alert.is-warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }
.ui-alert.is-info { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }

/* ---------- Toast ลอยด้านล่างจอ ---------- */
.ui-toast {
  position: fixed;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom, 22px));
  transform: translate(-50%, 16px) scale(.96);
  background: linear-gradient(135deg, #163447, #0e2230);
  color: #fff;
  padding: 11px 20px;
  border-radius: var(--r-full);
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 0 12px 28px rgba(15, 23, 42, .28);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s, transform .22s cubic-bezier(.2, .9, .3, 1.2);
  z-index: 95;
  max-width: calc(100vw - 32px);
  text-align: center;
}
.ui-toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
