@font-face {
  font-family: "Peyda";
  src: url("../../fonts/peyda-light.ttf") format("truetype");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Peyda";
  src: url("../../fonts/Peyda-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #d7dbe0;
  --surface: #f8fafc;
  --surface-2: #ffffff;
  --navy: #0f172a;
  --navy-2: #1e293b;
  --orange: #f97316;
  --orange-dark: #ea580c;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #d7dde5;
  --shadow: 0 12px 30px rgba(15, 23, 42, .08);
  --shadow-hover: 0 18px 40px rgba(15, 23, 42, .14);
  --radius: 22px;
}

* { box-sizing: border-box }
html, body { margin: 0; padding: 0 }

body {
  font-family: "Peyda", Tahoma, sans-serif;
  background: linear-gradient(180deg, #d8dce1 0%, #e5e7eb 100%);
  color: var(--text);
  direction: rtl;
  min-height: 100vh;
}

a { text-decoration: none; color: inherit }
img { max-width: 100%; display: block }
button, input, textarea { font-family: inherit }

.site-shell { max-width: 1400px; margin: 0 auto; padding: 28px }

.hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, var(--navy), var(--navy-2));
  color: #fff;
  border-radius: 30px;
  padding: 42px;
  box-shadow: var(--shadow);
  margin-bottom: 30px;
}

.hero::before {
  content: "";
  position: absolute;
  inset: auto -80px -80px auto;
  width: 240px; height: 240px;
  background: radial-gradient(circle, rgba(249, 115, 22, .30), transparent 65%);
  pointer-events: none;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(249, 115, 22, .14);
  color: #fff;
  border: 1px solid rgba(249, 115, 22, .35);
  padding: 8px 14px;
  border-radius: 999px;
  margin-bottom: 18px;
}

.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(24px, 3vw, 44px);
  line-height: 1.4;
}

.hero p {
  margin: 0;
  color: #cbd5e1;
  font-size: 16px;
  line-height: 1.9;
  max-width: 760px;
}

.hero-actions { margin-top: 24px; display: flex; gap: 12px; flex-wrap: wrap }

.hero-btn {
  padding: 12px 18px;
  border-radius: 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.hero-btn-outline {
  background: rgba(255, 255, 255, .08);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .16);
}

.hero-btn-outline:hover {
  background: rgba(255, 255, 255, .14);
}

/* اصلاح گرید محصولات */
.products-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
}

.product-card {
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, .65);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: .25s transform, .25s box-shadow, .25s border-color;
  display: flex;
  flex-direction: column;
}

.product-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-hover);
  border-color: rgba(249, 115, 22, .35);
}

/* اصلاح بخش تصویر برای جلوگیری از کات شدن */
.product-image-wrap {
  aspect-ratio: 1 / 1; /* تغییر به مربع برای تقارن بهتر */
  background: #f1f5f9; /* رنگ پس‌زمینه برای فضاهای خالی عکس */
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.product-image {
  width: 100%;
  height: 100%;
  object-fit: contain; /* نمایش کامل عکس بدون کات شدن */
  transition: transform .3s ease;
}

.product-card:hover .product-image {
  transform: scale(1.04);
}

.product-info { padding: 18px }

.product-info h3 {
  margin: 0 0 10px;
  color: var(--navy);
  font-size: 18px;
  line-height: 1.6;
}

.meta-line {
  color: var(--muted);
  margin-top: 6px;
  font-size: 14px;
}

.pagination {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 28px 0 10px;
}

.page-link {
  min-width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(15, 23, 42, .05);
}

.page-link.active {
  background: var(--navy);
  color: #fff;
}

.empty-state {
  grid-column: 1/-1;
  background: #fff;
  border-radius: 24px;
  padding: 40px 24px;
  text-align: center;
  border: 1px dashed var(--border);
  box-shadow: var(--shadow);
}

.empty-state h2 { margin: 0 0 10px; color: var(--navy) }
.empty-state p { margin: 0; color: var(--muted) }

/* اصلاح مودال نمایش محصول */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .62);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 1000;
}

.modal-backdrop.open { display: flex }

.modal-card {
  width: min(1120px, 100%);
  background: #fff;
  border-radius: 28px;
  box-shadow: 0 25px 80px rgba(0, 0, 0, .25);
  position: relative;
  padding: 24px;
}

.modal-close {
  position: absolute;
  top: 14px;
  left: 14px;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: #eef2ff;
  color: var(--navy);
  font-size: 24px;
  cursor: pointer;
  z-index: 10;
}

.modal-grid {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 24px;
}

.main-image-wrap {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  background: #f8fafc; /* پس‌زمینه روشن برای مودال */
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
}

.main-image-wrap img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain; /* نمایش کامل در مودال */
}

.nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  color: #111827;
  cursor: pointer;
  font-size: 28px;
  line-height: 1;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  transition: .2s;
}
.nav-btn:hover { background: #fff; transform: translateY(-50%) scale(1.1); }

.prev-btn { right: 12px }
.next-btn { left: 12px }

.thumbs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.thumb {
  width: 72px;
  height: 72px;
  border-radius: 14px;
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
}

.thumb.active { border-color: var(--orange) }

.thumb img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.modal-details h2 {
  margin: 0 0 12px;
  color: var(--navy);
  font-size: 28px;
  line-height: 1.6;
}

.detail-item {
  background: #f8fafc;
  border: 1px solid var(--border);
  padding: 12px 14px;
  border-radius: 14px;
  margin-bottom: 10px;
}

.modal-details p {
  line-height: 1.95;
  color: #374151;
  white-space: pre-line;
}

/* بخش مدیریت تصاویر در مودال ویرایش (ادمین) */
#existing-images-section {
  margin-top: 20px;
  padding: 15px;
  background: #f1f5f9;
  border-radius: 14px;
}

#current-images-list {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.thumb-wrapper {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid #fff;
  cursor: pointer;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.thumb-wrapper img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.thumb-wrapper.to-delete {
  border-color: #ef4444;
  opacity: 0.5;
}

.thumb-wrapper.to-delete::after {
  content: "حذف";
  position: absolute;
  inset: 0;
  background: rgba(239, 68, 68, 0.6);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: bold;
}

/* لاگین و فرم‌ها */
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(480px, 100%);
  background: rgba(255, 255, 255, .92);
  border-radius: 24px;
  padding: 28px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, .65);
}

label {
  display: block;
  margin: 12px 0 8px;
  font-weight: 700;
  color: var(--navy);
}

input, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 15px;
  outline: none;
  background: #fff;
  transition: .2s border-color, .2s box-shadow;
}

input:focus, textarea:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, .12);
}

textarea { resize: vertical }

.btn-primary, .btn-secondary, .btn-danger, .btn-small, .btn-edit {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  transition: .2s opacity, .2s transform, .2s background;
}

.btn-primary { background: var(--orange); color: #fff }
.btn-primary:hover { background: var(--orange-dark) }
.btn-secondary { background: #e2e8f0; color: var(--navy) }
.btn-danger { background: #ef4444; color: #fff }
.btn-small { padding: 9px 12px; font-size: 14px }
.btn-edit { background: #0f172a; color: #fff }

.admin-toolbar {
  position: sticky;
  top: 0;
  z-index: 900;
  background: rgba(15, 23, 42, .96);
  color: #fff;
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  backdrop-filter: blur(10px);
}

.toolbar-title { font-weight: 700 }
.toolbar-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap }

.admin-shell { padding-top: 24px }
.admin-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap }

.alert {
  background: #fee2e2;
  color: #991b1b;
  padding: 12px 14px;
  border-radius: 14px;
  margin-bottom: 14px;
}

/* ریسپانسیو */
@media (max-width: 1200px) {
  .products-grid { grid-template-columns: repeat(3, minmax(0, 1fr)) }
  .modal-grid { grid-template-columns: 1fr }
}

@media (max-width: 768px) {
  .products-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) }
  .hero { padding: 26px }
  .site-shell { padding: 18px }
  .modal-card { padding: 18px }
  .admin-toolbar { flex-direction: column; align-items: stretch }
}

@media (max-width: 520px) {
  .products-grid { grid-template-columns: 1fr }
  .modal-details h2 { font-size: 22px }
  .product-info h3 { font-size: 16px }
  .hero h1 { font-size: 26px }
}
