/* MevaSearch Theme Marketplace — stylesheet
   Bazuje 1:1 na design systemie MevaSearch (Space Grotesk, czarno-biały SaaS look).
   Sekcja 1: tokens + base (identyczne z głównym serwisem)
   Sekcja 2: komponenty specyficzne dla marketplace
*/

:root {
  --bg: #fafafa;
  --bg-elevated: #ffffff;
  --fg: #0f0f0f;
  --fg-muted: #6b6b6b;
  --fg-subtle: #9a9a9a;
  --border: #e8e8e8;
  --border-hover: #d0d0d0;
  --accent: #0f0f0f;
  --accent-hover: #262626;
  --accent-fg: #ffffff;
  --accent-soft: rgba(15, 15, 15, 0.04);
  --success: #10b981;
  --danger: #e5484d;
  --radius: 12px;
  --radius-sm: 8px;
  --nav-h: 64px;
  --font-sans: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.06);
}

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.65;
  letter-spacing: 0.3px;
}

body.no-scroll {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

button,
input,
textarea,
select {
  font-family: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

h1,
h2,
h3,
h4 {
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

h1 {
  font-size: clamp(2.25rem, 5vw, 3.25rem);
}

h2 {
  font-size: clamp(1.5rem, 3vw, 2.25rem);
  font-weight: 500;
}

h3 {
  font-size: 1.0625rem;
  font-weight: 500;
}

.lead {
  font-size: clamp(1rem, 2vw, 1.125rem);
  color: var(--fg-muted);
  max-width: 540px;
  line-height: 1.7;
}

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  font-size: 0.9375rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all 0.25s ease;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--border-hover);
  background: var(--accent-soft);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  opacity: 0.88;
}

.btn-full {
  width: 100%;
}

.btn-sm {
  padding: 0.5rem 0.875rem;
  font-size: 0.8125rem;
}

/* Nav (reużyte z głównej strony) */
.nav {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-h);
  background: rgba(250, 250, 250, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.nav-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-weight: 600;
  font-size: 1.0625rem;
  color: var(--fg);
}

.logo svg {
  color: var(--accent);
}

.nav-links {
  display: none;
  align-items: center;
  gap: 0.25rem;
}

.nav-links a {
  padding: 0.5rem 0.875rem;
  font-size: 0.9375rem;
  color: var(--fg-muted);
  border-radius: var(--radius-sm);
}

.nav-links a:hover {
  color: var(--fg);
}

.nav-actions {
  display: none;
  align-items: center;
  gap: 0.75rem;
}

.nav-link-btn {
  padding: 0.5rem 0.75rem;
  font-size: 0.9375rem;
  color: var(--fg-muted);
}

.nav-link-btn:hover {
  color: var(--fg);
}

.theme-toggle {
  width: 2.25rem;
  height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--fg-muted);
}

.theme-toggle:hover {
  color: var(--fg);
  background: var(--accent-soft);
}

@media (min-width: 768px) {

  .nav-links,
  .nav-actions {
    display: flex;
  }
}

.mobile-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  color: var(--fg);
}

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

.mobile-nav {
  position: fixed;
  top: var(--nav-h);
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.2s ease;
  z-index: 99;
}

.mobile-nav.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.mobile-nav a {
  padding: 1rem;
  font-size: 1.0625rem;
  border-radius: var(--radius-sm);
}

.mobile-nav a:hover {
  background: var(--accent-soft);
}

.mobile-nav-actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

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

/* Footer */
.footer {
  padding: 3rem 0 2rem;
  border-top: 1px solid var(--border);
  margin-top: 4rem;
}

.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.footer-bottom p {
  font-size: 0.875rem;
  color: var(--fg-muted);
}

.footer-bottom a {
  color: var(--fg);
}

.footer-bottom a:hover {
  text-decoration: underline;
}

/* ============================================================
   MARKETPLACE — komponenty specyficzne
   ============================================================ */

/* Page header (hero uproszczony pod podstrony) */
.page-header {
  padding: 3.5rem 0 2.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

.page-header .overline {
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: 0.75rem;
}

.page-header h1 {
  margin-bottom: 0.75rem;
}

/* Sort tabs */
.sort-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 2rem 0 1.5rem;
}

.sort-tabs {
  display: inline-flex;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.25rem;
  gap: 0.25rem;
}

.sort-tabs a {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  color: var(--fg-muted);
  border-radius: 6px;
  transition: all 0.2s ease;
}

.sort-tabs a.active {
  background: var(--accent);
  color: var(--accent-fg);
}

.sort-tabs a:not(.active):hover {
  color: var(--fg);
}

.result-count {
  font-size: 0.875rem;
  color: var(--fg-muted);
}

/* Theme grid + card */
.theme-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  padding-bottom: 3rem;
}

@media (min-width: 640px) {
  .theme-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 960px) {
  .theme-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.theme-card {
  display: block;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all 0.25s ease;
}

.theme-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.theme-card-swatches {
  display: flex;
  height: 64px;
}

.theme-card-swatches .swatch {
  flex: 1;
}

.theme-card-body {
  padding: 1.125rem 1.25rem 1.25rem;
}

.theme-card-title {
  margin-bottom: 0.2rem;
}

.theme-card-author {
  font-size: 0.8125rem;
  color: var(--fg-muted);
  margin-bottom: 0.75rem;
}

.theme-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--fg-subtle);
}

.theme-card-meta span {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--fg-muted);
}

.empty-state h3 {
  color: var(--fg);
  margin-bottom: 0.5rem;
}

.load-more-wrap {
  display: flex;
  justify-content: center;
  padding: 1rem 0 4rem;
}

/* Search page */
.search-bar-wrap {
  padding: 2rem 0;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-elevated);
  border: 1.5px solid var(--border);
  border-radius: 50px;
  padding: 0.5rem 0.5rem 0.5rem 1.25rem;
  box-shadow: var(--shadow-sm);
}

.search-bar:focus-within {
  border-color: var(--border-hover);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-bar svg {
  flex-shrink: 0;
  color: var(--fg-subtle);
}

.search-bar input {
  flex: 1;
  border: none;
  outline: none;
  background: none;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  color: var(--fg);
}

.search-bar input::placeholder {
  color: var(--fg-subtle);
}

/* Theme detail page */
.theme-detail {
  padding: 3rem 0 5rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 2.5rem;
}

@media (min-width: 860px) {
  .theme-detail {
    grid-template-columns: 1.1fr 0.9fr;
    align-items: start;
  }
}

.theme-preview-frame {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.theme-preview-bar {
  display: flex;
  gap: 6px;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border);
}

.theme-preview-bar span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
}

/* Results mockup — mirrors maker.html's #tabResults markup, colors passed via inline style from PHP */
.rp-screen {
  display: flex;
  flex-direction: column;
  min-height: 460px;
  font-size: 15px;
}

.rp-head {
  border-bottom: 1px solid;
  flex-shrink: 0;
}

.rp-head-top {
  display: flex;
  align-items: center;
  padding: 0.6rem 0.9rem;
  gap: 0.75rem;
}

.rp-logo {
  font-size: 0.95rem;
  font-weight: 800;
  white-space: nowrap;
  letter-spacing: -0.3px;
}

.rp-logo .o {
  color: #f97316;
}

.rp-form {
  flex: 1;
  max-width: 340px;
  position: relative;
}

.rp-input {
  width: 100%;
  padding: 0.4rem 2rem 0.4rem 1.8rem;
  border-radius: 9999px;
  border: 1.5px solid;
  background: none;
  font-size: 0.78rem;
  font-family: var(--font-sans);
  outline: none;
}

.rp-si {
  position: absolute;
  left: 0.55rem;
  top: 50%;
  transform: translateY(-50%);
  width: 0.8rem;
  height: 0.8rem;
}

.rp-submit {
  position: absolute;
  right: 0.25rem;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rp-nav {
  display: flex;
  padding: 0 0.9rem;
  gap: 0;
}

.rp-tab {
  padding: 0.35rem 0.6rem;
  font-size: 0.74rem;
  font-weight: 500;
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
}

.rp-tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  border-radius: 1px;
}

.rp-body {
  flex: 1;
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.rp-ai-box {
  border: 1px solid;
  border-radius: 8px;
  padding: 0.7rem 0.85rem;
  font-size: 0.78rem;
  line-height: 1.6;
  position: relative;
}

.rp-ai-label {
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 0.35rem;
  display: block;
}

.rp-result-bread {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.73rem;
  margin-bottom: 3px;
}

.rp-result-fav {
  width: 13px;
  height: 13px;
  border-radius: 3px;
  flex-shrink: 0;
}

.rp-result-title {
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.3;
  margin-bottom: 3px;
  text-decoration: underline;
}

.rp-result-desc {
  font-size: 0.78rem;
  opacity: 0.75;
  line-height: 1.5;
}

.rp-result {
  margin-bottom: 1rem;
}

.rp-foot {
  border-top: 1px solid;
  padding: 0.55rem 0.9rem;
  font-size: 0.66rem;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.rp-foot-links {
  display: flex;
  gap: 0.75rem;
}

.theme-info h1 {
  margin-bottom: 0.25rem;
}

.theme-info .author-line {
  color: var(--fg-muted);
  margin-bottom: 1.5rem;
}

.theme-info .stat-row {
  display: flex;
  gap: 1.5rem;
  padding: 1.25rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.theme-info .stat-row div {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.theme-info .stat-row .stat-num {
  font-size: 1.375rem;
  font-weight: 700;
}

.theme-info .stat-row .stat-lbl {
  font-size: 0.8125rem;
  color: var(--fg-muted);
}

.swatch-list {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  margin-bottom: 1.75rem;
}

.swatch-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.875rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.swatch-row .sw {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.swatch-row .sw-label {
  font-size: 0.875rem;
  color: var(--fg-muted);
  flex: 1;
}

.swatch-row .sw-hex {
  font-size: 0.8125rem;
  color: var(--fg-subtle);
  font-variant-numeric: tabular-nums;
}

/* Forms (login/register/add-theme/admin) */
.form-page {
  max-width: 460px;
  margin: 0 auto;
  padding: 4rem 0 5rem;
}

.form-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.25rem;
  box-shadow: var(--shadow-sm);
}

.form-card h1 {
  font-size: 1.5rem;
  margin-bottom: 0.4rem;
}

.form-card .form-sub {
  color: var(--fg-muted);
  font-size: 0.9375rem;
  margin-bottom: 1.75rem;
}

.field {
  margin-bottom: 1.125rem;
}

.field label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  margin-bottom: 0.4rem;
  color: var(--fg);
}

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field textarea,
.field select {
  width: 100%;
  padding: 0.7rem 0.875rem;
  font-size: 0.9375rem;
  font-family: var(--font-sans);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--fg);
  transition: border-color 0.2s;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--border-hover);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field-hint {
  font-size: 0.78125rem;
  color: var(--fg-subtle);
  margin-top: 0.35rem;
}

.field input[type="file"] {
  width: 100%;
  padding: 0.875rem;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: 0.875rem;
}

.alert {
  padding: 0.875rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-bottom: 1.25rem;
}

.alert-error {
  background: rgba(229, 72, 77, 0.08);
  color: #c0282d;
  border: 1px solid rgba(229, 72, 77, 0.25);
}

.alert-success {
  background: rgba(16, 185, 129, 0.08);
  color: #067a55;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.form-foot {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.875rem;
  color: var(--fg-muted);
}

.form-foot a {
  color: var(--fg);
  font-weight: 500;
  text-decoration: underline;
}

/* JSON spec box on add-theme.php */
.spec-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.125rem;
  font-size: 0.8125rem;
  margin-bottom: 1.5rem;
}

.spec-box pre {
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78125rem;
  line-height: 1.6;
  color: var(--fg-muted);
}

.spec-box p {
  margin-bottom: 0.5rem;
  color: var(--fg-muted);
}

.spec-box code {
  background: var(--accent-soft);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

/* Admin panel */
.admin-shell {
  padding: 2.5rem 0 5rem;
}

.admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2rem;
}

.admin-tabs {
  display: inline-flex;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.25rem;
  gap: 0.25rem;
  margin-bottom: 1.75rem;
}

.admin-tabs a {
  padding: 0.55rem 1.1rem;
  font-size: 0.875rem;
  color: var(--fg-muted);
  border-radius: 6px;
}

.admin-tabs a.active {
  background: var(--accent);
  color: var(--accent-fg);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 0.875rem 1rem;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border);
}

.admin-table th {
  color: var(--fg-muted);
  font-weight: 500;
  font-size: 0.78125rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--bg);
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-table .row-actions {
  display: flex;
  gap: 0.5rem;
}

.admin-swatches {
  display: flex;
  gap: 4px;
}

.admin-swatches span {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.review-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

@media (min-width: 860px) {
  .review-layout {
    grid-template-columns: 1fr 1fr;
  }
}

.review-meta-table {
  width: 100%;
  font-size: 0.875rem;
}

.review-meta-table td {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.review-meta-table td:first-child {
  color: var(--fg-muted);
  width: 140px;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-pending {
  background: rgba(245, 158, 11, 0.12);
  color: #92660a;
}

.badge-approved {
  background: rgba(16, 185, 129, 0.12);
  color: #067a55;
}

.badge-rejected {
  background: rgba(229, 72, 77, 0.12);
  color: #c0282d;
}

@media (max-width: 600px) {
  .admin-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}
