@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f3f0ea;
  --bg-2: #ebe6dc;
  --ink: #1c2421;
  --muted: #5d6a64;
  --card: #fffdf8;
  --line: #d5cec2;
  --accent: #0f6b5c;
  --accent-2: #0a4f44;
  --danger: #9b2c2c;
  --warn: #7a5b12;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(28, 36, 33, 0.06);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Vazirmatn", Tahoma, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 100% -10%, #d7ebe4 0%, transparent 55%),
    radial-gradient(900px 400px at 0% 0%, #f0e2c8 0%, transparent 50%),
    var(--bg);
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); }
.wrap { width: min(1120px, calc(100% - 2rem)); margin-inline: auto; }
.main { padding: 1.5rem 0 3rem; }
.muted { color: var(--muted); }
.site-header {
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(10px);
  background: rgba(243, 240, 234, 0.88);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.9rem 0; }
.brand { display: flex; flex-direction: column; gap: 0.1rem; color: inherit; }
.brand-mark { font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.brand-name { font-size: 1.15rem; font-weight: 700; }
.nav { display: flex; gap: 1rem; flex-wrap: wrap; }
.nav a { color: var(--ink); font-weight: 500; }
.site-footer { border-top: 1px solid var(--line); padding: 1.25rem 0 2rem; color: var(--muted); font-size: 0.9rem; }

.hero { padding: 1.5rem 0 1rem; }
.hero h1 { margin: 0 0 0.4rem; font-size: clamp(1.8rem, 4vw, 2.4rem); }
.filters { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 0.6rem; margin: 1rem 0 1.25rem; }
@media (max-width: 800px) { .filters { grid-template-columns: 1fr; } }

.input, select.input, textarea.input, input[type="file"].input {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  font: inherit;
  color: inherit;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 999px; padding: 0.65rem 1.1rem; font: inherit; cursor: pointer;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); color: #fff; }
.btn-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.linkish { background: none; border: none; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }
.linkish.danger { color: var(--danger); }
.inline { display: inline; }

.car-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.car-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  color: inherit;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.car-card:hover { transform: translateY(-3px); box-shadow: 0 16px 34px rgba(28,36,33,0.1); color: inherit; }
.car-card-media { aspect-ratio: 4/3; background: var(--bg-2); }
.car-card-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.placeholder { height: 100%; display: grid; place-items: center; color: var(--muted); }
.car-card-body { padding: 0.85rem 1rem 1rem; }
.car-card-body h2 { margin: 0 0 0.25rem; font-size: 1.05rem; }

.car-detail h1 { margin-top: 0.2rem; }
.crumb { color: var(--muted); }
.prose, .notes-grid, .gallery-section { margin-top: 1.5rem; }
.notes-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.notes-grid > div, .panel, .form-card, .auth-card, .match-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow);
}
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0.75rem; }
.gallery-item { border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: #fff; }
.gallery-item img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.admin-gallery { margin-top: 1.5rem; }
.gallery-item-admin { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 0.5rem; }
.gallery-item-admin img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.75rem; margin: 1rem 0 1.5rem; }
@media (max-width: 800px) { .stat-grid { grid-template-columns: 1fr 1fr; } }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; display: flex; flex-direction: column; gap: 0.25rem; }
.stat strong { font-size: 1.5rem; }
.dash-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.panel { margin-bottom: 1rem; }
.panel.warn { border-color: #e2c56d; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: right; padding: 0.65rem 0.4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.actions { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.stack { display: grid; gap: 0.85rem; }
.form-card label, .auth-card label { display: grid; gap: 0.35rem; }
.auth-card { max-width: 420px; margin: 2rem auto; }
.empty { padding: 2rem; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.messages { margin-top: 1rem; display: grid; gap: 0.5rem; }
.flash { padding: 0.75rem 1rem; border-radius: 10px; background: #e7f3ef; }
.flash-error, .flash-error * { background: #fde8e8; color: var(--danger); }
.flash-success { background: #e7f3ef; }
.match-card { margin-bottom: 0.85rem; }
.match-card.pending { border-color: #c9a227; }
.match-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.5rem; margin-bottom: 0.75rem; }
.match-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.5rem; align-items: center; }
.clamp { max-height: 4.5em; overflow: hidden; }
.pagination { display: flex; gap: 1rem; justify-content: center; margin-top: 1.5rem; align-items: center; }
code { font-size: 0.85em; background: var(--bg-2); padding: 0.1rem 0.35rem; border-radius: 6px; }

button, a, input, select, textarea { transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, color 0.2s ease, transform 0.2s ease; }
button, select, input[type="checkbox"], input[type="file"] { cursor: pointer; }
:focus-visible { outline: 3px solid rgba(15, 107, 92, 0.3); outline-offset: 3px; }

/* Public featured-car slideshow */
.car-slider {
  position: relative;
  min-height: clamp(320px, 48vw, 540px);
  margin: 0.5rem 0 1.5rem;
  border-radius: 24px;
  overflow: hidden;
  background: #18211e;
  box-shadow: 0 24px 60px rgba(28, 36, 33, 0.18);
  isolation: isolate;
}
.car-slider-track, .car-slide { position: absolute; inset: 0; }
.car-slide {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.7s cubic-bezier(0.22, 1, 0.36, 1), visibility 0.7s;
}
.car-slide.is-active { opacity: 1; visibility: visible; z-index: 1; }
.car-slide img { width: 100%; height: 100%; object-fit: cover; display: block; }
.car-slide-shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(8, 20, 17, 0.15) 10%, rgba(8, 20, 17, 0.82) 100%),
    linear-gradient(0deg, rgba(8, 20, 17, 0.55), transparent 55%);
}
.car-slide-content {
  position: absolute;
  z-index: 2;
  inset-inline-start: clamp(1.5rem, 5vw, 4rem);
  inset-block-end: clamp(2rem, 7vw, 4.5rem);
  color: #fff;
  max-width: 520px;
}
.car-slide-content h2 { font-size: clamp(2rem, 6vw, 4rem); margin: 0.35rem 0 1rem; line-height: 1.1; }
.slide-kicker { color: #bfe3d9; font-size: 0.82rem; font-weight: 700; letter-spacing: 0.04em; }
.slide-link { color: #10221d; background: #fff; border-color: #fff; }
.slide-link:hover { color: #fff; background: var(--accent); border-color: var(--accent); }
.slider-arrow {
  position: absolute;
  z-index: 3;
  inset-block-start: 50%;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  background: rgba(10, 30, 24, 0.42);
  color: #fff;
  backdrop-filter: blur(10px);
  transform: translateY(-50%);
}
.slider-arrow:hover { background: var(--accent); transform: translateY(-50%) scale(1.04); }
.slider-next { inset-inline-end: 1rem; }
.slider-prev { inset-inline-start: 1rem; }
.slider-arrow svg { width: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.slider-dots { position: absolute; z-index: 3; inset-inline: 0; inset-block-end: 1rem; display: flex; justify-content: center; gap: 0.45rem; }
.slider-dots button { width: 9px; height: 9px; padding: 0; border: 0; border-radius: 99px; background: rgba(255,255,255,0.55); }
.slider-dots button.is-active { width: 28px; background: #fff; }

/* Structured car editor */
.car-editor { padding: clamp(1rem, 3vw, 1.6rem); }
.car-editor h2 { margin: 0; font-size: 1.15rem; }
.car-editor label { display: grid; gap: 0.4rem; font-weight: 700; }
.car-editor label .errorlist { font-weight: 400; }
.editor-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.85rem; }
.main-photo-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: var(--bg);
}
.main-photo-preview { width: 150px; height: 110px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); }
.parts-editor { margin-top: 0.25rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.btn-add-part { flex-shrink: 0; border-color: rgba(15, 107, 92, 0.35); color: var(--accent); }
.btn-add-part span { font-size: 1.2rem; margin-inline-end: 0.35rem; }
.part-form-list { display: grid; gap: 0.85rem; }
.part-form-card { border: 1px solid var(--line); border-radius: 16px; padding: 1rem; background: #fff; box-shadow: 0 4px 20px rgba(28,36,33,0.05); display: grid; gap: 0.85rem; }
.part-form-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.part-remove { border: 0; background: #faeeee; color: var(--danger); border-radius: 999px; padding: 0.4rem 0.75rem; font: inherit; }
.part-remove:hover { background: #f2dcdc; }
.part-photo-strip { display: flex; gap: 0.5rem; overflow-x: auto; padding-block: 0.25rem; }
.part-photo-strip img { width: 76px; height: 58px; flex: 0 0 auto; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.part-empty { margin-top: 0.75rem; padding: 1.25rem; }
.publish-check { display: flex !important; align-items: center; gap: 0.55rem !important; }
.publish-check input { width: 18px; height: 18px; }
.editor-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }

/* Dashboard attention list */
.stat-attention { border-color: #d8b84d; background: #fff9e6; }
.missing-photo-panel { border-color: #d8b84d; }
.missing-photo-panel .panel-head { align-items: flex-start; }
.missing-photo-panel .panel-head h2, .missing-photo-panel .panel-head p { margin-block: 0 0.25rem; }
.count-badge { display: inline-flex; border-radius: 999px; background: #fff2bd; color: #664c00; padding: 0.35rem 0.7rem; white-space: nowrap; }
.table-scroll { overflow-x: auto; }

/* Car detail structured parts */
.car-main-photo { margin: 1rem 0 1.5rem; border-radius: 22px; overflow: hidden; background: var(--bg-2); box-shadow: var(--shadow); }
.car-main-photo img { width: 100%; max-height: 620px; aspect-ratio: 16 / 9; display: block; object-fit: cover; }
.car-parts { display: grid; gap: 1rem; margin-top: 1.5rem; }
.car-part { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: clamp(1rem, 3vw, 1.5rem); box-shadow: var(--shadow); }
.car-part-copy h2 { margin: 0.25rem 0 0.5rem; }
.car-part-copy p { margin-bottom: 1rem; }
.part-gallery { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }

@media (max-width: 700px) {
  .editor-grid, .main-photo-field { grid-template-columns: 1fr; }
  .main-photo-preview { width: 100%; height: auto; aspect-ratio: 16 / 9; }
  .parts-editor .panel-head { align-items: stretch; flex-direction: column; }
  .btn-add-part { width: 100%; }
  .car-slider { min-height: 360px; border-radius: 18px; }
  .car-slide-shade { background: linear-gradient(0deg, rgba(8, 20, 17, 0.9), rgba(8, 20, 17, 0.05) 75%); }
  .car-slide-content { inset-inline: 1.25rem; inset-block-end: 3rem; }
  .slider-arrow { width: 40px; height: 40px; inset-block-start: 42%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
