/* ============================================================
   Apex Trading Shop
   Design concept: precision-instrument panels rather than soft
   SaaS cards. A single cut corner (clip-path) is the signature
   shape, used only on the hero visual and the buy panel. Color
   codes meaning: blue = interactive, amber = monetary value,
   green = confirmed, coral = destructive. One motion moment: a
   live pulse on the hero signal line.
   ============================================================ */

:root {
  --bg: #080B13;
  --surface: #0E1420;
  --surface-2: #141B2C;
  --border: #212A40;
  --border-bright: #2E3B57;
  --text: #EAF0FF;
  --text-dim: #8994B3;
  --text-faint: #5A6480;
  --signal: #4C7CFF;
  --signal-bright: #6E93FF;
  --signal-glow: rgba(76, 124, 255, 0.35);
  --value: #FFB020;
  --positive: #34D399;
  --danger: #FF5C72;
  --radius: 3px;
  --clip: 28px;
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Manrope', -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(ellipse 900px 600px at 15% -10%, rgba(76,124,255,0.10), transparent 60%),
    url('/static/img/bg-lines.svg') center 20% / cover no-repeat,
    var(--bg);
  background-attachment: fixed, fixed, fixed;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px;
}

h1, h2, h3 { font-family: var(--font-display); letter-spacing: -0.01em; }

/* ---- Cut-corner panel: the one geometric signature, used sparingly ---- */
.clip-panel {
  clip-path: polygon(0 0, calc(100% - var(--clip)) 0, 100% var(--clip), 100% 100%, 0 100%);
  border: 1px solid var(--border-bright);
  background-color: var(--surface);
  background-image: url('/static/img/bg-lines-card.svg');
  background-size: cover;
  background-position: center 70%;
  background-repeat: no-repeat;
}

/* ---- Header ---- */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 22px 0;
}
.site-header-inner {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.brand {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-mark { width: 26px; height: 26px; flex-shrink: 0; }
.brand .brand-domain {
  color: var(--text-faint);
  font-size: 13px;
  font-weight: 400;
  margin-left: 10px;
  font-family: var(--font-body);
}
.nav-links {
  display: flex;
  gap: 28px;
  font-size: 14.5px;
  color: var(--text-dim);
}
.nav-links a:hover { color: var(--signal-bright); }
.cart-link { display: inline-flex; align-items: center; gap: 5px; }

/* ---- Hero ---- */
.hero-section {
  padding: 64px 0 48px;
  border-bottom: 1px solid var(--border);
}
.hero-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 40px;
  align-items: center;
}
@media (max-width: 860px) { .hero-grid { grid-template-columns: 1fr; } }
@media (max-width: 860px) { .hero-section { padding-top: 44px; } }

.hero-grid h1 {
  font-size: clamp(32px, 4.2vw, 46px);
  line-height: 1.12;
  font-weight: 600;
  margin: 0 0 18px;
}
.hero-grid p.lede {
  color: var(--text-dim);
  max-width: 480px;
  font-size: 17px;
  margin: 0 0 26px;
}
.hero-grid .hero-actions { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.hero-grid .hero-count { font-size: 13.5px; color: var(--text-faint); }

.hero-visual {
  padding: 0;
  aspect-ratio: 4 / 3;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.featured-card { text-decoration: none; color: inherit; transition: border-color 0.15s ease; }
a.featured-card:hover { border-color: var(--signal); }
.featured-eyebrow { padding: 16px 20px 0; font-size: 13px; color: var(--signal-bright); font-weight: 600; }
.featured-thumb {
  flex-grow: 1;
  margin: 14px 20px 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-2);
  min-height: 0;
}
.featured-thumb img { width: 100%; height: 100%; object-fit: cover; }
.featured-thumb-empty { width: 100%; height: 100%; background: linear-gradient(135deg, var(--surface-2), var(--surface)); }
.featured-info { padding: 14px 20px 20px; }
.featured-name { font-family: var(--font-display); font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.featured-desc {
  color: var(--text-dim); font-size: 13px; margin: 0 0 12px;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.featured-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.featured-empty { justify-content: center; }
.featured-empty .featured-info { padding: 20px; text-align: center; }

/* ---- Buttons ---- */
.btn {
  display: inline-block;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  border: 1px solid transparent;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--signal);
  color: #061024;
}
.btn-primary:hover { background: var(--signal-bright); box-shadow: 0 0 0 3px var(--signal-glow); }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border-bright);
  color: var(--text);
}
.btn-ghost:hover { border-color: var(--signal); color: var(--signal-bright); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.empty-state {
  padding: 64px 24px;
  text-align: center;
  color: var(--text-dim);
  border: 1px dashed var(--border-bright);
  border-radius: var(--radius);
  margin: 40px 0;
}
.empty-state a { color: var(--signal-bright); text-decoration: underline; }

.flash-banner {
  background: rgba(52, 211, 153, 0.10);
  border: 1px solid rgba(52, 211, 153, 0.35);
  color: var(--positive);
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  margin: 24px 0 -12px;
}
.flash-banner a { color: var(--signal-bright); text-decoration: underline; }
.flash-banner.flash-error {
  background: rgba(255, 92, 114, 0.10);
  border-color: rgba(255, 92, 114, 0.35);
  color: var(--danger);
}

/* Anchor wraps only the clickable card body; the add-to-cart form sits
   outside it. display:contents removes it from layout without affecting
   the click target of its children. */
.card-link { display: contents; }

/* ---- Product grid ---- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
  margin: 40px 0 64px;
}
.product-card {
  background-color: var(--surface);
  background-image: url('/static/img/bg-lines-card.svg');
  background-size: cover;
  background-position: center 60%;
  background-repeat: no-repeat;
  border: 1px solid var(--border);
  border-left: 3px solid var(--signal);
  border-radius: var(--radius);
  padding: 18px 18px 20px;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s ease, transform 0.18s ease, box-shadow 0.18s ease;
}
.product-card:hover {
  border-color: var(--border-bright);
  border-left-color: var(--signal-bright);
  transform: translateY(-3px);
  box-shadow: 0 10px 28px rgba(0,0,0,0.35), 0 0 0 1px var(--signal-glow);
}
.product-card .thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--surface-2);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  font-size: 12.5px;
}
.product-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.product-card .tag-row {
  font-size: 12.5px;
  color: var(--text-faint);
  margin-bottom: 8px;
}
.product-card h3 { font-size: 17px; margin: 0 0 8px; font-weight: 600; }
.product-card p { color: var(--text-dim); font-size: 13.5px; margin: 0 0 16px; flex-grow: 1; }
.product-card .card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  padding-top: 14px;
  gap: 10px;
}
.price { font-family: var(--font-display); font-weight: 600; font-size: 16px; color: var(--value); }

/* ---- Product detail ---- */
.product-detail {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 48px;
  padding: 48px 0 72px;
}
@media (max-width: 860px) { .product-detail { grid-template-columns: 1fr; } }

.gallery-main {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 10px;
}
.gallery-main img { width: 100%; height: 100%; object-fit: cover; }
.gallery-thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.gallery-thumbs img {
  width: 68px; height: 68px; object-fit: cover;
  border-radius: var(--radius); border: 1px solid var(--border); cursor: pointer;
}

.pd-eyebrow { font-size: 13px; color: var(--text-faint); margin-bottom: 10px; }
.product-detail h1 { font-size: 30px; margin: 0 0 14px; }

.spec-table {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 18px 0 22px;
  font-size: 13.5px;
}
.spec-table div { display: flex; justify-content: space-between; padding: 9px 14px; border-bottom: 1px solid var(--border); color: var(--text-dim); }
.spec-table div:last-child { border-bottom: none; }
.spec-table span.val { color: var(--text); font-weight: 500; }

.product-detail .desc { color: var(--text-dim); margin-bottom: 26px; white-space: pre-line; max-width: 62ch; }

.buy-panel { padding: 22px; }
.buy-panel .price-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 16px; }
.buy-panel .price-row .price { font-size: 26px; }
#paypal-button-container { min-height: 45px; }
.note { font-size: 12.5px; color: var(--text-faint); margin-top: 14px; }

/* ---- Cart ---- */
.cart-list { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.cart-row {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.cart-row:last-child { border-bottom: none; }
.cart-thumb { width: 56px; height: 56px; flex-shrink: 0; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); }
.cart-thumb img { width: 100%; height: 100%; object-fit: cover; }
.cart-info { flex-grow: 1; min-width: 0; }
.cart-name { font-weight: 600; font-size: 14.5px; }
.cart-meta { font-size: 12.5px; color: var(--text-faint); margin-top: 2px; }

/* ---- Footer ---- */
.site-footer { border-top: 1px solid var(--border); padding: 30px 0; color: var(--text-faint); font-size: 13px; }

/* ---- Admin ---- */
.admin-shell { padding: 32px 0 80px; }
.admin-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 28px; }
.admin-bar h1 { font-size: 22px; margin: 0; }

.stat-row { display: flex; gap: 14px; margin-bottom: 32px; }
.stat-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; flex: 1; }
.stat-box .label { font-size: 12px; color: var(--text-faint); }
.stat-box .value { font-family: var(--font-display); font-size: 24px; font-weight: 600; margin-top: 4px; }

table.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.admin-table th, table.admin-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
table.admin-table th { color: var(--text-faint); font-weight: 500; font-size: 12.5px; }
table.admin-table tr:hover td { background: var(--surface); }

.badge { font-size: 11.5px; padding: 3px 9px; border-radius: var(--radius); font-weight: 600; }
.badge-active { background: rgba(52,211,153,0.14); color: var(--positive); }
.badge-inactive { background: rgba(90,100,128,0.16); color: var(--text-dim); }
.badge-paid { background: rgba(52,211,153,0.14); color: var(--positive); }
.badge-created { background: rgba(255,176,32,0.14); color: var(--value); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; max-width: 760px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
.field input[type=text], .field input[type=number], .field select, .field textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); padding: 10px 12px; font-family: var(--font-body); font-size: 14px;
}
.field textarea { min-height: 90px; resize: vertical; }
.field input[type=file] { color: var(--text-dim); font-size: 13px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }

.login-shell { max-width: 360px; margin: 90px auto; padding: 30px; border: 1px solid var(--border-bright); border-radius: var(--radius); background: var(--surface); }
.login-shell h1 { font-size: 19px; margin-top: 0; }
.error-text { color: var(--danger); font-size: 13.5px; margin: 10px 0; }

.img-thumb-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.img-thumb-row .item { position: relative; }
.img-thumb-row img { width: 70px; height: 70px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--border); }
.img-thumb-row button { position: absolute; top: -6px; right: -6px; background: var(--danger); color: #fff; border: none; border-radius: 50%; width: 18px; height: 18px; font-size: 11px; cursor: pointer; line-height: 1; }

.action-row { display: flex; gap: 10px; margin-top: 20px; }

.releases-box { border: 1px solid var(--border-bright); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 24px; }
.releases-pending { border-color: rgba(255,176,32,0.4); background: rgba(255,176,32,0.06); }
.release-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 10px 0; border-top: 1px solid var(--border); }
.release-row:first-of-type { border-top: none; }

.release-history { margin-top: 18px; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; }
.release-history summary { cursor: pointer; font-size: 13.5px; color: var(--text-dim); user-select: none; }
.release-history summary:hover { color: var(--text); }
.release-history-list { margin-top: 12px; }
.release-history-item { padding: 10px 0; border-top: 1px solid var(--border); }
.release-history-item:first-child { border-top: none; padding-top: 0; }
.release-history-name { font-size: 13.5px; font-weight: 600; }
.release-history-name .note { font-weight: 400; margin-left: 8px; }

/* ---- FAQ chat widget ---- */
.chat-toggle {
  position: fixed;
  bottom: 22px;
  right: 22px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--signal);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(76,124,255,0.45);
  z-index: 1000;
  transition: transform 0.15s ease;
}
.chat-toggle:hover { transform: scale(1.06); }
.chat-toggle svg { width: 24px; height: 24px; }

.chat-panel {
  position: fixed;
  bottom: 90px;
  right: 22px;
  width: 340px;
  max-width: calc(100vw - 32px);
  max-height: min(560px, calc(100vh - 120px));
  background: var(--surface);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  display: none;
  flex-direction: column;
  z-index: 1000;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
.chat-panel.open { display: flex; }

.chat-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.chat-head strong { font-family: var(--font-display); font-size: 14.5px; }
.chat-close { background: none; border: none; color: var(--text-faint); cursor: pointer; font-size: 20px; line-height: 1; padding: 0; }
.chat-close:hover { color: var(--text); }

.chat-body {
  flex-grow: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 120px;
}
.chat-msg { font-size: 13.5px; line-height: 1.5; max-width: 88%; padding: 9px 12px; border-radius: var(--radius); }
.chat-msg.bot { background: var(--surface-2); color: var(--text); align-self: flex-start; }
.chat-msg.user { background: var(--signal); color: #061024; align-self: flex-end; }

.chat-quick { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 12px; flex-shrink: 0; }
.chat-quick button {
  font-size: 12px; padding: 6px 10px; border-radius: var(--radius);
  background: transparent; border: 1px solid var(--border-bright); color: var(--text-dim); cursor: pointer;
}
.chat-quick button:hover { border-color: var(--signal); color: var(--signal-bright); }

.chat-input-row { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); flex-shrink: 0; }
.chat-input-row input {
  flex-grow: 1; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); padding: 10px 12px; font-size: 16px; font-family: var(--font-body); min-width: 0;
}
.chat-input-row button {
  background: var(--signal); border: none; color: #061024; border-radius: var(--radius);
  padding: 0 16px; cursor: pointer; font-weight: 600; font-size: 13px;
}

.chat-leave-msg { display: flex; flex-direction: column; gap: 8px; padding: 0 16px 12px; flex-shrink: 0; }
.chat-leave-msg input, .chat-leave-msg textarea {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); padding: 10px 12px; font-size: 16px; font-family: var(--font-body); resize: vertical;
}
.chat-leave-msg textarea { min-height: 140px; }

/* ---- Badges (New / Popular / Risk level) ---- */
.badge-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.tag { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: var(--radius); text-transform: capitalize; }
.tag-new { background: rgba(76,124,255,0.16); color: var(--signal-bright); }
.tag-popular {
  background: rgba(255,176,32,0.16); color: var(--value);
  position: relative; overflow: hidden;
}
.tag-popular::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,0.35) 50%, transparent 70%);
  background-size: 220% 100%;
  animation: shimmer 3.2s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
  .tag-popular::after { animation: none; }
}
@keyframes shimmer {
  0% { background-position: 120% 0; }
  55%, 100% { background-position: -60% 0; }
}
.tag-risk-low { background: rgba(52,211,153,0.16); color: var(--positive); }
.tag-risk-medium { background: rgba(137,148,179,0.20); color: var(--text-dim); }
.tag-risk-high { background: rgba(255,92,114,0.16); color: var(--danger); }
