/* ==========================================================================
   Stock management page. Builds on the variables and components in style.css.
   ========================================================================== */

[hidden] { display: none !important; }

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

/* ---------- Page head ---------- */
.stock-head {
  display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; justify-content: space-between;
  padding: 32px 0 22px;
}
.stock-head h1 { font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 800; letter-spacing: -.025em; }
.stock-head p { margin-top: 6px; color: var(--muted); font-size: 15px; }
.stock-head-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Buttons (extra variants) ---------- */
.btn-primary { background: var(--green); color: #fff; box-shadow: 0 6px 16px -8px rgba(15, 138, 95, .8); }
.btn-primary:hover { background: var(--green-700); }
.btn-primary:disabled { opacity: .6; cursor: default; }
.btn-danger { color: #9f1239; }
.btn-danger:hover { background: #fff1f2; }

/* ---------- Summary tiles ---------- */
.summary { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 20px; }
@media (min-width: 820px) { .summary { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.summary .stat { background: #fff; box-shadow: var(--shadow); padding: 14px 16px; }
.summary .stat-value { font-size: 1.5rem; }

/* ---------- Toolbar: filters and search ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }
.seg {
  display: inline-flex; gap: 2px; padding: 4px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
}
.seg button {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  padding: 7px 12px; border-radius: 9px; font-size: 14px; font-weight: 700; color: var(--ink-2);
}
.seg button:hover { background: var(--mint); }
.seg button[aria-pressed="true"] { background: var(--mint); color: var(--green-900); box-shadow: inset 0 0 0 1px var(--mint-2); }
.toolbar select, .toolbar input[type="search"] {
  padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line-2); background: #fff; font-size: 14px;
}
.toolbar select:focus, .toolbar input[type="search"]:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(15, 138, 95, .15); }
.toolbar input[type="search"] { flex: 1 1 220px; min-width: 0; }

/* ---------- Vehicle cards ---------- */
.vehicle-list { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .vehicle-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.vehicle {
  display: flex; flex-direction: column; min-width: 0; overflow: hidden;
  background: #fff; border: 1px solid var(--line); border-top: 4px solid var(--line-2);
  border-radius: 20px; box-shadow: var(--shadow);
}
.vehicle.s-available { border-top-color: var(--green); }
.vehicle.s-booked { border-top-color: #d97706; }
.vehicle.s-sold { border-top-color: #64748b; }

/* Picture at the top: the first uploaded photo, or the drawing when there is none */
.vehicle-media {
  position: relative; display: flex; align-items: center; justify-content: center;
  aspect-ratio: 2 / 1; overflow: hidden;
  background: linear-gradient(135deg, var(--mint) 0%, var(--mint-2) 100%);
}
a.vehicle-media { display: block; }
.vehicle-media img { display: block; width: 100%; height: 100%; object-fit: cover; }
.vehicle-media svg { width: min(120px, 40%); height: auto; }
.media-top {
  position: absolute; top: 12px; left: 12px; right: 12px; z-index: 1;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.media-type {
  padding: 3px 10px; border-radius: 999px; background: rgba(255, 255, 255, .92);
  font-size: 12px; font-weight: 800; color: var(--ink-2);
}

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; letter-spacing: .02em; }
.badge-available { background: var(--mint); color: var(--green-700); }
.badge-booked { background: #fef3c7; color: #92400e; }
.badge-sold { background: #e2e8f0; color: #334155; }

.vehicle-body { display: flex; flex-direction: column; gap: 10px; flex: 1; padding: 14px 16px 16px; }
.vehicle-title { font-size: 18px; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; overflow-wrap: anywhere; }
.vehicle-meta { margin-top: -4px; font-size: 13px; font-weight: 600; color: var(--muted); overflow-wrap: anywhere; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; color: var(--ink-2); }

.vehicle-specs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; margin: 0; }
.vehicle-specs > div { min-width: 0; }
.vehicle-specs dt { font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.vehicle-specs dd { margin: 3px 0 0; overflow-wrap: anywhere; }

.vehicle-price {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 10px 14px; border-radius: 12px; background: var(--mint);
}
.vehicle-price span { font-size: 13px; font-weight: 800; color: var(--green-700); }
.vehicle-price strong { font-size: 20px; font-weight: 800; letter-spacing: -.01em; color: var(--green-900); font-variant-numeric: tabular-nums; }

.buyer {
  padding: 10px 14px; border: 1px dashed var(--line-2); border-radius: 12px;
  font-size: 14px; color: var(--ink-2); overflow-wrap: anywhere;
}
.buyer-label { margin-bottom: 4px; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.buyer-name { font-weight: 800; color: var(--ink); }
.buyer a { color: var(--green-700); font-weight: 700; text-decoration: none; }
.buyer a:hover { text-decoration: underline; }
.buyer-address { margin-top: 2px; white-space: pre-line; color: var(--muted); }

.vehicle-notes { font-size: 13px; color: var(--muted); white-space: pre-line; overflow-wrap: anywhere; }
.vehicle-actions { display: flex; gap: 10px; margin-top: auto; padding-top: 4px; }
.vehicle-actions .btn { flex: 1 1 0; justify-content: center; padding: 9px 12px; font-weight: 800; }

/* Compact cards: the picture sits beside the details on every normal screen, phones included */
@media (min-width: 320px) {
  .vehicle { flex-direction: row; }
  .vehicle-media { flex: 0 0 34%; aspect-ratio: auto; }
  .vehicle-media img { position: absolute; inset: 0; }
  .vehicle-media svg { width: min(96px, 60%); }
  .media-top { flex-direction: column; align-items: flex-start; top: 10px; left: 10px; right: auto; }
  .media-type { font-size: 11px; padding: 2px 8px; }
  .badge { font-size: 11px; padding: 2px 8px; }

  .vehicle-body { gap: 8px; padding: 12px 14px 14px; }
  .vehicle-title { font-size: 16px; }
  .vehicle-meta { margin-top: -4px; font-size: 12px; }
  .vehicle-specs { grid-template-columns: 1fr; gap: 6px; }
  .vehicle-specs dt { font-size: 10px; }
  .vehicle-specs dd { margin-top: 1px; font-size: 12px; }
  .vehicle-price { flex-direction: column; align-items: flex-start; gap: 2px; padding: 8px 10px; border-radius: 10px; }
  .vehicle-price span { font-size: 11px; }
  .vehicle-price strong { font-size: 17px; }
  .buyer { padding: 8px 10px; font-size: 13px; }
  .buyer-label { margin-bottom: 2px; font-size: 10px; }
  .vehicle-notes { font-size: 12px; }
  .vehicle-actions { gap: 8px; padding-top: 0; }
  .vehicle-actions .btn { padding: 7px 10px; font-size: 13px; }
}

.empty {
  padding: 30px; text-align: center; color: var(--muted);
  background: #fff; border: 1px dashed var(--line-2); border-radius: var(--radius);
}

/* ---------- Login / first-run password ---------- */
.gate { max-width: 420px; margin: 40px auto; }
.gate h2 { font-size: 20px; font-weight: 800; }
.gate > p { margin-top: 6px; font-size: 14px; color: var(--muted); }
.gate-form { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.gate-form .btn { align-self: flex-start; }

/* ---------- Form fields ---------- */
.fld { display: flex; flex-direction: column; gap: 6px; min-width: 0; font-size: 13px; font-weight: 700; color: var(--ink-2); }
.fld input, .fld select, .fld textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line-2); background: #fbfdfc;
  font-size: 15px; font-weight: 500; color: var(--ink);
}
.fld textarea { resize: vertical; font-family: inherit; }
.fld input:focus, .fld select:focus, .fld textarea:focus {
  outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(15, 138, 95, .15);
}

.form-grid { display: grid; gap: 12px 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) {
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-2 { grid-column: 1 / -1; }
}

.group { min-width: 0; margin: 0; padding: 14px 16px 16px; border: 1px solid var(--line); border-radius: 14px; }
.group legend { padding: 0 6px; font-size: 13px; font-weight: 800; color: var(--green-900); }
.group-hint { margin: 0 0 10px; font-size: 13px; color: var(--muted); }

.form-error { min-height: 1.3em; margin-top: 10px; font-size: 14px; font-weight: 600; color: #9f1239; }

/* ---------- Add / edit dialog ---------- */
.dialog {
  width: min(680px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow: auto;
  padding: 0; border: 0; border-radius: 18px;
  box-shadow: 0 30px 60px -20px rgba(6, 78, 59, .35);
}
.dialog::backdrop { background: rgba(13, 31, 24, .45); }
.dialog-form { padding: 22px 22px 18px; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.dialog-head h2 { font-size: 20px; font-weight: 800; letter-spacing: -.01em; }
.icon-btn {
  appearance: none; border: 0; cursor: pointer; width: 34px; height: 34px; border-radius: 50%;
  background: var(--mint); color: var(--green-900); font-size: 20px; line-height: 1;
}
.icon-btn:hover { background: var(--mint-2); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

/* ---------- Phone ---------- */
@media (max-width: 560px) {
  .stock-head { padding-top: 24px; }
  .dialog-form { padding: 18px 16px 16px; }
}
