/* ============================================================
 * Etikettenkontrolle — Styles
 *
 * Wird sowohl im Kiosk (chargenverfolgung-kiosk.html) als auch in
 * der Admin-App (index.html → Betrieb → Etikettenkontrolle) geladen.
 * ============================================================ */

/* Wichtig: das HTML-Attribut [hidden] muss display:flex/grid besiegen,
   sonst bleiben Lightbox/Reject/Skip/Config-Modal sichtbar. */
.ek-lightbox[hidden],
.ek-reject-modal[hidden],
.ek-config-modal[hidden],
.etiketten-skip-modal[hidden] {
  display: none !important;
}


/* =================================================================
 * KIOSK: screen-etiketten-foto
 * Helles Theme passend zu .abschluss-panel (var(--panel)/var(--text)).
 * Layout: Panel = Flex-Column; Header oben, Liste scrollt, Buttons unten.
 * ================================================================= */

.etiketten-foto-panel {
  width: min(1100px, 100%);
  max-height: calc(100vh - 140px);    /* topbar ~110px + Sicherheits-Puffer */
  display: flex;
  flex-direction: column;
  overflow: hidden;                   /* Liste übernimmt das Scrolling */
}

.etiketten-foto-panel .eyebrow,
.etiketten-foto-panel h1,
.etiketten-foto-panel #etiketten-foto-fortschritt {
  flex: 0 0 auto;
}

#etiketten-foto-fortschritt {
  font-size: 14px;
  margin: 0 0 8px;
  color: #475569;
}

.etiketten-foto-liste {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-right: 4px;
  margin: 8px 0 14px;
}

.etiketten-anlage-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 12px 16px;
}

.etiketten-anlage-name {
  font-weight: 800;
  font-size: 16px;
  margin-bottom: 10px;
  color: #0f172a;
}

.etiketten-slots {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.etiketten-slot {
  background: #fff;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 160px;
  transition: border-color 0.2s, background 0.2s;
}

.etiketten-slot-done    { border-color: #16a34a; background: #f0fdf4; }
.etiketten-slot-skipped { border-color: #f59e0b; background: #fffbeb; }
.etiketten-slot-error   { border-color: #dc2626; background: #fef2f2; }
.etiketten-slot-uploading { border-color: #3b82f6; }

.etiketten-slot-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  color: #0f172a;
  font-size: 14px;
}

.etiketten-pflicht {
  background: #dc2626;
  color: #fff;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 800;
  letter-spacing: 0.3px;
}

.etiketten-optional {
  background: #e2e8f0;
  color: #475569;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 700;
}

.etiketten-slot-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  justify-content: center;
  align-items: center;
}

.etiketten-slot-body button {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: none;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}

.etiketten-btn-foto {
  background: #3b82f6;
  color: #fff;
}
.etiketten-btn-foto:hover { background: #2563eb; }

.etiketten-btn-skip {
  background: #f1f5f9;
  color: #334155;
}
.etiketten-btn-skip:hover { background: #e2e8f0; }

.etiketten-btn-erneut {
  background: #e2e8f0;
  color: #334155;
}

.etiketten-thumb {
  width: 100%;
  max-height: 100px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
}

.etiketten-slot-info {
  color: #16a34a;
  font-weight: 700;
  font-size: 14px;
}

.etiketten-skip-info {
  font-size: 24px;
  color: #b45309;
  font-weight: 800;
}

.etiketten-skip-grund {
  font-size: 12px;
  color: #92400e;
  text-align: center;
  padding: 0 8px;
}

.etiketten-uploading {
  color: #2563eb;
  font-weight: 700;
  animation: ekPulse 1.2s ease-in-out infinite;
}

.etiketten-error {
  color: #b91c1c;
  font-weight: 700;
  text-align: center;
  font-size: 13px;
}

@keyframes ekPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.etiketten-foto-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 8px;
  padding: 0 8px;
  box-sizing: border-box;
}

.etiketten-foto-actions button {
  border-radius: 10px;
  border: none;
  cursor: pointer;
  color: #fff;
  font-weight: 800;
}

#etiketten-foto-zurueck {
  flex: 0 0 auto;
  padding: 12px 22px;
  font-size: 14px;
  min-width: 120px;
  max-width: 200px;
  background: #475569;
}

#etiketten-foto-weiter {
  flex: 0 1 auto;
  padding: 16px 48px;
  font-size: 16px;
  min-width: 280px;
  max-width: 100%;
  background: #16a34a;
  border-radius: 12px;
}

#etiketten-foto-weiter:disabled {
  background: #cbd5e1;
  color: #64748b;
  cursor: not-allowed;
}

/* iPad 11" Portrait / kleinere Tablets: kompakter */
@media (max-height: 900px) {
  .etiketten-foto-panel { max-height: calc(100vh - 130px); padding: 18px 22px; }
  .etiketten-anlage-card { padding: 10px 12px; }
  .etiketten-slots { gap: 8px; }
  .etiketten-slot { min-height: 140px; padding: 8px; }
  .etiketten-thumb { max-height: 80px; }
  #etiketten-foto-zurueck { padding: 10px 18px; font-size: 13px; min-width: 100px; }
  #etiketten-foto-weiter { padding: 14px 36px; font-size: 15px; min-width: 240px; }
}

/* Schmal: bei sehr engen iPads / Hochformat → Buttons untereinander */
@media (max-width: 600px) {
  .etiketten-foto-actions { gap: 8px; padding: 0 4px; }
  #etiketten-foto-weiter {
    width: 100%;
    min-width: 0;
    order: 1;             /* primärer Knopf zuerst */
  }
  #etiketten-foto-zurueck {
    width: 100%;
    max-width: 100%;
    order: 2;             /* unter dem grünen */
    background: #94a3b8;
  }
}


/* ----- Kiosk: Skip-Modal ----------------------------------------- */

.etiketten-skip-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.etiketten-skip-content {
  background: #1e293b;
  color: #fff;
  padding: 24px;
  border-radius: 14px;
  width: min(440px, 92vw);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.etiketten-skip-content h2 {
  margin: 0 0 4px;
  font-size: 18px;
}

.etiketten-skip-content label {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.75);
}

.etiketten-skip-content select,
.etiketten-skip-content textarea {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  border-radius: 8px;
  padding: 10px;
  font-size: 15px;
  font-family: inherit;
  resize: vertical;
}

.etiketten-skip-content textarea { min-height: 80px; }

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

.etiketten-skip-actions button {
  padding: 10px 18px;
  border-radius: 8px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
}

#etiketten-skip-confirm {
  background: #f59e0b;
}


/* =================================================================
 * ADMIN: Etikettenkontrolle-View (in index.html)
 * ================================================================= */

.ek-card {
  padding: 20px;
}

.ek-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.ek-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ek-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.ek-kpi {
  background: #f1f5f9;
  border-left: 4px solid #64748b;
  border-radius: 8px;
  padding: 12px 14px;
}

.ek-kpi-label {
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 700;
  color: #475569;
  letter-spacing: 0.5px;
}

.ek-kpi-value {
  font-size: 28px;
  font-weight: 800;
  color: #0f172a;
  line-height: 1;
  margin-top: 4px;
}

.ek-kpi-ok { border-left-color: #16a34a; background: #dcfce7; }
.ek-kpi-bad { border-left-color: #dc2626; background: #fee2e2; }
.ek-kpi-skip { border-left-color: #f59e0b; background: #fef3c7; }

.ek-filterbar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  align-items: end;
  margin-bottom: 18px;
  padding: 12px;
  background: #f8fafc;
  border-radius: 10px;
}

.ek-filterbar label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
}

.ek-filterbar input,
.ek-filterbar select {
  padding: 8px;
  font-size: 14px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
}

.ek-filter-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-self: end;
}

.ek-grid {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.ek-anlage {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px 16px;
}

.ek-anlage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.ek-anlage-title {
  font-weight: 700;
  font-size: 16px;
  color: #0f172a;
}

.ek-anlage-bulk-ok {
  font-size: 13px;
  padding: 6px 12px;
  white-space: nowrap;
}

.ek-cards {
  display: grid;
  gap: 12px;
}

/* Drei Größenstufen für den QK-Workflow */
.ek-cards-small  { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.ek-cards-medium { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.ek-cards-large  { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }

.ek-cards-small  .ek-card-thumb,
.ek-cards-small  .ek-card-skip { height: 100px; }
.ek-cards-medium .ek-card-thumb,
.ek-cards-medium .ek-card-skip { height: 140px; }
.ek-cards-large  .ek-card-thumb,
.ek-cards-large  .ek-card-skip { height: 240px; }

.ek-cards-small .ek-card-title { font-size: 11px; }
.ek-cards-large .ek-card-title { font-size: 14px; }

/* Größen-Umschalter in der Filter-Action-Leiste */
.ek-size-toggle {
  display: inline-flex;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  overflow: hidden;
  height: 36px;
  flex: 0 0 auto;        /* nicht im flex-Container strecken */
  width: max-content;
  margin-right: 4px;
}
.ek-size-btn {
  background: #fff;
  border: none;
  padding: 0;
  width: 36px;            /* fixe Breite pro Button */
  height: 100%;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  color: #475569;
  border-right: 1px solid #cbd5e1;
  flex: 0 0 36px;         /* nicht aus dem Container herausstrecken */
}
.ek-size-btn:last-child { border-right: none; }
.ek-size-btn.active {
  background: #4f46e5;
  color: #fff;
}
.ek-size-btn:hover:not(.active) { background: #f1f5f9; }

.ek-card-title {
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: -2px 0 4px;
}

.ek-card-foto {
  background: #fff;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.ek-card-foto:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.ek-card-status-ok { border-color: #16a34a; }
.ek-card-status-abgelehnt { border-color: #dc2626; }
.ek-card-status-offen { border-color: #f59e0b; }

.ek-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
}

.ek-card-typ {
  background: #0f172a;
  color: #fff;
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 11px;
  letter-spacing: 0.3px;
}

.ek-card-karton .ek-card-typ { background: #1d4ed8; }
.ek-card-beutel .ek-card-typ { background: #7c3aed; }
.ek-card-uebersprungen .ek-card-typ { background: #f59e0b; }

.ek-card-status {
  font-size: 11px;
  font-weight: 700;
  color: #475569;
}

.ek-card-status-ok .ek-card-status { color: #16a34a; }
.ek-card-status-abgelehnt .ek-card-status { color: #dc2626; }
.ek-card-status-offen .ek-card-status { color: #d97706; }

.ek-card-thumb {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: 6px;
  cursor: zoom-in;
  background: #f1f5f9;
}

.ek-card-skip {
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fef3c7;
  color: #92400e;
  border-radius: 6px;
  font-size: 36px;
  font-weight: 800;
  flex-direction: column;
}

.ek-card-skip-grund {
  font-size: 12px;
  font-weight: 600;
  margin-top: 4px;
  text-align: center;
  padding: 0 8px;
  color: #78350f;
}

.ek-card-bemerkung {
  font-size: 12px;
  color: #b91c1c;
  background: #fee2e2;
  padding: 6px 8px;
  border-radius: 6px;
}

.ek-card-result {
  font-size: 11px;
  color: #475569;
  flex: 1;
}

.ek-card-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.ek-card-actions button {
  padding: 6px 10px;
  font-size: 13px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  flex: 1;
}


/* ----- Lightbox -------------------------------------------------- */

.ek-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ek-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
}

.ek-lightbox-content {
  position: relative;
  max-width: 92vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.ek-lightbox-content img {
  max-width: 92vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
}

.ek-lightbox-close {
  position: absolute;
  top: -36px;
  right: 0;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: none;
  font-size: 32px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  line-height: 1;
}

.ek-lightbox-info {
  color: #fff;
  font-size: 14px;
  text-align: center;
  background: rgba(0, 0, 0, 0.45);
  padding: 8px 14px;
  border-radius: 8px;
}


/* ----- Reject Modal --------------------------------------------- */

.ek-reject-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(15, 23, 42, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ek-reject-content {
  background: #fff;
  border-radius: 12px;
  padding: 22px;
  width: min(460px, 92vw);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ek-reject-content h3 {
  margin: 0;
  color: #dc2626;
}

.ek-reject-content textarea {
  min-height: 100px;
  padding: 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
}

.ek-reject-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}


/* ----- Konfig-Modal --------------------------------------------- */

.ek-config-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ek-config-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
}

.ek-config-content {
  position: relative;
  background: #fff;
  border-radius: 14px;
  width: min(720px, 95vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ek-config-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ek-config-header h2 {
  margin: 0;
  font-size: 18px;
}

.ek-config-close {
  background: transparent;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: #64748b;
  line-height: 1;
}

.ek-config-body {
  padding: 18px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ek-cfg-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ek-cfg-row > span {
  font-size: 13px;
  font-weight: 600;
  color: #475569;
}

.ek-cfg-row input[type=text],
.ek-cfg-row input[type=number] {
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 14px;
}

.ek-cfg-check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.ek-cfg-grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.ek-cfg-section {
  border-top: 1px solid #e2e8f0;
  padding-top: 14px;
  margin-top: 6px;
}

.ek-cfg-section h3 {
  margin: 0 0 4px;
  font-size: 15px;
}

.ek-cfg-anlagen-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}

.ek-cfg-anlagen-table th,
.ek-cfg-anlagen-table td {
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid #f1f5f9;
  font-size: 14px;
}

.ek-cfg-anlagen-table th {
  background: #f8fafc;
  font-weight: 700;
  color: #475569;
  font-size: 12px;
}

.ek-cfg-skipgruende {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}

.ek-cfg-skip-row {
  display: flex;
  gap: 6px;
}

.ek-cfg-skip-row input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
}

.ek-cfg-skip-del {
  padding: 4px 10px;
  font-size: 18px;
  line-height: 1;
}

.ek-config-footer {
  padding: 14px 20px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: #f8fafc;
}

.alert-error {
  background: #fee2e2;
  color: #991b1b;
  padding: 12px 16px;
  border-radius: 8px;
  border-left: 4px solid #dc2626;
}

/* Vorstufe Schichtleiter-Freigabe (chargenverfolgung-sl-etiketten.js).
   OK-Fotos sind fuer die QK erledigt, NIO-Fotos landen genau deshalb hier. */
.ek-card-sl {
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
  padding: 5px 8px;
  border-radius: 6px;
  margin-top: 6px;
}
.ek-card-sl.ok { background: #dcfce7; color: #166534; }
.ek-card-sl.bad { background: #fee2e2; color: #991b1b; }
.ek-card-sl .dim { font-weight: 400; opacity: .75; }
