/* assets/css/app.css */
:root {
  --red:     #C0392B;
  --red-dark:#96281B;
  --red-bg:  #FDECEA;
  --green:   #27AE60;
  --green-bg:#EAF6EE;
  --gray-0:  #ffffff;
  --gray-1:  #f7f7f7;
  --gray-2:  #ebebeb;
  --gray-3:  #d0d0d0;
  --gray-5:  #888;
  --gray-8:  #2c2c2c;
  --text:    #1a1a1a;
  --radius:  10px;
  --shadow:  0 2px 12px rgba(0,0,0,.09);
}

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

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  background: var(--gray-1);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

/* ── Top-Bar ─────────────────────────────────────── */
#topbar {
  background: var(--red);
  color: #fff;
  padding: 0 16px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
#topbar .logo { font-size: 22px; }
#topbar h1 { font-size: 16px; font-weight: 600; flex: 1; line-height: 1.2; }
#topbar .sub { font-size: 11px; opacity: .8; }
#btn-back {
  background: none; border: none; color: #fff;
  font-size: 24px; cursor: pointer; padding: 4px 8px 4px 0;
  display: none;
}
#topbar-actions { display: flex; gap: 8px; align-items: center; }
#btn-logout, #btn-admin, #btn-druckliste {
  background: rgba(255,255,255,.18);
  border: none; color: #fff; border-radius: 6px;
  font-size: 12px; padding: 5px 10px; cursor: pointer;
  white-space: nowrap;
}
#btn-logout:hover, #btn-admin:hover, #btn-druckliste:hover { background: rgba(255,255,255,.28); }

/* ── Screens ─────────────────────────────────────── */
.screen { display: none; padding: 16px; max-width: 600px; margin: 0 auto; }
.screen.active { display: block; }

/* ── Cards ───────────────────────────────────────── */
.card {
  background: var(--gray-0);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}

/* ── Form Elements ───────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-5);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 5px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1.5px solid var(--gray-3);
  border-radius: 8px;
  font-size: 15px;
  background: var(--gray-0);
  color: var(--text);
  transition: border-color .15s;
}
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--red);
}

/* ── Buttons ─────────────────────────────────────── */
.btn {
  display: block;
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: opacity .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); }
.btn-secondary {
  background: var(--gray-0);
  color: var(--text);
  border: 1.5px solid var(--gray-3);
  margin-top: 8px;
}
.btn-secondary:hover { background: var(--gray-1); }
.btn-green { background: var(--green); color: #fff; }
.btn-sm {
  display: inline-block;
  width: auto;
  padding: 6px 14px;
  font-size: 13px;
}
.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-5);
  font-size: 18px;
  padding: 4px;
}
.btn-icon:hover { color: var(--red); }

/* ── Login Screen ────────────────────────────────── */
#screen-login.active {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: calc(100vh - 56px);
}
#screen-login .hero {
  text-align: center;
  margin-bottom: 28px;
}
#screen-login .hero .emoji { font-size: 56px; line-height: 1; }
#screen-login .hero h2 { font-size: 22px; font-weight: 700; margin-top: 10px; }
#screen-login .hero p { color: var(--gray-5); font-size: 14px; margin-top: 4px; }

/* ── Einsatz-Liste ───────────────────────────────── */
.einsatz-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--gray-0);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  cursor: pointer;
  border-left: 4px solid var(--red);
  transition: box-shadow .15s;
}
.einsatz-item:hover { box-shadow: 0 4px 18px rgba(0,0,0,.13); }
.einsatz-item .ei-icon { font-size: 28px; }
.einsatz-item .ei-info { flex: 1; }
.einsatz-item .ei-title { font-size: 15px; font-weight: 600; }
.einsatz-item .ei-meta  { font-size: 12px; color: var(--gray-5); margin-top: 2px; }
.einsatz-item .ei-arrow { font-size: 20px; color: var(--gray-3); }
.badge-count {
  background: var(--red-bg);
  color: var(--red);
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
}

/* ── Fahrzeug-Grid ───────────────────────────────── */
.vehicle-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.vehicle-card {
  background: var(--gray-0);
  border-radius: 12px;
  padding: 20px 10px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  border: 0.5px solid var(--gray-2);
  position: relative;
  transition: box-shadow .15s, transform .1s;
  text-align: center;
  box-shadow:
    0 1px 0 rgba(255,255,255,.6) inset,
    0 -3px 0 rgba(0,0,0,.06) inset,
    0 3px 6px rgba(0,0,0,.10);
}
.vehicle-card:active { transform: scale(.98); }
.vehicle-card:hover {
  box-shadow:
    0 1px 0 rgba(255,255,255,.6) inset,
    0 -3px 0 rgba(0,0,0,.08) inset,
    0 5px 12px rgba(0,0,0,.14);
}
.vehicle-card.done {
  border-color: var(--green);
  box-shadow:
    0 1px 0 rgba(255,255,255,.5) inset,
    0 -3px 0 rgba(0,0,0,.10) inset,
    0 3px 6px rgba(39,174,96,.25);
}
.vehicle-card .vc-name { font-size: 18px; font-weight: 700; color: var(--text); letter-spacing: .01em; }
.vehicle-card .vc-status { font-size: 11px; color: var(--gray-5); font-weight: 500; }
.vehicle-card.done .vc-status { color: #1e8449; }
.vehicle-card .vc-count {
  position: absolute;
  top: -6px; right: -6px;
  background: var(--green);
  color: #fff;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0,0,0,.25), 0 1px 0 rgba(255,255,255,.3) inset;
  border: 2px solid var(--gray-0);
}
.vehicle-card.wache-card {
  border-style: dashed;
  border-color: var(--gray-3);
  box-shadow: none;
  background: var(--gray-1);
}
.vehicle-card.wache-card .vc-name { font-size: 14px; }
.vehicle-card.wache-card.done {
  border-style: dashed;
  border-color: var(--green);
  box-shadow: none;
}
.vehicle-card.inactive {
  box-shadow: none;
  border-style: solid;
}

/* ── Besatzungs-Liste ────────────────────────────── */
.person-list { margin: 0 -16px; }
.person-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--gray-2);
}
.person-row:last-child { border-bottom: none; }
.person-name { flex: 1; font-size: 15px; }
.cb-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 44px;
}
.cb-col label { font-size: 9px; color: var(--gray-5); text-transform: uppercase; }
.cb-col input[type=checkbox] {
  width: 22px; height: 22px;
  accent-color: var(--red);
  cursor: pointer;
}
.cb-header {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 16px 8px;
  font-size: 10px;
  color: var(--gray-5);
  text-transform: uppercase;
  font-weight: 600;
}
.cb-header span { min-width: 44px; text-align: center; }

/* ── Email-Chips ─────────────────────────────────── */
.chip-area {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px;
  background: var(--gray-1);
  border: 1.5px solid var(--gray-3);
  border-radius: 8px;
  min-height: 44px;
  margin-bottom: 8px;
}
.chip {
  background: var(--red-bg);
  color: var(--red);
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.chip .chip-x {
  cursor: pointer;
  font-size: 14px;
  opacity: .7;
  background: none;
  border: none;
  color: inherit;
  padding: 0;
  line-height: 1;
}
.chip .chip-x:hover { opacity: 1; }
.chip-input-row { display: flex; gap: 8px; }
.chip-input-row input { flex: 1; }
.chip-input-row .btn { width: auto; padding: 11px 16px; }

/* ── Kopiertext-Box ──────────────────────────────── */
#kopiertext-box {
  background: var(--gray-1);
  border: 1.5px solid var(--gray-3);
  border-radius: 8px;
  padding: 12px;
  font-family: monospace;
  font-size: 12px;
  white-space: pre;
  overflow-x: auto;
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 8px;
}

/* ── Admin ───────────────────────────────────────── */
.admin-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--gray-2);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.admin-tabs::-webkit-scrollbar { display: none; }
.admin-tab {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-5);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
  white-space: nowrap;
  flex-shrink: 0;
}
.admin-tab.active { color: var(--red); border-bottom-color: var(--red); }
.admin-tab-content { display: none; }
.admin-tab-content.active { display: block; }
.kamerad-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-2);
}
.kamerad-row:last-child { border-bottom: none; }
.kamerad-row .kr-name { flex: 1; font-size: 14px; }
.kamerad-row .kr-badges { display: flex; gap: 6px; }
.badge-agt {
  background: #FFF3CD;
  color: #856404;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
}
.badge-inaktiv {
  background: var(--gray-2);
  color: var(--gray-5);
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
}

/* ── Toast ───────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gray-8);
  color: #fff;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 14px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .25s;
  z-index: 999;
  white-space: nowrap;
}
#toast.show { opacity: 1; }

/* ── Loading ─────────────────────────────────────── */
.spinner {
  border: 3px solid var(--gray-2);
  border-top-color: var(--red);
  border-radius: 50%;
  width: 32px; height: 32px;
  animation: spin .7s linear infinite;
  margin: 32px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.section-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--gray-5);
  margin: 16px 0 8px;
}
.info-hint {
  background: var(--red-bg);
  border-left: 3px solid var(--red);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--red);
  margin-bottom: 14px;
}
.success-box {
  background: var(--green-bg);
  border-left: 3px solid var(--green);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 13px;
  color: #155724;
  margin-bottom: 14px;
}

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 420px) {
  .vehicle-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
}
@media (min-width: 540px) {
  .vehicle-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ── Druckansicht ────────────────────────────────── */
#print-only-container { display: none; }

@media print {
  @page { size: A5 landscape; margin: 12mm 14mm; }

  html, body {
    margin: 0 !important;
    padding: 0 !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
  }

  body > *:not(#print-only-container) { display: none !important; }

  #print-only-container {
    display: block !important;
    position: static !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  #print-only-container * {
    min-height: 0 !important;
  }
  #print-only-container #druck-fragment {
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
  }
}
