/*
 * Components for the marketplace pages (header, forms, product detail,
 * dashboard, pagination). Built only from the design tokens and patterns
 * in site.css — site.css itself is the original design and stays untouched.
 */

/* ============ INNER-PAGE HEADER ============ */
.site-header {
  width: 100%;
  justify-self: stretch;
  background: var(--navy);
  color: #c9d5ef;
}

.site-header-inner {
  max-width: 1296px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.site-header .brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-size: 22px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.header-search {
  flex: 1;
  max-width: 520px;
}

.header-search input {
  width: 100%;
  padding: 11px 18px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  color: #fff;
  font: inherit;
  font-size: 14px;
  outline: none;
}

.header-search input::placeholder { color: #8fa0c4; }
.header-search input:focus { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.4); }

.header-nav {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-left: auto;
}

.header-nav a,
.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: #c9d5ef;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.header-nav a:hover,
.link-button:hover { color: #fff; text-decoration: underline; }
.header-nav form { margin: 0; }

.header-nav .header-cta,
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #086eff, #00a8ff);
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 119, 255, .28);
}

.header-nav .header-cta:hover,
.btn-primary:hover { color: #fff; text-decoration: none; filter: brightness(1.06); }

/* ============ PAGE LAYOUT ============ */
main#main { min-height: calc(100vh - 420px); }

.page-title {
  margin: 0 0 6px;
  color: var(--ink);
  font-size: clamp(24px, 2.4vw, 30px);
  font-weight: 800;
  letter-spacing: -.01em;
}

.page-lead {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

a.more-btn { display: inline-block; text-decoration: none; }

.btn-danger {
  padding: 12px 28px;
  border: 1px solid var(--heart);
  border-radius: 999px;
  background: var(--heart);
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.btn-danger:hover { filter: brightness(.94); }

.text-link { color: var(--blue); font-weight: 600; text-decoration: none; }
.text-link:hover { text-decoration: underline; }
.text-danger { color: var(--heart); }

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 28px;
}

.panel + .panel { margin-top: 24px; }
.panel h2 { margin: 0 0 18px; color: var(--ink); font-size: 18px; font-weight: 800; }

.panel-narrow { max-width: 560px; margin: 0 auto; }
.panel-narrow.panel-wide { max-width: 760px; }

.button-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 24px;
}

/* ============ MESSAGES ============ */
.flash-list {
  list-style: none;
  margin: 0 0 24px;
  padding: 0;
  display: grid;
  gap: 10px;
}

.flash {
  padding: 13px 18px;
  border: 1px solid #bcd9ff;
  border-radius: 8px;
  background: #eaf4ff;
  color: var(--navy);
  font-size: 14px;
  font-weight: 600;
}

.flash.success { border-color: #b6e3c6; background: #edf9f1; color: #155c32; }
.flash.error { border-color: #f3c0c2; background: #fdf0f0; color: #8c1d22; }
.flash.warning { border-color: #f4dc9c; background: #fff8e6; color: #6b4b00; }

/* ============ FORMS ============ */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 20px;
}

.form-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.form-field.full { grid-column: 1 / -1; }

.form-field > label,
.form-label {
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

.form-field input[type="text"],
.form-field input[type="email"],
.form-field input[type="password"],
.form-field input[type="url"],
.form-field input[type="number"],
.form-field input[type="search"],
.form-field select,
.form-field textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
}

.form-field textarea { resize: vertical; line-height: 1.5; }

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  border-color: var(--blue);
  outline: none;
  box-shadow: 0 0 0 3px rgba(0,119,255,.15);
}

.form-field input[type="file"] { font-size: 14px; color: var(--muted); }

/* Django's RadioSelect renders <div id="id_x"><div><label><input> …</label></div>… */
.form-field > div[id] {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}

.form-field > div[id] label { display: inline-flex; align-items: center; gap: 6px; font-size: 15px; color: var(--ink); cursor: pointer; }

.field-help { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.field-help ul { display: block; padding-left: 18px; list-style: disc; }

.field-errors,
.form-errors {
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--heart);
  font-size: 13px;
  font-weight: 600;
}

.form-errors {
  margin-bottom: 18px;
  padding: 12px 16px;
  border: 1px solid #f3c0c2;
  border-radius: 8px;
  background: #fdf0f0;
}

.form-field.has-error input,
.form-field.has-error select,
.form-field.has-error textarea { border-color: var(--heart); }

.form-footer-links {
  margin-top: 20px;
  color: var(--muted);
  font-size: 14px;
}

.fee-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
  padding: 14px 18px;
  border-radius: 8px;
  background: #eaf4ff;
  color: var(--navy);
  font-size: 14px;
}

.fee-note strong { font-size: 20px; }

/* ============ PAGINATION ============ */
.pagination { align-items: center; gap: 6px; flex-wrap: wrap; }
.pagination a.filter-btn { text-decoration: none; }
.pagination .filter-btn[aria-current="page"] {
  background: #212529;
  border-color: #212529;
  color: #fff;
}
.pagination .gap { color: var(--muted); padding: 0 4px; }

.catalog-note {
  margin: -12px 0 22px;
  color: var(--muted);
  font-size: 14px;
}

/* ============ PRODUCT DETAIL ============ */
.breadcrumb {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 14px;
}

.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--blue); text-decoration: underline; }

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 40px;
  align-items: start;
}

.gallery-main {
  display: grid;
  place-items: center;
  aspect-ratio: 1 / 1;
  max-height: 560px;
  width: 100%;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--media);
  overflow: hidden;
}

.gallery-main img,
.gallery-main .placeholder {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}

.gallery-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.gallery-thumb {
  aspect-ratio: 1 / 1;
  padding: 4px;
  border: 2px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

.gallery-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.gallery-thumb[aria-current="true"] { border-color: var(--blue); }

.detail-company {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.detail-price {
  margin: 18px 0 6px;
  color: var(--ink);
  font-size: 28px;
  font-weight: 800;
}

.detail-price small { color: var(--muted); font-size: 14px; font-weight: 600; }

.detail-stock { margin: 0 0 22px; color: var(--muted); font-size: 15px; }
.detail-stock strong { color: var(--ink); }

.detail-section { margin-top: 26px; }
.detail-section h2 { margin: 0 0 10px; color: var(--ink); font-size: 16px; font-weight: 800; }

.detail-description {
  color: var(--ink);
  font-size: 15px;
  line-height: 1.7;
}

.keyword-list { display: flex; flex-wrap: wrap; gap: 6px; }
.keyword-list a.filter-btn { text-decoration: none; font-size: 13px; }

.detail-video video {
  width: 100%;
  max-height: 520px;
  border-radius: 8px;
  background: #000;
}

.company-card {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-top: 26px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.company-logo {
  flex: 0 0 56px;
  width: 56px;
  height: 56px;
  border-radius: 10px;
  object-fit: contain;
  background: #f6f8fb;
}

.company-card h3 { margin: 0 0 4px; color: var(--ink); font-size: 16px; }
.company-card p { margin: 0 0 4px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.company-card a { color: var(--blue); text-decoration: none; }
.company-card a:hover { text-decoration: underline; }

.preview-banner {
  margin-bottom: 20px;
  padding: 12px 16px;
  border: 1px solid #f4dc9c;
  border-radius: 8px;
  background: #fff8e6;
  color: #6b4b00;
  font-size: 14px;
  font-weight: 600;
}

/* ============ DASHBOARD ============ */
.dash-nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.dash-nav a.filter-btn { text-decoration: none; }
.dash-nav a[aria-current="page"] { background: #212529; border-color: #212529; color: #fff; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stat-card span { display: block; color: var(--muted); font-size: 14px; }
.stat-card strong { display: block; margin-top: 6px; color: var(--ink); font-size: 30px; font-weight: 800; }

.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th,
.data-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  text-align: left;
  vertical-align: middle;
}

.data-table th { color: var(--muted); font-size: 13px; font-weight: 700; }
.data-table .actions { white-space: nowrap; text-align: right; }
.data-table .actions a { margin-left: 12px; }

.thumb {
  width: 52px;
  height: 52px;
  border-radius: 6px;
  object-fit: contain;
  background: var(--media);
  display: block;
}

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status-badge.live { background: #edf9f1; color: #155c32; }
.status-badge.draft { background: #eef1f6; color: var(--muted); }

.image-manager {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 8px;
}

.image-tile {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  color: var(--ink);
}

.image-tile img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  border-radius: 6px;
  background: var(--media);
}

.image-tile label { display: flex; align-items: center; gap: 6px; }
.image-tile input[type="number"] { width: 64px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 4px; font: inherit; }
.image-tile.is-main { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }

.current-video video { width: 100%; max-width: 420px; border-radius: 8px; background: #000; margin-bottom: 8px; }

.profile-head { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }

.empty-state {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
}

/* ============ RESPONSIVE ============ */
@media (max-width: 1100px) {
  .detail-grid { gap: 28px; }
}

@media (max-width: 760px) {
  .site-header { width: 100vw; }
  .site-header-inner { flex-wrap: wrap; gap: 12px; padding: 12px 14px; }
  .header-search { order: 3; flex-basis: 100%; max-width: none; }
  .header-nav { gap: 14px; }
  .detail-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr; }
  .panel { padding: 20px; }
  .data-table .hide-sm { display: none; }
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.image-help { margin-bottom: 14px; }
.push-right { margin-left: auto; }

/* ============ CART ============ */
.text-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--blue);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.text-button:hover { text-decoration: underline; }
.text-button.text-danger { color: var(--heart); }
.inline-form,
.data-table .actions form { display: inline; margin: 0; }
.cart-qty { display: flex; align-items: center; gap: 8px; margin: 0; }
.cart-qty input { width: 70px; }
.cart-total { margin: 16px 0 0; text-align: right; font-size: 16px; }
.add-to-cart { display: flex; align-items: center; gap: 10px; margin: 16px 0; }
.add-to-cart input { width: 80px; }
