/* ==========================================================================
   Screen168 Member Super-App — Native HTML5 / CSS3 Design System
   Zero-Framework, Instant-Load (<50ms), Mobile & LINE LIFF Optimized
   ========================================================================== */

:root {
  --primary: #0284c7;
  --primary-dark: #0369a1;
  --primary-light: #e0f2fe;
  --accent: #00aeee;
  --line-green: #06c755;
  --line-green-dark: #05a546;
  --indigo: #4f46e5;
  --indigo-light: #eef2ff;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.14);
  --header-h: 56px;
  --bottom-nav-h: 54px;
  --sidebar-w: 230px;
  --safe-top: 0px;
  --safe-bottom: 0px;
}

html.in-liff,
body.in-liff {
  --header-h: 0px;
}

/* iPhone & iPad Safe Area Support (Safari & Home Screen PWA) while keeping Android & LINE LIFF 0px flush */
html.is-ios:not(.in-liff) {
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
html.is-ios.is-pwa:not(.in-liff) {
  --safe-top: env(safe-area-inset-top, 0px);
}
html.keyboard-open {
  --safe-bottom: 0px !important;
}

/* Prevent iOS Safari / iPhone from auto-zooming page when focusing inputs */
@supports (-webkit-touch-callout: none) {
  input,
  textarea,
  select {
    font-size: max(16px, 1em) !important;
  }
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  position: fixed;
  inset: 0;
  font-family: 'Prompt', 'Noto Sans Thai Looped', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

/* Google Material Icons (Flutter Icon Parity) */
.mi, .mi-o {
  font-weight: normal;
  font-style: normal;
  font-size: 20px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'liga';
  user-select: none;
  flex-shrink: 0;
}
.mi {
  font-family: 'Material Icons Round', 'Material Icons';
}
.mi-o {
  font-family: 'Material Icons Outlined', 'Material Icons';
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 2px;
  position: relative;
  transition: color 0.15s;
}
.bottom-nav-item .nav-icon {
  font-size: 22px;
  line-height: 1;
}
.bottom-nav-item.active {
  color: var(--primary);
  font-weight: 700;
}

.nav-badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 18px);
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--surface);
}
/* ==========================================================================
   Common UI Components (Cards, Buttons, Badges, Inputs, Sub-tabs)
   ========================================================================== */
.page-container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px 16px 36px 16px;
}
.page-container.narrow {
  max-width: 680px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  margin-bottom: 14px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 13.5px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}
.btn-line {
  background: var(--line-green);
  color: #fff;
}
.btn-line:hover:not(:disabled) {
  background: var(--line-green-dark);
}
.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-outline {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-outline:hover:not(:disabled) {
  background: var(--bg);
}
.btn-chat-tag {
  background: rgba(79, 70, 229, 0.08);
  color: var(--indigo);
  border: 1px solid rgba(79, 70, 229, 0.32);
  padding: 4px 9px;
  border-radius: 10px;
  font-size: 11.5px;
  font-weight: 600;
}
.btn-chat-tag:hover {
  background: rgba(79, 70, 229, 0.15);
}
.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}
.btn-lg {
  padding: 13px 20px;
  font-size: 15px;
  border-radius: var(--radius-md);
}
.btn-block {
  width: 100%;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

/* Sub-tab Bar */
.subtab-bar {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 12px;
  gap: 4px;
  overflow-x: auto;
  flex-shrink: 0;
}
.subtab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 16px;
  border: none;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.subtab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Inputs */
.form-group {
  margin-bottom: 14px;
}
.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.15s, background 0.15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
}

/* Floating Action Button */
.fab-container {
  position: fixed;
  right: 20px;
  bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 18px);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  z-index: 25;
}
@media (min-width: 860px) {
  .fab-container {
    bottom: 24px;
    right: 28px;
  }
}
.fab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 48px;
  padding: 0 18px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  border: none;
  box-shadow: 0 6px 20px rgba(2, 132, 199, 0.35);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.fab-btn:hover {
  transform: translateY(-2px);
}

/* ==========================================================================
   Home Screen: Member Tier Card & Calendar
   ========================================================================== */
.tier-card {
  border-radius: var(--radius-lg);
  padding: 18px;
  color: #fff;
  position: relative;
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
}
.tier-progress-track {
  width: 100%;
  height: 7px;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  overflow: hidden;
  margin: 10px 0 6px 0;
}
.tier-progress-bar {
  height: 100%;
  background: #fde047;
  border-radius: 999px;
  transition: width 0.3s ease;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.cal-weekday {
  background: #f8fafc;
  padding: 8px 4px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.cal-day {
  min-height: 54px;
  padding: 6px;
  background: #fff;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  position: relative;
  transition: background 0.12s;
}
.cal-day:hover {
  background: #f1f5f9;
}
.cal-day.today {
  background: rgba(2, 132, 199, 0.07);
}
.cal-day.selected {
  background: var(--primary);
  color: #fff;
}
.cal-day.outside {
  background: #f8fafc;
  color: #cbd5e1;
  pointer-events: none;
}
.cal-closed-tag {
  position: absolute;
  right: 4px;
  bottom: 4px;
  background: var(--danger);
  color: #fff;
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 6px;
}

/* ==========================================================================
   Products Grid & 3D Banner
   ========================================================================== */
.banner-3d {
  background: linear-gradient(135deg, #0f172a, #1e293b);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: var(--radius-lg);
  padding: 16px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  margin-bottom: 16px;
  box-shadow: var(--shadow-md);
}
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 14px;
}
.product-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
}
.product-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #f8fafc;
  object-fit: cover;
}

/* ==========================================================================
   Chat Screen — Exact 1:1 Flutter ChatScreen & ChatBubble
   ========================================================================== */
#tab-chat {
  padding: 0 !important;
  max-width: none !important;
  margin: 0 !important;
}

.flt-chat-wrap {
  display: flex;
  flex-direction: column;
  flex: 1;
  height: 100%;
  min-height: 0;
  background: #ffffff;
  overflow: hidden;
}

.flt-chat-header {
  background: #ffffff;
  padding: 12px 16px;
  border-bottom: 1px solid #eeeeee;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.flt-chat-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.flt-chat-shop-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #f5f5f5;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.flt-chat-shop-avatar img {
  width: 36px;
  height: 36px;
  object-fit: cover;
  display: block;
}

.flt-chat-header-titles {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.flt-chat-header-title {
  font-size: 15px;
  font-weight: 700;
  color: #212121;
  line-height: 1.25;
}
.flt-chat-header-subtitle {
  font-size: 12px;
  color: #757575;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.flt-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.flt-chat-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: #616161;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}
.flt-chat-icon-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

/* Search Bar */
.flt-chat-search-bar {
  background: #ffffff;
  padding: 6px 12px;
  border-bottom: 1px solid #eeeeee;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.flt-chat-search-pill {
  flex: 1;
  height: 34px;
  background: #f5f5f5;
  border-radius: 18px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.flt-chat-search-pill input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 13px;
  font-family: inherit;
  color: #212121;
  min-width: 0;
}

/* Messages Scroll Area */
.flt-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  background: #ffffff;
}

.flt-chat-date-sep {
  align-self: center;
  margin: 12px 0;
  padding: 5px 14px;
  background: #e0e0e0;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  color: #616161;
}

.flt-chat-msg-wrap {
  padding-bottom: 12px;
  display: flex;
  flex-direction: column;
}

.flt-chat-msg-row {
  display: flex;
  align-items: flex-end;
}
.flt-chat-msg-row.user {
  justify-content: flex-end;
}
.flt-chat-msg-row.shop {
  justify-content: flex-start;
  align-items: flex-start;
}

.flt-chat-sender-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #f5f5f5;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  margin-right: 8px;
}
.flt-chat-sender-avatar img {
  width: 28px;
  height: 28px;
  object-fit: cover;
  display: block;
}

.flt-chat-user-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-end;
  padding-right: 6px;
  padding-bottom: 2px;
  flex-shrink: 0;
}
.flt-chat-read-avatars {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-bottom: 2px;
}
.flt-chat-read-avatar {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #e3f2fd;
  color: #1565c0;
  font-size: 7px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.flt-chat-read-avatar img {
  width: 12px;
  height: 12px;
  object-fit: cover;
}
.flt-chat-read-text {
  font-size: 10px;
  color: #1e88e5;
  font-weight: 700;
  line-height: 1.1;
}
.flt-chat-time {
  font-size: 10px;
  color: #9e9e9e;
  line-height: 1.2;
}
.flt-chat-shop-time {
  padding-top: 4px;
  padding-left: 6px;
  padding-bottom: 2px;
  font-size: 10px;
  color: #9e9e9e;
}

.flt-chat-bubble {
  max-width: 300px;
  padding: 8px 12px;
  font-size: 14px;
  line-height: 1.45;
  color: #212121;
  word-break: break-word;
  position: relative;
  cursor: pointer;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.flt-chat-bubble.user {
  background: rgba(0, 185, 0, 0.15);
  border-radius: 16px 16px 4px 16px;
  border: 1px solid transparent;
}
.flt-chat-bubble.shop {
  background: #ffffff;
  border-radius: 16px 16px 16px 4px;
  border: 1px solid #eeeeee;
}
.flt-chat-bubble.highlighted {
  background: rgba(255, 213, 79, 0.35) !important;
  border: 2px solid #ffb300 !important;
}

.flt-chat-reply-quote {
  margin-bottom: 6px;
  padding: 8px;
  background: rgba(76, 175, 80, 0.15);
  border-radius: 8px;
  cursor: pointer;
}

.flt-chat-img-thumb {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  display: inline-block;
  background: #f1f5f9;
}
.flt-chat-img-thumb img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 10px;
}
.flt-chat-img-badge {
  position: absolute;
  right: 4px;
  bottom: 4px;
  padding: 2px 5px;
  background: rgba(0, 0, 0, 0.54);
  border-radius: 6px;
  color: #ffffff;
  font-size: 9px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

/* Reply Preview Bar above Input */
.flt-chat-reply-bar {
  background: #fafafa;
  padding: 8px 16px;
  border-top: 1px solid #eeeeee;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Input Bar */
.flt-chat-input-wrap {
  background: #ffffff;
  padding: 6px 12px 10px;
  border-top: 1px solid #eeeeee;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.flt-chat-ext-hint {
  padding: 0 8px 4px;
  font-size: 10px;
  color: #9e9e9e;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.flt-chat-input-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.flt-chat-pill-input {
  flex: 1;
  background: #f5f5f5;
  border-radius: 24px;
  padding: 10px 16px;
  border: none;
  outline: none;
  font-size: 14px;
  font-family: inherit;
  color: #212121;
  resize: none;
  max-height: 100px;
  line-height: 1.35;
}
.flt-chat-pill-input::placeholder {
  color: #9e9e9e;
}

/* ==========================================================================
   Image & Shirt Studio (5 Tabs)
   ========================================================================== */
.studio-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  padding: 0;
  max-width: 1360px;
  margin: 0 auto;
}
@media (min-width: 960px) {
  .studio-layout {
    grid-template-columns: 1fr 380px;
    align-items: start;
    gap: 18px;
  }
}
.studio-canvas-box {
  background: #1e293b;
  background-image:
    linear-gradient(45deg, #0f172a 25%, transparent 25%),
    linear-gradient(-45deg, #0f172a 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #0f172a 75%),
    linear-gradient(-45deg, transparent 75%, #0f172a 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  border-radius: var(--radius-lg);
  min-height: 420px;
  max-height: 72vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  border: 1px solid #334155;
}
.studio-canvas-box canvas, .studio-canvas-box img {
  max-width: 100%;
  max-height: 68vh;
  object-fit: contain;
}
.color-swatch-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid var(--border);
  font-size: 12px;
  font-family: monospace;
}
.swatch-dot {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid rgba(0,0,0,0.2);
}

/* ==========================================================================
   CCTV Live Grid
   ========================================================================== */
.cctv-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  padding: 16px;
}
@media (min-width: 600px) {
  .cctv-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (min-width: 960px) {
  .cctv-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
.cctv-card {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow-md);
}
.cctv-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.cctv-cam-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.68);
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 6px;
}

