/* Werksverkauf Partner-Portal */

:root {
  --bg: #f6f4f0;
  --surface: #ffffff;
  --surface-muted: #f1eee8;
  --border: #e2ddd3;
  --text: #1f2328;
  --text-muted: #5f6670;
  /* Accent of the macOS app; dark text on it for readable contrast */
  --accent: #8eae3c;
  --accent-hover: #7c9a30;
  --accent-text: #5f7a1f;
  --accent-soft: #eef4dd;
  --on-accent: #1f2328;
  --success: #2f7a4b;
  --success-soft: #e3f2e8;
  --warning: #9a6200;
  --warning-soft: #fbf0d9;
  --error: #b42318;
  --error-soft: #fde8e6;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(31, 35, 40, 0.06), 0 4px 16px rgba(31, 35, 40, 0.05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--font);
}

a { color: var(--accent-text); }
a:hover { color: var(--text); }

h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 1em; }

[hidden] { display: none !important; }

/* MARK: - Layout */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text span { font-size: 0.85rem; color: var(--text-muted); }

.site-nav { display: flex; align-items: center; gap: 18px; }

.site-nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
}

.site-nav a:hover, .site-nav a.is-active { color: var(--text); }
.site-nav a.is-active { border-bottom: 2px solid var(--accent); }

main {
  flex: 1;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 16px 48px;
}

main.narrow { max-width: 440px; }

.site-footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.875rem;
}

.site-footer nav { display: flex; gap: 16px; }
.site-footer a { color: var(--text-muted); }

#loading {
  flex: 1;
  display: grid;
  place-items: center;
  color: var(--text-muted);
}

/* MARK: - Cards */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 24px;
}

.card > :last-child { margin-bottom: 0; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.page-head h1 { margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--text-muted); }

.muted { color: var(--text-muted); }
.small { font-size: 0.875rem; }

/* MARK: - Forms */

.form-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 16px;
}

.field { display: flex; flex-direction: column; gap: 6px; grid-column: span 6; }
.field.span-2 { grid-column: span 2; }
.field.span-3 { grid-column: span 3; }
.field.span-4 { grid-column: span 4; }

label, .label { font-weight: 600; font-size: 0.925rem; }
.hint { color: var(--text-muted); font-size: 0.85rem; font-weight: 400; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="tel"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

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

input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 1px;
}

.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-weight: 500;
}

.checkbox input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--accent); }

fieldset {
  border: 0;
  padding: 0;
  margin: 0;
}

.section-title {
  margin: 8px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  grid-column: span 6;
}

.section-title:first-child { border-top: 0; padding-top: 0; margin-top: 0; }

/* MARK: - Buttons */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.button:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.button:disabled { opacity: 0.6; cursor: progress; }

.button.secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.button.secondary:hover { background: var(--accent-soft); color: var(--text); }

.button.danger {
  background: var(--surface);
  color: var(--error);
  border-color: var(--error-soft);
}

.button.danger:hover { background: var(--error-soft); color: var(--error); }

.button.full { width: 100%; }

.button-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.link-button {
  border: 0;
  background: none;
  padding: 0;
  color: var(--text-muted);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

.link-button:hover { color: var(--text); }

/* MARK: - Messages */

.message {
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 0.95rem;
}

.message-error { background: var(--error-soft); color: var(--error); }
.message-success { background: var(--success-soft); color: var(--success); }
.message-info { background: var(--surface-muted); color: var(--text); }
.message-warning { background: var(--warning-soft); color: var(--warning); }

/* MARK: - Location list */

.location-list { list-style: none; margin: 0; padding: 0; }

.location-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.location-item:last-child { border-bottom: 0; }

.location-logo {
  flex: none;
  width: 52px;
  height: 52px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  object-fit: contain;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  font-weight: 700;
  overflow: hidden;
}

.location-main { flex: 1; min-width: 0; }
.location-main strong { display: block; overflow-wrap: anywhere; }
.location-main span { color: var(--text-muted); font-size: 0.9rem; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-left: 6px;
  vertical-align: middle;
}

.badge-hidden { background: var(--warning-soft); color: var(--warning); }

.empty-state { color: var(--text-muted); margin: 0; }

/* MARK: - Map */

.map {
  height: 320px;
  border-radius: 8px;
  border: 1px solid var(--border);
  z-index: 0;
}

/* MARK: - Image galleries */

.gallery {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-muted);
}

.gallery-items {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}

.gallery.is-empty .gallery-items { display: none; }

.gallery-item {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.gallery-item img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: #fff;
}

.gallery-item button {
  width: 100%;
  border: 0;
  border-top: 1px solid var(--border);
  padding: 6px;
  background: var(--surface);
  color: var(--error);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}

.gallery-item button:hover { background: var(--error-soft); }

.file-button input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.file-button { position: relative; }

.gallery-status { margin: 8px 0 0; font-size: 0.85rem; }

/* MARK: - Terms */

.terms {
  max-height: 360px;
  overflow-y: auto;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-muted);
  margin-bottom: 16px;
  font-size: 0.95rem;
}

.terms ol { padding-left: 20px; margin: 0; }
.terms li { margin-bottom: 10px; }

/* MARK: - Sticky save bar */

.save-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 24px;
  margin: 0 -24px -24px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* MARK: - Small screens */

@media (max-width: 640px) {
  .site-header { padding: 12px 16px; }
  .card { padding: 18px; }
  .save-bar { margin: 0 -18px -18px; padding: 12px 18px; }
  .field.span-2, .field.span-3, .field.span-4 { grid-column: span 6; }
  h1 { font-size: 1.35rem; }
}

.section-desc { margin: 4px 0 0; color: var(--text-muted); font-size: 0.925rem; }
