/* ============================================================
   Projekte-App – Design basierend auf MettlerAPP
   ============================================================ */

:root {
  --primary: #122941;
  --primary-light: #1a3a5c;
  --accent: #C87A00;
  --accent-dark: #a56400;
  --bg: #F1F3F4;
  --bg-card: #ffffff;
  --text: #1a1a1a;
  --text-secondary: #52647C;
  --text-light: #8a9bb5;
  --border: #dce3eb;
  --border-dark: #c5cdd8;
  --success: #22c55e;
  --success-bg: #f0fdf4;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(18,41,65,0.08);
  --shadow-lg: 0 4px 16px rgba(18,41,65,0.12);
  --header-height: 56px;
  --nav-height: 60px;
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font-family);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

/* ---- Header ---- */
.app-header {
  background: var(--primary);
  color: white;
  padding: 0 16px;
  padding-top: env(safe-area-inset-top, 0);
  height: calc(var(--header-height) + env(safe-area-inset-top, 0));
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-lg);
}

.app-header__title {
  font-size: 18px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.app-header__subtitle {
  font-size: 11px;
  opacity: 0.7;
  margin-top: 2px;
}

.app-header__spacer { flex: 1; }

.app-header__user {
  font-size: 12px;
  opacity: 0.8;
  margin-right: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.header-btn {
  background: none;
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: background 0.2s;
}

.header-btn:hover { background: rgba(255,255,255,0.1); }

/* ---- Bottom Navigation ---- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid var(--border);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom, 0);
  z-index: 100;
  box-shadow: 0 -6px 18px rgba(0,0,0,0.06);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 600;
  border: none;
  background: none;
  transition: color 0.2s;
  position: relative;
}

.nav-item.active { color: var(--accent); }
.nav-item svg { width: 22px; height: 22px; margin-bottom: 3px; }

.nav-badge {
  position: absolute;
  top: 2px;
  right: calc(50% - 18px);
  min-width: 16px;
  height: 16px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 2px #fff;
}

/* ---- Content ---- */
.app-content {
  flex: 1;
  padding: 16px;
  padding-bottom: calc(var(--nav-height) + 20px + env(safe-area-inset-bottom, 0));
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

/* ---- Cards ---- */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: transform 0.15s, box-shadow 0.15s;
}

.card--clickable { cursor: pointer; }
.card--clickable:active { transform: scale(0.98); }

.card__title { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.card__subtitle { font-size: 13px; color: var(--text-secondary); }
.card__meta { display: flex; gap: 12px; margin-top: 8px; font-size: 12px; color: var(--text-light); }

/* ---- Badges ---- */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.badge--success { background: var(--success-bg); color: #16a34a; }
.badge--warning { background: var(--warning-bg); color: #d97706; }
.badge--danger { background: var(--danger-bg); color: var(--danger); }
.badge--info { background: #eff6ff; color: #2563eb; }
.badge--neutral { background: #f3f4f6; color: #6b7280; }

/* Compat mit alten card__badge Klassen */
.card__badge { display: inline-block; padding: 3px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; background: #f3f4f6; color: #6b7280; }
.card__badge--success { background: var(--success-bg); color: #16a34a; }
.card__badge--warning { background: var(--warning-bg); color: #d97706; }

/* ---- Calendar Week (Kalenderwoche) ---- */
.kw-header {
  background: white;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.kw-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.kw-nav-btn {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  color: var(--text);
}

.kw-title { text-align: center; font-weight: 700; font-size: 15px; }
.kw-subtitle { text-align: center; font-size: 13px; color: var(--text-secondary); }

.kw-days { display: flex; justify-content: space-between; text-align: center; }

.kw-day {
  flex: 1;
  cursor: pointer;
  padding: 6px 2px;
}

.kw-day-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }

.kw-day-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 4px auto 2px;
  font-size: 13px;
  font-weight: 600;
}

.kw-day.selected .kw-day-num { background: var(--accent); color: white; }
.kw-day.today .kw-day-label { color: var(--danger); }

.kw-day-dot { height: 8px; display: flex; justify-content: center; gap: 3px; }
.kw-dot { width: 6px; height: 6px; border-radius: 50%; background: #3b82f6; }
.kw-dot.done { background: var(--success); }

/* ---- Tracking Row (Abfahrt / Arbeitsstart / km) ---- */
.track-row {
  display: flex;
  gap: 8px;
  margin: 16px 0;
}

.track-btn {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}

.track-btn:active { transform: scale(0.97); }
.track-btn.active { border-color: var(--success); background: var(--success-bg); }

.track-icon { font-size: 20px; flex-shrink: 0; }
.track-label { font-size: 11px; font-weight: 600; color: var(--text-secondary); }
.track-value { font-size: 14px; font-weight: 700; }

/* ---- Forms ---- */
.form-group { margin-bottom: 14px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-label--required::after { content: ' *'; color: var(--danger); }

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: white;
  color: var(--text);
  transition: border-color 0.2s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(200,122,0,0.15);
}

.form-textarea { min-height: 100px; resize: vertical; }
.form-input--error { border-color: var(--danger); }
.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; }

/* ---- Buttons ---- */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: scale(0.97); }

.btn--primary { background: var(--accent); color: white; }
.btn--primary:hover:not(:disabled) { background: var(--accent-dark); }
.btn--secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn--danger { background: var(--danger); color: white; }
.btn--success { background: var(--success); color: white; }
.btn--full { width: 100%; }
.btn--sm { padding: 8px 14px; font-size: 13px; }

/* ---- Section Headers ---- */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 20px 0 12px;
}

.section-title { font-weight: 700; font-size: 14px; color: var(--text-secondary); }

/* ---- Detail Section ---- */
.detail-section {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.detail-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 4px;
  margin-top: 12px;
}

/* ---- Device Items (Positionen) ---- */
.device-item {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: transform 0.15s;
}

.device-item:active { transform: scale(0.98); }
.device-item--completed { border-color: #86efac; background: #f0fdf4; }
.device-item--draft { border-color: #fde68a; background: #fffbeb; }

.device-header { display: flex; align-items: center; }
.device-info { flex: 1; min-width: 0; }
.device-sn { font-weight: 600; font-size: 14px; }
.device-model { font-size: 12px; color: var(--text-secondary); }
.device-loc { font-size: 12px; color: var(--text-light); }
.device-arrow { color: var(--text-light); font-size: 22px; margin-left: 8px; }

.device-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.device-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
}

/* ---- Toast ---- */
.toast-container {
  position: fixed;
  bottom: calc(var(--nav-height) + 16px + env(safe-area-inset-bottom, 0));
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: white;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.3s ease;
  pointer-events: auto;
}

.toast--success { background: var(--success); }
.toast--error { background: var(--danger); }
.toast--info { background: var(--primary); }
.toast--warning { background: #d97706; }

.toast--out { animation: toast-out 0.3s ease forwards; }

@keyframes toast-in { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(20px); } }

/* ---- Modal ---- */
.modal-container {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.5);
}

.modal {
  background: var(--bg-card);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
}

.modal__title { font-size: 18px; font-weight: 600; margin-bottom: 16px; }
.modal__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ---- Utilities ---- */
.is-hidden { display: none !important; }
.text-center { text-align: center; }
.text-sm { font-size: 13px; }
.text-muted { color: var(--text-secondary); }
.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 16px; }
.mt-lg { margin-top: 24px; }
.mb-sm { margin-bottom: 8px; }
.mb-md { margin-bottom: 16px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-between { justify-content: space-between; }
.flex-center { align-items: center; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }

/* ---- Empty State ---- */
.empty-state { text-align: center; padding: 32px; color: var(--text-secondary); }
.empty-state__icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state__text { font-size: 15px; }

/* ---- Loading ---- */
.loading { display: flex; align-items: center; justify-content: center; padding: 32px; }

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Login ---- */
.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 32px;
  background: var(--primary);
}

.login-form {
  width: 100%;
  max-width: 360px;
  background: var(--bg-card);
  border-radius: 12px;
  padding: 32px 24px;
  box-shadow: var(--shadow-lg);
}

.login-form__logo { text-align: center; font-size: 2.5rem; margin-bottom: 16px; }

.login-form__title {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 24px;
  color: var(--primary);
}

/* ---- Ticket List ---- */
.ticket-list { list-style: none; }

.ticket-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s;
}

.ticket-item:active { transform: scale(0.98); }

.ticket-item__header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 4px; gap: 8px; }
.ticket-item__title { font-weight: 600; font-size: 15px; min-width: 0; }
.ticket-item__id { font-weight: 700; font-size: 15px; color: var(--text-secondary); flex-shrink: 0; }
.ticket-item__address { font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.ticket-item__meta { display: flex; gap: 12px; font-size: 12px; color: var(--text-light); }

/* ---- Photo Capture ---- */
.photo-capture {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s;
}

.photo-capture:hover { border-color: var(--accent); }
.photo-capture img { max-width: 100%; max-height: 200px; border-radius: 6px; }
