/* ===== متغیرها ===== */
:root {
  --primary: #06b6d4;
  --primary-dark: #0e7490;
  --secondary: #7c3aed;
  --accent: #f59e0b;
  --bg: #f3f5f8;
  --card-bg: #ffffff;
  --text-dark: #1f2937;
  --text-gray: #6b7280;
  --border: #e5e7eb;
  --danger: #ef4444;
  --success: #10b981;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(0,0,0,0.06);
  --shadow-hover: 0 8px 24px rgba(0,0,0,0.12);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: Tahoma, "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text-dark);
  direction: rtl;
  line-height: 1.7;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* ===== هدر ===== */
.site-header {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-text {
  font-size: 22px;
  font-weight: bold;
  color: #fff;
}

.logo-accent {
  color: #fde68a;
}

.main-nav ul {
  display: flex;
  gap: 6px;
  align-items: center;
}

.nav-link {
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 15px;
  transition: background 0.2s;
  display: block;
}

.nav-link:hover, .nav-link.active {
  background: rgba(255,255,255,0.2);
}

.instagram-link {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
}

.instagram-link:hover {
  background: rgba(255,255,255,0.2);
}

.footer-instagram {
  display: inline-block;
  margin-top: 8px;
  color: var(--secondary);
  font-size: 13px;
  font-weight: bold;
}

.footer-instagram:hover {
  text-decoration: underline;
}

.dropdown {
  position: relative;
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: 110%;
  right: 0;
  background: #fff;
  border-radius: 10px;
  box-shadow: var(--shadow-hover);
  min-width: 170px;
  overflow: hidden;
  z-index: 200;
}

.dropdown:hover .dropdown-menu {
  display: block;
}

.dropdown-menu li a {
  display: block;
  padding: 12px 16px;
  color: var(--text-dark);
  font-size: 14px;
}

.dropdown-menu li a:hover {
  background: var(--bg);
}

.menu-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  padding: 6px;
}

.menu-toggle span {
  width: 26px;
  height: 3px;
  background: #fff;
  border-radius: 3px;
}

/* ===== هیرو / جستجو ===== */
.hero {
  text-align: center;
  padding: 46px 20px 34px;
  background: linear-gradient(180deg, rgba(6,182,212,0.08), transparent);
}

.hero h1 {
  font-size: 26px;
  color: var(--text-dark);
  margin-bottom: 10px;
}

.hero p {
  color: var(--text-gray);
  margin-bottom: 22px;
  font-size: 15px;
}

.search-box {
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  gap: 8px;
  background: #fff;
  padding: 6px;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.search-box input {
  flex: 1;
  border: none;
  outline: none;
  padding: 12px 14px;
  font-size: 15px;
  background: transparent;
  color: var(--text-dark);
}

.search-box button {
  border: none;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  padding: 0 22px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: bold;
  transition: opacity 0.2s;
}

.search-box button:hover { opacity: 0.9; }

.search-box select {
  border: none;
  outline: none;
  padding: 0 10px;
  font-size: 14px;
  background: var(--bg);
  border-radius: 8px;
  color: var(--text-dark);
  max-width: 130px;
}

/* ===== نوار دسته‌بندی ===== */
.categories-bar {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px 20px;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scrollbar-width: none;
}

.categories-bar::-webkit-scrollbar { display: none; }

.cat-btn {
  flex-shrink: 0;
  border: 1.5px solid var(--border);
  background: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  color: var(--text-dark);
  transition: all 0.2s;
  white-space: nowrap;
}

.cat-btn:hover {
  border-color: var(--primary);
}

.cat-btn.active {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  border-color: transparent;
  font-weight: bold;
}

/* ===== بخش آگهی‌ها ===== */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 20px 40px;
}

.section-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 18px;
}

.section-head h2 {
  font-size: 19px;
  color: var(--text-dark);
}

.ads-count {
  color: var(--text-gray);
  font-size: 13px;
}

.ads-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}

.ad-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
}

.ad-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
}

.ad-card .ad-image-wrap {
  position: relative;
  width: 100%;
  height: 160px;
  background: #eef0f3;
}

.ad-card .ad-image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ad-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
}

.ad-card .ad-body {
  padding: 12px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.ad-title {
  font-size: 15px;
  font-weight: bold;
  color: var(--text-dark);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 40px;
}

.ad-price {
  color: var(--accent);
  font-weight: bold;
  font-size: 15px;
}

.ad-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-gray);
  font-size: 12px;
  margin-top: auto;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
}

.empty-msg {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-gray);
}

.empty-msg p {
  font-size: 20px;
  margin-bottom: 6px;
}

/* ===== فوتر ===== */
.site-footer {
  text-align: center;
  padding: 22px;
  color: var(--text-gray);
  font-size: 13px;
  border-top: 1px solid var(--border);
  background: #fff;
}

/* ===== مودال‌ها ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.55);
  z-index: 1000;
  align-items: flex-start;
  justify-content: center;
  padding: 30px 16px;
  overflow-y: auto;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 26px 22px;
  width: 100%;
  max-width: 480px;
  position: relative;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
  animation: modalIn 0.25s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(-14px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal h2 {
  font-size: 18px;
  margin-bottom: 18px;
  color: var(--text-dark);
}

.modal-close {
  position: absolute;
  top: 14px;
  left: 14px;
  background: var(--bg);
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 18px;
  color: var(--text-gray);
  line-height: 1;
}

.modal-close:hover {
  background: var(--border);
}

.modal form {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.modal label {
  font-size: 13px;
  color: var(--text-gray);
  margin-top: 10px;
  margin-bottom: 4px;
}

.modal input,
.modal select,
.modal textarea {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 11px 12px;
  font-size: 14px;
  outline: none;
  color: var(--text-dark);
  background: #fafafa;
  transition: border-color 0.2s;
  resize: vertical;
}

.modal input:focus,
.modal select:focus,
.modal textarea:focus {
  border-color: var(--primary);
  background: #fff;
}

.image-preview {
  margin-top: 10px;
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: 10px;
  border: 1.5px solid var(--border);
}

.submit-btn {
  margin-top: 18px;
  border: none;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  padding: 13px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: bold;
  transition: opacity 0.2s;
}

.submit-btn:hover { opacity: 0.9; }

.login-hint {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-gray);
  text-align: center;
}

/* ===== مودال جزئیات ===== */
.detail-modal {
  max-width: 560px;
}

.detail-img {
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  border-radius: 10px;
  margin-bottom: 16px;
}

.detail-cat {
  display: inline-block;
  background: var(--bg);
  color: var(--primary-dark);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  margin-bottom: 10px;
}

.detail-title {
  font-size: 19px;
  font-weight: bold;
  margin-bottom: 8px;
}

.detail-price {
  color: var(--accent);
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 14px;
}

.detail-desc {
  color: var(--text-dark);
  font-size: 14px;
  margin-bottom: 16px;
  line-height: 1.9;
}

.detail-meta {
  display: flex;
  justify-content: space-between;
  color: var(--text-gray);
  font-size: 13px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.delete-ad-btn {
  margin-top: 16px;
  width: 100%;
  border: none;
  background: var(--danger);
  color: #fff;
  padding: 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: bold;
}

.delete-ad-btn:hover { opacity: 0.9; }

/* ===== بنر حالت آزمایشی ===== */
.local-mode-banner {
  background: #fef3c7;
  color: #92400e;
  text-align: center;
  font-size: 12.5px;
  padding: 9px 14px;
  border-bottom: 1px solid #fde68a;
  line-height: 1.7;
}

/* ===== نشان پیام خوانده‌نشده ===== */
.unread-badge {
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  margin-right: 4px;
}

/* ===== دکمه‌های عملیات در جزئیات آگهی ===== */
.detail-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.expiry-note {
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--text-gray);
  background: var(--bg);
  padding: 8px 12px;
  border-radius: 8px;
  text-align: center;
}

.contact-phone-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  border-radius: 10px;
  padding: 12px 14px;
  margin-top: 10px;
}

.contact-phone-box a {
  color: var(--primary-dark);
  font-weight: bold;
  font-size: 15px;
}

.action-btn {
  border: none;
  border-radius: 10px;
  padding: 12px;
  font-size: 14px;
  font-weight: bold;
  color: #fff;
  width: 100%;
}

.action-btn.chat-btn { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); }
.action-btn.edit-btn { background: var(--secondary); }
.action-btn.report-btn { background: #fff; color: var(--danger); border: 1.5px solid var(--danger); }

/* ===== چت ===== */
.chat-modal {
  display: flex;
  flex-direction: column;
  max-height: 80vh;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 4px;
  min-height: 200px;
  max-height: 45vh;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}

.chat-bubble {
  max-width: 75%;
  padding: 9px 13px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.6;
}

.chat-bubble.mine {
  align-self: flex-start;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  border-bottom-left-radius: 2px;
}

.chat-bubble.theirs {
  align-self: flex-end;
  background: #fff;
  border: 1px solid var(--border);
  border-bottom-right-radius: 2px;
}

.chat-bubble .chat-time {
  display: block;
  font-size: 10px;
  opacity: 0.7;
  margin-top: 4px;
}

.chat-form {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.chat-form input {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 11px 12px;
  font-size: 14px;
  outline: none;
}

.chat-form button {
  border: none;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  padding: 0 20px;
  border-radius: 8px;
  font-weight: bold;
}

/* ===== لیست گفتگوها ===== */
.conversations-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 60vh;
  overflow-y: auto;
}

.conversation-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
}

.conversation-item:hover {
  background: var(--bg);
}

.conversation-info strong {
  display: block;
  font-size: 14px;
  margin-bottom: 3px;
}

.conversation-info span {
  font-size: 12px;
  color: var(--text-gray);
}

/* ===== پنل مدیریت ===== */
.admin-modal {
  max-width: 600px;
}

.admin-reports-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 65vh;
  overflow-y: auto;
}

.admin-report-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}

.admin-report-item .report-title {
  font-weight: bold;
  font-size: 14px;
  margin-bottom: 4px;
}

.admin-report-item .report-meta {
  font-size: 12px;
  color: var(--text-gray);
  margin-bottom: 10px;
}

.admin-report-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-report-actions button {
  flex: 1;
  border: none;
  border-radius: 8px;
  padding: 8px;
  font-size: 12px;
  font-weight: bold;
  color: #fff;
  min-width: 90px;
}

.admin-report-actions .btn-delete { background: var(--danger); }
.admin-report-actions .btn-block { background: #b91c1c; }
.admin-report-actions .btn-dismiss { background: var(--text-gray); }

/* ===== قوانین ===== */
.terms-content {
  max-height: 65vh;
  overflow-y: auto;
  font-size: 14px;
  line-height: 2;
  color: var(--text-dark);
}

.terms-content p {
  margin-bottom: 10px;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text-dark);
  color: #fff;
  padding: 13px 22px;
  border-radius: 999px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
  z-index: 2000;
  box-shadow: 0 6px 20px rgba(0,0,0,0.25);
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== ریسپانسیو ===== */
@media (max-width: 768px) {
  .menu-toggle {
    display: flex;
  }

  .main-nav {
    display: none;
    width: 100%;
    order: 3;
  }

  .main-nav.open {
    display: block;
  }

  .header-container {
    flex-wrap: wrap;
  }

  .main-nav ul {
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding-top: 10px;
  }

  .dropdown-menu {
    position: static;
    display: none;
    box-shadow: none;
    background: rgba(255,255,255,0.08);
    margin-top: 4px;
  }

  .dropdown.open .dropdown-menu {
    display: block;
  }

  .dropdown-menu li a {
    color: #fff;
  }

  .hero h1 {
    font-size: 21px;
  }

  .search-box {
    flex-direction: column;
  }

  .search-box select {
    max-width: 100%;
  }

  .search-box button {
    padding: 12px;
  }

  .ads-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .ad-card .ad-image-wrap {
    height: 120px;
  }

  .ad-title {
    font-size: 13px;
    min-height: 34px;
  }

  .ad-price {
    font-size: 13px;
  }
}

@media (max-width: 420px) {
  .ads-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .logo-text {
    font-size: 18px;
  }
}
