/* ==========================================================================
   AutoHaus Motors — hand-written stylesheet (public site + admin panel)
   ========================================================================== */

:root {
  --color-bg: #f7f7f9;
  --color-surface: #ffffff;
  --color-text: #1b1e24;
  --color-text-muted: #6b7280;
  --color-border: #e5e7eb;
  --color-primary: #14213d;
  --color-primary-hover: #0d1730;
  --color-accent: #fca311;
  --color-accent-hover: #e2920b;
  --color-success: #1a7f4a;
  --color-success-bg: #e6f6ee;
  --color-warning: #a15c00;
  --color-warning-bg: #fff3dd;
  --color-danger: #b91c1c;
  --color-danger-bg: #fdeaea;
  --color-sold-bg: #eceef1;
  --color-sold-text: #4b5563;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.10);
  --max-width: 1200px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

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

img {
  max-width: 100%;
  display: block;
}

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

h1, h2, h3, h4 {
  margin: 0 0 0.5em;
  line-height: 1.25;
}

p {
  margin: 0 0 1em;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

/* --- Site header / nav --------------------------------------------- */

.site-header {
  background: var(--color-primary);
  color: #fff;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 18px;
  padding-bottom: 18px;
}

.site-header .logo {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
}

.site-header nav a {
  color: rgba(255, 255, 255, 0.85);
  font-weight: 500;
  margin-left: 24px;
  font-size: 0.95rem;
}

.site-header nav a:hover {
  color: #fff;
}

/* --- Footer ----------------------------------------------------------- */

.site-footer {
  margin-top: 60px;
  padding: 28px 0;
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.85rem;
  text-align: center;
}

/* --- Page heading ------------------------------------------------------- */

.page-heading {
  padding: 40px 0 8px;
}

.page-heading p {
  color: var(--color-text-muted);
}

.page-heading-tight {
  padding: 32px 0 8px;
}

/* --- Landing page: hero -------------------------------------------------- */

.hero {
  background-image: linear-gradient(rgba(20, 33, 61, 0.78), rgba(20, 33, 61, 0.88)),
    url('../img/hero.jpg');
  background-size: cover;
  background-position: center;
  color: #fff;
  padding: 100px 0;
}

.hero-inner {
  max-width: 620px;
}

.hero h1 {
  font-size: 2.4rem;
  margin-bottom: 16px;
}

.hero p {
  font-size: 1.05rem;
  color: rgba(255, 255, 255, 0.92);
  margin-bottom: 28px;
}

/* --- Landing page: intro + CTA ------------------------------------------- */

.intro-section {
  padding: 48px 0 8px;
  max-width: 760px;
}

.intro-section h2 {
  font-size: 1.5rem;
}

.intro-section p {
  color: var(--color-text-muted);
}

.cta-banner {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px;
  text-align: center;
  margin: 44px 0 60px;
}

.cta-banner h2 {
  font-size: 1.4rem;
}

.cta-banner p {
  color: var(--color-text-muted);
  margin-bottom: 20px;
}

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

.car-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
  padding: 24px 0 60px;
}

.car-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  display: flex;
  flex-direction: column;
}

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

.car-card.is-sold {
  opacity: 0.72;
}

.car-card-media {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #e9eaee;
}

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

.car-card-body {
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.car-card-title {
  font-size: 1.05rem;
  font-weight: 700;
}

.car-card-year {
  color: var(--color-text-muted);
  font-weight: 500;
}

.car-card-price {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-top: auto;
}

.car-card-specs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  color: var(--color-text-muted);
  font-size: 0.87rem;
}

/* --- Status badges --------------------------------------------------- */

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-available {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.badge-reserved {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.badge-sold {
  background: var(--color-sold-bg);
  color: var(--color-sold-text);
}

.card-badge {
  position: absolute;
  top: 10px;
  left: 10px;
}

/* --- Car detail page --------------------------------------------------- */

.car-detail {
  padding: 32px 0 60px;
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 40px;
}

.gallery-main {
  aspect-ratio: 4 / 3;
  background: #e9eaee;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 12px;
}

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

.gallery-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.gallery-thumbs img {
  width: 84px;
  height: 64px;
  object-fit: cover;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid transparent;
  opacity: 0.75;
}

.gallery-thumbs img:hover,
.gallery-thumbs img.is-active {
  opacity: 1;
  border-color: var(--color-accent);
}

.detail-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 28px;
}

.car-detail-info h1 {
  font-size: 1.7rem;
}

.car-detail-price {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--color-primary);
  margin: 6px 0 18px;
}

.spec-list {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 20px;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  padding: 16px 0;
}

.spec-list li {
  font-size: 0.92rem;
}

.spec-list .label {
  color: var(--color-text-muted);
  display: block;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.back-link {
  display: inline-block;
  margin-bottom: 20px;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.back-link:hover {
  color: var(--color-text);
}

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

/* --- Buttons ------------------------------------------------------------ */

.btn {
  display: inline-block;
  padding: 9px 18px;
  border-radius: 6px;
  font-size: 0.92rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  text-align: center;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}

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

.btn-accent {
  background: var(--color-accent);
  color: #1b1e24;
}

.btn-accent:hover {
  background: var(--color-accent-hover);
}

.btn-secondary {
  background: #fff;
  color: var(--color-text);
  border-color: var(--color-border);
}

.btn-secondary:hover {
  background: #f2f3f5;
}

.btn-danger {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border-color: #f3c8c8;
}

.btn-danger:hover {
  background: #f8d9d9;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 0.82rem;
}

.btn-block {
  display: block;
  width: 100%;
}

/* --- Forms ---------------------------------------------------------- */

.form-group {
  margin-bottom: 18px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

label {
  display: block;
  font-weight: 600;
  font-size: 0.88rem;
  margin-bottom: 6px;
}

input[type="text"],
input[type="number"],
input[type="password"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
  background: #fff;
  color: var(--color-text);
}

textarea {
  resize: vertical;
  min-height: 120px;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(20, 33, 61, 0.12);
}

.field-hint {
  color: var(--color-text-muted);
  font-size: 0.8rem;
  margin-top: 4px;
}

/* --- Flash messages ------------------------------------------------- */

.flash {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 0.92rem;
}

.flash-success {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.flash-error {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

/* --- Admin: login ----------------------------------------------------- */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary);
  padding: 20px;
}

.login-box {
  background: #fff;
  padding: 36px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 380px;
}

.login-box h1 {
  font-size: 1.3rem;
  margin-bottom: 4px;
}

.login-box .subtitle {
  color: var(--color-text-muted);
  font-size: 0.88rem;
  margin-bottom: 24px;
}

/* --- Admin: shell / bar ------------------------------------------------- */

.admin-bar {
  background: var(--color-primary);
  color: #fff;
}

.admin-bar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
}

.admin-bar a {
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.9rem;
  margin-left: 20px;
}

.admin-bar a:hover {
  color: #fff;
}

.admin-bar .logo {
  font-weight: 700;
}

.admin-main {
  padding: 32px 0 60px;
}

.admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}

/* --- Admin: cars table -------------------------------------------------- */

.admin-table-wrap {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}

table.admin-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.9rem;
  white-space: nowrap;
}

.admin-table th {
  color: var(--color-text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 700;
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-table .thumb {
  width: 56px;
  height: 42px;
  object-fit: cover;
  border-radius: 4px;
  background: #e9eaee;
}

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

.admin-table form {
  display: inline;
}

/* --- Admin: car form / image manager ----------------------------------- */

.admin-panel {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 30px;
  max-width: 820px;
}

.admin-panel h2 {
  font-size: 1.1rem;
  margin: 28px 0 14px;
  padding-top: 18px;
  border-top: 1px solid var(--color-border);
}

.admin-panel h2:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.image-manager-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.image-manager-item {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 8px;
  background: #fafafa;
}

.image-manager-item img {
  width: 100%;
  height: 90px;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 8px;
}

.image-manager-item .order-input {
  width: 100%;
  padding: 6px 8px;
  font-size: 0.85rem;
  margin-bottom: 6px;
}

.image-manager-item .btn {
  width: 100%;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}

.checkbox-label {
  font-weight: 400;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.checkbox-label input {
  width: auto;
}

.error-list {
  margin: 0;
  padding-left: 18px;
}

/* --- Responsive ------------------------------------------------------- */

@media (max-width: 860px) {
  .car-detail {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .hero {
    padding: 64px 0;
  }

  .hero h1 {
    font-size: 1.9rem;
  }
}

@media (max-width: 560px) {
  .site-header .container,
  .admin-bar .container {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .site-header nav a {
    margin-left: 0;
    margin-right: 16px;
  }

  .admin-bar a {
    margin-left: 0;
    margin-right: 16px;
  }

  .admin-toolbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
}
