/* Somewear design tokens — extracted from Figma (crF0rIw8peIDKhzYCrImtI) */
:root {
  --blue-950: #1c2e35;
  --blue-600: #3e7b8b;
  --blue-500: #5098a7;
  --blue-400: #72b1be;
  --blue-300: #b2d4dc;
  --blue-200: #cee4e9;
  --grey-700: #6f655f;
  --grey-400: #a49e93;
  --grey-50: #f7f6f5;
  --primary-100: #f6eecf;
  --cream-50: #fdf6e8;
  --white: #ffffff;
  --black: #000000;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Manrope', system-ui, sans-serif;
  color: var(--blue-950);
  background: #f4f2ee;
}

/* Mobile-first: centered phone-width column that still fills wider screens gracefully */
.app-shell {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--white);
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 40px rgba(28, 46, 53, 0.08);
}

@media (min-width: 431px) {
  body { background: #e9e5db; padding: 24px 0; }
  .app-shell { min-height: calc(100vh - 48px); border-radius: 28px; overflow: hidden; }
}

.page-content {
  flex: 1;
  padding: 16px 20px 100px;
  overflow-y: auto;
}

.page-content.no-nav-pad { padding-bottom: 24px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 999px;
  font-family: inherit;
  font-weight: 700;
  font-size: 15px;
  padding: 14px 20px;
  cursor: pointer;
  width: 100%;
  text-decoration: none;
  box-sizing: border-box;
  transition: opacity 0.15s ease, transform 0.05s ease;
}
a.btn { text-decoration: none; }
.icon-btn { text-decoration: none; }
.pill-select { text-decoration: none; }

/* กันไอคอน SVG ขยายใหญ่ผิดปกติเวลาไม่มีการกำหนดขนาดจากที่อื่น */
.btn svg, .icon-btn svg, .pill-select svg { width: 18px; height: 18px; flex-shrink: 0; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--blue-500); color: var(--white); }
.btn-primary:hover { background: var(--blue-600); }
.btn-secondary { background: var(--white); color: var(--blue-600); border: 1.5px solid var(--blue-400); }
.btn-secondary:hover { background: var(--blue-200); }
.btn-outline-dark { background: var(--white); color: var(--blue-950); border: 1.5px solid #e4e0d8; }
.btn-line { background: #06c755; color: var(--white); }
.btn-ig { background: linear-gradient(45deg, #f9ce34, #ee2a7b, #6228d7); color: var(--white); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.pill-select {
  border-radius: 999px;
  border: 1.5px solid #e4e0d8;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 13px;
  background: var(--white);
  color: var(--blue-950);
  cursor: pointer;
}
.pill-select.active { border-color: var(--blue-500); background: var(--blue-200); color: var(--blue-600); }

.chip {
  border-radius: 999px;
  background: var(--blue-200);
  color: var(--blue-600);
  font-weight: 700;
  font-size: 11px;
  padding: 6px 12px;
  white-space: nowrap;
}

.card {
  background: var(--white);
  border-radius: 18px;
  border: 1px solid #eeece6;
}

.divider { height: 1px; background: #eeece6; border: none; margin: 16px 0; }

.icon-btn {
  width: 40px; height: 40px;
  border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--white);
  border: 1.5px solid #eeece6;
  cursor: pointer;
}

input[type="text"], input[type="email"], input[type="date"], textarea, select {
  width: 100%;
  border: 1.5px solid #e4e0d8;
  border-radius: 14px;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 14px;
  color: var(--blue-950);
  background: var(--white);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--blue-500); }

label.field-label {
  font-weight: 700;
  font-size: 12px;
  color: var(--blue-950);
  margin-bottom: 6px;
  display: block;
}

/* Bottom nav */
.bottom-nav {
  position: sticky;
  bottom: 0;
  left: 0; right: 0;
  background: var(--white);
  border-top: 1px solid #eeece6;
  display: flex;
  padding: 10px 8px calc(10px + env(safe-area-inset-bottom));
}
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  color: var(--grey-400);
  text-decoration: none;
}
.bottom-nav a.active { color: var(--blue-500); }
.bottom-nav svg { width: 22px; height: 22px; }

/* Product card — proportions/radius match Figma "Content Card" (108/135 photo, 8px radius) */
.product-card { display: block; text-decoration: none; color: inherit; margin-bottom: 12px; }
.product-card img { width: 100%; aspect-ratio: 108/135; object-fit: cover; border-radius: 8px; background: #eee; }
.product-card .pc-title { font-weight: 600; font-size: 12px; margin-top: 8px; line-height: 1.3; }
.product-card .pc-shop { font-size: 10px; color: var(--grey-700); }
.product-card .pc-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; font-size: 12px; }

/* Home header — cream rounded-bottom search bar (Figma "Search home") */
.home-header {
  background: var(--primary-100);
  border-radius: 0 0 30px 30px;
  padding: 14px 24px 16px;
  box-shadow: 0 4px 10px rgba(51, 99, 113, 0.15);
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 0 -20px 18px;
}
.home-header h1 { flex: 1; font-size: 16px; font-weight: 700; color: var(--blue-950); margin: 0; line-height: 1.5; }
.home-header .icon-btn { background: var(--white); flex-shrink: 0; }

/* Trending category — circular avatar + label (Figma "picture+name") */
.trending-avatar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  flex-shrink: 0;
  width: 64px;
}
.trending-avatar .avatar-circle {
  width: 64px; height: 64px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  background: var(--blue-200);
}
.trending-avatar span.label { font-size: 10px; color: var(--grey-700); text-align: center; line-height: 1.3; }

/* แถบตั้งวันที่เช่าล่วงหน้า */
.date-range-bar {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  background: var(--blue-200);
  border: none;
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 18px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}
.date-range-bar .icon { width: 18px; height: 18px; color: var(--blue-600); flex-shrink: 0; }
.date-range-bar .text { flex: 1; font-size: 13px; font-weight: 600; color: var(--blue-950); }
.date-range-bar .edit { font-size: 11px; font-weight: 700; color: var(--blue-600); }

.heart-btn {
  border: none; background: rgba(255,255,255,0.9);
  width: 32px; height: 32px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.heart-btn svg { width: 17px; height: 17px; }
.heart-btn.saved svg { fill: #e0577f; stroke: #e0577f; }

/* Filter sheet */
.sheet-overlay {
  position: fixed; inset: 0; background: rgba(28,46,53,0.4);
  display: none; align-items: flex-end; justify-content: center; z-index: 50;
}
.sheet-overlay.open { display: flex; }
.sheet {
  background: var(--white);
  width: 100%; max-width: 430px;
  border-radius: 24px 24px 0 0;
  max-height: 85vh;
  overflow-y: auto;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
}

/* แชทในแอป (chatThread.js) */
.chat-thread { display: flex; flex-direction: column; height: 100%; min-height: 420px; }
.chat-messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px 2px 14px; }
.chat-messages-empty { text-align: center; color: var(--grey-400); font-size: 12px; padding: 30px 10px; }
.chat-bubble { max-width: 78%; padding: 10px 14px; border-radius: 16px; font-size: 13px; line-height: 1.5; word-break: break-word; }
.chat-bubble.mine { align-self: flex-end; background: var(--blue-500); color: var(--white); border-bottom-right-radius: 4px; }
.chat-bubble.theirs { align-self: flex-start; background: var(--grey-50); color: var(--blue-950); border-bottom-left-radius: 4px; }
.chat-bubble.system { align-self: center; background: var(--blue-200); color: var(--blue-600); font-size: 11px; font-weight: 700; text-align: center; border-radius: 999px; padding: 8px 16px; }
.chat-bubble img { max-width: 180px; width: 100%; border-radius: 12px; display: block; margin-top: 6px; }
.chat-bubble-time { font-size: 10px; opacity: 0.65; margin-top: 4px; }
.chat-composer { display: flex; gap: 8px; align-items: center; padding-top: 12px; border-top: 1px solid #eeece6; }
.chat-composer input[type="text"] { flex: 1; margin: 0; }
.chat-composer .icon-btn { flex-shrink: 0; }

/* การ์ดออเดอร์ในแชท — แยกจากบับเบิลข้อความ (ไม่ใช่สี่เหลี่ยมพูดคุย) เพื่อให้เด่น อ่านง่าย และกดไปหน้าสินค้าได้จริง */
.order-card-wrap { max-width: 84%; display: flex; flex-direction: column; gap: 4px; margin: 2px 0; }
.order-card-wrap.mine { align-self: flex-end; align-items: flex-end; }
.order-card-wrap.theirs { align-self: flex-start; align-items: flex-start; }
.order-card-caption { font-size: 12px; color: var(--grey-400); padding: 0 4px; }
.order-card {
  display: flex; gap: 12px; align-items: center; width: 100%;
  background: var(--white); border: 1.5px solid #eeece6; border-radius: 16px; padding: 10px;
  text-decoration: none; color: inherit; box-shadow: 0 1px 4px rgba(28,46,53,0.06);
}
.order-card img { width: 68px; height: 88px; object-fit: cover; border-radius: 10px; flex-shrink: 0; margin: 0; }
.order-card-noimg { width: 68px; height: 88px; border-radius: 10px; background: var(--blue-200); color: var(--blue-600); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 20px; flex-shrink: 0; }
.order-card-info { min-width: 0; flex: 1; }
.order-card-name { font-weight: 700; font-size: 13px; margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--blue-950); }
.order-card-meta { font-size: 12px; color: var(--grey-400); line-height: 1.5; }
.order-card-cta { font-size: 11px; font-weight: 700; color: var(--blue-600); margin-top: 6px; display: flex; align-items: center; gap: 2px; }
.order-card-cta svg { width: 12px; height: 12px; }

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: var(--blue-950); color: var(--white);
  padding: 10px 18px; border-radius: 999px; font-size: 13px; font-weight: 600;
  z-index: 100; opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
.toast.show { opacity: 1; }
