/* ============================================================
   FahrtenbuchMobil – Ergänzungen zum FahrtenbuchV2-Stylesheet
   (fahrtenbuch.min.css liefert Tokens, Buttons, Felder, Farben)
   ============================================================ */

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
  background-color: var(--fb-bg);
  overscroll-behavior-y: none;
}

body {
  -webkit-tap-highlight-color: transparent;
}

/* iOS zoomt bei Schriftgröße < 16px in Eingabefelder */
input,
select,
textarea {
  font-size: 16px !important;
}

textarea.textarea {
  height: auto;
  min-height: 5.5rem;
  padding-top: 0.6rem;
  padding-bottom: 0.6rem;
  resize: vertical;
}

/* ---------- App-Leiste ---------- */
.m-appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: calc(env(safe-area-inset-top) + 0.6rem) 0.75rem 0.6rem;
  border-bottom: 1px solid var(--fb-border);
  background-color: rgba(20, 25, 32, 0.94);
  backdrop-filter: blur(10px);
}

.m-appbar-brand {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.m-appbar-brand span:last-child {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.m-icon-btn {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 2.6rem;
  height: 2.6rem;
  padding: 0;
  border: 1px solid var(--fb-border);
  border-radius: var(--fb-radius);
  background: var(--fb-surface-2);
  color: var(--fb-text-muted);
  cursor: pointer;
}

.m-icon-btn:active {
  transform: scale(0.96);
  color: var(--fb-accent-strong);
}

/* ---------- Views ---------- */
.m-content {
  width: min(640px, 100%);
  margin: 0 auto;
  padding: 1rem 1rem calc(env(safe-area-inset-bottom) + 1.5rem);
}

.m-has-footer {
  padding-bottom: calc(env(safe-area-inset-bottom) + 6rem);
}

.m-splash {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 1rem;
  min-height: 100dvh;
  color: var(--fb-text-muted);
}

.m-splash-mark {
  width: 4rem;
  height: 4rem;
  border-radius: 18px;
  animation: m-pulse 1.4s ease-in-out infinite;
}

.m-splash-mark i {
  font-size: 2.2rem !important;
}

.m-splash .m-no-anim {
  animation: none;
  background: linear-gradient(135deg, #f87171, #b91c1c);
}

.m-network-text {
  max-width: 320px;
  padding: 0 1rem;
  text-align: center;
}

.m-network-text h2 {
  margin: 0 0 0.5rem;
  font-size: 1.2rem;
  color: var(--fb-text);
}

.m-network-text p {
  margin: 0 0 0.4rem;
}

@keyframes m-pulse {
  50% {
    transform: scale(0.92);
    opacity: 0.7;
  }
}

.auth-page {
  padding-top: calc(env(safe-area-inset-top) + 1.5rem);
  padding-bottom: calc(env(safe-area-inset-bottom) + 1.5rem);
}

/* ---------- Begrüßung ---------- */
.m-greeting {
  margin-bottom: 1.25rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--fb-border);
  border-radius: var(--fb-radius-lg);
  background:
    radial-gradient(600px 200px at 0% 0%, rgba(201, 138, 91, 0.16), transparent 70%),
    var(--fb-surface-1);
}

.m-greeting-label {
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fb-text-subtle);
}

.m-greeting-name {
  font-size: 1.15rem;
  font-weight: 600;
}

.m-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.m-section-head .form-section-title {
  margin: 0;
}

/* ---------- Fahrzeugliste ---------- */
.m-vehicle-list {
  display: grid;
  gap: 0.75rem;
}

.m-vehicle {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  padding: 0.75rem 0.8rem 0.8rem;
  border: 1px solid var(--fb-border);
  border-left: 4px solid var(--fb-accent);
  border-radius: var(--fb-radius-lg);
  background: linear-gradient(180deg, var(--fb-surface-2), var(--fb-surface-1));
  color: var(--fb-text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.m-vehicle-top {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.m-vehicle-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.m-vehicle-actions .btn,
.m-vehicle-actions .btn-ghost {
  height: 2.75rem;
  padding: 0 0.6rem;
}

.m-vehicle-actions i {
  font-size: 1.2rem;
}

.m-vehicle img {
  flex: 0 0 auto;
  width: 5.2rem;
  height: 3.6rem;
  object-fit: contain;
  border-radius: 8px;
  background-color: var(--fb-surface-3);
}

.m-vehicle-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.m-vehicle-name {
  font-size: 1.05rem;
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.m-vehicle-status {
  font-size: 0.85rem;
  color: var(--fb-text-muted);
}

/* ---------- Schadensmeldung ---------- */
.m-count {
  color: var(--fb-text-subtle);
  font-weight: 500;
}

.m-photo-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.m-file-btn {
  height: 2.9rem;
  margin: 0;
  font-size: 0.92rem;
  color: var(--fb-text);
}

.m-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 0.5rem;
}

.m-thumbs:empty {
  display: none;
}

.m-thumb {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid var(--fb-border);
  border-radius: 8px;
  background-color: var(--fb-surface-3);
}

.m-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: zoom-in;
}

.m-thumb-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  place-items: center;
  width: 1.8rem;
  height: 1.8rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background-color: rgba(13, 16, 21, 0.8);
  color: var(--fb-danger);
  cursor: pointer;
}

.m-thumb-remove i {
  font-size: 1.1rem;
}

.m-year-select {
  width: auto !important;
  min-width: 6.5rem;
  height: 2.4rem !important;
}

.m-damage-list {
  display: grid;
  gap: 0.6rem;
}

.m-damage-item {
  border: 1px solid var(--fb-border);
  border-radius: var(--fb-radius);
  background-color: var(--fb-surface-2);
}

.m-damage-item summary {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.7rem 0.8rem;
  list-style: none;
  cursor: pointer;
}

.m-damage-item summary::-webkit-details-marker {
  display: none;
}

.m-damage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.m-damage-date {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--fb-accent-strong);
}

.m-damage-badges {
  display: flex;
  gap: 0.35rem;
}

.m-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background-color: var(--fb-surface-4);
  font-size: 0.72rem;
  color: var(--fb-text-muted);
}

.m-badge i {
  font-size: 0.85rem;
}

.m-badge-work {
  background-color: rgba(251, 191, 36, 0.15);
  color: var(--fb-warning);
}

.m-damage-desc {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  font-size: 0.92rem;
}

.m-damage-item[open] .m-damage-desc {
  display: none;
}

.m-damage-detail {
  display: grid;
  gap: 0.6rem;
  padding: 0 0.8rem 0.8rem;
}

.m-damage-creator {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--fb-text-muted);
}

.m-damage-creator i {
  font-size: 1rem;
  color: var(--fb-accent);
}

.m-damage-fulltext {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ---------- Bildvorschau ---------- */
.m-lightbox {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 1rem;
  background-color: rgba(0, 0, 0, 0.88);
  cursor: zoom-out;
}

.m-lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
}

.m-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--fb-text-subtle);
}

.m-empty-small {
  margin: 0;
  font-size: 0.85rem;
  color: var(--fb-text-subtle);
}

/* ---------- Eintrag ---------- */
.m-vehicle-head {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.m-vehicle-head img {
  width: 5.5rem;
  height: 3.8rem;
  object-fit: contain;
  border-radius: 8px;
  background-color: var(--fb-surface-3);
}

.m-vehicle-head-name {
  font-size: 1.2rem;
  font-weight: 600;
}

.m-vehicle-head-driver {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.88rem;
  color: var(--fb-text-muted);
}

.m-vehicle-head-driver i {
  font-size: 1.1rem;
  color: var(--fb-accent);
}

.m-card {
  margin-bottom: 0.9rem;
  padding: 1rem;
  border: 1px solid var(--fb-border);
  border-radius: var(--fb-radius-lg);
  background-color: var(--fb-surface-1);
}

.m-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.m-hint {
  margin: 0.5rem 0 0;
  font-size: 0.78rem;
  color: var(--fb-text-subtle);
}

.m-required {
  color: var(--fb-danger);
}

.m-devices {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr));
  gap: 0.25rem 0.75rem;
}

.m-devices .checkbox-wrapper {
  padding: 0.5rem 0;
}

.m-fuel-list {
  display: grid;
  gap: 0.75rem;
}

.m-fuel-row {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
  padding: 0.8rem;
  padding-right: 3.6rem;
  border: 1px solid var(--fb-border);
  border-radius: var(--fb-radius);
  background-color: var(--fb-surface-2);
}

.m-fuel-row .custom-field:nth-child(3) {
  grid-column: 1 / -1;
}

.m-fuel-remove {
  position: absolute;
  top: 0.8rem;
  right: 0.8rem;
  color: var(--fb-danger);
}

/* ---------- Footer ---------- */
.m-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem 1rem calc(env(safe-area-inset-bottom) + 0.75rem);
  border-top: 1px solid var(--fb-border);
  background-color: rgba(26, 32, 41, 0.96);
  backdrop-filter: blur(10px);
}

.m-footer .btn,
.m-footer .btn-ghost {
  flex: 1 1 0;
  height: 3rem;
}

.m-footer .btn {
  flex-grow: 2;
}

/* ---------- Spinner ---------- */
.m-spinner {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background-color: rgba(13, 16, 21, 0.55);
}

.m-spinner-ring {
  width: 3rem;
  height: 3rem;
  border: 4px solid var(--fb-surface-4);
  border-top-color: var(--fb-accent);
  border-radius: 50%;
  animation: m-spin 0.8s linear infinite;
}

@keyframes m-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Toasts ---------- */
.m-toast-host {
  position: fixed;
  left: 1rem;
  right: 1rem;
  bottom: calc(env(safe-area-inset-bottom) + 5.5rem);
  z-index: 110;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  pointer-events: none;
}

.m-toast {
  max-width: 560px;
  width: 100%;
  padding: 0.8rem 1rem;
  border: 1px solid var(--fb-border-strong);
  border-left: 4px solid var(--fb-success);
  border-radius: var(--fb-radius);
  background-color: var(--fb-surface-3);
  color: var(--fb-text);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
  animation: m-toast-in 200ms ease;
}

.m-toast.m-toast-error {
  border-left-color: var(--fb-danger);
}

.m-toast ul {
  margin: 0;
  padding-left: 1.1rem;
}

@keyframes m-toast-in {
  from {
    transform: translateY(10px);
    opacity: 0;
  }
}

/* ---------- Bestätigungsdialog ---------- */
.m-dialog {
  width: min(420px, calc(100% - 2rem));
  padding: 0;
  border: 1px solid var(--fb-border-strong);
  border-radius: 16px;
  background-color: var(--fb-surface-1);
  color: var(--fb-text);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.m-dialog::backdrop {
  background-color: rgba(0, 0, 0, 0.6);
}

.m-dialog form {
  margin: 0;
}

.m-dialog-title {
  padding: 1rem 1.1rem 0.4rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.m-dialog-body {
  padding: 0 1.1rem 1rem;
  color: var(--fb-text-muted);
}

.m-dialog-warning {
  margin-top: 0.75rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid rgba(251, 191, 36, 0.4);
  border-radius: var(--fb-radius);
  background-color: rgba(251, 191, 36, 0.1);
  color: var(--fb-warning);
}

.m-dialog-actions {
  display: flex;
  gap: 0.75rem;
  padding: 0.8rem 1.1rem 1.1rem;
}

.m-dialog-actions button {
  flex: 1 1 0;
  height: 2.8rem;
}

/* ---------- Native Datum-/Uhrzeit-Felder (Handy-Picker) ---------- */
/* iOS Safari: leere date/time-Felder fallen sonst in der Höhe zusammen,
   ignorieren die Breite und richten den Wert zentriert aus */
input[type="date"],
input[type="time"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 2.75rem;
  text-align: left;
  font-variant-numeric: tabular-nums;
}

input[type="date"]::-webkit-date-and-time-value,
input[type="time"]::-webkit-date-and-time-value {
  text-align: left;
}
