/* AutoHub Syria — base styles. No build step: plain CSS, loaded directly. */

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--page-plane);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; display: flex; flex-direction: column; }
/* A wide CSS Grid child (e.g. .stats-row, .listing-grid with minmax()) can
   make a flex item's stretched cross size resolve to its content's
   max-content width instead of the container width. An explicit width
   pins it to the real available space so the grid wraps instead of
   overflowing the page horizontally. */
body > * { width: 100%; min-width: 0; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; display: block; }

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- Header ---------- */
header.topbar {
  background: var(--header-bg);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 20px;
  max-width: 1180px;
  margin: 0 auto;
  flex-wrap: wrap;
}

.brand-mark { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.brand-mark img { height: 26px; width: auto; }
.logo-dark { display: none; }
header.topbar .logo-light { display: block; }
header.topbar .logo-dark { display: none; }

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  flex-wrap: wrap;
}

.nav-item {
  position: relative;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: rgba(255,255,255,0.85);
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-inline-start: auto;
}

.icon-btn {
  background: none; border: none; color: #fff; opacity: 0.85;
  padding: 6px; border-radius: var(--radius-md); font-size: 16px;
}
.icon-btn:hover { opacity: 1; background: rgba(255,255,255,0.08); }

.lang-btn {
  background: none; border: 1px solid rgba(255,255,255,0.25); color: #fff;
  padding: 6px 12px; border-radius: 999px; font-size: 13px; display: flex; align-items: center; gap: 6px;
}
.lang-btn:hover { border-color: rgba(255,255,255,0.5); }

.account-chip {
  color: #fff; font-size: 13px; opacity: 0.85; padding: 6px 4px;
}

.sell-cta {
  border: 1px solid #fff; color: #fff; background: none;
  padding: 8px 16px; border-radius: 999px; font-size: 14px; font-weight: 600;
  white-space: nowrap;
}
.sell-cta:hover { background: #fff; color: var(--header-bg); }

/* ---------- Hero ---------- */
.hero {
  background: linear-gradient(180deg, var(--brand-tint), var(--page-plane));
  padding: 48px 0 40px;
}
.hero h1 { font-size: 34px; margin: 0 0 10px; letter-spacing: -0.5px; }
.hero p.sub { font-size: 16px; color: var(--text-secondary); margin: 0 0 28px; max-width: 560px; }

.quick-search {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 16px 18px 14px; max-width: 720px;
}
.search-row { display: flex; gap: 10px; flex-wrap: wrap; }
.search-field {
  flex: 1 1 200px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-1); font-size: 14px; color: var(--text-primary);
}
.search-cta {
  flex: 1 1 220px; border: none; border-radius: var(--radius-sm); background: var(--brand); color: #fff;
  font-weight: 600; font-size: 14px; padding: 12px 18px;
}
.search-cta:hover { background: var(--brand-dark); }

/* ---------- Sections ---------- */
.section { padding: 44px 0; }
.section h2 { font-size: 22px; margin: 0 0 18px; }

.placeholder-card {
  border: 1px dashed var(--border); border-radius: var(--radius-lg);
  padding: 28px; color: var(--text-muted); text-align: center; background: var(--surface-2);
}

/* ---------- Brand chips ---------- */
.brand-chips { display: flex; gap: 10px; flex-wrap: wrap; }
.brand-chip {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-primary);
  padding: 8px 16px; border-radius: 999px; font-size: 14px;
}
.brand-chip:hover { border-color: var(--brand); color: var(--brand); }

/* ---------- Listing grid ---------- */
.results-header { margin-bottom: 16px; }
.results-count { font-size: 13px; color: var(--text-muted); }

.listing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px;
}
.listing-grid .placeholder-card { grid-column: 1 / -1; }

.listing-card {
  display: block; border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface-2); overflow: hidden;
}
.listing-card:hover { border-color: var(--brand); }
.listing-card-photo {
  aspect-ratio: 4 / 3; background: var(--page-plane);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.listing-card-photo img { width: 100%; height: 100%; object-fit: cover; }
.no-photo, .no-photo-lg { color: var(--text-muted); font-size: 13px; }
.no-photo-lg {
  aspect-ratio: 16 / 9; background: var(--page-plane); border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
}
.listing-card-body { padding: 12px 14px; }
.listing-card-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.listing-card-price { font-size: 16px; font-weight: 700; color: var(--brand); margin-bottom: 4px; }
.listing-card-city { font-size: 13px; color: var(--text-muted); }

/* ---------- Listing detail page ---------- */
.back-link { display: inline-block; font-size: 14px; color: var(--text-secondary); margin-bottom: 18px; }
.back-link:hover { color: var(--brand); }

.listing-detail { display: grid; grid-template-columns: 1.2fr 1fr; gap: 32px; }
.listing-gallery img {
  display: block; width: 100%; max-height: 560px; border-radius: var(--radius-md);
  object-fit: contain; background: var(--page-plane);
}
.thumb-row { display: flex; gap: 8px; margin-top: 8px; overflow-x: auto; }
.thumb { width: 84px; height: 60px; object-fit: cover; border-radius: var(--radius-sm); flex-shrink: 0; }

.listing-info h1 { font-size: 24px; margin: 0 0 8px; }
.listing-price { font-size: 22px; font-weight: 700; color: var(--brand); margin-bottom: 4px; }
.listing-meta { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }
.listing-info h2 { font-size: 17px; margin: 22px 0 12px; }

.spec-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; }
.spec-row { display: flex; justify-content: space-between; border-bottom: 1px solid var(--border); padding-bottom: 8px; font-size: 14px; }
.spec-label { color: var(--text-muted); }
.spec-value { font-weight: 600; }

.listing-desc { font-size: 14px; line-height: 1.6; color: var(--text-secondary); white-space: pre-wrap; }

.seller-card {
  margin-top: 22px; border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 18px; background: var(--surface-2);
}
.seller-name { font-size: 15px; font-weight: 600; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.role-badge {
  font-size: 11px; font-weight: 500; color: var(--text-muted); border: 1px solid var(--border);
  border-radius: 999px; padding: 2px 8px;
}
.seller-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-call, .btn-whatsapp {
  flex: 1 1 140px; text-align: center; padding: 11px 16px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600;
}
.btn-call { background: var(--brand); color: #fff; }
.btn-call:hover { background: var(--brand-dark); }
.btn-whatsapp { background: var(--status-good); color: #fff; }
.btn-whatsapp:hover { opacity: 0.9; }

/* ---------- Generic forms (post a car, etc.) ---------- */
.form-card {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 26px; max-width: 640px;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.form-field input, .form-field select, .form-field textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-1); color: var(--text-primary); font-size: 14px; font-family: inherit;
}
.form-field textarea { resize: vertical; min-height: 90px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.form-submit {
  margin-top: 20px; width: 100%; border: none; border-radius: var(--radius-sm); background: var(--brand);
  color: #fff; font-weight: 600; font-size: 14px; padding: 13px;
}
.form-submit:hover { background: var(--brand-dark); }
.form-submit:disabled { opacity: 0.6; cursor: not-allowed; }
.form-msg { font-size: 13px; margin-top: 12px; padding: 10px; border-radius: var(--radius-sm); display: none; }
.form-msg.error { display: block; background: var(--brand-tint); color: var(--brand-dark); }

.payment-box {
  margin-top: 24px; padding: 20px; border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--page-plane);
}
.payment-qr { width: 160px; height: 160px; margin: 12px 0 16px; border-radius: var(--radius-sm); }

.existing-photos { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.existing-photo { position: relative; width: 84px; height: 84px; }
.existing-photo img { width: 100%; height: 100%; object-fit: cover; border-radius: var(--radius-sm); }
.existing-photo-remove {
  position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%;
  border: none; background: var(--status-critical); color: #fff; font-size: 14px; line-height: 1;
  display: flex; align-items: center; justify-content: center; padding: 0;
}
html[dir="rtl"] .existing-photo-remove { right: auto; left: -6px; }

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
}

/* ---------- Dealer dashboard ---------- */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 32px; }
.stat-tile { border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-2); padding: 16px 18px; }
.stat-value { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.stat-label { font-size: 13px; color: var(--text-muted); }

.chart-bars { display: flex; align-items: flex-end; gap: 12px; height: 140px; margin: 0 0 32px; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.chart-bar { flex: 1; width: 100%; max-width: 36px; display: flex; align-items: flex-end; background: var(--page-plane); border-radius: var(--radius-sm); overflow: hidden; }
.chart-bar-fill { width: 100%; background: var(--brand); border-radius: var(--radius-sm) var(--radius-sm) 0 0; min-height: 2px; }
.chart-count { font-size: 12px; font-weight: 600; margin-top: 6px; }
.chart-label { font-size: 11px; color: var(--text-muted); }

.listings-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-md); }
.listings-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.listings-table th, .listings-table td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.listings-table th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); background: var(--surface-2); }
.listings-table tbody tr:last-child td { border-bottom: none; }
html[dir="rtl"] .listings-table th, html[dir="rtl"] .listings-table td { text-align: right; }

.status-badge { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.status-active { background: rgba(12,163,12,0.12); color: var(--status-good); }
.status-pending { background: rgba(250,178,25,0.15); color: var(--status-warning); }
.status-rejected { background: rgba(208,59,59,0.12); color: var(--status-critical); }
.status-sold { background: var(--page-plane); color: var(--text-muted); }

.row-actions { display: flex; gap: 6px; }
.row-action { border: 1px solid var(--border); background: none; color: var(--text-secondary); padding: 5px 10px; border-radius: var(--radius-sm); font-size: 12px; }
.row-action:hover { border-color: var(--brand); color: var(--brand); }
.row-action-danger:hover { border-color: var(--status-critical); color: var(--status-critical); }

/* ---------- Footer ---------- */
footer.site-footer {
  margin-top: auto;
  background: var(--surface-1);
  border-top: 1px solid var(--border);
  padding: 40px 0 24px;
  color: var(--text-secondary);
  font-size: 14px;
}
footer.site-footer img { height: 22px; margin-bottom: 10px; }
footer .logo-dark { display: none; }
@media (prefers-color-scheme: dark) {
  footer .logo-light { display: none; }
  footer .logo-dark { display: block; }
}
.footer-blurb { max-width: 320px; color: var(--text-muted); font-size: 13px; }
.footer-cols { display: flex; gap: 48px; flex-wrap: wrap; margin: 24px 0; }
.footer-col h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin: 0 0 10px; }
.footer-col a { display: block; padding: 4px 0; font-size: 14px; }
.footer-col a:hover { color: var(--brand); }
.footer-bottom { border-top: 1px solid var(--border); padding-top: 18px; font-size: 12px; color: var(--text-muted); }

/* ---------- Demo/build banner ---------- */
.build-banner {
  background: var(--brand-tint); color: var(--brand-dark);
  text-align: center; font-size: 13px; padding: 8px 16px;
}

/* ---------- RTL ---------- */
html[dir="rtl"] .topbar-actions { margin-inline-start: auto; }
html[dir="rtl"] .lang-btn, html[dir="rtl"] .icon-btn { direction: ltr; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text-primary); color: var(--surface-1); padding: 12px 18px; border-radius: var(--radius-sm);
  font-size: 14px; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s;
  z-index: 100; max-width: 90vw; text-align: center;
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  .hero h1 { font-size: 26px; }
  .topbar-nav { order: 3; width: 100%; }
  .search-row { flex-direction: column; }
  .search-row .search-field,
  .search-row .search-cta { flex: 1 1 auto; width: 100%; }
  .listing-detail { grid-template-columns: 1fr; }
  .spec-grid { grid-template-columns: 1fr; }
}
