
/* ============================================================
   RESET & THEME TOKENS
   ============================================================ */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg: #060b13;
  --bg2: #0c1524;
  --bg3: #111d2e;
  --blue: #38bdf8;
  --blue2: #0284c7;
  --green: #10b981;
  --red: #ef4444;
  --yellow: #f59e0b;
  --text: #f1f5f9;
  --muted: #64748b;
  --sub: #94a3b8;
  --border: rgba(255, 255, 255, 0.07);
  --card: rgba(255, 255, 255, 0.03);
}

body {
  font-family: 'TH Sarabun New', 'THSarabunNew', 'TH Sarabun PSK', 'THSarabunPSK', 'Sarabun', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

#pastList.expanded .past-extra { display: block !important; }
.expanded .hist-extra { display: block !important; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
#loginPage {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(6, 11, 19, .8), rgba(6, 11, 19, .95)),
    url('../assets/optimized/forest-900.webp') center/cover no-repeat;
}
#loginPage.hidden { display: none; }

/* ============================================================
   LOADING SCREEN — โลโก้กลม + จุดแสงโคจร (ไม่มีเส้นวงกลม)
   ============================================================ */
#loadingScreen {
  position: fixed;
  inset: 0;
  z-index: 9998;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  background:
    linear-gradient(180deg, rgba(6, 11, 19, .48), rgba(6, 11, 19, .68)),
    url('../assets/optimized/IMG_4023-900.webp') center/cover no-repeat;
}
#loadingScreen.show { display: flex; }
.loading-ring-wrap {
  position: relative;
  width: 124px;
  height: 124px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.loading-ring {
  display: none;
}
.loading-ring-outer {
  inset: 1px;
  border: 1px solid rgba(56, 189, 248, .16);
  border-top-color: rgba(103, 232, 249, .88);
  border-right-color: rgba(45, 212, 191, .42);
  box-shadow: 0 0 18px rgba(34, 211, 238, .08);
  animation: loadingSpin 3.2s linear infinite;
}
.loading-ring-inner {
  inset: 11px;
  border: 1px dashed rgba(45, 212, 191, .22);
  border-left-color: rgba(153, 246, 228, .66);
  animation: loadingSpinReverse 4.8s linear infinite;
}
.loading-orbit-dot {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
}
.loading-orbit-dot::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  width: 7px;
  height: 7px;
  margin-left: -3.5px;
  border-radius: 50%;
  background: #67e8f9;
  box-shadow: 0 0 13px rgba(103, 232, 249, .9);
}
.loading-dot-a { animation: loadingSpin 3.2s linear infinite; }
.loading-dot-b {
  inset: 11px;
  animation: loadingSpinReverse 4.8s linear infinite;
}
.loading-dot-b::after {
  width: 5px;
  height: 5px;
  margin-left: -2.5px;
  background: #5eead4;
  box-shadow: 0 0 11px rgba(94, 234, 212, .72);
}
.loading-logo {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(153, 246, 228, .48);
  box-shadow: 0 0 22px rgba(45, 212, 191, .25), 0 8px 26px rgba(0, 0, 0, .28);
  transform-origin: 50% 64%;
  animation: loadingLogoBreathe 2.8s ease-in-out infinite;
}
@keyframes loadingSpin { to { transform: rotate(360deg); } }
@keyframes loadingSpinReverse { to { transform: rotate(-360deg); } }
@keyframes loadingLogoBreathe {
  0%, 100% { transform: translateX(0) rotate(0deg) scale(1); filter: brightness(.96); }
  25% { transform: translateX(-3px) rotate(-2deg) scale(1.022); filter: brightness(1.01); }
  50% { transform: translateX(0) rotate(0deg) scale(1.038); filter: brightness(1.06); }
  75% { transform: translateX(3px) rotate(2deg) scale(1.022); filter: brightness(1.01); }
}
.loading-text { font-size: 13px; color: var(--sub); font-weight: 600; letter-spacing: .3px; animation: loadingPulse 1.4s ease-in-out infinite; }
@keyframes loadingPulse { 0%, 100% { opacity: .6; } 50% { opacity: 1; } }

.loading-retry-btn{
  margin-top:12px;padding:9px 20px;border-radius:999px;
  border:1px solid rgba(56,189,248,.4);background:rgba(56,189,248,.12);
  color:#7dd3fc;font-size:12px;font-weight:800;cursor:pointer;font-family:inherit;
  animation:none!important;
}
.loading-retry-btn:active{transform:scale(.96)}

@media (prefers-reduced-motion: reduce) {
  .loading-ring,
  .loading-orbit-dot,
  .loading-logo,
  .loading-text { animation: none !important; }
}

.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo img {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  border: 3px solid var(--blue);
  box-shadow: 0 0 28px rgba(56, 189, 248, .35);
  object-fit: cover;
  display: block;
  margin: 0 auto 14px;
}
.login-logo h1 { font-size: 30px; font-weight: 800; color: var(--blue); }
.login-logo p { font-size: 13px; color: var(--sub); margin-top: 4px; }

.login-card {
  width: 100%;
  max-width: 360px;
  background: rgba(8, 18, 15, .4);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(45, 212, 191, .18);
  border-radius: 24px;
  padding: 28px 22px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .5);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.login-card .inp-wrap { width: 100%; max-width: 100%; }
.login-card .btn-login { width: 100%; }
.login-card h2 { font-size: 18px; font-weight: 700; color: #fff; margin-bottom: 10px; }
.login-desc { font-size: 13px; color: var(--sub); margin-bottom: 26px; line-height: 1.6; }

.inp-wrap { position: relative; margin-bottom: 14px; }
.inp-pre { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-size: 15px; pointer-events: none; }
.inp {
  width: 100%;
  height: 50px;
  background: var(--bg3);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  color: #fff;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: .2s;
  padding: 0 14px 0 46px;
}
.inp:focus { border-color: var(--blue); }
.inp::placeholder { color: var(--muted); }

.btn-login {
  width: 100%;
  height: 50px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--blue2), var(--blue));
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(2, 132, 199, .3);
  margin-top: 4px;
}
.btn-login:disabled { background: #1e293b; color: #475569; box-shadow: none; cursor: not-allowed; }
.login-note { font-size: 11px; color: var(--muted); text-align: center; margin-top: 14px; }

/* LINE login page polish */
.login-logo img { animation: loginLogoIn .5s cubic-bezier(.2,.8,.2,1); }
@keyframes loginLogoIn { from { opacity: 0; transform: scale(.8) translateY(6px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.login-card { animation: fadeUp .4s ease .1s both; }
#lineLoginStep h2, #phoneStep h2 { letter-spacing: .2px; }
.btn-login[style*="06C755"]:active { transform: scale(.98); }
.line-profile-card {
  display: flex; align-items: center; gap: 12px;
  background: rgba(6, 199, 85, .08);
  border: 1px solid rgba(6, 199, 85, .28);
  border-radius: 16px;
  padding: 12px 14px;
  margin-bottom: 22px;
  width: 100%;
  animation: fadeUp .35s ease;
}
.line-profile-card img { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; border: 2px solid #06C755; flex-shrink: 0; }
.line-profile-card .name { font-size: 14px; color: #fff; font-weight: 700; }
.line-profile-card .status { font-size: 11px; color: var(--green); margin-top: 2px; display: flex; align-items: center; gap: 4px; }

/* Welcome card polish */
.login-card {
  position: relative;
  overflow: hidden;
  padding-top: 34px;
}
.login-card::before {
  content: '';
  position: absolute;
  top: 0; left: 18%; right: 18%;
  height: 3px;
  border-radius: 0 0 6px 6px;
  background: linear-gradient(90deg, transparent, #2dd4bf, transparent);
  opacity: .8;
}
#lineLoginStep h2 {
  font-size: 21px;
  font-weight: 800;
  margin-bottom: 10px;
}
.wave-emoji {
  display: inline-block;
  animation: waveHand 2.2s ease-in-out infinite;
  transform-origin: 70% 70%;
}
@keyframes waveHand {
  0%, 55%, 100% { transform: rotate(0deg); }
  10% { transform: rotate(14deg); }
  20% { transform: rotate(-8deg); }
  30% { transform: rotate(14deg); }
  40% { transform: rotate(-4deg); }
}
.login-desc { font-size: 13.5px; line-height: 1.7; }
.login-note-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: 999px;
  margin-top: 18px;
  font-size: 11px;
  color: var(--muted);
}

/* ปุ่มปิดหน้าล็อกอิน (โผล่เฉพาะตอนถูกเรียกขึ้นมาระหว่างเยี่ยมชมแบบไม่ล็อกอิน — ให้กลับไปดูทริปต่อได้) */
#loginCloseBtn {
  display: none;
  position: absolute;
  top: 18px;
  left: 18px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .08);
  border: none;
  color: #fff;
  font-size: 17px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(6px);
}

/* ============================================================
   APP SHELL / HEADER / BOTTOM NAV
   ============================================================ */
#appShell { display: block; }

.hdr {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding-bottom: 53px;
  margin-bottom: 2px;
}
/* หน้าอื่นนอกจากหน้าแรกไม่มีกล่องทักทาย เลยไม่ต้องเผื่อระยะด้านล่างเยอะขนาดนั้น */
.hdr.no-greet { padding-bottom: 0; }
.hdr-brand { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.hdr-brand img { width: 60px; height: 60px; border-radius: 50%; border: 2px solid var(--blue); object-fit: cover; }
.hdr-brand h1 { font-size: 16px; font-weight: 800; color: var(--blue); }
.hdr-brand span { font-size: 8px; color: #fff; opacity: .7; display: block; }
.hdr-btn {
  background: var(--card);
  border: 1px solid var(--border);
  color: #fff;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}

.bnav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: rgba(6, 11, 19, .94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 500;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.bnav-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 10px 0 12px; cursor: pointer; gap: 4px; }
.bnav-item .ico { font-size: 22px; height: 24px; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.bnav-item .ico svg { width: 23px; height: 23px; display: block; }
.bnav-item .lbl { font-size: 10px; font-weight: 600; color: var(--muted); }
.bnav-item.active .lbl { color: var(--blue); }
.bnav-item.active .ico { color: var(--blue); filter: drop-shadow(0 0 6px rgba(56, 189, 248, .6)); }
.nav-avatar { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; display: none; border: 1.5px solid var(--muted); }
.bnav-item.active .nav-avatar { border-color: var(--blue); }

/* ============================================================
   PAGE / LAYOUT UTILITIES
   ============================================================ */
.view-page { display: none; }
.view-page.active-page { display: block; animation: fadeUp .3s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.main { max-width: 480px; margin: 0 auto; padding: 16px 16px 100px; }
.divider { height: 1px; background: var(--border); margin: 20px 0; }
