:root {
  --bg: #0b1220;
  --bg2: #121b2f;
  --text: #e6e9f2;
  --muted: #a8b0c3;
  --card: rgba(255, 255, 255, 0.06);
  --card-border: rgba(255, 255, 255, 0.12);
  --accent: #7c5cff;
  --accent-2: #4cc9f0;
  --ring: rgba(124, 92, 255, 0.45);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color: #111827;
  background: #f7f8fb url('assets/landingpage-bg.png') no-repeat bottom center / cover;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.60);
  pointer-events: none;
  z-index: 0;
}

.page {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  align-items: start;
  justify-items: center;
  padding: 48px 20px;
  gap: 32px;
  position: relative;
  z-index: 1; /* above overlay */
}

.brand {
  text-align: center;
  display: grid;
  gap: 10px;
}

/* SR brand logo above title */
.brand-logo {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid rgba(0,0,0,0.12);
  margin: 0 auto 6px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.12);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.brand-logo img { width: 100%; height: 100%; object-fit: contain; padding: 8px; }

.logo {
  font-size: 42px;
}

/* top icon for driver form */
.logo-avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid rgba(0,0,0,0.1);
  display: grid;
  place-items: center;
  margin: 0 auto;
  box-shadow: 0 8px 18px rgba(0,0,0,0.12);
  overflow: hidden;
}
.logo-avatar img { width: 100%; height: 100%; object-fit: contain; padding: 8px; }

.title {
  font-family: 'Cinzel', serif;
  font-size: 44px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #000;
  text-shadow: 0 1px 0 #fff, 0 2px 16px rgba(0,0,0,0.06);
}

.tagline {
  font-family: 'Alex Brush', cursive;
  color: #d01f1f;
  font-size: 28px;
  margin-top: 6px;
  text-shadow: 0 1px 0 #fff, 0 1px 12px rgba(0,0,0,0.06);
  font-weight: 600;
  -webkit-text-stroke: 0.3px rgba(0,0,0,0.15);
}

.accent { color: #2b4bf2; }

.role-grid {
  width: 100%;
  max-width: 900px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 36px;
  justify-items: center;
}

.role-card {
  appearance: none;
  background: transparent;
  border: none;
  color: inherit;
  padding: 0;
  text-align: center;
  display: grid;
  align-content: start;
  justify-items: center;
  gap: 12px;
  cursor: pointer;
}

.role-card:hover .avatar {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(0,0,0,0.18);
}

.role-card:focus-visible { outline: none; }

.avatar {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: #ffffff;
  display: grid;
  place-items: center;
  border: 1px solid rgba(0,0,0,0.08);
  box-shadow: 0 10px 24px rgba(0,0,0,0.10);
  overflow: hidden;
  transition: transform 200ms ease, box-shadow 200ms ease;
  padding: 10px;
}

.avatar img { width: 100%; height: 100%; object-fit: contain; }

.role-title {
  display: inline-block;
  background: rgba(234, 234, 242, 0.95);
  color: #2845e7;
  font-weight: 700;
  font-size: 16px;
  padding: 10px 16px;
  border-radius: 9999px;
  box-shadow: 0 6px 14px rgba(0,0,0,0.12);
  border: 1px solid rgba(0,0,0,0.06);
}

.role-desc {
  display: none;
}

.footer {
  color: var(--muted);
  font-size: 13px;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(6px);
  background: linear-gradient(180deg,#111827,#0b1220); /* solid, high contrast */
  color: #fff;
  border: 1px solid rgba(255,255,255,0.06);
  padding: 14px 18px;
  border-radius: 12px;
  box-shadow: 0 18px 40px rgba(2,6,23,0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms cubic-bezier(.2,.9,.2,1), transform 220ms cubic-bezier(.2,.9,.2,1);
  z-index: 1200; /* sit above page elements */
  min-width: 160px;
  max-width: 680px;
  text-align: center;
  white-space: normal;
  line-height: 1.2;
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Form */
.form-card {
  width: 100%;
  max-width: 900px;
  border: 1px solid rgba(0,0,0,0.08);
  background: rgba(255,255,255,0.92);
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 18px 40px rgba(0,0,0,0.18);
  backdrop-filter: blur(4px);
}

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

.form-field { display: grid; gap: 8px; }

/* Inline tyre details row */
.inline-section {
  margin-top: 18px;
  border: 1px solid rgba(0,0,0,0.08);
  background: rgba(255,255,255,0.95);
  border-radius: 12px;
  padding: 14px 16px 16px;
}

.inline-section legend {
  padding: 0 6px;
  font-size: 13px;
  font-weight: 700;
  color: #374151;
}

.inline-fields {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

/* Dynamic tyre rows */
.tyre-rows { display: grid; gap: 10px; margin-top: 8px; }
.tyre-row {
  display: grid;
  grid-template-columns: 40px minmax(100px, 1fr) minmax(100px, 1fr) minmax(80px, 1fr) minmax(80px, 1fr) minmax(100px, 1fr) 40px;
  gap: 8px;
  align-items: center;
}
.tyre-row .mini-field { display: grid; gap: 6px; }
.tyre-row label { font-size: 11px; color: #4b5563; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tyre-row input,
.tyre-row select {
  height: 36px;
  width: 100%;
  box-sizing: border-box;
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,0.06);
  padding: 6px 8px;
  background: #ffffff;
  font-size: 13px;
}

/* input with icon (camera) */
.input-with-icon { position: relative; display: inline-block; width: 100%; }
.input-with-icon input[type="text"] { padding-right: 44px; }
.icon-btn { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: none; background: linear-gradient(180deg,var(--accent),#6546ff); color: #fff; width:34px; height:34px; border-radius:8px; display: inline-grid; place-items: center; cursor: pointer; box-shadow: 0 8px 20px rgba(124,92,255,0.18); }
.icon-btn i { font-size: 16px; }
.icon-btn svg { width: 16px; height: 16px; display: block; }
.icon-btn:focus { outline: none; box-shadow: 0 0 0 4px rgba(124,92,255,0.12); }
.hidden-file { display: none; }

/* Professional select styling for tyre brand */
.tyre-row select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='8' viewBox='0 0 14 8'%3E%3Cpath fill='%234b5563' d='M7 8L0 0h14z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px 8px;
  padding-right: 36px; /* space for caret */
  color: #111827;
}

.tyre-row select:focus {
  outline: none;
  box-shadow: 0 0 0 4px rgba(124,92,255,0.12);
  border-color: #7c5cff;
}

/* Hide default arrow on Firefox dropdowns */
select:-moz-focusring { color: transparent; text-shadow: 0 0 0 #111827; }
.tyre-row .serial-field { justify-items: center; }
.tyre-row .serial-field input.serial {
  width: 46px;
  height: 36px;
  background: #f3f4f6;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.06);
  text-align: center;
  padding: 0;
}

/* Remove number input arrows/spinners for serial (cross-browser) */
.tyre-row .serial-field input.serial::-webkit-outer-spin-button,
.tyre-row .serial-field input.serial::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.tyre-row .serial-field input.serial {
  appearance: textfield;
  -moz-appearance: textfield; /* Firefox */
}
.tyre-controls { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.btn-sm { padding: 8px 10px; border-radius: 8px; font-size: 14px; }
.btn-add { background: linear-gradient(180deg, #34c759, #22a85a); box-shadow: 0 8px 18px rgba(34,168,90,0.12); color: #fff; border: none; }
.btn-remove { background: transparent; color: #ef4444; border: 1px solid rgba(239,68,68,0.12); font-weight: 700; }
.remove-field button { height: 36px; width: 36px; display: inline-grid; place-items: center; border-radius: 8px; padding: 0; }
.hint { color: #6b7280; font-size: 12px; }

@media (max-width: 720px) {
  .tyre-row { grid-template-columns: 56px 1fr; grid-auto-rows: auto; }
  .tyre-row .mini-field:nth-child(n+3) { grid-column: 2 / -1; }
  .remove-field { grid-column: 2 / -1; justify-self: end; }
}

.mini-field { display: grid; gap: 6px; }
.mini-field label { font-size: 12px; font-weight: 600; color: #4b5563; }
.mini-field input { height: 40px; }
.mini-field select {
  height: 40px;
  background: #ffffff;
  color: #111827;
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 10px;
  padding: 0 10px;
  outline: none;
}

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

.form-field input,
.form-field textarea {
  width: 100%;
  background: #ffffff;
  color: #111827;
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 10px;
  padding: 12px 14px;
  outline: none;
  transition: box-shadow 150ms ease, border-color 150ms ease, background 150ms ease;
}

.form-field input::placeholder,
.form-field textarea::placeholder {
  color: #9ca3af;
}

.form-field input:focus,
.form-field textarea:focus {
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.35);
  border-color: #7c5cff;
  background: #ffffff;
}

.form-actions {
  margin-top: 18px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.btn {
  appearance: none;
  background: linear-gradient(180deg, var(--accent), #6546ff);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease, opacity 150ms ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(124,92,255,0.35); }
.btn:active { transform: translateY(0); }

.btn-ghost {
background: rgba(124, 92, 255, 0.1);
color: var(--accent);
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
border: 1px solid rgba(124, 92, 255, 0.3);
transition: all 0.2s ease;
}

.btn-ghost:hover {
background: rgba(124, 92, 255, 0.15);
border-color: var(--accent);
transform: translateY(-1px);
box-shadow: 0 4px 8px rgba(124, 92, 255, 0.15);
}

@media (max-width: 720px) {
.page { padding: 32px 16px; }
.title { font-size: 28px; }
.role-grid { grid-template-columns: 1fr; }
.form-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}

/* Modal styles */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1300;
  padding: 20px;
  overflow-y: auto;
  backdrop-filter: blur(4px);
}

.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 24px 48px rgba(0,0,0,0.2);
  position: relative;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #111827;
}

.btn-close {
  background: none;
  border: none;
  font-size: 24px;
  color: #6b7280;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 8px;
}

.btn-close:hover {
  background: rgba(0,0,0,0.05);
}

.modal-body {
  padding: 20px;
}

.image-preview-area {
  aspect-ratio: 16/9;
  background: #f3f4f6;
  border: 2px dashed #d1d5db;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 200ms ease;
}

.image-preview-area:hover {
  border-color: var(--accent);
  background: #f5f3ff;
}

.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: #6b7280;
}

.upload-placeholder svg {
  color: #9ca3af;
}

.upload-text {
  font-size: 14px;
  font-weight: 500;
}

.preview-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
}

/* Update camera button for has-image state */
.icon-btn[data-has-image="true"] {
  background: #10b981;
}
