/* ========== Design Tokens ========== */
:root {
  --bg-primary: #121212;
  --bg-card: #1E1E1E;
  --bg-input: #2C2C2C;
  --gold: #D4AF37;
  --gold-hover: #C5A028;
  --text-primary: #E0E0E0;
  --text-secondary: #A0A0A0;
  --danger: #CF6679;
  --success: #4CAF50;
  --border-color: #444;                          /* <-- NEW: border token for theming */
  --border-radius: 12px;
  --touch-target-min: 48px;
  --font-size-body: 16px;
  --font-size-small: 14px;
  --font-size-heading: 20px;
}

/* ========== Light Theme Overrides ========== */

html.light-theme {
  --bg-primary: #F5F5F5;
  --bg-card: #FFFFFF;
  --bg-input: #F0F0F0;
  --gold: #B8860B;        /* darker gold for white background contrast */
  --gold-hover: #9E6E0B;
  --text-primary: #212121;
  --text-secondary: #555555;
  --danger: #B00020;
  --success: #2E7D32;
  --border-color: #CCCCCC;
}

/* ========== Reset & Base ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: var(--font-size-body);
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.3s ease, color 0.3s ease;   /* <-- NEW: smooth theme switch */
}

input, button, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

/* ========== App Shell ========== */
#app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* ========== Screen Containers ========== */
.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

/* ========== Offline Banner ========== */
.offline-banner {
  background: var(--danger);
  color: #121212;
  text-align: center;
  padding: 8px;
  font-weight: bold;
  font-size: var(--font-size-small);
}

/* ========== Toast ========== */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 12px 16px;
  border-radius: var(--border-radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  border-left: 4px solid var(--gold);
  pointer-events: auto;
  animation: slideIn 0.3s ease;
}
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }

@keyframes slideIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ========== Login Screen ========== */
.login-container {
  justify-content: center;
}
.login-logo {
  font-size: 28px;
  font-weight: bold;
  text-align: center;
  color: var(--gold);
  margin-bottom: 32px;
}
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  margin-bottom: 4px;
  color: var(--text-secondary);
  font-size: var(--font-size-small);
}
.form-group input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-color);         /* <-- CHANGED: use token instead of #444 */
  border-radius: var(--border-radius);
  background: var(--bg-input);
  color: var(--text-primary);
  min-height: var(--touch-target-min);
}
.form-group input:focus {
  outline: none;
  border-color: var(--gold);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch-target-min);
  padding: 12px 24px;
  border-radius: var(--border-radius);
  font-weight: 600;
  transition: background 0.2s;
}
.btn-primary {
  background: var(--gold);
  color: #121212;
  width: 100%;
}
.btn-primary:hover, .btn-primary:focus-visible {
  background: var(--gold-hover);
}
.btn-primary:disabled {
  opacity: 0.6;
  pointer-events: none;
}

.error-message {
  color: var(--danger);
  font-size: var(--font-size-small);
  margin-top: 12px;
  text-align: center;
}

/* ========== Main Screen ========== */

.driver-name {
  font-size: var(--font-size-heading);
  font-weight: bold;
}
.vehicle-plate {
  color: var(--gold);
  font-weight: 600;
  margin-top: 4px;
}

.card {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  min-height: 80px;
  transition: background 0.2s;
}
.card:hover, .card:focus-visible {
  background: #2A2A2A;
}
.card-title {
  font-weight: 600;
}
.card-status {
  font-size: var(--font-size-small);
  color: var(--text-secondary);
}

.retry-btn {
  background: var(--bg-card);
  color: var(--gold);
  border: 1px solid var(--gold);
  min-height: var(--touch-target-min);
  padding: 0 16px;
  border-radius: var(--border-radius);
  margin-top: 12px;
  align-self: center;
}
.retry-btn:disabled { opacity: 0.4; }

/* ========== Checklist Form ========== */
.checklist-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);   /* <-- CHANGED: use token instead of #333 */
}
.checklist-item:last-child { border-bottom: none; }
.toggle-group {
  display: flex;
  gap: 12px;
}
.toggle-btn {
  min-width: 60px;
  min-height: var(--touch-target-min);
  border-radius: var(--border-radius);
  font-weight: bold;
  background: var(--bg-input);
  color: var(--text-primary);
}
.toggle-btn.active-yes { background: var(--success); color: #121212; }
.toggle-btn.active-no { background: var(--danger); color: #121212; }

.comment-input {
  width: 100%;
  margin-top: 8px;
  padding: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);          /* <-- CHANGED: use token instead of #555 */
  border-radius: var(--border-radius);
  min-height: var(--touch-target-min);
}

.camera-btn {
  background: var(--bg-input);
  border: 1px dashed var(--gold);
  padding: 12px;
  border-radius: var(--border-radius);
  width: 100%;
  min-height: var(--touch-target-min);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}
.camera-btn img { max-width: 100%; border-radius: 8px; margin-top: 8px; }

/* ========== Trip Screen ========== */
.trip-timer {
  font-size: 32px;
  text-align: center;
  font-weight: bold;
  margin: 24px 0;
  color: var(--gold);
}

/* ========== Fuel Form ========== */
.form-row {
  display: flex;
  gap: 12px;
}
.form-row .form-group { flex: 1; }

/* ========== Utility ========== */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-16 { margin-top: 16px; }

/* Theme toggle button */
.theme-toggle-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  z-index: 10;
  transition: background 0.2s, color 0.2s;
}
.theme-toggle-btn:active {
  transform: scale(0.95);
}
/* Make the header position relative so the button can be absolutely positioned inside */
.header {
  position: relative;
  text-align: center;
  margin-bottom: 24px;
}

/* ========== Modal System (mobile‑first, touch‑friendly) ========== */

/* Overlay – covers the full screen, semi‑transparent */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}

/* Card – sits inside the overlay, constrained width */
.modal-card {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 24px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Title */
.modal-title {
  font-size: var(--font-size-heading);
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.3;
}

/* Body text */
.modal-body {
  font-size: var(--font-size-body);
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.5;
}

/* Input – matches the existing form‑group input */
.modal-input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: var(--font-size-body);
  min-height: var(--touch-target-min);
}
.modal-input:focus {
  outline: none;
  border-color: var(--gold);
}

/* Button row */
.modal-buttons {
  display: flex;
  gap: 12px;
  margin-top: 4px;
}
.modal-buttons .btn {
  flex: 1;
}

/* Secondary button style (used for Cancel, Manual Entry, etc.) */
.btn-secondary {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  min-height: var(--touch-target-min);
  padding: 12px 16px;
  border-radius: var(--border-radius);
  font-weight: 600;
  text-align: center;
  transition: background 0.2s;
}
.btn-secondary:active {
  background: var(--border-color);
}
.btn-secondary:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* Fade‑in animation */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Error message inside modal – reuse existing .error-message rules */
.modal-card .error-message {
  margin: 0;
  text-align: left;
}

