/* DTS Cars — one stylesheet for the public page and the admin page. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --text: #16191f;
  --muted: #5d6573;
  --border: #dde1e7;
  --accent: #c8102e;
  --accent-text: #ffffff;
  --accent-soft: #fde8eb;
  --gold: #8a5700;
  --gold-soft: #fff3d6;
  --ok: #146c34;
  --ok-soft: #e3f5e9;
  --warn: #9a5b00;
  --warn-soft: #fff1d6;
  --danger: #b42318;
  --toast-error-bg: #b42318; /* same dark red in both themes: white text stays readable */
  --radius: 12px;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 8%);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #181b21;
    --surface-2: #20242c;
    --text: #e8eaee;
    --muted: #9aa3b2;
    --border: #2c313b;
    --accent: #ff4d5e;
    --accent-text: #16070a;
    --accent-soft: #3a1419;
    --gold: #f2b64a;
    --gold-soft: #33270f;
    --ok: #4cc77a;
    --ok-soft: #12301d;
    --warn: #f2b64a;
    --warn-soft: #33270f;
    --danger: #ff6b5e;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: inherit; }
img { max-width: 100%; display: block; }
code { font-size: 0.9em; background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 4px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5rem; }
[hidden] { display: none !important; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 720px; }
.section { padding: 48px 16px; }
.wrap.section { padding-left: 16px; padding-right: 16px; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.error { color: var(--danger); }

/* Header / footer */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 60px; flex-wrap: wrap; }
.brand { font-weight: 800; font-size: 1.25rem; text-decoration: none; letter-spacing: -0.02em; }
.brand span { color: var(--accent); }
.brand small { font-weight: 500; font-size: 0.8rem; color: var(--muted); margin-left: 4px; }
.site-header nav { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.site-header nav a { text-decoration: none; color: var(--muted); font-weight: 500; }
.site-header nav a:hover { color: var(--text); }

.site-footer { border-top: 1px solid var(--border); padding: 24px 0; color: var(--muted); font-size: 0.9rem; }
.site-footer .wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

/* Hero */
.hero { padding: 56px 0 24px; }
.hero h1 { font-size: clamp(2rem, 5vw, 3rem); letter-spacing: -0.03em; max-width: 16ch; }
.hero p { color: var(--muted); max-width: 60ch; font-size: 1.1rem; margin: 0; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.band { background: var(--surface-2); padding-left: 0; padding-right: 0; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; padding: 10px 18px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.small { padding: 6px 12px; font-size: 0.875rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Pills */
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; white-space: nowrap; }
.pill.warn, .pill.status-pending { background: var(--warn-soft); color: var(--warn); }
.pill.loyal { background: var(--gold-soft); color: var(--gold); }
.pill.status-approved { background: var(--ok-soft); color: var(--ok); }
.pill.status-rejected { background: var(--surface-2); color: var(--muted); }

/* Filters + forms */
.filters { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 12px; margin-bottom: 24px; }
label { display: grid; gap: 4px; font-size: 0.9rem; font-weight: 500; }
label > span { color: var(--muted); }
input, select, textarea {
  font: inherit; width: 100%; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
textarea { resize: vertical; }
.form { padding: 24px; display: grid; gap: 16px; }
.form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form .row.three { grid-template-columns: repeat(3, 1fr); }
.form .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.form-result { margin: 0; min-height: 1.5em; }
.form-result.ok { color: var(--ok); }
.form-result.error { color: var(--danger); }
.stars { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px 16px; }
.stars legend { font-size: 0.9rem; font-weight: 500; color: var(--muted); margin-bottom: 4px; padding: 0; }
.stars label { display: flex; align-items: center; gap: 6px; font-weight: 500; }
.stars input, .toggle input { width: auto; }
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.toggle span { color: var(--text); }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* Car grid */
.car-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.car-card { overflow: hidden; display: flex; flex-direction: column; }
.car-open { padding: 0; border: 0; background: none; cursor: pointer; display: block; width: 100%; }
.car-img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; background: var(--surface-2); }
.car-img.empty { display: grid; place-items: center; }
.car-placeholder { width: 45%; fill: var(--border); }
.car-body { padding: 16px; display: grid; gap: 8px; flex: 1; align-content: start; }
.car-body .btn { justify-self: start; margin-top: 4px; }
.car-title-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.car-title-row h3 { margin: 0; font-size: 1.1rem; }
.price { font-size: 1.25rem; font-weight: 800; margin: 0; letter-spacing: -0.01em; }
.specs { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.specs li { font-size: 0.8rem; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--muted); }
.empty-state { padding: 32px 0; }

/* Car dialog */
.car-dialog {
  width: min(640px, calc(100% - 32px)); padding: 0; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); color: var(--text);
}
.car-dialog::backdrop { background: rgb(0 0 0 / 55%); }
.car-dialog .close {
  position: absolute; top: 8px; right: 8px; z-index: 1; width: 36px; height: 36px; border-radius: 50%;
  border: 0; background: rgb(0 0 0 / 55%); color: #fff; font-size: 1.4rem; cursor: pointer; line-height: 1;
}
.detail-body { padding: 20px 24px 24px; display: grid; gap: 12px; }
.detail-body h2 { margin: 0; }
.detail-body .btn { justify-self: start; }
.detail-list { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; }
.description { margin: 0; white-space: pre-line; }

/* Posts */
.post-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.post-card { padding: 18px; display: grid; gap: 8px; align-content: start; }
.post-card.loyal { border-color: color-mix(in srgb, var(--gold) 45%, var(--border)); }
.post-card header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.post-card .message { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
.post-card footer { font-size: 0.85rem; }
.rating { color: var(--gold); letter-spacing: 2px; }

/* Contact buttons */
.contact-buttons { display: flex; flex-wrap: wrap; gap: 10px; }
.hero-contact { margin-top: 20px; }
a.btn { text-decoration: none; }

/* Loyal customers */
.loyal-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.loyal-card { padding: 18px; display: grid; grid-template-columns: 88px 1fr; gap: 16px; align-items: start; }
.loyal-card.is-hidden { opacity: 0.6; }
.loyal-body { display: grid; gap: 6px; min-width: 0; }
.loyal-body header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.loyal-body h3 { margin: 0; font-size: 1.05rem; }
.loyal-body .message { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
.loyal-meta { margin: 0; }
.person-photo { width: 88px; height: 88px; border-radius: 50%; object-fit: cover; background: var(--surface-2); }
.person-photo.empty {
  display: grid; place-items: center; font-weight: 800; font-size: 1.5rem;
  color: var(--gold); background: var(--gold-soft);
}

/* Photo picker (admin) */
.field-label { font-size: 0.9rem; font-weight: 500; color: var(--muted); display: block; margin-bottom: 4px; }
.photo-row { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.photo-preview { width: 160px; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); }
.photo-preview.round { width: 96px; height: 96px; aspect-ratio: auto; border-radius: 50%; }
.photo-controls { display: grid; gap: 8px; flex: 1; min-width: 220px; justify-items: start; }
.photo-controls input[type="file"] { padding: 8px; }
.photo-controls details { width: 100%; }
.photo-controls summary { cursor: pointer; color: var(--muted); font-size: 0.875rem; margin-bottom: 6px; }
.thumb { width: 64px; height: 40px; object-fit: cover; border-radius: 6px; background: var(--surface-2); display: block; }
.thumb.round { width: 40px; border-radius: 50%; }
.notice { padding: 10px 14px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); margin: 0 0 20px; }

/* Car photo viewer (public details) */
.gallery { display: grid; gap: 8px; background: var(--surface-2); }
.gallery-stage { position: relative; }
.gallery-main { display: block; }
.gallery-nav {
  position: absolute; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border-radius: 50%;
  border: 0; background: rgb(0 0 0 / 55%); color: #fff; font-size: 1.6rem; line-height: 1; cursor: pointer;
}
.gallery-nav.prev { left: 8px; }
.gallery-nav.next { right: 8px; }
.gallery-counter {
  position: absolute; left: 8px; bottom: 8px; padding: 2px 8px; border-radius: 999px;
  background: rgb(0 0 0 / 55%); color: #fff; font-size: 0.8rem; font-weight: 600;
}
.gallery-strip { display: flex; gap: 6px; overflow-x: auto; padding: 0 8px 8px; }
.strip-thumb { padding: 0; border: 2px solid transparent; border-radius: 6px; background: none; cursor: pointer; flex: 0 0 auto; }
.strip-thumb[aria-current="true"] { border-color: var(--accent); }
.strip-thumb img { width: 64px; height: 40px; object-fit: cover; border-radius: 4px; display: block; }
.load-more { display: flex; justify-content: center; margin-top: 24px; }

/* Gallery editor (admin) */
.gallery-field { display: grid; gap: 8px; justify-items: start; }
.gallery-tiles { display: flex; flex-wrap: wrap; gap: 10px; }
.gallery-tiles:empty { display: none; }
.tile { position: relative; width: 132px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.tile-img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; display: block; }
.tile-img.busy { display: grid; place-items: center; font-size: 0.8rem; color: var(--muted); }
.tile-badge {
  position: absolute; top: 6px; left: 6px; padding: 1px 8px; border-radius: 999px; font-size: 0.7rem; font-weight: 700;
  background: var(--accent); color: var(--accent-text);
}
.tile-badge.low { top: auto; bottom: 40px; background: var(--warn-soft); color: var(--warn); }
.tile-actions { display: flex; justify-content: space-between; gap: 4px; padding: 4px; background: var(--surface); }
.icon-btn {
  flex: 1; min-width: 32px; height: 28px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text); cursor: pointer; font-size: 0.8rem;
}
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.icon-btn.danger { color: var(--danger); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.gallery-add { position: relative; }
.gallery-add:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.gallery-add.disabled { opacity: 0.5; pointer-events: none; }

/* Car list toolbar (admin) */
.list-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.list-toolbar input[type="search"] { flex: 1; min-width: 180px; width: auto; }
.list-toolbar select { width: auto; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg { font: inherit; font-weight: 600; padding: 8px 14px; border: 0; background: var(--surface); color: var(--muted); cursor: pointer; }
.seg + .seg { border-left: 1px solid var(--border); }
.seg[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 12px; }

/* Backups & storage (admin) */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-bottom: 16px; }
.panel { padding: 20px; display: grid; gap: 10px; align-content: start; }
.panel h2 { font-size: 1.1rem; margin: 0; }
.panel p { margin: 0; }
.meter { height: 12px; border-radius: 999px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--border); }
.meter div { height: 100%; background: var(--ok); border-radius: 999px; transition: width 0.3s; }
.meter div.warn { background: var(--warn); }
.meter div.danger { background: var(--danger); }
.restore-file { margin-top: 12px; }
.plain-list { margin: 0; padding-left: 20px; }
.notice.soft { background: var(--surface-2); color: var(--muted); }
.notice .btn { margin-left: 8px; }

/* Admin */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat { padding: 14px 16px; display: grid; gap: 2px; }
.stat span { font-size: 0.85rem; }
.stat strong { font-size: 1.6rem; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tab {
  font: inherit; font-weight: 600; padding: 10px 16px; border: 0; background: none; color: var(--muted);
  border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center;
}
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.car-form { margin-bottom: 24px; }
.toolbar { display: flex; gap: 12px; margin-bottom: 16px; }
.toolbar label { min-width: 180px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.data-table th, .data-table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); background: var(--surface-2); }
.data-table select { width: auto; padding: 6px 8px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.admin-posts .row-actions { margin-top: 4px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 8px; font-weight: 600;
  max-width: calc(100% - 32px); box-shadow: 0 6px 20px rgb(0 0 0 / 20%);
}
.toast:empty { opacity: 0; pointer-events: none; }
.toast.error { background: var(--toast-error-bg); color: #fff; }
.name-warning { margin: 0; padding: 6px 10px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); font-size: 0.875rem; font-weight: 600; }

/* Phones */
@media (max-width: 760px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .filters label:first-child { grid-column: 1 / -1; }
  .form .row, .form .row.three { grid-template-columns: 1fr; }
  .section { padding: 32px 16px; }
  .post-list, .loyal-list { grid-template-columns: 1fr; }
  .loyal-card { grid-template-columns: 64px 1fr; gap: 12px; }
  .person-photo { width: 64px; height: 64px; }
  .person-photo.empty { font-size: 1.15rem; }
}
