/* app.css — site-wide styles
   - L1~L5 seller level colors
   - top announcement bar (does not occlude content)
   - dark mode support
*/

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #06b6d4;

  --announcement-bg: rgba(254, 240, 138, 0.92);
  --announcement-fg: #713f12;
  --announcement-border: rgba(180, 83, 9, 0.2);

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow:    0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);

  --radius: 12px;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: #334155;
  --primary: #818cf8;
  --primary-hover: #a5b4fc;

  --announcement-bg: rgba(113, 63, 18, 0.85);
  --announcement-fg: #fef9c3;
  --announcement-border: rgba(202, 138, 4, 0.4);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding-top: 36px;  /* leave room for announcement bar */
  min-height: 100vh;
}

/* ============= TOP ANNOUNCEMENT BAR (does not occlude content) ============= */
.announcement-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 36px;
  background: var(--announcement-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--announcement-border);
  display: flex;
  align-items: center;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  overflow: hidden;
}
.announcement-bar .label {
  flex-shrink: 0;
  padding: 0 12px;
  font-weight: 600;
  color: var(--announcement-fg);
  font-size: 13px;
  border-right: 1px solid var(--announcement-border);
  height: 100%;
  display: flex;
  align-items: center;
  background: rgba(0,0,0,0.04);
}
.announcement-bar .track-wrap {
  flex: 1;
  overflow: hidden;
  position: relative;
  height: 100%;
}
.announcement-bar .track {
  display: inline-flex;
  align-items: center;
  height: 100%;
  white-space: nowrap;
  animation: scroll-left 60s linear infinite;
  padding-left: 100%;
}
.announcement-bar .item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 32px;
  font-size: 13px;
  color: var(--announcement-fg);
}
.announcement-bar .item::before {
  content: "📢";
  font-size: 12px;
}
@keyframes scroll-left {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-100%); }
}
.announcement-bar.paused .track { animation-play-state: paused; }
.announcement-bar .toggle {
  padding: 0 12px;
  font-size: 12px;
  color: var(--announcement-fg);
  cursor: pointer;
  user-select: none;
  border-left: 1px solid var(--announcement-border);
  height: 100%;
  display: flex;
  align-items: center;
  background: rgba(0,0,0,0.04);
}

/* ============= LEVEL COLORS L1~L5 ============= */
.lv { font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.lv-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.lv-1 { color: #64748b; }
.lv-1 .lv-badge { background: linear-gradient(135deg, #e2e8f0, #cbd5e1); color: #475569; border: 1px solid #94a3b8; }

.lv-2 { color: #b45309; }
.lv-2 .lv-badge { background: linear-gradient(135deg, #fed7aa, #fdba74); color: #7c2d12; border: 1px solid #c2410c; }

.lv-3 .lv-badge {
  background: linear-gradient(135deg, #f1f5f9, #e2e8f0 30%, #cbd5e1);
  color: #334155;
  border: 1px solid #94a3b8;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6);
}

.lv-4 .lv-badge {
  background: linear-gradient(135deg, #fde68a, #fbbf24 40%, #d97706);
  color: #78350f;
  border: 1px solid #b45309;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.5), 0 1px 4px rgba(180, 83, 9, 0.3);
}

/* 黑金钻 L5: animated shimmering dark gold */
.lv-5 { position: relative; }
.lv-5 .lv-badge {
  background: linear-gradient(135deg, #1a1a1a 0%, #0a0a0a 40%, #2d1b00 60%, #1a1a1a 100%);
  background-size: 200% 200%;
  animation: lv5-shift 6s linear infinite;
  color: #ffd700;
  border: 1px solid #ffd700;
  box-shadow: 0 0 8px rgba(255, 215, 0, 0.4), inset 0 0 12px rgba(255, 215, 0, 0.15);
  text-shadow: 0 0 4px rgba(255, 215, 0, 0.6);
  letter-spacing: 1px;
}
.lv-5::after {
  content: "👑";
  margin-left: 2px;
  font-size: 12px;
  filter: drop-shadow(0 0 2px rgba(255, 215, 0, 0.8));
}
@keyframes lv5-shift {
  0%   { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

/* ============= GENERAL ============= */
.container { max-width: 1280px; margin: 0 auto; padding: 0 20px; }
.surface { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px; font-size: 14px; font-weight: 500;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; transition: all .15s; text-decoration: none;
  font-family: inherit;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { background: #dc2626; border-color: #dc2626; }
.btn-success { background: var(--success); color: white; border-color: var(--success); }
.btn-warn { background: var(--warning); color: white; border-color: var(--warning); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { padding: 6px; min-width: 32px; }
.input, select.input, textarea.input {
  width: 100%; padding: 8px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 14px; font-family: inherit;
  transition: border-color .15s;
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1); }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }

/* ============= NAV ============= */
.nav {
  position: sticky;
  top: 36px;  /* below announcement bar */
  z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.nav-inner {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 20px;
  max-width: 1280px; margin: 0 auto;
}
.nav .brand {
  font-weight: 700; font-size: 18px; color: var(--primary);
  text-decoration: none; display: inline-flex; align-items: center; gap: 8px;
}
.nav .brand .logo {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, #6366f1, #ec4899);
  display: inline-flex; align-items: center; justify-content: center;
  color: white; font-size: 16px;
}
.nav-links { display: flex; gap: 4px; flex: 1; }
.nav-links a {
  padding: 6px 12px; border-radius: 6px; font-size: 14px;
  color: var(--text-muted); text-decoration: none;
}
.nav-links a:hover { background: var(--surface-2); color: var(--text); }
.nav-links a.active { background: var(--primary); color: white; }
.nav-actions { display: flex; gap: 8px; align-items: center; }

/* ============= ACCOUNT CARD ============= */
.account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.account-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  display: flex; flex-direction: column;
  border: 1px solid var(--border);
  position: relative;
}
.account-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.account-card .cover {
  height: 160px;
  background: linear-gradient(135deg, #6366f1, #ec4899);
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 48px; font-weight: 700;
  position: relative;
}
.account-card .cover img { width: 100%; height: 100%; object-fit: cover; }
.account-card .top-badge {
  position: absolute; top: 8px; left: 8px;
  padding: 2px 8px; border-radius: 4px;
  background: rgba(0,0,0,0.7); color: white;
  font-size: 11px; font-weight: 600;
}
.account-card .pin-badge {
  position: absolute; top: 8px; right: 8px;
  padding: 2px 8px; border-radius: 4px;
  background: linear-gradient(135deg, #ef4444, #f97316);
  color: white; font-size: 11px; font-weight: 700;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4);
}
.account-card .new-badge {
  position: absolute; bottom: 8px; left: 8px;
  padding: 2px 8px; border-radius: 4px;
  background: linear-gradient(135deg, #10b981, #059669);
  color: white; font-size: 11px; font-weight: 700;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.4);
}
.account-card .fav-btn {
  background: none; border: none; cursor: pointer;
  font-size: 18px; padding: 2px 4px; border-radius: 4px;
  transition: transform .15s;
}
.account-card .fav-btn:hover { transform: scale(1.2); background: var(--surface-2); }
.account-card .body { padding: 12px 14px; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.account-card .title { font-weight: 600; font-size: 15px; color: var(--text); }
.account-card .meta { display: flex; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--text-muted); }
.account-card .price-row {
  margin-top: auto;
  display: flex; justify-content: space-between; align-items: center;
  padding-top: 8px;
}
.account-card .price { font-size: 20px; font-weight: 700; color: var(--danger); }
.account-card .price small { font-size: 12px; color: var(--text-muted); font-weight: 400; }
.account-card .seller-line {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-muted);
  padding-top: 8px; border-top: 1px dashed var(--border);
}

/* ============= FILTERS ============= */
.filters {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
}
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12px;
  background: var(--surface);
  cursor: pointer;
  user-select: none;
  transition: all .15s;
}
.chip:hover { border-color: var(--primary); }
.chip.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ============= BADGES ============= */
.badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.badge-top { background: linear-gradient(135deg, #fef3c7, #fde68a); color: #92400e; border: 1px solid #f59e0b; }
.badge-role { background: var(--surface-2); color: var(--text); }
.badge-level { background: rgba(99, 102, 241, 0.1); color: var(--primary); }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-approved { background: #d1fae5; color: #065f46; }
.badge-rejected { background: #fee2e2; color: #991b1b; }

/* ============= MODAL ============= */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  max-width: 720px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.modal-body { padding: 20px; }
.modal-close {
  background: none; border: none; font-size: 24px;
  cursor: pointer; color: var(--text-muted); padding: 0; line-height: 1;
}

/* ============= TOAST ============= */
.toast-container {
  position: fixed; top: 60px; right: 20px;
  z-index: 2000; display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 12px 18px;
  background: var(--surface);
  border-radius: 8px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
  animation: toast-in .25s ease;
  max-width: 360px;
  font-size: 14px;
}
.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--danger); }
.toast.warn    { border-left-color: var(--warning); }
@keyframes toast-in {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ============= TABLES ============= */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { font-weight: 600; color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.table tr:hover td { background: var(--surface-2); }

/* ============= EMPTY STATE ============= */
.empty {
  padding: 60px 20px; text-align: center; color: var(--text-muted);
  background: var(--surface); border-radius: var(--radius);
}
.empty .emoji { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }

/* ============= UTILITY ============= */
.row { display: flex; gap: 12px; align-items: center; }
.row.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 12px; }
.gap-sm { gap: 6px; } .gap-md { gap: 12px; } .gap-lg { gap: 24px; }
.mt-sm { margin-top: 8px; } .mt-md { margin-top: 16px; } .mt-lg { margin-top: 24px; }
.mb-sm { margin-bottom: 8px; } .mb-md { margin-bottom: 16px; } .mb-lg { margin-bottom: 24px; }
.text-sm { font-size: 12px; } .text-lg { font-size: 16px; } .text-xl { font-size: 20px; }
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-center { text-align: center; }
.fw-bold { font-weight: 600; }

/* ============= CHAT ============= */
.chat-bubble {
  max-width: 70%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 14px;
  word-wrap: break-word;
}
.chat-bubble.mine {
  background: var(--primary); color: white; align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.chat-bubble.theirs {
  background: var(--surface-2); color: var(--text); align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.chat-bubble.system {
  background: var(--surface-2);
  color: var(--text-muted);
  align-self: center;
  font-size: 12px;
  font-style: italic;
}
.chat-container {
  display: flex; flex-direction: column; gap: 8px;
  padding: 16px;
  max-height: 50vh; overflow-y: auto;
}

/* ============= RESPONSIVE ============= */
@media (max-width: 768px) {
  .nav-inner { flex-wrap: wrap; padding: 10px 14px; }
  .nav-links { order: 3; flex-basis: 100%; overflow-x: auto; }
  .container { padding: 0 12px; }
  body { padding-top: 36px; }
  .filters { grid-template-columns: 1fr 1fr; padding: 12px; }
  /* modal full-screen on mobile */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal { max-width: 100%; max-height: 95vh; border-radius: 12px 12px 0 0; }
  /* tab row scrollable */
  .tab-row { overflow-x: auto; flex-wrap: nowrap; }
  .tab { white-space: nowrap; flex-shrink: 0; }
  /* publish button stays reachable */
  .nav-actions { gap: 4px; }
  .nav-actions .btn-sm { padding: 4px 8px; font-size: 12px; }
  /* file inputs bigger tap target */
  input[type=file].input { padding: 12px; min-height: 48px; }
}