:root {
  --primary: #e31e24;
  --primary-dark: #c4191f;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --bg: #f8f9fb;
  --white: #ffffff;
  --border: #e5e7eb;
  --success: #10b981;
  --shadow: 0 4px 20px rgba(0,0,0,.08);
  --radius: 12px;
}

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

body {
  font-family: 'Peyda', system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
}

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

.container { max-width: 1200px; margin: 0 auto; padding: 0 1rem; }

/* Header */
.site-header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 0.75rem;
}

.header-start {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  flex: 1;
}

.header-chat-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: white;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.header-chat-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: #fef2f2;
}

.header-chat-btn img {
  width: 20px;
  height: 20px;
  opacity: 0.8;
}

.header-chat-btn:hover img {
  opacity: 1;
}

button.header-chat-btn {
  font-family: inherit;
  cursor: pointer;
}

/* صفحه اصلی: فقط آیکون + جلب توجه */
.page-home .header-chat-label {
  display: none;
}

.page-home .header-chat-btn {
  position: relative;
  padding: 0.5rem;
  width: 46px;
  height: 46px;
  justify-content: center;
  border-radius: 50%;
  border-color: var(--primary);
  background: linear-gradient(145deg, #fff 0%, #fef2f2 100%);
  color: var(--primary);
  box-shadow: 0 2px 10px rgba(227, 30, 36, 0.28);
  animation: header-chat-glow 2.4s ease-in-out infinite;
}

.page-home .header-chat-btn::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  opacity: 0;
  animation: header-chat-ring 2.4s ease-out infinite;
  pointer-events: none;
}

.page-home .header-chat-btn img {
  width: 22px;
  height: 22px;
  opacity: 1;
  filter: brightness(0) saturate(100%) invert(18%) sepia(89%) saturate(4523%) hue-rotate(350deg) brightness(92%) contrast(93%);
}

.page-home .header-chat-btn:hover {
  transform: scale(1.06);
  background: var(--primary);
}

.page-home .header-chat-btn:hover img {
  filter: brightness(0) invert(1);
}

.page-home .header-user-label {
  display: none;
}

.page-home .header-user-btn {
  padding: 0.5rem;
  width: 46px;
  height: 46px;
  justify-content: center;
  border-radius: 50%;
  gap: 0;
}

.page-home .header-user-btn img {
  width: 22px;
  height: 22px;
  opacity: 1;
}

@keyframes header-chat-glow {
  0%, 100% { box-shadow: 0 2px 10px rgba(227, 30, 36, 0.25); }
  50% { box-shadow: 0 4px 18px rgba(227, 30, 36, 0.45); }
}

@keyframes header-chat-ring {
  0% { transform: scale(0.92); opacity: 0.55; }
  70% { transform: scale(1.15); opacity: 0; }
  100% { transform: scale(1.15); opacity: 0; }
}

.header-end {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.header-user-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: white;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
  text-decoration: none;
}

.header-user-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: #fef2f2;
}

.header-user-btn img {
  width: 20px;
  height: 20px;
  opacity: 0.8;
}

button.header-user-btn {
  font-family: inherit;
  cursor: pointer;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

.main-nav { display: flex; gap: 1.5rem; }
.main-nav a { font-weight: 500; color: var(--text-muted); }
.main-nav a:hover { color: var(--primary); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .65rem 1.25rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: .9rem;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all .2s;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { border-color: var(--border); background: white; }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-success { background: var(--success); color: white; }
.btn-sm { padding: .4rem .8rem; font-size: .8rem; }
.btn-block { width: 100%; }
.btn-lg { padding: .85rem 1.75rem; font-size: 1rem; }

/* Hero — base search form (used on search page) */
.search-form { max-width: 900px; margin: 0 auto; }

.search-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto;
  gap: .75rem;
  background: white;
  padding: .75rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.search-row input,
.search-row select {
  padding: .75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .95rem;
}

/* Sections */
.section { padding: 3rem 0; }
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.section-header h2 { font-size: 1.75rem; }
.result-count { color: var(--text-muted); }

/* Car Grid */
.car-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 1.5rem;
}

.car-grid-sm { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

.car-card {
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform .2s, box-shadow .2s;
}

.car-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 30px rgba(0,0,0,.12);
}

.car-card-image {
  position: relative;
  aspect-ratio: 4/3;
  background: #eee;
  overflow: hidden;
}

.car-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.badge {
  position: absolute;
  top: .75rem;
  right: .75rem;
  background: var(--primary);
  color: white;
  padding: .25rem .6rem;
  border-radius: 4px;
  font-size: .75rem;
  font-weight: 600;
  z-index: 2;
}

.badge-lg { font-size: .85rem; padding: .4rem .8rem; }
.badge-warranty { right: auto; left: .75rem; background: #2563eb; }

.car-card-body { padding: 1rem; }
.car-card-body h3 { font-size: 1rem; margin-bottom: .25rem; }
.car-price { color: var(--primary); margin: .25rem 0; }
.car-meta { font-size: .85rem; color: var(--text-muted); }

/* Why section */
.why-section { background: white; }
.why-section h2 { text-align: center; margin-bottom: 2rem; }
.why-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
}
.why-card {
  text-align: center;
  padding: 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.why-icon { font-size: 2.5rem; margin-bottom: 1rem; }

/* Car Detail */
.breadcrumb {
  padding: 1rem;
  font-size: .9rem;
  color: var(--text-muted);
}
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb span { margin: 0 .5rem; }

.car-detail { padding-bottom: 3rem; }

.detail-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
}

.gallery-main {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: #eee;
  aspect-ratio: 4/3;
}

.gallery-main img { width: 100%; height: 100%; object-fit: cover; }

.gallery-thumbs {
  display: flex;
  gap: .5rem;
  margin-top: .75rem;
  overflow-x: auto;
}

.thumb-btn {
  border: 2px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
  width: 80px;
  height: 60px;
}

.thumb-btn.active { border-color: var(--primary); }
.thumb-btn img { width: 100%; height: 100%; object-fit: cover; }

.detail-info h1 { font-size: 1.5rem; margin-bottom: 1rem; }
.detail-price { font-size: 1.75rem; font-weight: 700; color: var(--primary); }
.detail-finance { color: var(--text-muted); margin: .5rem 0; }
.detail-meta { color: var(--text-muted); margin-bottom: 1.5rem; }

.contact-buttons { display: flex; gap: .75rem; flex-wrap: wrap; margin-bottom: 2rem; }

.highlights h2 { font-size: 1.1rem; margin-bottom: 1rem; }
.highlights-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .75rem;
}
.highlight-item {
  background: white;
  padding: .75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.highlight-item span { display: block; font-size: .8rem; color: var(--text-muted); }

.detail-section {
  background: white;
  padding: 2rem;
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}
.detail-section h2 { margin-bottom: 1rem; font-size: 1.25rem; }

.description-text { white-space: pre-line; color: #374151; }

.features-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: .5rem;
  list-style: none;
}
.features-list li::before { content: '✓ '; color: var(--success); font-weight: bold; }

.specs-table { display: grid; gap: 0; }
.spec-row {
  display: flex;
  justify-content: space-between;
  padding: .75rem 0;
  border-bottom: 1px solid var(--border);
}
.spec-row span { color: var(--text-muted); }

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 2rem;
}

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

/* Footer */
.site-footer {
  background: #333333;
  color: #d1d5db;
  padding: 3rem 0 0;
  margin-top: 2rem;
}
.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
  padding-bottom: 2rem;
}
.footer-grid h3, .footer-grid h4 { color: white; margin-bottom: .75rem; }
.footer-grid ul { list-style: none; }
.footer-grid li { margin-bottom: .5rem; }
.footer-grid a:hover { color: white; }
.footer-contact-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.footer-contact-list li {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin-bottom: 0;
  font-size: 0.9rem;
  line-height: 1.45;
}
.footer-contact-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  margin-top: 0.1rem;
  color: #9ca3af;
}
.footer-contact-icon img {
  width: 18px;
  height: 18px;
  opacity: 0.85;
  filter: brightness(0) saturate(100%) invert(72%) sepia(6%) saturate(347%) hue-rotate(182deg) brightness(92%) contrast(88%);
}
.footer-contact-list a:hover { color: white; }
.footer-bottom {
  border-top: 1px solid #4a4a4a;
  padding: 1rem;
  text-align: center;
  font-size: .85rem;
}

@media (max-width: 768px) {
  .search-row { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}
