:root {
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-ink: #0f172a;
  --color-text: #1e293b;
  --color-muted: #64748b;
  --color-border: #e2e8f0;
  --color-surface: #ffffff;
  --color-bg: #f6f8fb;
  --color-success-bg: #dcfce7;
  --color-success-text: #15803d;
  --color-info-bg: #e0f2fe;
  --color-info-text: #0369a1;
  --color-neutral-bg: #f1f5f9;
  --color-neutral-text: #475569;
  --color-danger-bg: #fee2e2;
  --color-danger-text: #b91c1c;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);
}

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

html {
  scroll-behavior: smooth;
}

body {
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

h1, h2, h3 {
  color: var(--color-ink);
  letter-spacing: -0.02em;
}

/* --- Navbar --- */

.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 3rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--color-ink);
  text-decoration: none;
  display: inline-block;
}

.logo span {
  color: var(--color-primary);
}

.nav-links {
  display: flex;
  align-items: center;
}

.nav-links a {
  margin-left: 1.75rem;
  text-decoration: none;
  color: var(--color-muted);
  font-weight: 500;
  transition: color 0.15s ease;
}

.nav-links a:hover {
  color: var(--color-ink);
}

.nav-links .dealer-link {
  background: var(--color-primary);
  color: #ffffff;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-md);
  transition: background 0.15s ease;
}

.nav-links .dealer-link:hover {
  background: var(--color-primary-dark);
  color: #ffffff;
}

/* --- Hero --- */

.hero-section {
  text-align: center;
  padding: 5rem 1rem 3.5rem;
  background:
    radial-gradient(circle at 15% 20%, rgba(37, 99, 235, 0.10) 0%, transparent 45%),
    radial-gradient(circle at 85% 15%, rgba(37, 99, 235, 0.08) 0%, transparent 40%),
    linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
}

.hero-section h1 {
  font-size: 2.75rem;
  font-weight: 800;
  margin-bottom: 0.6rem;
}

.hero-section p {
  color: var(--color-muted);
  font-size: 1.05rem;
}

.trust-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.5rem 2.5rem;
  margin-top: 2rem;
  color: var(--color-muted);
  font-size: 0.9rem;
  font-weight: 500;
}

.trust-strip span {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.search-box {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  max-width: 800px;
  margin: 2.5rem auto 0;
  background: var(--color-surface);
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.field {
  display: flex;
  flex-direction: column;
  text-align: left;
  min-width: 160px;
}

.field label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-muted);
  margin-bottom: 0.3rem;
}

.field select, .field input, .field textarea {
  padding: 0.65rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field select:focus, .field input:focus, .field textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.btn-search {
  align-self: flex-end;
  padding: 0.7rem 1.8rem;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.btn-search:hover {
  background: var(--color-primary-dark);
}

.btn-search:active {
  transform: translateY(1px);
}

/* --- Layout --- */

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

.inventory-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 1rem;
}

.inventory-header h2 {
  font-size: 1.4rem;
}

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

/* --- Car cards --- */

.car-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
}

.car-card-clickable {
  cursor: pointer;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.car-card-clickable:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
}

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

.car-card-content {
  padding: 1.25rem;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

/* Pin the action button(s) to the bottom so every card in a row lines up,
   whatever the amount of content above them */
.car-card-content .btn-contact-dealer,
.car-card-content .dashboard-card-actions {
  margin-top: auto;
  width: 100%;
}

.car-card-content .details {
  margin-bottom: 1rem;
}

.car-card-content .features {
  margin-bottom: 1rem;
}

.car-card-content h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.15rem;
}

.deal-badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 999px;
  margin-bottom: 0.6rem;
  letter-spacing: 0.02em;
}

.deal-great { background: var(--color-success-bg); color: var(--color-success-text); }
.deal-good { background: var(--color-info-bg); color: var(--color-info-text); }
.deal-fair { background: var(--color-neutral-bg); color: var(--color-neutral-text); }
.deal-high { background: var(--color-danger-bg); color: var(--color-danger-text); }

.car-price {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--color-ink);
  margin: 0.3rem 0;
}

.details {
  color: var(--color-muted);
  font-size: 0.9rem;
}

.features {
  margin-top: 0.6rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.badge {
  display: inline-block;
  background: var(--color-neutral-bg);
  color: var(--color-neutral-text);
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.btn-contact {
  width: 100%;
  margin-top: 1rem;
  padding: 0.75rem;
  background: var(--color-ink);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
}

/* --- Dealer / admin dashboards --- */

.dashboard-box {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  padding: 1.5rem;
  max-width: 500px;
  margin: 0 auto 1.5rem;
}

.dashboard-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}

.dashboard-form .btn-search {
  align-self: stretch;
}

.status-message {
  color: #dc2626;
  font-size: 0.9rem;
  min-height: 1.2rem;
}

.btn-cancel {
  padding: 0.7rem 1.8rem;
  background: var(--color-neutral-bg);
  color: var(--color-neutral-text);
  border: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-cancel:hover {
  background: #e2e8f0;
}

.dashboard-card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.btn-edit, .btn-delete {
  flex: 1;
  padding: 0.5rem;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s ease;
}

.btn-edit:hover, .btn-delete:hover {
  filter: brightness(0.95);
}

.btn-edit {
  background: var(--color-info-bg);
  color: var(--color-info-text);
}

.btn-delete {
  background: var(--color-danger-bg);
  color: var(--color-danger-text);
}

/* --- Contact Dealer modal --- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1000;
}

.modal-box {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  max-width: 440px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow-lg);
}

.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--color-muted);
}

.btn-contact-dealer {
  width: 100%;
  margin-top: 1rem;
  padding: 0.7rem;
  background: var(--color-primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-contact-dealer:hover {
  background: var(--color-primary-dark);
}

/* --- Dealer inquiry inbox --- */

.inquiry-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.inquiry-card.unread {
  border-left: 4px solid var(--color-primary);
  background: #f8fafc;
}

.inquiry-card .inquiry-meta {
  font-size: 0.85rem;
  color: var(--color-muted);
  margin-bottom: 0.4rem;
}

.inquiry-card .inquiry-message {
  margin: 0.5rem 0;
}

.verify-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--color-neutral-bg);
  color: var(--color-neutral-text);
}

.verify-tag.ok {
  background: var(--color-success-bg);
  color: var(--color-success-text);
}

/* --- Vehicle photos --- */

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 0.5rem;
}

.photo-thumb {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  aspect-ratio: 1;
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-thumb .btn-remove-photo {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(15, 23, 42, 0.75);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
}

.car-card-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
  background: var(--color-neutral-bg);
  display: block;
}

.car-card-image-placeholder {
  width: 100%;
  height: 200px;
  background: var(--color-neutral-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 0.9rem;
}

/* --- Vehicle detail page --- */

.detail-layout {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 2rem;
  margin: 2rem 0;
  align-items: start;
}

@media (max-width: 800px) {
  .detail-layout {
    grid-template-columns: 1fr;
  }
}

.detail-main-photo {
  width: 100%;
  max-height: 420px;
  object-fit: cover;
  border-radius: var(--radius-lg);
  background: var(--color-neutral-bg);
}

.detail-thumb-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  overflow-x: auto;
}

.detail-thumb {
  width: 80px;
  height: 60px;
  object-fit: cover;
  border-radius: var(--radius-md);
  cursor: pointer;
  flex-shrink: 0;
  border: 2px solid transparent;
  transition: border-color 0.15s ease;
}

.detail-thumb:hover {
  border-color: var(--color-primary);
}

.spec-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 1.5rem;
  margin-top: 1rem;
}

.spec-row {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 0.3rem;
  font-size: 0.9rem;
}

.spec-label {
  color: var(--color-muted);
}

/* --- Footer --- */

.site-footer {
  margin-top: 3rem;
  background: #0a2158;
  color: #dbe4f5;
  font-size: 0.92rem;
}

.footer-main {
  display: grid;
  grid-template-columns: 320px 1fr;
}

.footer-brand {
  background: #071a45;
  padding: 2.5rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1rem;
}

.footer-brand-tile {
  background: #ffffff;
  border-radius: 16px;
  width: 132px;
  height: 132px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.footer-brand-tile img {
  width: 104px;
  height: 104px;
  display: block;
}

.site-footer .logo {
  color: #ffffff;
  font-size: 1.4rem;
}

.site-footer .logo span {
  color: #60a5fa;
}

.footer-tagline {
  color: #b7c6e4;
  line-height: 1.5;
}

.footer-cta {
  display: inline-block;
  background: var(--color-primary);
  color: #ffffff;
  text-decoration: none;
  font-weight: 600;
  padding: 0.7rem 1.2rem;
  border-radius: var(--radius-md);
  transition: background 0.15s ease;
}

.footer-cta:hover {
  background: var(--color-primary-dark);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem 4rem;
  padding: 2.5rem 3rem;
}

.footer-col h4 {
  color: #ffffff;
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  letter-spacing: 0;
}

.footer-col ul {
  list-style: none;
}

.footer-col li {
  margin-bottom: 0.75rem;
}

.footer-col a {
  color: #dbe4f5;
  text-decoration: none;
}

.footer-col a:hover {
  color: #ffffff;
  text-decoration: underline;
}

.footer-bottom {
  background: #030b1f;
  color: #9fb0d0;
  font-size: 0.82rem;
  padding: 1rem 2rem;
}

@media (max-width: 800px) {
  .footer-main {
    grid-template-columns: 1fr;
  }

  .footer-links {
    padding: 2rem 1.5rem;
    gap: 1.75rem 3rem;
  }
}

/* Bot trap: off-screen rather than display:none so simple bots still fill it in */
.hp-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.approval-banner {
  border-left: 4px solid #2563eb;
  background: #eff6ff;
  max-width: none;
}

.approval-banner.rejected {
  border-left-color: #b91c1c;
  background: #fef2f2;
}

/* --- Dealer agreement / consent --- */

.agreement-page {
  max-width: 820px;
}

.agreement-page h1 {
  font-size: 1.7rem;
  margin: 1.5rem 0 0.25rem;
}

.agreement-text {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  max-height: 420px;
  overflow-y: auto;
  margin: 1rem 0 1.5rem;
  line-height: 1.6;
}

.agreement-text h3 {
  font-size: 1rem;
  margin: 1rem 0 0.25rem;
}

.agreement-text h3:first-child {
  margin-top: 0;
}

.consent-check {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  font-size: 0.95rem;
  cursor: pointer;
}

.consent-check input {
  margin-top: 0.25rem;
  width: 1.1rem;
  height: 1.1rem;
  flex-shrink: 0;
}

.consent-signed {
  border-left: 4px solid var(--color-success-text);
  background: #f0fdf4;
}

.consent-banner {
  border-left: 4px solid #d97706;
  background: #fffbeb;
  max-width: none;
}

.evidence-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
}

.evidence-table th, .evidence-table td {
  text-align: left;
  vertical-align: top;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.evidence-table th {
  width: 30%;
  color: var(--color-muted);
  font-weight: 600;
}

.evidence-text {
  white-space: pre-wrap;
  background: #f8fafc;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1rem;
  font-size: 0.85rem;
  max-height: 360px;
  overflow-y: auto;
}

@media print {
  .navbar, .no-print, .chat-fab, .chat-panel { display: none !important; }
  .evidence-text { max-height: none; }
}

/* --- Chat assistant --- */

.chat-fab {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--color-primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  z-index: 900;
  transition: background 0.15s ease, transform 0.15s ease;
}

.chat-fab:hover {
  background: var(--color-primary-dark);
  transform: scale(1.05);
}

.chat-fab:focus-visible, .chat-chip:focus-visible, .chat-send:focus-visible, .chat-close:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.45);
  outline-offset: 2px;
}

.chat-panel {
  position: fixed;
  right: 1.25rem;
  bottom: 5.5rem;
  width: 370px;
  max-width: calc(100vw - 2rem);
  height: 540px;
  max-height: calc(100vh - 7rem);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 900;
}

.chat-panel[hidden] {
  display: none;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  background: #0a2158;
  color: #ffffff;
}

.chat-header strong {
  display: block;
  font-size: 1rem;
}

.chat-header span {
  display: block;
  font-size: 0.75rem;
  color: #b7c6e4;
  margin-top: 0.15rem;
}

.chat-close {
  background: none;
  border: none;
  color: #ffffff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: var(--color-bg);
}

.chat-msg {
  max-width: 88%;
  padding: 0.6rem 0.85rem;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.chat-msg.bot {
  align-self: flex-start;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
}

.chat-msg.user {
  align-self: flex-end;
  background: var(--color-primary);
  color: #ffffff;
}

.chat-msg a {
  color: var(--color-primary);
  font-weight: 600;
}

.chat-list {
  list-style: none;
  margin-top: 0.4rem;
}

.chat-list li {
  padding: 0.45rem 0;
  border-top: 1px solid var(--color-border);
  font-size: 0.85rem;
}

.chat-chips {
  display: flex;
  gap: 0.4rem;
  padding: 0.6rem 0.75rem;
  overflow-x: auto;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
}

.chat-chip {
  flex-shrink: 0;
  white-space: nowrap;
  background: var(--color-neutral-bg);
  color: var(--color-ink);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
}

.chat-chip:hover {
  background: var(--color-info-bg);
  border-color: var(--color-primary);
}

.chat-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
}

.chat-input {
  flex: 1;
  min-width: 0;
  padding: 0.6rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-family: inherit;
}

.chat-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.chat-send {
  background: var(--color-primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 0 1rem;
  font-weight: 600;
  cursor: pointer;
}

.chat-send:hover {
  background: var(--color-primary-dark);
}

@media (max-width: 640px) {
  .chat-panel {
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    height: 78vh;
    max-height: 78vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  .chat-fab {
    right: 1rem;
    bottom: 1rem;
  }
}

/* --- Responsive: narrow / mobile screens --- */

@media (max-width: 640px) {
  .navbar {
    flex-wrap: wrap;
    padding: 1rem 1.25rem;
    row-gap: 0.5rem;
  }

  .nav-links {
    width: 100%;
    flex-wrap: wrap;
    justify-content: center;
  }

  .nav-links a {
    margin-left: 0;
    margin-right: 1.25rem;
  }

  .nav-links a:last-child {
    margin-right: 0;
  }

  .hero-section {
    padding: 3rem 1rem 2.5rem;
  }

  .hero-section h1 {
    font-size: 2rem;
  }

  .search-box {
    padding: 1.25rem;
  }

  .field {
    min-width: 0;
    flex: 1 1 100%;
  }

  .btn-search {
    align-self: stretch;
  }

  .trust-strip {
    gap: 0.75rem 1.5rem;
    font-size: 0.82rem;
  }
}
