/* ============================================================
   Godswar Marketplace — design tokens
   Theme: an enchanted bazaar at dusk. Deep cosmic-violet stone,
   warm gold torchlight, and a low arcane glow drifting through
   the hall. Listings read as lit trade tablets; the notification
   bell carries a living wax-seal badge.
   ============================================================ */

:root {
  /* Color — cosmic-violet stone lit by gold torchlight */
  --obsidian:         #120b21;
  --obsidian-raised:  #1c1336;
  --stone:            #261a49;
  --stone-line:       #4a3a78;
  --parchment:        #f7ecd6;
  --parchment-dim:    #bcaed9;
  --ember:            #f0b429;
  --ember-bright:     #ffce54;
  --rune-red:         #e2483d;
  --rune-red-bright:  #ff7a63;
  --verdigris:        #3fd6a0;
  --arcane:           #9d7bff;
  --arcane-bright:    #b79bff;

  /* RGB shadows for glows / alpha layers */
  --ember-rgb:  240, 180, 41;
  --red-rgb:    226, 72, 61;
  --verd-rgb:   63, 214, 160;
  --arc-rgb:    157, 123, 255;

  /* Type */
  --font-display: 'Cinzel', Georgia, 'Times New Roman', serif;
  --font-body: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;

  /* Layout */
  --radius: 10px;
  --shadow-deep: 0 16px 36px -10px rgba(4, 2, 12, 0.65);
  --shadow-glow: 0 0 0 1px rgba(var(--ember-rgb), 0.12), 0 18px 40px -14px rgba(var(--ember-rgb), 0.22);
  --max-width: 1140px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--obsidian);
  color: var(--parchment);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  isolation: isolate;
}

/* ---------- Ambient aurora backdrop — the signature touch ---------- */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(620px 460px at 12% -6%, rgba(var(--ember-rgb), 0.16), transparent 60%),
    radial-gradient(560px 480px at 88% 8%, rgba(var(--arc-rgb), 0.14), transparent 55%),
    radial-gradient(700px 600px at 50% 110%, rgba(var(--red-rgb), 0.09), transparent 60%),
    radial-gradient(900px 700px at 100% 100%, rgba(var(--verd-rgb), 0.06), transparent 55%);
  animation: aurora-drift 26s ease-in-out infinite alternate;
}
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.35;
  background-image: radial-gradient(rgba(var(--ember-rgb), 0.35) 0.6px, transparent 0.6px);
  background-size: 34px 34px;
  mix-blend-mode: soft-light;
}
@keyframes aurora-drift {
  0%   { transform: translate3d(0, 0, 0) scale(1); }
  50%  { transform: translate3d(-2%, 1.5%, 0) scale(1.04); }
  100% { transform: translate3d(2%, -1%, 0) scale(1.02); }
}

::selection { background: rgba(var(--ember-rgb), 0.35); color: var(--parchment); }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: var(--obsidian); }
::-webkit-scrollbar-thumb { background: var(--stone-line); border-radius: 10px; border: 2px solid var(--obsidian); }
::-webkit-scrollbar-thumb:hover { background: var(--ember); }

a { color: var(--ember-bright); text-decoration: none; transition: color 0.15s ease; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--ember-bright);
  outline-offset: 2px;
  border-radius: 3px;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--parchment);
  margin: 0 0 0.5em 0;
}
h1 {
  background: linear-gradient(135deg, var(--parchment) 35%, var(--ember-bright) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

p { color: var(--parchment); }

.container { max-width: var(--max-width); margin: 0 auto; padding: 0 24px; width: 100%; }

/* ---------- Top nav ---------- */
.topnav {
  background: linear-gradient(180deg, rgba(28, 19, 54, 0.92), rgba(18, 11, 33, 0.92));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--stone-line);
  box-shadow: 0 1px 0 rgba(var(--ember-rgb), 0.08);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topnav .container { display: flex; align-items: center; justify-content: space-between; height: 68px; gap: 24px; }
.brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-display); font-size: 1.25rem;
  color: var(--ember-bright);
  text-shadow: 0 0 18px rgba(var(--ember-rgb), 0.45);
  transition: filter 0.2s ease;
}
.brand:hover { filter: brightness(1.15); text-decoration: none; }
.brand .sigil { font-size: 1.4rem; display: inline-block; animation: sigil-glow 3.2s ease-in-out infinite; }
@keyframes sigil-glow {
  0%, 100% { transform: rotate(-4deg) scale(1); filter: drop-shadow(0 0 4px rgba(var(--ember-rgb), 0.5)); }
  50%      { transform: rotate(4deg) scale(1.08); filter: drop-shadow(0 0 12px rgba(var(--ember-rgb), 0.85)); }
}
.nav-links { display: flex; align-items: center; gap: 22px; font-size: 0.92rem; flex: 1; }
.nav-links a { color: var(--parchment-dim); font-weight: 500; position: relative; padding: 4px 0; }
.nav-links a::after {
  content: ''; position: absolute; left: 0; right: 100%; bottom: -2px; height: 2px;
  background: linear-gradient(90deg, var(--ember), var(--arcane));
  transition: right 0.22s ease; border-radius: 2px;
}
.nav-links a:hover { color: var(--ember-bright); text-decoration: none; }
.nav-links a:hover::after { right: 0; }
.nav-right { display: flex; align-items: center; gap: 16px; }

.bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--stone);
  border: 1px solid var(--stone-line);
  color: var(--parchment-dim);
  font-size: 1.1rem;
  transition: transform 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.bell:hover { color: var(--ember-bright); text-decoration: none; border-color: var(--ember); transform: translateY(-1px); box-shadow: 0 0 16px rgba(var(--ember-rgb), 0.3); }
.bell .badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: linear-gradient(140deg, var(--rune-red-bright), var(--rune-red));
  color: var(--parchment);
  font-size: 0.68rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--obsidian);
  box-shadow: 0 0 10px rgba(var(--red-rgb), 0.7);
  animation: badge-pulse 1.8s ease-in-out infinite;
}
@keyframes badge-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.14); }
}

.user-chip { font-size: 0.88rem; color: var(--parchment-dim); }
.user-chip strong { color: var(--ember-bright); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.9rem;
  border: 1px solid transparent;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  transition: transform 0.12s ease, filter 0.15s ease, box-shadow 0.2s ease, border-color 0.15s ease;
}
.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,0.35) 48%, transparent 66%);
  transform: translateX(-120%);
  transition: transform 0.5s ease;
}
.btn:hover::before { transform: translateX(120%); }
.btn:hover { text-decoration: none; filter: brightness(1.06); }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn-primary {
  background: linear-gradient(160deg, var(--ember-bright), var(--ember) 70%);
  color: #1c1308;
  box-shadow: 0 8px 20px -6px rgba(var(--ember-rgb), 0.55);
}
.btn-primary:hover { box-shadow: 0 10px 26px -6px rgba(var(--ember-rgb), 0.75); transform: translateY(-1px); }
.btn-secondary { background: var(--stone); color: var(--parchment); border-color: var(--stone-line); }
.btn-secondary:hover { border-color: var(--ember); }
.btn-danger { background: linear-gradient(160deg, var(--rune-red-bright), var(--rune-red)); color: #2a0d0a; box-shadow: 0 8px 18px -8px rgba(var(--red-rgb), 0.6); }
.btn-danger:hover { filter: brightness(1.1); }
.btn-ghost { background: transparent; color: var(--parchment-dim); border-color: var(--stone-line); }
.btn-ghost:hover { border-color: var(--ember); color: var(--ember-bright); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 14px; font-size: 0.8rem; }

/* ---------- Cards / trade tablets ---------- */
.tablet {
  background: linear-gradient(165deg, var(--obsidian-raised), var(--stone) 130%);
  border: 1px solid var(--stone-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-deep);
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.25s ease, border-color 0.2s ease;
  animation: rise-in 0.5s ease backwards;
}
.tablet::before {
  /* glowing carved top rule, like a lit tablet edge */
  content: '';
  position: absolute;
  top: 0; left: 16px; right: 16px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--ember), var(--arcane), transparent);
  opacity: 0.55;
  border-radius: 2px;
}
.tablet::after {
  /* soft corner glow, low and quiet until hovered */
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px rgba(var(--ember-rgb), 0);
  transition: box-shadow 0.25s ease;
  pointer-events: none;
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.item-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 18px;
  margin-top: 24px;
}
.item-grid .tablet:nth-child(1) { animation-delay: 0.02s; }
.item-grid .tablet:nth-child(2) { animation-delay: 0.06s; }
.item-grid .tablet:nth-child(3) { animation-delay: 0.10s; }
.item-grid .tablet:nth-child(4) { animation-delay: 0.14s; }
.item-grid .tablet:nth-child(5) { animation-delay: 0.18s; }
.item-grid .tablet:nth-child(6) { animation-delay: 0.22s; }

.item-card {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.item-card:hover, a.item-card:hover, .tablet:hover {
  transform: translateY(-4px);
  border-color: rgba(var(--ember-rgb), 0.45);
  box-shadow: var(--shadow-glow), var(--shadow-deep);
}
.item-card:hover::after { box-shadow: inset 0 0 0 1px rgba(var(--ember-rgb), 0.25); }
.item-card .thumb {
  height: 130px;
  border-radius: 8px;
  background:
    radial-gradient(circle at 30% 20%, rgba(var(--ember-rgb), 0.12), transparent 60%),
    var(--obsidian);
  border: 1px solid var(--stone-line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  color: var(--stone-line);
  font-size: 1.8rem;
  overflow: hidden;
  transition: border-color 0.2s ease;
}
.item-card:hover .thumb { border-color: rgba(var(--ember-rgb), 0.4); color: var(--ember); }
.item-card .thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.35s ease; }
.item-card:hover .thumb img { transform: scale(1.06); }
.item-card .cat-tag {
  align-self: flex-start;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--verdigris);
  border: 1px solid rgba(var(--verd-rgb), 0.45);
  background: rgba(var(--verd-rgb), 0.08);
  border-radius: 4px;
  padding: 2px 8px;
}
.item-card h3 { font-size: 1.05rem; margin: 0; -webkit-text-fill-color: var(--parchment); background: none; }
.item-card .price { font-family: var(--font-display); color: var(--ember-bright); font-size: 1.2rem; text-shadow: 0 0 14px rgba(var(--ember-rgb), 0.35); }
.item-card .seller { font-size: 0.8rem; color: var(--parchment-dim); }
.item-card .seal {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 9px;
  border-radius: 20px;
  font-weight: 700;
  backdrop-filter: blur(4px);
}
.seal-pending { background: rgba(var(--ember-rgb), 0.2); color: var(--ember-bright); border: 1px solid rgba(var(--ember-rgb), 0.5); }
.seal-sold { background: rgba(var(--red-rgb), 0.2); color: var(--rune-red-bright); border: 1px solid rgba(var(--red-rgb), 0.5); }

/* ---------- Forms ---------- */
.form-panel {
  max-width: 480px;
  margin: 48px auto;
  padding: 32px;
}
.form-panel.wide { max-width: 640px; }
label { display: block; font-size: 0.85rem; color: var(--parchment-dim); margin-bottom: 6px; margin-top: 16px; font-weight: 600; }
label:first-of-type { margin-top: 0; }
input, textarea, select {
  width: 100%;
  background: var(--obsidian);
  border: 1px solid var(--stone-line);
  color: var(--parchment);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: var(--font-body);
  font-size: 0.92rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, textarea:focus, select:focus { border-color: var(--ember); box-shadow: 0 0 0 3px rgba(var(--ember-rgb), 0.18); outline: none; }
textarea { resize: vertical; min-height: 90px; }
.help-text { font-size: 0.78rem; color: var(--parchment-dim); margin-top: 4px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.88rem;
  margin-bottom: 16px;
  border-left: 3px solid transparent;
}
.alert-error { background: rgba(var(--red-rgb), 0.14); border: 1px solid rgba(var(--red-rgb), 0.4); border-left-color: var(--rune-red-bright); color: #ffd3cd; }
.alert-success { background: rgba(var(--verd-rgb), 0.14); border: 1px solid rgba(var(--verd-rgb), 0.4); border-left-color: var(--verdigris); color: #cdf5e4; }
.alert-info { background: rgba(var(--ember-rgb), 0.12); border: 1px solid rgba(var(--ember-rgb), 0.4); border-left-color: var(--ember-bright); color: #ffe9bd; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--stone-line); }
th { color: var(--parchment-dim); font-weight: 700; text-transform: uppercase; font-size: 0.72rem; letter-spacing: 0.06em; }
tr { transition: background 0.15s ease; }
tr:hover td { background: rgba(var(--ember-rgb), 0.06); }

.status-pill {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.status-pending { background: rgba(var(--ember-rgb), 0.2); color: var(--ember-bright); }
.status-accepted { background: rgba(var(--verd-rgb), 0.22); color: #a2f0cb; }
.status-completed { background: rgba(var(--verd-rgb), 0.32); color: #c3f7de; }
.status-declined, .status-cancelled { background: rgba(var(--red-rgb), 0.2); color: var(--rune-red-bright); }
.status-available { background: rgba(var(--verd-rgb), 0.22); color: #a2f0cb; }
.status-sold { background: rgba(var(--red-rgb), 0.2); color: var(--rune-red-bright); }
.status-removed { background: var(--stone); color: var(--parchment-dim); }
.status-banned { background: rgba(var(--red-rgb), 0.2); color: var(--rune-red-bright); }
.status-active { background: rgba(var(--verd-rgb), 0.22); color: #a2f0cb; }

/* ---------- Stat cards (admin) ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin: 24px 0; }
.stat-card { padding: 18px 20px; }
.stat-card .label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--parchment-dim); font-weight: 600; }
.stat-card .value { font-family: var(--font-display); font-size: 2.1rem; color: var(--ember-bright); margin-top: 6px; text-shadow: 0 0 16px rgba(var(--ember-rgb), 0.3); }

/* ---------- Misc ---------- */
.page-header { margin: 36px 0 8px; display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.page-header p { color: var(--parchment-dim); margin: 0; }
.section { margin: 32px 0; }
.empty-state { text-align: center; padding: 64px 20px; color: var(--parchment-dim); }
.empty-state .glyph { font-size: 2.6rem; margin-bottom: 12px; opacity: 0.75; filter: drop-shadow(0 0 14px rgba(var(--ember-rgb), 0.4)); }
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 16px 0 0; }
.chip { padding: 6px 15px; border-radius: 16px; border: 1px solid var(--stone-line); color: var(--parchment-dim); font-size: 0.82rem; transition: all 0.15s ease; }
.chip.active { border-color: var(--ember); color: #1c1308; background: linear-gradient(140deg, var(--ember-bright), var(--ember)); font-weight: 700; }
.chip:hover { text-decoration: none; border-color: var(--ember); color: var(--ember-bright); }
.chip.active:hover { color: #1c1308; }
.search-input { flex: 1; min-width: 180px; }

.detail-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 28px; margin-top: 20px; }
@media (max-width: 760px) {
  .detail-grid { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .nav-links { display: none; }
}

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--stone-line); margin-top: 16px; }
.tab { padding: 10px 16px; color: var(--parchment-dim); font-size: 0.88rem; border-bottom: 2px solid transparent; cursor: pointer; transition: color 0.15s ease, border-color 0.15s ease; }
.tab:hover { color: var(--ember-bright); }
.tab.active { color: var(--ember-bright); border-color: var(--ember); }

.notif-item { padding: 16px 18px; border-bottom: 1px solid var(--stone-line); display: flex; gap: 14px; transition: background 0.15s ease; }
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: rgba(var(--ember-rgb), 0.07); border-left: 2px solid var(--ember); }
.notif-icon { font-size: 1.3rem; flex-shrink: 0; }
.notif-time { font-size: 0.74rem; color: var(--parchment-dim); }

footer {
  border-top: 1px solid var(--stone-line);
  padding: 30px 0;
  margin-top: auto;
  color: var(--parchment-dim);
  font-size: 0.82rem;
  text-align: center;
  position: relative;
}
footer::before {
  content: '';
  position: absolute; top: -1px; left: 50%; transform: translateX(-50%);
  width: 140px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--ember), transparent);
}

.admin-shell { display: grid; grid-template-columns: 220px 1fr; gap: 0; min-height: calc(100vh - 68px); }
.admin-sidebar { background: var(--obsidian-raised); border-right: 1px solid var(--stone-line); padding: 24px 0; }
.admin-sidebar a { display: block; padding: 10px 24px; color: var(--parchment-dim); font-size: 0.9rem; border-right: 2px solid transparent; transition: all 0.15s ease; }
.admin-sidebar a:hover, .admin-sidebar a.active { background: rgba(var(--ember-rgb), 0.08); color: var(--ember-bright); text-decoration: none; border-right-color: var(--ember); }
.admin-main { padding: 32px; overflow-x: auto; }
@media (max-width: 760px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-sidebar { display: flex; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--stone-line); padding: 8px 0; }
  .admin-sidebar a { padding: 8px 16px; white-space: nowrap; border-right: none; border-bottom: 2px solid transparent; }
  .admin-sidebar a:hover, .admin-sidebar a.active { border-right: none; border-bottom-color: var(--ember); }
}
