/* checkin-tablets-v1 — merchant tablet management. Self-contained. */

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-sans); -webkit-font-smoothing: antialiased; }
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }

/* ============ APP SHELL ============ */
.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 720px);
  gap: 24px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

/* ============ SIDEBAR ============ */
.sidebar { position: sticky; top: 24px; height: calc(100vh - 48px); display: flex; flex-direction: column; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 14px; font-size: 32px; font-weight: 800; margin-bottom: 36px; color: var(--text); }
.brand img { width: 42px; height: 42px; object-fit: contain; }
.sidebar nav { display: flex; flex-direction: column; gap: 8px; }
.sidebar nav a {
  padding: 14px 18px;
  color: var(--text-soft);
  border-radius: 999px;
  font-weight: 600;
  font-size: 16px;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.sidebar nav a.active,
.sidebar nav a:hover {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-card);
}
.new-post {
  border-radius: 999px;
  background: var(--cta-bg);
  color: var(--cta-text);
  font-weight: 700;
  padding: 14px 22px;
  font-size: 16px;
}

/* ============ MAIN ============ */
.main { min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; min-height: 44px; gap: 12px;
}
.topbar .back {
  display: none;
  width: 36px; height: 36px;
  align-items: center; justify-content: center;
  font-size: 22px; color: var(--text);
}
.topbar h1 { font-size: 26px; margin: 0; font-weight: 700; letter-spacing: -0.01em; flex: 1; }
.topbar-brand { display: none; align-items: center; gap: 8px; color: var(--text); font-weight: 800; font-size: 22px; letter-spacing: -0.01em; }
.topbar-brand img { width: 24px; height: 24px; object-fit: contain; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 18px 22px;
  margin-bottom: 14px;
}
.sec-head { margin-bottom: 14px; }
.sec-head h2 { font-size: 15px; margin: 0; font-weight: 700; }
.sec-sub { margin: 4px 0 0; font-size: 12px; color: var(--text-soft); line-height: 1.5; }

.pg-back {
  display: inline-block;
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-soft);
}
.pg-back:hover { color: var(--primary-dark); }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: 0.5px; }

/* 被禁止用戶入口（右對齊 people icon + 人數，同 checkin-rank-v1 一致） */
.visitors-bar { text-align: right; margin: 0 0 10px; }
.visitors-link {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  transition: background 0.15s;
}
.visitors-link b { font-weight: 800; }
.visitors-link.banned { background: #fee2e2; color: #b91c1c; }
.visitors-link.banned:hover { background: #b91c1c; color: #fff; }
.visitors-bar[hidden] { display: none !important; }

#view-list[hidden], #view-detail[hidden] { display: none !important; }

/* ============ TABLET LIST ============ */
.t-list { display: flex; flex-direction: column; }
.t-row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 2px;
  border-bottom: 1px solid var(--line);
  transition: background 0.15s;
}
.t-row:last-child { border-bottom: 0; }
.t-row:hover { background: var(--surface-soft); }
.t-ic {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.t-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.t-main b { font-size: 13.5px; }
.t-main small { font-size: 11px; color: var(--text-muted); }
.t-stat { text-align: right; display: flex; flex-direction: column; gap: 2px; flex-shrink: 0; }
.t-stat b { font-size: 13px; font-variant-numeric: tabular-nums; }
.t-stat small { font-size: 10.5px; color: var(--text-muted); }
.t-chev { color: var(--text-muted); flex-shrink: 0; }
.t-row.off .t-ic, .t-row.off .t-main, .t-row.off .t-stat { opacity: 0.5; }

.t-pill {
  flex-shrink: 0;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 800;
}
.t-pill.on { background: rgba(16, 185, 129, 0.14); color: #059669; }
.t-pill.off { background: #fee2e2; color: #b91c1c; }

/* ============ DETAIL HEAD ============ */
.t-headcard .t-idrow { display: flex; align-items: center; gap: 12px; }
.t-who { flex: 1; min-width: 0; }
.t-who b { display: block; font-size: 15px; font-weight: 800; }
.t-who small { display: block; font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.t-namebtn { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; text-align: left; }
.t-namebtn svg { color: var(--text-muted); flex-shrink: 0; transition: color 0.15s; }
.t-namebtn:hover svg { color: var(--primary-dark); }
.t-toggle {
  display: block;
  width: 100%;
  margin-top: 14px;
  padding: 11px 16px;
  border-radius: 12px;
  border: 1px solid #fca5a5;
  background: #fff;
  color: #b91c1c;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.t-toggle:hover { background: #fee2e2; }
.t-toggle.undo { border-color: var(--line); color: var(--text-soft); }
.t-toggle.undo:hover { background: var(--primary-soft); color: var(--primary-dark); border-color: var(--primary); }
.t-hint { margin: 10px 0 0; font-size: 11px; color: var(--text-muted); line-height: 1.55; }

/* ============ MAP ============ */
.t-map { border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--surface-soft); }
.t-map iframe { display: block; width: 100%; height: 220px; border: 0; }
.t-addr {
  margin: 10px 0 0;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-soft);
}

/* ============ DAILY BARS ============ */
.t-days { display: flex; flex-direction: column; gap: 8px; }
.d-row { display: flex; align-items: center; gap: 10px; }
.d-row small { width: 58px; flex-shrink: 0; font-size: 11.5px; color: var(--text-soft); font-weight: 600; }
.d-row b { width: 34px; flex-shrink: 0; text-align: right; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.d-bar { flex: 1; height: 10px; border-radius: 999px; background: var(--surface-soft); overflow: hidden; }
.d-bar i {
  display: block; height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  min-width: 4px;
}

/* ============ USER RECORDS (同 checkin-rank-v1 樣式) ============ */
.t-users { display: flex; flex-direction: column; max-height: 420px; overflow-y: auto; scrollbar-width: thin; }
.rk-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--line);
}
.rk-row:last-child { border-bottom: 0; }
.rk-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-dark);
  display: grid; place-items: center;
  font-weight: 800;
  font-size: 14px;
  flex-shrink: 0;
}
.rk-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.rk-main b { font-size: 13.5px; }
.rk-main small { font-size: 11.5px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rk-pill {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 1px 7px;
  border-radius: 999px;
  background: #fee2e2;
  color: #b91c1c;
  font-size: 10.5px;
  font-weight: 700;
}
.rk-pill.freq { background: #fef3c7; color: #b45309; }
.rk-stats { text-align: right; display: flex; flex-direction: column; gap: 2px; flex-shrink: 0; }
.rk-stats b { font-size: 13px; }
.rk-stats small { font-size: 11px; color: var(--text-muted); }
.rk-act {
  flex-shrink: 0;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid #fca5a5;
  background: #fff;
  color: #b91c1c;
  font-size: 12px;
  font-weight: 700;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.rk-act:hover { background: #fee2e2; }
.rk-act.undo { border-color: var(--line); color: var(--text-muted); }
.rk-act.undo:hover { background: var(--primary-soft); color: var(--primary-dark); border-color: var(--primary); }
.rk-row.banned .rk-avatar,
.rk-row.banned .rk-main b,
.rk-row.banned .rk-stats { opacity: 0.55; }
.rk-foot {
  margin: 10px 2px 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--text-muted);
}

/* ============ RENAME MODAL ============ */
.tn-modal { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; }
.tn-modal[hidden] { display: none !important; }
.tn-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.45); }
.tn-sheet {
  position: relative;
  width: min(320px, calc(100vw - 48px));
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.3);
  padding: 20px;
}
.tn-sheet h3 { margin: 0 0 12px; font-size: 15px; font-weight: 800; }
#tn-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  font-weight: 700;
  color: var(--text);
  background: var(--surface);
}
#tn-input:focus { outline: 2px solid var(--primary); border-color: transparent; }
.tn-actions { display: flex; gap: 10px; margin-top: 14px; }
.tn-actions button {
  flex: 1;
  padding: 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  transition: background 0.15s, color 0.15s;
}
.tn-cancel { border: 1px solid var(--line); color: var(--text-soft); }
.tn-cancel:hover { background: var(--surface-soft); }
.tn-save { background: var(--cta-bg); color: var(--cta-text); }

/* ============ TOAST ============ */
.ck-toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translate(-50%, 12px);
  background: var(--text);
  color: white;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.4);
  opacity: 0;
  pointer-events: none;
  z-index: 200;
  transition: opacity 0.2s, transform 0.2s;
}
.ck-toast.show { opacity: 0.92; transform: translate(-50%, 0); }
.ck-toast[hidden] { display: none !important; }

/* ============ MOBILE NAV ============ */
.mobile-nav { display: none; }

/* ============ RESPONSIVE ============ */
@media (max-width: 1024px) {
  .app-shell { grid-template-columns: 220px minmax(0, 1fr); padding: 16px; gap: 18px; }
}

@media (max-width: 720px) {
  .app-shell { grid-template-columns: 1fr; padding: 0; gap: 0; }
  .sidebar { display: none; }
  .main { padding: 14px 16px 100px; }
  .topbar { padding: 4px 0 10px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
  .topbar .back { display: inline-flex; }
  .topbar h1 { font-size: 18px; text-align: center; }
  .topbar-brand { display: none; }

  .mobile-nav {
    position: fixed;
    left: 12px; right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: center;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--line);
    border-radius: 24px;
    box-shadow: var(--shadow-card);
    padding: 10px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    z-index: 20;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s;
  }
  .mobile-nav.nav-hidden {
    transform: translateY(calc(100% + 24px));
    opacity: 0;
    pointer-events: none;
  }
  .mobile-nav a { text-align: center; font-size: 12px; color: var(--text-soft); padding: 8px 4px; }
  .mobile-nav a.active { color: var(--text); font-weight: 600; }
  .mobile-nav .compose-btn {
    width: 46px; height: 46px;
    margin: auto; padding: 0;
    border-radius: 50%;
    background: var(--cta-bg); color: var(--cta-text);
    display: grid; place-items: center; line-height: 1;
  }
}
