/* ======== بیس ======== */
body {
  font-family: 'Vazirmatn', sans-serif;
  margin: 0;
  padding: 0;
  background: #f5f5f5;
  color: #333;
  line-height: 1.6;
  padding-bottom: 70px;
}

a { text-decoration: none; color: inherit; }

/* ======== هدر ======== */
header {
  background: #00964E;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
}

header .logo { font-size: 20px; font-weight: bold; }

header .search-bar {
  flex: 1;
  display: flex;
  align-items: center;
  margin: 0 15px;
  background: #fff;
  border-radius: 30px;
  padding: 5px 12px;
}

header .search-bar input {
  border: none;
  outline: none;
  flex: 1;
  padding: 6px 8px;
  font-size: 14px;
}

.search-icon { width: 18px; height: 18px; margin-left: 5px; }

header .cta {
  background: #e63946;
  color: #fff;
  padding: 13px 12px 10px;
  border-radius: 30px;
  font-weight: bold;
  transition: 0.2s;
}

header .cta:hover { background: #c72c3a; }

/* ======== هیرو ======== */
.hero {
  text-align: center;
  padding: 30px 15px;
  background: #fff;
}

.hero h1 { margin: 0; font-size: 22px; color: #00964E; }
.hero p { margin-top: 8px; font-size: 15px; color: #666; }

/* ======== دسته‌بندی ======== */
.categories {
  display: flex;
  justify-content: center;
  gap: 15px;
  padding: 10px;
  background: #fff;
  border-bottom: 1px solid #eee;
  overflow-x: auto;
}

.category {
  flex: 0 0 auto;
  text-align: center;
  font-size: 13px;
  cursor: pointer;
  color: #555;
}

.category i { display: block; font-size: 20px; margin-bottom: 4px; }
.category.active-cat { color: #00964E; font-weight: bold; }

/* ======== مرتب‌سازی ======== */
.sort-bar {
  display: flex;
  align-items: center;
  padding: 10px 15px;
  background: #fff;
  border-bottom: 1px solid #eee;
}

.sort-bar label { margin-left: 10px; }

.sort-bar select {
  margin-left: auto;
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid #ccc;
  background: #fff;
  font-size: 14px;
}

/* ======== لیست آگهی ======== */
.ads {
  padding: 15px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 15px;
}

.ad-card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  transition: all 0.2s ease;
}

/* border زرد برای ویژه */
.ad-card.special {
  border: 2px solid #ff9800;
}

.ad-card img { width: 100%; height: 180px; object-fit: cover; }

/* عنوان و توضیحات با فاصله کم و مارجین بیشتر از راست */
.ad-card h3,
.ad-card p {
  margin-right: 12px; /* فاصله از سمت راست */
  margin-left: 0;
  text-align: right; /* راست‌چین */
  color: #333;
}

.ad-card h3 {
  font-size: 16px;
  margin-top: 10px;
  margin-bottom: 4px; /* فاصله کم با توضیحات */
}

.ad-card p {
  font-size: 14px;
  margin-bottom: 8px;
  color: #555;
}

/* ردیف پایین کارت شامل badge و دکمه */
.ad-card .card-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 10px 10px;
}

/* badge */
.ad-card .badge {
  background: #ff9800;
  color: #fff;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: bold;
}

/* ======== دکمه بهتر اطلاعات بیشتر ======== */
.ad-card .more-info-btn {
  padding: 8px 14px;
  border: none;
  border-radius: 12px;
  background: #00964E;
  color: #fff;
  font-weight: bold;
  cursor: pointer;
  font-size: 14px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
  transition: 0.3s ease;
}

.ad-card .more-info-btn:hover {
  background: #007a3e;
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0,0,0,0.25);
}

/* ======== فرم ثبت آگهی ======== */
.overlay {
  position: fixed;
  padding-top: 2rem;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.overlay.active { display: flex; }

.ad-form {
  background: #fff;
  padding: 20px;
  border-radius: 16px;
  width: 90%;
  max-width: 400px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  animation: fadeIn 0.3s ease;
  padding-bottom: 90px;
  position: relative;
}

.ad-form h3 { margin-top: 0; margin-bottom: 15px; font-size: 18px; color: #00964E; }
.ad-form label { display: block; margin: 10px 0 5px; font-weight: 600; }

.ad-form input, .ad-form select, .ad-form input[type="number"], .ad-form input[type="file"] {
  width: 100%;
  height: 36px;
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  margin-bottom: 10px;
  box-sizing: border-box;
}

.ad-form input[type="number"]::-webkit-outer-spin-button,
.ad-form input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.ad-form input[type="number"] { -moz-appearance: textfield; }

.checkbox-wrapper {
  display: flex;
  align-items: center;
  margin: 10px 0;
  gap: 8px;
}

.checkbox-wrapper input[type="checkbox"] { width: 18px; height: 18px; accent-color: #ff9800; }
.checkbox-wrapper label { font-size: 14px; margin: 0; }

.form-buttons {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 15px;
  position: sticky;
  bottom: 0;
  background: #fff;
  padding: 12px 0 0;
}

.form-buttons button {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  font-weight: bold;
  transition: 0.2s;
}

.btn-save { background: #00964E; color: #fff; margin-bottom: 1rem; }
.btn-save:hover { background: #007a3e; }
.btn-cancel { background: #e63946; color: #fff;margin-bottom: 1rem; }
.btn-cancel:hover { background: #c72c3a; }

/* ======== ناوبری پایین ======== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid #ddd;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 6px 0;
  z-index: 1000;
}

.bottom-nav a { text-align: center; font-size: 12px; color: #555; }
.bottom-nav a i { display: block; font-size: 18px; margin-bottom: 2px; }
.bottom-nav a.active { color: #00964E; font-weight: bold; }

.bottom-nav .add {
  background: #e63946;
  color: #fff;
  font-size: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  padding-top: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: -25px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

/* ======== ریسپانسیو ======== */
@media (max-width: 600px) {
  .overlay { align-items: flex-end; }
  .ad-form {
    width: 100%;
    max-width: none;
    max-height: 90%;
    border-radius: 16px 16px 0 0;
    padding: 20px 16px 90px;
  }
  #search{
    width: 120px;
  }
  .ad-card img {
    height: 230px; /* موبایل */
  }
  header .search-bar input {
    width: 100px;
  }
}
/* ======== انیمیشن ======== */
@keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* ======== Styles for validation/errors/toast ======== */
.input-error {
  color: #e63946;
  font-size: 13px;
  margin-top: 6px;
  display: block;
  text-align: right;
  margin-right: 12px;
}

.ad-form input.invalid,
.ad-form select.invalid,
.ad-form input[type="file"].invalid {
  border-color: #e63946;
  box-shadow: 0 0 0 4px rgba(230,57,70,0.06);
}

.ad-form input.valid,
.ad-form select.valid,
.ad-form input[type="file"].valid {
  border-color: #00964E;
  box-shadow: 0 0 0 4px rgba(0,150,78,0.04);
}

.btn-save[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* small shake for attention */
@keyframes shake {
  0% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-4px); }
  100% { transform: translateX(0); }
}

.invalid.shake {
  animation: shake 0.4s ease;
}

/* toast */
.toast {
  position: fixed;
  right: 20px;
  bottom: 90px;
  background: #00964E;
  color: #fff;
  padding: 10px 14px;
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.2);
  z-index: 1500;
  display: none;
  font-weight: 600;
}

.toast.show {
  display: block;
  animation: toastIn 0.35s ease;
}

@keyframes toastIn { from { transform: translateY(20px); opacity: 0 } to { transform: translateY(0); opacity: 1 } }
/* فقط تغییر جدید برای چک‌باکس قیمت توافقی */
#new-agreed-price {
  width: 18px;
  height: 18px;
  accent-color: #00964E;
}
#new-special{
  width: 18px;
  height: 18px;
  accent-color: #00964E;
}
.ad-card img {
  width: 100%;
  height: 180px;
  object-fit: cover; /* حالت پیش‌فرض */
  background: #f5f5f5;
  border-bottom: 1px solid #eee;
}

.ad-card img.contain {
  object-fit: contain;
  background: #f5f5f5;
}

@media (max-width: 600px) {
  .ad-card img {
    height: 230px;
  }
  header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    flex-wrap: nowrap;
  }

  header .logo {
    font-size: 16px;
    flex-shrink: 0;
  }

  header .search-bar {
    flex: 1 1 auto;
    min-width: 0;
    padding: 4px 8px;
    margin: 0 4px;
    border-radius: 20px;
  }

  header .search-bar input {
    width: 100%;
    font-size: 13px;
  }

  header .cta {
    flex-shrink: 0;
    font-size: 13px;
    padding: 6px 10px; /* ارتفاع متناسب با نوار سرچ */
    line-height: 1; 
    height: 28px; /* دقیقا هم‌اندازه نوار سرچ */
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
  }
  /* اختیاری: کوچیک‌تر کردن آیکون سرچ برای گوشی */
  .search-icon {
    width: 16px;
    height: 16px;
  }
}
.small-alert{
  color:red; 
  font-size:14px;
  display:block; 
  margin-top:2px;
}