/* Retourenportal — neutrale Basis. Brand-Farbe kommt via --primary-color
   aus dem JS, das die Branding-Response auswertet. */
:root {
  --primary-color: #1a1a1a;
  --primary-color-hover: #333;
  --bg: #fafafa;
  --surface: #ffffff;
  --text: #1a1a1a;
  --text-muted: #666;
  --border: #e0e0e0;
  --error: #c0392b;
  --success: #27ae60;
  --radius: 8px;
  --max-width: 720px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.portal-header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.portal-header img {
  height: 80px;
  max-width: 80%;
  width: auto;
}

.portal-header img[src=""],
.portal-header img:not([src]) { display: none; }

@media (max-width: 600px) {
  .portal-header { padding: 20px 16px; }
  .portal-header img { height: 56px; }
}

.portal-main {
  max-width: var(--max-width);
  margin: 32px auto;
  padding: 0 24px;
}

.view {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

h2 {
  margin: 0 0 16px;
  font-size: 1.4rem;
  font-weight: 600;
}

.hint, .order-context {
  color: var(--text-muted);
  margin: 0 0 20px;
}

.order-context strong { color: var(--text); }

form label {
  display: block;
  margin-bottom: 16px;
  font-weight: 500;
}

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

.info-btn {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: var(--text-muted);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  font-style: italic;
  font-family: Georgia, serif;
  cursor: pointer;
  padding: 0;
  line-height: 18px;
  text-align: center;
  transition: background 0.15s;
}

.info-btn:hover, .info-btn[aria-expanded="true"] {
  background: var(--primary-color);
}

.info-popover {
  margin: -8px 0 16px;
  padding: 12px 14px;
  background: rgba(0,0,0,0.04);
  border-left: 3px solid var(--primary-color);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.5;
}

.info-popover a {
  color: var(--primary-color);
  text-decoration: underline;
}

input[type="text"], textarea, select {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  margin-top: 6px;
}

input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: -2px;
  border-color: transparent;
}

textarea { resize: vertical; min-height: 60px; }

.optional { color: var(--text-muted); font-weight: 400; }

.btn-primary, .btn-secondary {
  font: inherit;
  font-weight: 500;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
}

.btn-primary {
  background: var(--primary-color);
  color: #fff;
}

.btn-primary:hover { background: var(--primary-color-hover); }

.btn-primary:disabled, .btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover { background: #f5f5f5; }

.actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  justify-content: space-between;
}

.error {
  color: var(--error);
  background: rgba(192, 57, 43, 0.08);
  padding: 12px;
  border-radius: var(--radius);
  margin-top: 16px;
  font-size: 0.95rem;
}

.frist-hint {
  margin-top: 24px;
  padding: 12px 16px;
  background: rgba(0,0,0,0.04);
  border-radius: var(--radius);
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Positions-Liste */
.position-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: start;
}

.position-card.selected {
  border-color: var(--primary-color);
  background: rgba(0,0,0,0.02);
}

/* View "choice" — Umtausch vs Rückgabe */
.choice-list {
  display: grid;
  gap: 16px;
  margin: 24px 0;
}

.choice-card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: border-color 0.15s, background 0.15s;
}

.choice-card:hover,
.choice-card:focus-visible {
  border-color: var(--primary-color);
  background: rgba(0,0,0,0.02);
  outline: none;
}

.choice-card h3 {
  margin: 0 0 6px;
  font-size: 1.1rem;
  font-weight: 600;
}

.choice-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Tausch-Artikel-Picker (Exchange-Modus) */
.exchange-picker {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.exchange-picker .picker-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-bottom: 4px;
}

.exchange-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  background: var(--surface);
  transition: border-color 0.15s, background 0.15s;
}

.exchange-option:hover {
  border-color: var(--primary-color);
}

.exchange-option.selected {
  border-color: var(--primary-color);
  background: rgba(0,0,0,0.03);
}

.exchange-option input[type="radio"] {
  margin: 0;
}

.exchange-option img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 4px;
  background: #f0f0f0;
  flex-shrink: 0;
}

.exchange-option .opt-info {
  flex: 1;
  min-width: 0;
}

.exchange-option .opt-name {
  font-size: 0.95rem;
  font-weight: 500;
  margin: 0 0 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.exchange-option .opt-sku {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.exchange-option .opt-stock-warning {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 2px;
}

.position-card.blocked {
  grid-template-columns: 1fr;
  background: rgba(0,0,0,0.025);
  opacity: 0.78;
}

.position-card.blocked .product-image {
  filter: grayscale(0.4);
}

.blocked-notice {
  margin-top: 12px;
  padding: 10px 14px;
  background: rgba(0,0,0,0.06);
  border-left: 3px solid var(--text-muted);
  border-radius: var(--radius);
  font-size: 0.9rem;
  color: var(--text-muted);
}

.product-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.product-image {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 6px;
  background: #f0f0f0;
  flex-shrink: 0;
}

.position-info h3 {
  margin: 0 0 4px;
  font-size: 1rem;
  font-weight: 600;
}

.position-info .meta {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.position-controls {
  text-align: right;
}

.position-controls label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 400;
}

.position-controls .qty-row {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}

.position-controls select {
  width: 70px;
  margin: 0;
}

.reason-select {
  margin-top: 12px;
  display: none;
}

.position-card.selected .reason-select { display: block; }

.reason-select select {
  width: 100%;
  margin-top: 4px;
}

.reason-select textarea {
  margin-top: 8px;
  font-size: 0.9rem;
}

.global-comment {
  margin: 24px 0 0;
}

.global-comment label { margin: 0; }

.loading {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  z-index: 100;
}

/* `display: flex` würde sonst das HTML-`hidden`-Attribut überschreiben.
   Gleiche Falle bei jedem Element, das ein nicht-default `display` hat. */
[hidden] { display: none !important; }

.mailbox-block {
  margin: 0 0 28px;
  font-size: 1rem;
  color: var(--text);
  line-height: 1.5;
}

.retoure-nr {
  font-size: 1.6rem;
  font-weight: 700;
  background: rgba(0,0,0,0.04);
  padding: 16px;
  border-radius: var(--radius);
  text-align: center;
  margin: 16px 0;
  letter-spacing: 0.05em;
}

.return-address {
  background: rgba(0,0,0,0.04);
  padding: 16px;
  border-radius: var(--radius);
  font-family: inherit;
  white-space: pre-wrap;
  margin: 12px 0 24px;
}

.info {
  background: rgba(0,0,0,0.04);
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 1rem;
  color: var(--text);
}

.portal-footer {
  display: flex;
  gap: 24px;
  justify-content: center;
  padding: 24px;
  margin-top: 32px;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}

.portal-footer a {
  color: var(--text-muted);
  text-decoration: none;
}

.portal-footer a:hover { color: var(--text); text-decoration: underline; }

@media (max-width: 600px) {
  .view { padding: 20px; }
  .position-card { grid-template-columns: 1fr; }
  .position-controls { text-align: left; }
  .position-controls .qty-row { justify-content: flex-start; }
  .actions { flex-direction: column-reverse; }
  .actions button { width: 100%; }
}
