/*
 * DIENSTFAHRTEN PRIVATAUTOS - CLOUDFLARE VERSION
 * Alle Styles für Login, Landing Page und Error Page
 */

/* === GLOBALE RESET & BASIS === */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

* {
  box-sizing: border-box;
}

/* iOS: verhindere, dass Safari die Seite „zusammenzoomt" / Schrift verkleinert */
html {
  -webkit-text-size-adjust: 100%;
}

/* Media-Viewport sauber halten, keine Minwidth-Zoom-Fallen */
html, body {
  width: 100%;
}

/* Verhindere Layout-Ausreißer, die Mobile-Zoom triggern */
*,
*::before,
*::after {
  box-sizing: border-box;
  min-width: 0;
}

/* Medien nie breiter als der Screen */
img, svg, video, canvas {
  max-width: 100%;
  height: auto;
}

/* === LOADING SPINNER === */
html::before {
  content: "";
  position: fixed;
  inset: 0;
  background: #fff;
  z-index: 99999;
}

html::after {
  content: "";
  position: fixed;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border: 3px solid #e5e7eb;
  border-top-color: #6b21a8;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  z-index: 100000;
}

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

/* Spinner ausblenden sobald .ready */
html.ready::before,
html.ready::after {
  display: none !important;
}

/* Bis ready → nichts vom Body rendern (verhindert Flackern) */
body {
  display: none;
}

html.ready body {
  display: block;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* === THEME VARIABLEN === */
:root {
  --bg: #f6f6f6;
  --fg: #111;
  --muted: #666;
  --primary: #6b21a8;
}

/* === BODY & LAYOUT === */
body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  margin: 0;
  padding: 24px;
  background: var(--bg);
  color: var(--fg);
}

.center {
  text-align: center;
}

.title {
  margin: 20px 0 20px 0;
}

.titlesize {
  font-size: 23px;
}

.wrap {
  max-width: 680px;
  margin: 0 auto;
}

.card {
  background: #fff;
  border: 1px solid #eee;
  border-radius: 20px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.07);
  padding: 22px;
}

h1 {
  font-size: 20px;
  margin: 0 0 6px;
}

/* Gradient für Benutzernamen */
/* Login: Orange → Türkis */
h1#greeting {
  background: linear-gradient(135deg, #fe6b07 0%, #00546f 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: inline-block;
}

/* Landing: Orange → Grün */
h1#userName {
  background: linear-gradient(135deg, #fe6b07 0%, #82c342 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: inline-block;
}

/* Wenn loading: kein Gradient */
h1#greeting.loading,
h1#userName.loading {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s ease-in-out infinite;
  -webkit-text-fill-color: transparent;
}

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

.row {
  margin: 12px 0;
}

.space {
  margin: 12px 0;
}

/* === LOGO === */
.logo-wrap {
  text-align: center;
  margin: 0 auto 12px;
  max-width: 100%;
  overflow: visible;
}

.logo {
  height: 48px;
  width: auto;
  max-width: 100%;
  display: block;
  margin: 0 auto;
  object-fit: contain;
}

/* === ALERT BOXES === */
.alert-warn {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
  border-radius: 10px;
  padding: 10px 12px;
  margin: 12px 0;
  display: none;
}

.alert-warn.show {
  display: block;
}

.alert {
  background: #fee2e2;
  border: 1px solid #fca5a5;
  border-radius: 10px;
  padding: 12px 14px;
  margin: 12px 0;
  font-size: 15px;
  line-height: 1.45;
}

.alertdarkred {
  color: #991b1b;
}

/* === FORM ELEMENTS === */
input[type="password"],
input[type="text"],
input[type="date"],
.input {
  width: 100%;
  max-width: 100%;
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  font-size: 16px;
  line-height: 1.4;
  box-sizing: border-box;
}

/* iOS Safari Date Input Fix */
input[type="date"] {
  -webkit-appearance: none;
  -moz-appearance: textfield;
  min-height: 1.2em;
}

button,
.btn {
  margin-top: 12px;
  padding: 12px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  width: 100%;
  font-size: 16px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  display: inline-block;
  text-decoration: none;
  text-align: center;
}

.btn-danger {
  background: #de3a68;
}

.btn-danger:hover {
  filter: brightness(0.95);
}

.btn-warning {
  background: #f27411;
  margin-left: 8px;
}

.btn-ghost {
  background: #fff;
  border: 1px solid #e5e7eb;
  color: #444;
}

/* === LANDING PAGE SPEZIFISCH === */
.pill {
  display: inline-block;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 6px 10px;
  margin-right: 8px;
  background: #fafafa;
  margin-bottom: 5px;
}

/* Loading skeleton für Daten */
.pill.loading {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s ease-in-out infinite;
  color: transparent;
  min-width: 150px;
}

/* Loading skeleton für Namen (h1) */
h1.loading {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s ease-in-out infinite;
  color: transparent;
  display: inline-block;
  min-width: 200px;
  border-radius: 8px;
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.flex-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* === STEPS BOX === */
.steps {
  margin-top: 12px;
  background: #fafafa;
  border: 1px dashed #e5e7eb;
  border-radius: 12px;
  padding: 12px;
}

.steps li {
  margin: 6px 0;
}

/* === ACCORDION (GELBE BOX) === */
.notice-acc {
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 12px;
  padding: 0;
  overflow: hidden;
  color: #78350f;
}

.notice-acc .acc-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
  outline: none;
}

.notice-acc .acc-header:hover {
  background: #fde68a;
}

.notice-acc .acc-header:focus-visible {
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.35) inset;
  border-radius: 12px;
}

.notice-acc .acc-ic {
  flex: 0 0 auto;
  display: inline-flex;
}

.notice-acc .acc-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.notice-acc .acc-text strong {
  color: #78350f;
  font-weight: 700;
  line-height: 1.1;
}

.notice-acc .acc-sub {
  font-size: 14px;
  color: #92400e;
}

.notice-acc .chev {
  margin-left: auto;
  display: inline-flex;
  transition: transform 0.2s ease;
}

.notice-acc.open .chev {
  transform: rotate(90deg);
}

.notice-acc .acc-body {
  display: none;
  padding: 0 14px 14px;
}

.notice-acc.open .acc-body {
  display: block;
}

/* === MODAL === */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100002;
}

.modal-backdrop.show {
  display: flex;
}

.modal {
  background: #fff;
  border: 1px solid #eee;
  border-radius: 16px;
  padding: 16px;
  width: min(520px, calc(100% - 32px));
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.15);
  box-sizing: border-box;
}

.modal h3 {
  margin: 5px 0 15px 0;
  font-size: 18px;
}

.modal .row {
  margin: 10px 0;
  width: 100%;
  box-sizing: border-box;
}

.modal label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  color: #333;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 8px;
}

.modal .error-msg {
  color: #dc2626;
  background: #fee2e2;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  padding: 8px 10px;
  margin-top: 10px;
  font-size: 14px;
}

.modal .success-msg {
  color: #16a34a;
  background: #dcfce7;
  border: 1px solid #86efac;
  border-radius: 8px;
  padding: 8px 10px;
  margin-top: 10px;
  font-size: 14px;
}

/* === STICKY CTA (NUR MOBILE) === */
.sticky-cta {
  display: none;
}

/* === MOBILE OPTIMIERUNG === */
@media (max-width: 520px) {
  body {
    padding: 16px;
    /* Wichtig: min-height damit Content scrollbar ist */
    min-height: 100vh;
  }

  .wrap {
    padding: 0 4px;
    /* Zusätzlicher Platz unten für sticky buttons */
    padding-bottom: 120px;
  }

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

  .actions .btn {
    width: 100%;
  }
}

/* === FORMULAR-SEITE === */

.form-page .card {
  max-width: 720px;
}

/* Mitarbeiter Name Box */
.ma-name-box {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 2px solid #7dd3fc;
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 24px;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.08);
}

/* Letzter KM Stand Info Box */
.last-km-info {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 1px solid #bae6fd;
  border-radius: 8px;
  padding: 10px 14px;
  margin-top: 8px;
  font-size: 13px;
  color: #0369a1;
  font-weight: 600;
  line-height: 1.4;
  box-shadow: 0 1px 3px rgba(59, 130, 246, 0.08);
}

/* Warning-Variante (wenn KM Start < letztes KM Ende) */
.last-km-info.warning {
  background: linear-gradient(135deg, #fef9c3 0%, #fef08a 100%);
  border: 1px solid #fcd34d;
  color: #92400e;
  box-shadow: 0 1px 3px rgba(251, 191, 36, 0.12);
}

.ma-name-label {
  font-size: 13px;
  font-weight: 600;
  color: #0369a1;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.ma-name-value {
  font-size: 20px;
  font-weight: 700;
  color: #0c4a6e;
  min-height: 28px;
}

.ma-name-value.loading {
  background: linear-gradient(90deg, #dbeafe 25%, #bfdbfe 50%, #dbeafe 75%);
  background-size: 200% 100%;
  animation: loading 1.5s ease-in-out infinite;
  color: transparent;
  border-radius: 6px;
  display: inline-block;
  min-width: 200px;
}

.form-group {
  margin-bottom: 32px;
}

/* Form Section Divider */
.form-divider {
  height: 1px;
  background: #e5e7eb;
  margin: 24px 0;
}

.form-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 8px;
  color: var(--fg);
}

.field-icon {
  width: 20px;
  height: 20px;
  opacity: 0.7;
}

.icon-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.checkbox-icon {
  width: 20px;
  height: 20px;
  opacity: 0.7;
  margin-right: 4px;
}

.required {
  color: #dc2626;
  font-weight: 700;
}

.field-hint {
  font-size: 14px;
  color: #666;
  margin: 6px 0 0;
  line-height: 1.5;
}

.info-box {
  background: #fef3c7;
  border: 1px solid #fbbf24;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 24px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.info-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  margin-top: 2px;
}

.info-content {
  flex: 1;
}

.info-content strong {
  display: block;
  margin-bottom: 8px;
  color: #78350f;
}

.info-content p {
  margin: 4px 0;
  font-size: 14px;
  line-height: 1.5;
}

.info-content .small {
  font-size: 13px;
  margin-top: 12px;
}

.km-info {
  margin-top: 8px;
  font-size: 14px;
  font-weight: 600;
}

.photo-preview img {
  display: block;
  max-width: 100%;
  max-height: 200px;
  border-radius: 8px;
  margin-top: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.input-file {
  font-size: 14px;
  padding: 0;
  cursor: pointer;
  border: none;
  display: block;
  width: 100%;
}

.input-file::-webkit-file-upload-button {
  background: #6b7280;
  color: #fff;
  border: none;
  padding: 12px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  margin-bottom: 8px;
  display: block;
  width: 100%;
  font-size: 15px;
}

.input-file::-webkit-file-upload-button:hover {
  background: #4b5563;
}

/* File name display below button */
.input-file::after {
  content: attr(data-filename);
  display: inline-block;
  font-size: 13px;
  color: #666;
  margin-top: 8px;
  padding: 8px 12px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  min-height: 20px;
  max-width: fit-content;
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  transition: all 0.2s;
}

.checkbox-label:hover {
  background: #f9fafb;
  border-color: var(--primary);
}

.checkbox-label input[type="checkbox"] {
  margin-top: 2px;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.checkbox-label span {
  flex: 1;
  font-size: 14px;
  line-height: 1.5;
}

.error-msg {
  background: #fee2e2;
  border: 1px solid #fca5a5;
  color: #dc2626;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}

.conditional {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Modal für KM-Differenz */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100002;
}

.modal-backdrop.show {
  display: flex;
}

.modal {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal h3 {
  margin: 0 0 16px;
  color: #d97706;
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.modal-actions .btn {
  flex: 1;
}

/* Mobile Anpassungen für Formular */
@media (max-width: 520px) {
  .form-group {
    margin-bottom: 20px;
  }

  .info-box {
    flex-direction: column;
  }

  .modal {
    max-width: 95%;
    padding: 20px;
  }

  .modal-actions {
    flex-direction: column;
  }

  .input-file::-webkit-file-upload-button {
    padding: 12px 24px;
    font-size: 15px;
    min-height: 44px;
  }
}

/* === ROUTE MAP === */
.route-map-container {
  margin-bottom: 24px;
  border: 2px solid #6b21a8;
  border-radius: 12px;
  overflow: hidden;
  animation: fadeIn 0.4s ease;
}

.route-header {
  background: linear-gradient(135deg, #6b21a8 0%, #9333ea 100%);
  color: #fff;
  padding: 12px 16px;
  font-size: 15px;
}

.map-canvas {
  width: 100%;
  height: 350px;
  background: #f3f4f6;
}

.route-info {
  padding: 16px;
  background: #fafafa;
  border-top: 1px solid #e5e7eb;
  font-size: 14px;
  line-height: 1.6;
}

#routeWarning {
  padding: 0 16px 16px 16px;
}

@media (max-width: 520px) {
  .map-canvas {
    height: 280px;
  }

  .route-info {
    padding: 12px;
    font-size: 13px;
  }

  #routeWarning {
    padding: 0 12px 12px 12px;
  }
}
