/* HKW Cars Admin */

:root {
  --navy:        #0b1f33;
  --navy-hover:  #1a3a5c;
  --bg:          #f4f6f9;
  --card:        #ffffff;
  --text:        #1a1d21;
  --muted:       #6b7280;
  --border:      #e3e6eb;
  --green:       #15803d;
  --green-bg:    #ecfdf3;
  --amber:       #a16207;
  --amber-bg:    #fef9e7;
  --red:         #b91c1c;
  --red-bg:      #fef2f2;
  --radius:      10px;
  --sidebar-w:   240px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.5 var(--font);
  color: var(--text);
  background: var(--bg);
}

a { color: var(--navy); }
img { max-width: 100%; display: block; }
svg { width: 20px; height: 20px; fill: currentColor; flex-shrink: 0; }

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

/* ── Layout ── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  transition: transform .2s ease;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 20px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar__logo {
  font-weight: 800;
  letter-spacing: .04em;
  background: #fff;
  color: var(--navy);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 14px;
}
.sidebar__title { font-weight: 600; }

.sidebar__nav { padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; }
.sidebar__bottom { margin-top: auto; padding: 14px 10px; border-top: 1px solid rgba(255,255,255,.1); }

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: rgba(255,255,255,.78);
  text-decoration: none;
  font-weight: 500;
}
.sidebar__link:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar__link.is-active { background: rgba(255,255,255,.14); color: #fff; }

.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 28px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar__title { margin: 0; font-size: 20px; }
.topbar__menu {
  display: none;
  background: none;
  border: 0;
  padding: 6px;
  margin-left: -6px;
  color: var(--text);
  cursor: pointer;
}
.topbar__menu svg { width: 24px; height: 24px; }

.content { padding: 28px; max-width: 1280px; }

.sidebar-backdrop { display: none; }

/* ── Mobile ── */
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.is-open { transform: none; }
  .sidebar-backdrop.is-open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 20;
  }
  .main { margin-left: 0; }
  .topbar { padding: 14px 16px; }
  .topbar__menu { display: inline-flex; }
  .content { padding: 18px 16px; }
}

/* ── Cards ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
}
.card__title { margin: 0 0 8px; font-size: 17px; }

/* ── Stats ── */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat__label { color: var(--muted); font-size: 13px; font-weight: 500; }
.stat__value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ── Alerts ── */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 18px;
  border: 1px solid transparent;
  font-weight: 500;
}
.alert--success { background: var(--green-bg); color: var(--green); border-color: #bbf7d0; }
.alert--warning { background: var(--amber-bg); color: var(--amber); border-color: #fde68a; }
.alert--error   { background: var(--red-bg);   color: var(--red);   border-color: #fecaca; }

/* ── Sidebar user ── */
.sidebar__user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px 4px;
  margin-top: 8px;
  border-top: 1px solid rgba(255,255,255,.1);
}
.sidebar__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,.16);
  display: grid;
  place-items: center;
  font-weight: 700;
  flex-shrink: 0;
}
.sidebar__user-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.sidebar__user form { margin: 0; }
.sidebar__logout {
  background: none;
  border: 0;
  color: rgba(255,255,255,.7);
  padding: 6px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
}
.sidebar__logout:hover { color: #fff; background: rgba(255,255,255,.1); }

/* ── Form fields ── */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field__label { font-size: 13px; font-weight: 600; }
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: 15px/1.4 var(--font);
  background: #fff;
  color: var(--text);
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid rgba(11,31,51,.25);
  border-color: var(--navy);
}

/* ── Login page ── */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: var(--navy);
}
.login { width: 100%; max-width: 380px; }
.login__brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #fff;
  font-weight: 600;
  font-size: 17px;
  margin-bottom: 20px;
}
.login__card {
  background: var(--card);
  border-radius: 14px;
  padding: 28px 24px;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.login__title { margin: 0 0 18px; font-size: 22px; }
.login__submit { width: 100%; justify-content: center; padding: 12px; margin-top: 4px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ── Car list ── */
.card--flush { padding: 0; overflow: hidden; }

.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.list-head .btn { margin-bottom: 12px; }

.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs__item {
  padding: 10px 12px 12px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs__item:hover { color: var(--text); }
.tabs__item.is-active { color: var(--navy); border-bottom-color: var(--navy); }
.tabs__count {
  display: inline-block;
  min-width: 22px;
  padding: 0 6px;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--bg);
  font-size: 12px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.list-tools {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 14px 18px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
}
.list-tools input,
.list-tools select {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: 14px/1.3 var(--font);
  background: #fff;
}
.list-tools__search { flex: 1; min-width: 200px; }
.list-tools .btn { padding: 9px 16px; }
.list-tools__clear { font-size: 14px; }

.table-wrap { overflow-x: auto; }
.cars-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.cars-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  padding: 10px 14px;
  background: #fafbfc;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.cars-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.cars-table tbody tr:hover { background: #fafbfc; }
.cars-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.col-photo { width: 104px; }
.col-actions { white-space: nowrap; text-align: right; }

.thumb {
  display: block;
  width: 88px;
  aspect-ratio: 4 / 3;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb__none {
  display: grid;
  place-items: center;
  height: 100%;
  font-size: 11px;
  color: var(--muted);
}

.car-name { font-weight: 600; color: var(--text); text-decoration: none; }
.car-name:hover { text-decoration: underline; }
.car-meta { color: var(--muted); font-size: 13px; margin-top: 2px; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge--available { background: var(--green-bg); color: var(--green); }
.badge--reserved  { background: var(--amber-bg); color: var(--amber); }
.badge--draft     { background: #eef0f3; color: #4b5563; }
.badge--sold      { background: #e8edf3; color: var(--navy); }

.pill { font-size: 12px; font-weight: 600; margin-left: 6px; white-space: nowrap; }
.pill--featured { color: var(--amber); }

.photo-count { font-weight: 600; font-variant-numeric: tabular-nums; }
.photo-count.is-short { color: var(--red); }

.link-btn {
  display: inline-block;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  color: var(--navy);
}
.link-btn:hover { background: rgba(11,31,51,.07); }

.list-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  font-size: 14px;
  flex-wrap: wrap;
}
.pager { display: flex; gap: 4px; flex-wrap: wrap; }
.pager a {
  min-width: 34px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  text-align: center;
  text-decoration: none;
  color: var(--text);
}
.pager a.is-active { background: var(--navy); border-color: var(--navy); color: #fff; }

.empty { padding: 48px 18px; text-align: center; color: var(--muted); }

/* Car list on phones: each row becomes a card */
@media (max-width: 760px) {
  .cars-table thead { display: none; }
  .cars-table, .cars-table tbody, .cars-table tr, .cars-table td { display: block; width: 100%; }
  .cars-table tr {
    display: grid;
    grid-template-columns: 96px 1fr;
    column-gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
  }
  .cars-table td { padding: 2px 0; border: 0; text-align: left; }
  .cars-table td.col-photo { grid-row: span 6; width: auto; }
  .cars-table td[data-label] { display: flex; justify-content: space-between; gap: 8px; }
  .cars-table td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 13px; }
  .cars-table .num { text-align: left; }
  .cars-table .col-actions { text-align: left; margin-left: -10px; padding-top: 6px; }
  .thumb { width: 96px; }
}

/* ── Add / edit car ── */
.back-link { margin: -6px 0 16px; font-size: 14px; }
.back-link a { text-decoration: none; font-weight: 600; }

.edit-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 20px;
  align-items: start;
}
.edit-side { position: sticky; top: 90px; }
@media (max-width: 1060px) {
  .edit-layout { grid-template-columns: 1fr; }
  .edit-side { position: static; order: -1; }
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0 16px;
  margin-top: 14px;
}
.field--wide { grid-column: 1 / -1; }
.field textarea { resize: vertical; min-height: 90px; }
.field__hint { font-size: 12px; color: var(--muted); }
.field__error { font-size: 13px; color: var(--red); font-weight: 500; }
.field.has-error input,
.field.has-error select,
.field.has-error textarea { border-color: var(--red); background: var(--red-bg); }
.req { color: var(--red); }

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 18px;
  font-weight: 500;
  cursor: pointer;
}
.check input { width: 18px; height: 18px; accent-color: var(--navy); }

.btn--block { width: 100%; justify-content: center; }
.side-link { display: block; text-align: center; margin-top: 12px; font-weight: 600; font-size: 14px; }
.side-meta { margin: 14px 0 0; font-size: 13px; color: var(--muted); }
.side-cover { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; margin: 10px 0 8px; }
.text-red { color: var(--red); }

/* ── Photo manager ── */
.photo-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.photo-head .card__title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.photo-count-line { margin: 0; }
.photo-ready {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid #bbf7d0;
  padding: 10px 14px;
  border-radius: 8px;
  font-weight: 600;
}
.photo-ready a { color: var(--green); }

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 34px 20px;
  border: 2px dashed #c5ccd6;
  border-radius: var(--radius);
  background: var(--card);
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--navy); background: #f0f4f9; }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone:focus-within { outline: 2px solid rgba(11,31,51,.3); }
.dropzone svg { width: 36px; height: 36px; color: var(--navy); }
.dropzone span { font-size: 13px; }

.photo-tip { font-size: 14px; margin: 16px 0 12px; }

.photo-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
}
.photo {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: grab;
}
.photo img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--bg); }
.photo.is-dragging { opacity: .4; }
.photo.is-busy { opacity: .5; pointer-events: none; }
.photo.is-cover { border-color: var(--navy); box-shadow: 0 0 0 2px var(--navy); }

.photo__cover {
  display: none;
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--navy);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
}
.photo.is-cover .photo__cover { display: block; }
.photo.is-cover [data-action="cover"] { visibility: hidden; }

.photo__actions { display: flex; justify-content: space-between; gap: 4px; padding: 6px; }
.photo__btn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  padding: 5px 9px;
  font: 600 13px/1 var(--font);
  color: var(--navy);
  cursor: pointer;
}
.photo__btn:hover { background: #f0f4f9; }
.photo__btn--delete { color: var(--red); }
.photo__btn--delete:hover { background: var(--red-bg); }

.photo--uploading, .photo--error {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  min-height: 180px;
  cursor: default;
}
.photo--error { background: var(--red-bg); border-color: #fecaca; }
.photo__msg { margin: 0; font-size: 13px; word-break: break-word; }
.photo--error .photo__msg { color: var(--red); font-weight: 500; }
.photo__progress { height: 6px; border-radius: 999px; background: var(--bg); overflow: hidden; }
.photo__progress span { display: block; height: 100%; width: 0; background: var(--navy); transition: width .2s; }

/* ── Row actions menu ── */
.row-menu { display: inline-block; }
.row-menu summary { list-style: none; cursor: pointer; font-size: 16px; line-height: 1; }
.row-menu summary::-webkit-details-marker { display: none; }
.row-menu[open] summary { background: rgba(11,31,51,.1); }
.row-menu__list {
  position: fixed;
  z-index: 40;
  min-width: 200px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0,0,0,.14);
  padding: 6px;
  display: flex;
  flex-direction: column;
  text-align: left;
}
.row-menu__list button,
.row-menu__list a {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-radius: 6px;
  padding: 8px 10px;
  font: 500 14px/1.3 var(--font);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}
.row-menu__list button:hover,
.row-menu__list a:hover { background: var(--bg); }
.row-menu__list button:disabled { color: #a0a6ae; cursor: not-allowed; background: none; }
.row-menu__list hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
.row-menu__danger { color: var(--red) !important; }

/* ── Delete ── */
.side-delete {
  display: block;
  text-align: center;
  color: var(--red);
  font-size: 14px;
  font-weight: 600;
  padding: 8px;
}
.delete-card { display: flex; gap: 22px; align-items: flex-start; max-width: 760px; }
.delete-card__img { width: 220px; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.delete-card__actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.delete-card__actions form { margin: 0; }
@media (max-width: 640px) {
  .delete-card { flex-direction: column; }
  .delete-card__img { width: 100%; }
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid var(--navy);
  background: var(--navy);
  color: #fff;
  font: 600 14px/1.2 var(--font);
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--navy-hover); border-color: var(--navy-hover); }
.btn--ghost { background: transparent; color: var(--navy); }
.btn--ghost:hover { background: rgba(11,31,51,.06); color: var(--navy); }
.btn--danger { background: var(--red); border-color: var(--red); }
.btn--danger:hover { background: #991b1b; border-color: #991b1b; }
