/**
 * ArticlePicker — Styling für die zentrale Artikel-Auswahlkomponente
 * Verwendet in allen Positionseditoren (Angebot, Auftrag, Lieferschein, Rechnung).
 */

/* ── Input ──────────────────────────────────────────────────────────────── */

.ap-input {
  position: relative;
}

.ap-input--loading {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 50 50'%3E%3Cpath fill='%23999' d='M25 5A20 20 0 1 0 45 25' stroke='%23999' stroke-width='4' fill='none'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 25 25' to='360 25 25' dur='0.8s' repeatCount='indefinite'/%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  background-size: 14px 14px;
  padding-right: 26px !important;
}

/* ── Dropdown ───────────────────────────────────────────────────────────── */

.ap-dropdown {
  position: absolute;
  z-index: 10000;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15), 0 2px 6px rgba(0, 0, 0, 0.08);
  max-height: 400px;
  overflow-y: auto;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
}

/* Scrollbar */
.ap-dropdown::-webkit-scrollbar {
  width: 6px;
}
.ap-dropdown::-webkit-scrollbar-track {
  background: transparent;
}
.ap-dropdown::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}
.ap-dropdown::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* ── Results Header ─────────────────────────────────────────────────────── */

.ap-results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px 4px;
  border-bottom: 1px solid #f0f0f0;
  font-size: 11px;
  color: #6b7280;
}

.ap-results-count {
  font-weight: 600;
  color: #374151;
}

.ap-results-hint {
  font-size: 10px;
  color: #9ca3af;
}

/* ── Result List ────────────────────────────────────────────────────────── */

.ap-results-list {
  list-style: none;
  margin: 0;
  padding: 4px 0;
}

/* ── Result Item ────────────────────────────────────────────────────────── */

.ap-result-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f8f9fa;
  transition: background-color 0.1s ease;
}

.ap-result-item:last-child {
  border-bottom: none;
}

.ap-result-item:hover,
.ap-result-item--highlighted {
  background: #f0f4ff;
}

.ap-result-item--highlighted {
  outline: 2px solid #3b82f6;
  outline-offset: -2px;
  border-radius: 4px;
}

.ap-result-item--inactive {
  opacity: 0.55;
}

.ap-result-item--warning {
  border-left: 3px solid #f59e0b;
}

/* ── Result Main (Artikelnr + Name) ─────────────────────────────────────── */

.ap-result-main {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}

.ap-result-artnr {
  font-weight: 700;
  font-size: 13px;
  color: #1e3a5f;
  white-space: nowrap;
  min-width: 80px;
  font-variant-numeric: tabular-nums;
}

.ap-result-name {
  font-size: 13px;
  color: #374151;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Result Details (Einheit, Preis, Hersteller, Lager) ─────────────────── */

.ap-result-details {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 2px;
}

.ap-result-detail {
  font-size: 11px;
  color: #6b7280;
  white-space: nowrap;
}

.ap-result-detail-label {
  color: #9ca3af;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.ap-result-detail--stock {
  color: #059669;
  font-weight: 600;
}

.ap-missing {
  color: #ef4444;
  font-style: italic;
  font-size: 11px;
}

/* ── Warnungen ──────────────────────────────────────────────────────────── */

.ap-result-warnings {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.ap-warning-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  color: #92400e;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 4px;
  padding: 1px 6px;
  white-space: nowrap;
}

/* ── No Result ──────────────────────────────────────────────────────────── */

.ap-no-result {
  padding: 20px 16px;
  text-align: center;
  color: #6b7280;
}

.ap-no-result-icon {
  font-size: 24px;
  display: block;
  margin-bottom: 8px;
}

.ap-no-result-text {
  font-size: 13px;
  margin: 0 0 4px;
}

.ap-no-result-text strong {
  color: #374151;
}

.ap-no-result-hint {
  font-size: 11px;
  color: #9ca3af;
  margin: 0;
}

/* ── Error ──────────────────────────────────────────────────────────────── */

.ap-error {
  padding: 12px 16px;
  color: #dc2626;
  font-size: 12px;
  text-align: center;
}

.ap-error-icon {
  font-size: 16px;
}

/* ── Anpassung für Position-Table-Engine ────────────────────────────────── */

.pte-cell .ap-input {
  border: none;
  background: transparent;
  padding: 2px 4px;
  font-size: inherit;
  font-family: inherit;
  width: 100%;
  outline: none;
}

.pte-cell .ap-input:focus {
  background: #fff;
  box-shadow: inset 0 0 0 2px #3b82f6;
  border-radius: 3px;
}

.pte-cell .ap-input--loading {
  background-color: #fff;
}

/* ── Dark Mode Support (optional) ───────────────────────────────────────── */

@media (prefers-color-scheme: dark) {
  .ap-dropdown {
    background: #1f2937;
    border-color: #374151;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    color: #e5e7eb;
  }

  .ap-results-header {
    border-color: #374151;
    color: #9ca3af;
  }

  .ap-results-count {
    color: #e5e7eb;
  }

  .ap-result-item {
    border-color: #374151;
  }

  .ap-result-item:hover,
  .ap-result-item--highlighted {
    background: #1e3a5f;
  }

  .ap-result-artnr {
    color: #60a5fa;
  }

  .ap-result-name {
    color: #d1d5db;
  }

  .ap-result-detail {
    color: #9ca3af;
  }

  .ap-result-detail-label {
    color: #6b7280;
  }

  .ap-no-result {
    color: #9ca3af;
  }

  .ap-no-result-text strong {
    color: #e5e7eb;
  }

  .ap-warning-badge {
    background: #78350f;
    border-color: #92400e;
    color: #fbbf24;
  }

  .ap-missing {
    color: #f87171;
  }
}
