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

:root {
  --bg:        #1f2230;   /* Smart Coin dark navy */
  --surface:   #282c3f;
  --surface2:  #353a52;
  --border:    #454b68;
  --text:      #ffffff;
  --muted:     #9298b3;
  --accent:    #f7931a;   /* Bitcoin orange — Smart Coin theme color */
  --accent2:   #d97e0a;
  --success:   #22c55e;
  --danger:    #ef4444;
  --warning:   #f7931a;
  --radius:    12px;
  --radius-sm: 8px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Pages */
.page { display: none; flex-direction: column; min-height: 100dvh; }
.page.active { display: flex; }
.page-content { flex: 1; padding: 16px; padding-bottom: 80px; max-width: 480px; margin: 0 auto; width: 100%; }

/* Top bar */
.top-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 8px; max-width: 480px; margin: 0 auto; width: 100%;
}
.top-bar h1 { font-size: 20px; font-weight: 700; }

/* Bottom nav */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--surface); border-top: 1px solid var(--border);
  display: flex; z-index: 100;
}
.bottom-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 10px 0; text-decoration: none;
  color: var(--muted); font-size: 11px; gap: 4px; transition: color .15s;
}
.bottom-nav a.active { color: var(--accent); }
.bottom-nav svg { width: 22px; height: 22px; }
.nav-badge {
  position: absolute;
  top: 2px;
  left: 50%;
  margin-left: 6px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 99px;
  background: var(--danger, #e5484d);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  box-sizing: border-box;
}

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; text-align: center; }
.stat-card .value { font-size: 28px; font-weight: 700; color: var(--accent); }
.stat-card .label { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: var(--radius-sm); border: none;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: opacity .15s, transform .1s; text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: #1f2230; }
.btn-primary:hover { background: var(--accent2); }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-ghost   { background: var(--surface2); color: var(--text); }
.btn-tg      { background: #229ED9; color: #fff; font-size: 15px; padding: 12px 18px; }
.btn-tg:hover { background: #1c8dc2; }
.btn-sm      { padding: 6px 12px; font-size: 13px; }
.btn-full    { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary:disabled { background: var(--surface2); color: var(--muted); opacity: 1; }

/* Forms */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%; background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); padding: 10px 12px;
  font-size: 15px; outline: none; transition: border-color .15s;
}
.form-group input:focus,
.form-group textarea:focus { border-color: var(--accent); }
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Product list */
.product-item { display: flex; gap: 12px; align-items: flex-start; }
.product-thumb { width: 64px; height: 64px; border-radius: var(--radius-sm); object-fit: cover; background: var(--surface2); flex-shrink: 0; }
.product-thumb-placeholder { width: 64px; height: 64px; border-radius: var(--radius-sm); background: var(--surface2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 24px; }
.product-info { flex: 1; min-width: 0; }
.product-info h3 { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.product-info .price { color: var(--accent); font-weight: 700; font-size: 14px; margin-top: 2px; }
.product-info .stock { color: var(--muted); font-size: 12px; }
.product-actions { display: flex; gap: 6px; margin-top: 8px; }

/* Image upload */
.image-upload-area {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 24px; text-align: center; cursor: pointer;
  transition: border-color .15s; position: relative;
}
.image-upload-area:hover { border-color: var(--accent); }
.image-upload-area input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.image-preview { width: 100%; max-height: 200px; object-fit: cover; border-radius: var(--radius-sm); margin-bottom: 8px; }

/* Order badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.badge-pending   { background: #78350f; color: #fde68a; }
.badge-confirmed { background: #1e3a5f; color: #93c5fd; }
.badge-shipped   { background: #1e3a2f; color: #86efac; }
.badge-completed { background: #14532d; color: #4ade80; }
.badge-cancelled { background: #450a0a; color: #fca5a5; }

/* Filter tabs */
.filter-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 0 16px 12px; scrollbar-width: none; }
.filter-tabs::-webkit-scrollbar { display: none; }

/* Gallery grid */
.gallery-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.gallery-cell { position: relative; aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface2); }
.gallery-cell img { width: 100%; height: 100%; object-fit: cover; }
.gallery-cell.pending { outline: 2px dashed var(--accent); outline-offset: -2px; }
.gallery-remove {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(0,0,0,.65); color: #fff; border: none;
  font-size: 12px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.gallery-add {
  aspect-ratio: 1; border: 2px dashed var(--border); border-radius: var(--radius-sm);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer; color: var(--muted); transition: border-color .15s;
}
.gallery-add:hover { border-color: var(--accent); }

/* Shop logo upload */
.logo-upload { display: flex; align-items: center; gap: 14px; }
.logo-circle {
  width: 84px; height: 84px; border-radius: 50%;
  border: 2px dashed var(--border); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; text-align: center;
  color: var(--muted); font-size: 24px; line-height: 1.2;
  transition: border-color .15s; background: var(--surface2);
}
.logo-circle:hover { border-color: var(--accent); }
.logo-circle img { width: 100%; height: 100%; object-fit: cover; }

/* Weekly operating hours */
.hours-header, .hours-row {
  display: grid;
  grid-template-columns: 30px 1fr 52px;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.hours-header {
  padding-bottom: 6px;
  font-size: 10.5px; font-weight: 700; color: var(--muted);
  letter-spacing: 0;
}
.hours-head-times { text-align: center; }
.hours-head-off   { text-align: center; }
.hours-row:last-child { border-bottom: none; }
.hours-day { font-size: 13px; font-weight: 600; }
.hours-closed-label { display: flex; align-items: center; justify-content: center; }
.hours-times { display: flex; align-items: center; gap: 6px; min-width: 0; }
.hours-times input[type=time] {
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); padding: 5px 4px; font-size: 12px; flex: 1; min-width: 0; box-sizing: border-box;
}
.hours-times input:disabled { opacity: .35; }
.hours-row.is-closed .hours-times { opacity: .35; }

/* Special off-days chips */
.offday-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface2); border: 1px solid var(--border); border-radius: 99px;
  padding: 5px 6px 5px 12px; font-size: 12px; margin: 0 6px 6px 0;
}
.offday-chip button {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 14px; line-height: 1; padding: 2px 4px; border-radius: 50%;
}
.offday-chip button:hover { color: var(--danger); }

/* Map picker (shop location) */
.map-picker-wrap { position: relative; margin-top: 10px; border-radius: var(--radius); overflow: hidden; }
.search-clear-wrap { position: relative; }
.search-clear-wrap input { padding-right: 38px; }
.search-clear-btn {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 26px; height: 26px; border-radius: 50%; border: none;
  background: var(--surface2); color: var(--muted); cursor: pointer;
  font-size: 13px; display: flex; align-items: center; justify-content: center;
}
.search-clear-btn:hover { background: var(--border); color: var(--text); }
.map-picker { width: 100%; height: 240px; background: var(--surface2); }
.map-picker-loading { position: absolute; inset: 0; background: var(--surface2); display: flex; align-items: center; justify-content: center; }
.map-locate-btn {
  width: 40px; height: 40px; margin: 10px; border-radius: 50%;
  background: #fff; color: #1f2230; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.map-locate-btn:disabled { opacity: .5; }
.pac-container {
  z-index: 10000; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); margin-top: 4px; font-family: inherit;
}
.pac-item { color: var(--text); border-color: var(--border); padding: 8px 10px; font-size: 13px; }
.pac-item:hover, .pac-item-selected { background: var(--surface2); }
.pac-item-query { color: var(--text); }
.pac-matched { color: var(--accent); }
.pac-icon { filter: invert(1) brightness(1.6); }

/* Product tag badges */
.tag { display: inline-block; padding: 1px 7px; border-radius: 99px; font-size: 10px; font-weight: 600; margin-right: 4px; }
.tag-preorder { background: #78350f; color: #fde68a; }
.tag-ready    { background: #14532d; color: #4ade80; }
.tag-delivery { background: var(--surface2); color: var(--muted); }

/* Misc */
.section-title { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 12px; }
.empty-state { text-align: center; color: var(--muted); padding: 48px 0; }
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.error-msg { color: var(--danger); font-size: 13px; margin-top: 8px; }
.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.2); border-top-color: currentColor; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-center { display: flex; align-items: center; justify-content: center; padding: 64px 0; }
.quick-actions { display: flex; gap: 10px; }
.quick-actions .btn { flex: 1; }
.order-meta { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.order-meta span { margin-right: 12px; }
.order-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 6px; }
.delivery-box { background: var(--surface2); border-radius: var(--radius-sm); padding: 10px 12px; margin: 8px 0; }
.delivery-box-title { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.order-actions { display: flex; gap: 8px; margin-top: 10px; }
.order-actions .btn { flex: 1; }


/* ── มีจำหน่าย availability slider (LINE MAN style) ── */
.avail-switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.avail-switch input { opacity: 0; width: 0; height: 0; }
.avail-slider { position: absolute; inset: 0; background: var(--surface2, #555); border-radius: 24px; transition: .2s; }
.avail-slider:before { content: ""; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.avail-switch input:checked + .avail-slider { background: #22c55e; }
.avail-switch input:checked + .avail-slider:before { transform: translateX(20px); }
.avail-switch input:disabled + .avail-slider { opacity: .5; }

/* "Apply เวลาของวันจันทร์..." — centered at the top of the hours section */
.hours-apply-row { text-align: center; padding: 2px 0 8px; display: flex; flex-direction: column; align-items: center; }
.hours-apply-row .btn { font-size: 12px; padding: 5px 14px; }
