/* Vehicle roster page */

.vehicles-page {
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
}

.vehicle-roster {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  align-items: stretch;
  gap: 20px;
}

.vehicle-card {
  display: flex;
  width: 100%;
  min-width: 0;
  min-height: 340px;
  flex-direction: column;
  overflow: hidden;

  color: var(--text);
  text-decoration: none;

  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);

  transition:
    transform 150ms ease,
    border-color 150ms ease,
    background 150ms ease,
    box-shadow 150ms ease;
}

.vehicle-card:hover {
  color: var(--text);
  background: var(--surface-light);
  border-color: #5f718b;
  box-shadow: 0 12px 28px rgb(0 0 0 / 25%);
  transform: translateY(-3px);
}

.vehicle-card:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

.vehicle-card-picture {
  display: block;
  height: 150px;
  flex-shrink: 0;
  overflow: hidden;
  background: #182233;
  border-bottom: 1px solid var(--border);
}

.vehicle-card-picture img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.vehicle-card-placeholder {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  color: var(--text-muted);
  font-size: 3.25rem;
}

.vehicle-card-body {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  padding: 18px;
}

.vehicle-card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.vehicle-card-heading h3 {
  min-width: 0;
  margin: 0;
  color: var(--text);
  font-size: 1.05rem;
  overflow-wrap: anywhere;
}

.vehicle-type-badge {
  flex-shrink: 0;
  padding: 3px 8px;
  color: #bfdbfe;
  font-size: 0.72rem;
  line-height: 1.4;
  white-space: nowrap;
  background: #1e3a5f;
  border: 1px solid #31547d;
  border-radius: 999px;
}

.vehicle-card-details {
  display: grid;
  gap: 8px;
  margin: 18px 0 0;
}

.vehicle-card-details div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.vehicle-card-details dt {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.vehicle-card-details dd {
  min-width: 0;
  margin: 0;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  text-align: right;
  overflow-wrap: anywhere;
}

.vehicle-card-description {
  display: -webkit-box;
  margin: 16px 0 0;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 0.88rem;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.vehicle-card-link {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 18px;
  color: #93c5fd;
  font-size: 0.9rem;
  font-weight: 600;
}

/*
  The global form rule uses flex-row and align-items:flex-end.
  Reset it here so this form behaves exactly like a card.
*/
form.vehicle-card-new {
  display: flex;
  min-height: 340px;
  align-items: stretch;
  padding: 0;
  gap: 0;
  background: transparent;
  border: 2px dashed #4b5563;
}

form.vehicle-card-new:hover {
  background: rgba(59, 130, 246, 0.06);
  border-color: var(--primary);
}

.vehicle-card-new-button {
  display: flex;
  width: 100%;
  min-height: 336px;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;

  color: var(--text);
  text-align: center;

  background: transparent;
  border: 0;
  border-radius: 0;
}

.vehicle-card-new-button:hover {
  background: transparent;
}

.vehicle-card-new-button strong {
  font-size: 1.1rem;
}

.vehicle-card-new-button > span:last-child {
  max-width: 220px;
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.vehicle-card-new-icon {
  display: grid;
  width: 62px;
  height: 62px;
  margin-bottom: 16px;
  place-items: center;

  color: #bfdbfe;
  font-size: 2rem;
  font-weight: 400;

  background: #1e3a5f;
  border: 1px solid #31547d;
  border-radius: 50%;
}

/* Dedicated vehicle edit page */

.vehicle-page {
  max-width: 1500px;
  margin: 0 auto;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
}

.vehicle-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.vehicle-page-header form {
  flex-shrink: 0;
}

.back-link {
  display: inline-block;
  margin-bottom: 12px;
  color: var(--text-muted);
  text-decoration: none;
}

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

.vehicle-edit-form {
  display: grid;
  gap: 24px;
}

.vehicle-edit-form .card {
  margin: 0;
  padding: 24px;
}

.vehicle-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.82fr);
  gap: 24px;
  align-items: stretch;
}

.vehicle-routing-row {
  grid-template-columns: minmax(340px, 0.72fr) minmax(520px, 1.28fr);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.card-header h3 {
  margin: 0 0 4px;
}

.card-header p {
  margin: 0;
  color: var(--text-muted);
}

.record-id {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.vehicle-enabled-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
  padding: 12px 14px;
  background: #182233;
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
}

.vehicle-enabled-setting > div {
  display: grid;
  gap: 2px;
}

.vehicle-enabled-setting small {
  color: var(--text-muted);
}

.vehicle-enabled-setting .vehicle-enabled-control {
  flex: 0 0 auto;
}

.vehicle-enabled-label {
  min-width: 64px;
}

.vehicle-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.vehicle-form-grid .form-group {
  min-width: 0;
}

.vehicle-form-grid input,
.vehicle-form-grid textarea,
.vehicle-form-grid select,
.vehicle-cost-grid input {
  width: 100%;
}

.vehicle-edit-form input:not([type]) {
  min-height: 40px;
  padding: 8px 10px;
  color: var(--text);
  background: var(--surface-light);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
}

.vehicle-edit-form input:not([type]):focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.form-group-full {
  grid-column: 1 / -1;
}

.vehicle-image-card {
  display: flex;
  min-height: 390px;
  flex-direction: column;
}

.vehicle-image-stage {
  position: relative;
  display: grid;
  min-height: 245px;
  flex: 1;
  overflow: hidden;
  place-items: center;
  background:
    radial-gradient(circle at 50% 30%, rgb(91 143 217 / 15%), transparent 55%),
    #182233;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.vehicle-image-stage img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 330px;
  object-fit: contain;
}

.vehicle-image-stage img[hidden] {
  display: none;
}

.vehicle-image-empty {
  display: grid;
  justify-items: center;
  gap: 10px;
  color: var(--text-muted);
}

.vehicle-image-empty[hidden],
.vehicle-map-empty[hidden],
#vehicle-address-fields[hidden],
#vehicle-gps-fields[hidden] {
  display: none;
}

.vehicle-image-empty svg {
  width: 72px;
  fill: #526179;
}

.vehicle-image-button {
  width: 100%;
  margin-top: 14px;
}

.vehicle-image-help {
  margin-top: 7px;
  color: var(--text-muted);
  text-align: center;
}

.duration-inputs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.duration-inputs label,
.input-with-suffix,
.input-with-prefix {
  display: flex;
  align-items: stretch;
}

.duration-inputs input {
  min-width: 0;
  border-radius: var(--border-radius) 0 0 var(--border-radius);
}

.duration-inputs span,
.input-with-suffix span,
.input-with-prefix span {
  display: inline-flex;
  align-items: center;
  padding: 0 11px;
  color: var(--text-muted);
  white-space: nowrap;
  background: #182233;
  border: 1px solid var(--border);
}

.duration-inputs span,
.input-with-suffix span {
  border-left: 0;
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

.input-with-suffix input {
  min-width: 0;
  border-radius: var(--border-radius) 0 0 var(--border-radius);
}

.input-with-prefix span {
  border-right: 0;
  border-radius: var(--border-radius) 0 0 var(--border-radius);
}

.input-with-prefix input {
  min-width: 0;
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

.vehicle-location-method {
  display: flex;
  gap: 20px;
  margin: 0 0 18px;
  padding: 0;
  border: 0;
}

.vehicle-location-method legend {
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.vehicle-location-method label {
  display: flex;
  align-items: center;
  gap: 7px;
}

.vehicle-location-layout {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(260px, 0.9fr);
  gap: 18px;
}

.location-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.location-form-grid input {
  width: 100%;
}

.vehicle-location-status {
  min-height: 22px;
  margin: 10px 0 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.vehicle-location-status.error {
  color: #fca5a5;
}

.vehicle-location-status.success {
  color: #86efac;
}

.vehicle-map-wrap {
  position: relative;
  min-height: 270px;
  overflow: hidden;
  background: #182233;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.vehicle-location-map {
  width: 100%;
  height: 100%;
  min-height: 270px;
}

.vehicle-map-empty {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--text-muted);
  text-align: center;
  background: #182233;
}

.vehicle-cost-grid {
  display: grid;
  grid-template-columns: minmax(180px, 0.5fr) minmax(180px, 0.5fr) minmax(440px, 1.25fr);
  gap: 20px;
  align-items: start;
}

.fuel-cost-group {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  padding-left: 20px;
  border-left: 1px solid var(--border);
}

.calculated-cost {
  display: flex;
  min-height: 76px;
  flex-direction: column;
  justify-content: center;
  padding: 10px 14px;
  background: rgb(91 143 217 / 10%);
  border: 1px solid rgb(91 143 217 / 35%);
  border-radius: var(--border-radius);
}

.calculated-cost span,
.calculated-cost small {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.calculated-cost strong {
  color: #bfdbfe;
  font-size: 1.05rem;
}

.vehicle-form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin: 0;
}

.secondary-button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  padding: 9px 16px;
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  background: var(--surface-light);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
}

.secondary-button:hover {
  color: var(--text);
  background: var(--surface-hover);
}

@media (max-width: 750px) {
  .vehicle-page-header {
    flex-direction: column;
  }

  .vehicle-page-header form {
    width: 100%;
  }

  .vehicle-enabled-setting {
    align-items: flex-start;
    flex-direction: column;
  }

  .vehicle-form-grid,
  .location-form-grid,
  .duration-inputs {
    grid-template-columns: 1fr;
  }

  .form-group-full {
    grid-column: auto;
  }

  .vehicle-form-actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }
}

@media (max-width: 1150px) {
  .vehicle-row,
  .vehicle-routing-row,
  .vehicle-cost-grid {
    grid-template-columns: 1fr;
  }

  .fuel-cost-group {
    padding-top: 18px;
    padding-left: 0;
    border-top: 1px solid var(--border);
    border-left: 0;
  }
}

@media (max-width: 850px) {
  .vehicle-location-layout,
  .fuel-cost-group {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 420px) {
  .vehicle-roster {
    grid-template-columns: 1fr;
  }
}
