/* Shared merchant styles */
:root {
  --bg: #f9fafb;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --card: #ffffff;
  --primary: #2563eb;
  --danger: #dc2626;
  --nav: #111827;
}

* { box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--primary); text-decoration: none; }

.container { max-width: 1200px; margin: 32px auto; padding: 0 16px; }
.header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

.btn {
  display: inline-block;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  border: none;
  cursor: pointer;
}
.btn.secondary { background: #6b7280; }
.btn.danger { background: var(--danger); }

.input, select, textarea {
  width: 100%;
  max-width: 420px;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  font-size: 15px;
}
.input, select { min-height: 42px; }
textarea { min-height: 96px; resize: vertical; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.muted { color: #9ca3af; font-size: 12px; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--border); text-align: left; font-size: 14px; }
th { background: #f3f4f6; font-weight: 600; }

.thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }

.preview-list img { width: 80px; height: 80px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); margin-right: 6px; margin-top: 6px; }

/* Merchant navigation */
.nav {
  background: var(--nav);
  color: #fff;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.nav a { color: #fff; }
.nav .nav-brand { font-weight: 700; margin-right: 8px; }
.nav .nav-links { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.nav .nav-group { position: relative; display: flex; align-items: center; gap: 8px; }
.nav .nav-group-toggle {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: none;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.nav .nav-group-toggle::after { content: '▾'; opacity: .75; font-size: 12px; }
.nav .nav-group.open .nav-group-toggle::after { content: '▴'; }

/* Top layout: submenu dropdown */
.nav .nav-sub {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: rgba(17,24,39,0.98);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 12px;
  padding: 8px;
  min-width: 200px;
  box-shadow: 0 10px 22px rgba(0,0,0,0.25);
}
.nav .nav-group.open .nav-sub { display: block; }
.nav .nav-sub .nav-link { display: block; width: 100%; }

.nav .nav-link { padding: 6px 10px; border-radius: 8px; background: rgba(255,255,255,0.08); position: relative; }
.nav .nav-link.active { background: var(--primary); }
.nav .nav-actions { margin-left: auto; display: flex; gap: 8px; }
.nav .nav-toggle, .nav .nav-collapse { background: rgba(255,255,255,0.12); color: #fff; border: none; padding: 6px 10px; border-radius: 8px; cursor: pointer; }

/* Left nav layout: nested list */
.nav-left .nav .nav-links { flex-direction: column; align-items: stretch; }
.nav-left .nav .nav-group { flex-direction: column; align-items: stretch; gap: 6px; }
.nav-left .nav .nav-group-toggle { width: 100%; justify-content: space-between; }
.nav-left .nav .nav-sub { position: static; display: none; background: transparent; border: none; box-shadow: none; padding: 0 0 0 10px; min-width: 0; }
.nav-left .nav .nav-group.open .nav-sub { display: block; }
.nav-left .nav .nav-sub .nav-link { margin-top: 6px; }

.nav-left.nav-collapsed .nav .nav-sub { display: none !important; }
.nav-left.nav-collapsed .nav .nav-group-toggle { position: relative; color: transparent; }
.nav-left.nav-collapsed .nav .nav-group-toggle::before { content: attr(data-short); color: #fff; position: absolute; left: 10px; top: 6px; font-size: 14px; }
.nav-left.nav-collapsed .nav .nav-group-toggle::after { display: none; }

/* Left nav layout controlled on <html> */
.nav-left .nav { position: fixed; left: 0; top: 0; bottom: 0; width: 220px; flex-direction: column; align-items: stretch; padding: 16px; }
.nav-left .nav .nav-actions { margin-left: 0; margin-top: auto; }
.nav-left .nav .nav-links { flex-direction: column; align-items: stretch; }

.page { }
.nav-left .page { margin-left: 240px; }
.nav-left.nav-collapsed .page { margin-left: 84px; }

.nav-left.nav-collapsed .nav { width: 64px; padding: 12px 10px; }
.nav-left.nav-collapsed .nav .nav-links span { display: none; }
.nav-left.nav-collapsed .nav .nav-brand a { font-size: 0; }
.nav-left.nav-collapsed .nav .nav-brand a::before { content: '商'; font-size: 16px; font-weight: 700; }
.nav-left.nav-collapsed .nav .nav-link { color: transparent; }
.nav-left.nav-collapsed .nav .nav-link::before { content: attr(data-short); color: #fff; position: absolute; left: 10px; top: 6px; font-size: 14px; }
.nav-left.nav-collapsed .nav button { position: relative; color: transparent; }
.nav-left.nav-collapsed .nav button::before { content: attr(data-short); color: #fff; position: absolute; left: 10px; top: 6px; font-size: 14px; }

/* Sections / modals */
.section-title { display:flex; align-items:center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.flash { animation: flash 1.2s ease-in-out 0s 2; }
@keyframes flash {
  0% { box-shadow: 0 0 0 0 rgba(37,99,235,0); }
  50% { box-shadow: 0 0 0 6px rgba(37,99,235,0.25); }
  100% { box-shadow: 0 0 0 0 rgba(37,99,235,0); }
}

.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.45); display: none; align-items: center; justify-content: center; padding: 24px 16px; z-index: 1000; }
.modal.open { display: flex; }
.modal-card { width: min(760px, 100%); background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 16px; box-shadow: 0 20px 50px rgba(0,0,0,0.25); }
.modal-header { display:flex; align-items:center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.modal-title { font-size: 16px; font-weight: 700; }

/* Searchable combo */
.combo { position: relative; }
.combo-list { display: none; position: absolute; left: 0; right: 0; top: calc(100% + 6px); background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 6px; box-shadow: 0 12px 30px rgba(0,0,0,0.12); max-height: 280px; overflow: auto; z-index: 20; }
.combo.open .combo-list { display: block; }
.combo-item { padding: 8px 10px; border-radius: 10px; cursor: pointer; }
.combo-item:hover { background: #f3f4f6; }
.combo-empty { padding: 10px; color: #9ca3af; font-size: 13px; }

/* ===== Mobile-first enhancements (cards / responsive) ===== */

.d-only { display: block; }
.m-only { display: none; }

.btn.sm { padding: 7px 10px; border-radius: 10px; font-size: 14px; }
.btn.block { display: inline-flex; justify-content: center; align-items: center; width: 100%; }

.chip { display:inline-flex; align-items:center; gap:6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; border: 1px solid var(--border); background: #fff; color: var(--text); }
.chip.primary { border-color: rgba(37,99,235,.25); background: rgba(37,99,235,.08); color: #1d4ed8; }
.chip.success { border-color: rgba(16,185,129,.25); background: rgba(16,185,129,.10); color: #047857; }
.chip.warn { border-color: rgba(245,158,11,.25); background: rgba(245,158,11,.12); color: #b45309; }
.chip.danger { border-color: rgba(220,38,38,.25); background: rgba(220,38,38,.10); color: #b91c1c; }

.card-list { display:flex; flex-direction:column; gap: 12px; }
.card-item { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 14px; box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
.card-item .card-top { display:flex; gap: 12px; align-items:flex-start; }
.card-item .card-thumb { width: 64px; height: 64px; border-radius: 14px; border: 1px solid var(--border); object-fit: cover; background:#f3f4f6; flex: 0 0 auto; }
.card-item .card-title { font-size: 16px; font-weight: 750; line-height: 1.25; }
.card-item .card-sub { margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.35; word-break: break-all; }
.card-item .card-meta { margin-top: 10px; display:flex; flex-wrap:wrap; gap: 8px; }
.card-item .card-kv { display:flex; justify-content:space-between; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.card-item .card-kv .k { color: var(--muted); font-size: 12px; }
.card-item .card-kv .v { font-weight: 700; font-size: 13px; }
.card-item .card-actions { margin-top: 12px; display:flex; gap: 10px; flex-wrap: wrap; }

/* Sticky action bar (forms) */
.sticky-actions {
  margin-top: 16px;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}

/* Forms: keep controls comfortable */
.btn { min-height: 40px; }
.input, select, textarea { line-height: 1.2; }

@media (max-width: 860px) {
  body { padding-bottom: 86px; }
  .container { margin: 16px auto; padding: 0 12px; }

  /* 手机上强制使用顶部导航（即使用户在电脑上选了左侧导航） */
  .nav-left .nav { position: sticky; left: auto; top: 0; bottom: auto; width: auto; flex-direction: row; align-items: center; padding: 10px 16px; }
  .nav-left .page { margin-left: 0 !important; }
  .nav-left.nav-collapsed .page { margin-left: 0 !important; }
  .nav-left.nav-collapsed .nav { width: auto; padding: 10px 16px; }
  .nav-left.nav-collapsed .nav .nav-brand a { font-size: inherit; }
  .nav-left.nav-collapsed .nav .nav-brand a::before { content: none; }
  .nav-left.nav-collapsed .nav .nav-link::before { content: none; }
  .nav-left.nav-collapsed .nav button::before { content: none; }
  .header { flex-direction: column; align-items: flex-start; }
  .header > div { width: 100%; display:flex; gap: 10px; flex-wrap: wrap; }

  .input, select, textarea { max-width: 100%; }
  th, td { font-size: 13px; }

  /* show mobile-only sections */
  .d-only { display: none !important; }
  .m-only { display: block !important; }

  /* Top nav becomes a compact bar + collapsible content */
  .nav { flex-wrap: wrap; gap: 10px; }
  .nav .nav-links, .nav .nav-actions { display: none; width: 100%; }
  .nav.mobile-open .nav-links, .nav.mobile-open .nav-actions { display: flex; }
  .nav .nav-links { flex-direction: column; align-items: stretch; }
  .nav .nav-sub { position: static; background: transparent; border: none; box-shadow: none; padding: 6px 0 0 10px; }
  .nav .nav-link { width: 100%; }

  .nav .nav-actions { flex-direction: column; align-items: stretch; margin-left: 0; }
  .nav .nav-actions > * { width: 100%; }
  .nav .nav-actions input { max-width: 100% !important; }

  .nav .nav-mobile-toggle { display: inline-flex; margin-left: auto; }

  .sticky-actions {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 60;
    padding: 10px;
    border-radius: 16px;
    border: 1px solid rgba(229,231,235,0.9);
    background: rgba(249,250,251,0.82);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 10px 24px rgba(0,0,0,0.10);
  }
}

@media (min-width: 861px) {
  .nav .nav-mobile-toggle { display: none; }
}
