/* Umfrage-Modul: baut auf style.css auf (Variablen, Panels, Buttons, Tabellen, Dark-Mode). */

.umf-page, .umf-public {
  --surface: #fff;
  --surface-2: #f5f5f5;
  --line: #ddd;
  --line-soft: #eee;
}

html.dark-mode {
  background-color: #282b30 !important;
}

body.dark-mode {
  background-color: #282b30 !important;
  color: var(--text);
  --surface: #32363d;
  --surface-2: #24272d;
  --line: #1f2227;
  --line-soft: #1f2227;
}

body.dark-mode .save-bar {
  background: #32363d !important;
  border-top-color: #1f2227 !important;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, .4);
}

/* ========== Rahmen ========== */
.umf-wrap { max-width: 1000px; margin: 20px auto; padding: 0 16px 110px; }
.umf-wrap .panel { margin-bottom: 16px; }
.umf-pad { padding: 16px; }
.umf-muted { color: var(--muted); font-size: .9rem; }
.umf-toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.nowrap { white-space: nowrap; }

.umf-pill { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: .8rem; font-weight: 700; color: #fff; }
.umf-pill.open { background: var(--ok); }
.umf-pill.closed { background: var(--muted); }

.umf-table-flat { box-shadow: none; border-radius: 0; background: transparent; }
body.dark-mode .umf-table-flat { background: transparent; }
.umf-title-link { font-weight: 700; color: var(--primary); text-decoration: none; }
.umf-title-link:hover { text-decoration: underline; }
.umf-row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.umf-wrap .btn { min-height: 36px; }
.umf-wrap .btn-small { min-height: 34px; }

/* ========== Eingabefelder ========== */
.umf-input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 1rem; background: var(--surface); color: var(--text);
}
.umf-input:focus, .umf-wrap input:focus, .umf-wrap select:focus, .umf-wrap textarea:focus {
  outline: 2px solid var(--accent-active); outline-offset: 1px;
}
.umf-wrap .form-group input[type="text"], .umf-wrap .form-group textarea {
  background: var(--surface); color: var(--text); border-color: var(--line);
}
.umf-title-input { font-size: 1.3rem !important; font-weight: 700; }
.umf-settings { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 4px; }
.umf-warn {
  margin-top: 12px; padding: 10px 12px; border-left: 4px solid var(--warn);
  background: rgba(255, 152, 0, .12); border-radius: 6px; font-size: .92rem;
}

/* Schalter (Checkbox mit Beschriftung) */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; min-height: 40px; user-select: none; }
.switch input { width: 20px; height: 20px; accent-color: var(--primary); cursor: pointer; }

/* ========== Editor: Fragenkarten ========== */
.q-card {
  background: var(--surface); border: 1px solid var(--line); border-left: 5px solid transparent;
  border-radius: 10px; box-shadow: 0 2px 10px rgba(0, 0, 0, .08); padding: 16px; margin-bottom: 16px;
}
.q-card:focus-within { border-left-color: var(--accent-active); }
.q-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.q-num { font-weight: 700; color: var(--primary); }
.q-type { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); font-size: .95rem; }
.q-label { font-size: 1.05rem !important; font-weight: 600; }
.q-card .form-group { margin-bottom: 10px; }

.q-options { margin: 6px 0 4px; }
.opt-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.opt-row input[type="text"] { flex: 1; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); font-size: .98rem; }
.opt-mark { width: 18px; height: 18px; border: 2px solid var(--muted); flex-shrink: 0; text-align: center; font-size: .8rem; line-height: 14px; color: var(--muted); }
.opt-mark.radio { border-radius: 50%; }
.opt-mark.checkbox { border-radius: 4px; }
.opt-mark.select { border: 0; width: 22px; font-weight: 700; line-height: 18px; }
.icon-btn {
  min-width: 36px; min-height: 36px; border: 1px solid transparent; background: transparent; color: var(--muted);
  border-radius: 6px; cursor: pointer; font-size: 1rem;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }

.q-preview { color: var(--muted); border-bottom: 1px dashed var(--line); padding: 8px 2px; margin: 6px 0 4px; max-width: 60%; }
.q-scale-cfg { display: grid; grid-template-columns: 140px 1fr 1fr; gap: 10px; align-items: end; margin: 6px 0 4px; }
.q-scale-cfg label { font-size: .85rem; color: var(--muted); display: block; margin-bottom: 4px; }
.q-scale-cfg select, .q-scale-cfg input { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); }

.q-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; border-top: 1px solid var(--line-soft); margin-top: 12px; padding-top: 8px; }
.q-tools { display: flex; gap: 2px; }
.q-add { text-align: center; margin: 4px 0 8px; }

/* Speichern-Leiste */
.save-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; background: var(--surface);
  border-top: 1px solid var(--line); box-shadow: 0 -2px 10px rgba(0, 0, 0, .12); padding: 10px 16px;
}
.save-bar-inner { max-width: 1000px; margin: 0 auto; display: flex; align-items: center; justify-content: flex-end; gap: 14px; flex-wrap: wrap; }
.save-msg { margin-right: auto; font-size: .92rem; color: var(--muted); }
.save-msg.err { color: var(--error); font-weight: 700; }
.save-msg.ok { color: var(--ok); font-weight: 700; }
.save-links a { color: var(--primary); font-weight: 700; margin-right: 12px; text-decoration: none; }
.save-links a:hover { text-decoration: underline; }

.umf-toast {
  position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: #333; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 200; transition: .25s;
}
.umf-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ========== Ergebnisse ========== */
.umf-stats { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.umf-stat { background: var(--surface-2); border-radius: 10px; padding: 12px 20px; min-width: 130px; text-align: center; }
.umf-stat-num { font-size: 1.8rem; font-weight: 800; color: var(--primary); line-height: 1.3; }
.umf-stat-label { font-size: .85rem; color: var(--muted); }
.umf-tabs { display: flex; gap: 6px; border-bottom: 2px solid var(--line-soft); }
.tab-btn {
  padding: 10px 16px; min-height: 44px; border: 0; background: transparent; color: var(--muted);
  font-weight: 700; font-size: .95rem; cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.umf-help { margin-bottom: 8px; }
.umf-avg { font-size: 1.1rem; margin-bottom: 10px; }
.umf-avg strong { font-size: 1.5rem; color: var(--primary); }

.bar-row { display: grid; grid-template-columns: minmax(120px, 30%) 1fr 100px; gap: 12px; align-items: center; margin: 8px 0; }
.bar-label { overflow-wrap: anywhere; }
.bar-track { background: var(--surface-2); height: 22px; border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--primary); border-radius: 6px; min-width: 2px; }
.bar-val { font-variant-numeric: tabular-nums; font-size: .9rem; text-align: right; color: var(--muted); }

.text-answers { list-style: none; }
.text-answers li { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); display: flex; flex-direction: column; gap: 2px; }
.text-answers li:last-child { border-bottom: 0; }
.umf-rows td { max-width: 260px; overflow-wrap: anywhere; vertical-align: top; }

/* ========== Oeffentliche Umfrage ========== */
.umf-public-head {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  padding: 12px 20px; text-align: center; box-shadow: 0 2px 10px rgba(0, 0, 0, .2);
}
.umf-public-head .header-logo { max-height: 56px; max-width: 100%; }
.umf-shell { max-width: 720px; margin: 20px auto 60px; padding: 0 14px; }
.umf-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .08); padding: 20px; margin-bottom: 14px;
}
.umf-title { border-top: 8px solid var(--primary); }
.umf-title h1 { font-size: 1.7rem; line-height: 1.25; margin-bottom: 8px; }
.umf-desc { margin-bottom: 10px; }
.umf-msg h1 { font-size: 1.4rem; margin-bottom: 8px; }
.req { color: var(--error); margin-left: 4px; font-weight: 700; }
.q-block.has-error { border-color: var(--error); border-left: 5px solid var(--error); }
.q-title { font-weight: 700; font-size: 1.05rem; margin-bottom: 4px; }
.q-help { color: var(--muted); font-size: .92rem; margin-bottom: 10px; }
.q-block .umf-input { margin-top: 8px; }
.q-block .umf-input-date { max-width: 240px; }
.q-error { color: var(--error); font-size: .88rem; margin-top: 8px; min-height: 0; }
.q-error:empty { display: none; }
.form-error { color: var(--error); font-weight: 700; margin-left: 12px; }

.choice {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; min-height: 46px; margin-top: 8px;
  border: 1px solid var(--line); border-radius: 8px; cursor: pointer; transition: .15s background-color;
}
.choice:hover { background: var(--surface-2); }
.choice input { width: 20px; height: 20px; flex-shrink: 0; accent-color: var(--primary); }
.choice:has(input:checked) { border-color: var(--primary); background: rgba(211, 47, 47, .08); }
.choice:has(input:focus-visible) { outline: 3px solid var(--accent-active); outline-offset: 2px; }

.scale-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.scale-opt {
  flex: 1 1 44px; min-width: 44px; min-height: 46px; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-weight: 700; position: relative;
}
.scale-opt input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.scale-opt:hover { background: var(--surface-2); }
.scale-opt:has(input:checked) { background: var(--primary); border-color: var(--primary); color: #fff; }
.scale-opt:has(input:focus-visible) { outline: 3px solid var(--accent-active); outline-offset: 2px; }
.scale-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: .85rem; margin-top: 6px; }

.umf-submit { display: flex; align-items: center; flex-wrap: wrap; }
.btn-lg { padding: 12px 28px; font-size: 1rem; min-height: 46px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* ========== Dark-Mode (ergaenzt die Regeln aus style.css) ========== */
body.dark-mode .umf-input,
body.dark-mode .q-type,
body.dark-mode .opt-row input[type="text"],
body.dark-mode .q-scale-cfg select,
body.dark-mode .q-scale-cfg input { background: #24272d; color: var(--text); border-color: #1f2227; }
body.dark-mode .umf-input option, body.dark-mode .q-type option { background: #111; color: #fff; }
body.dark-mode .umf-card, body.dark-mode .q-card { box-shadow: 0 2px 10px rgba(0, 0, 0, .6); }
body.dark-mode .choice:has(input:checked) { background: rgba(239, 83, 80, .15); }
body.dark-mode .umf-title-link, body.dark-mode .save-links a { color: #ef5350; }
body.dark-mode .umf-input-date { color-scheme: dark; }

/* ========== Responsive ========== */
@media (max-width: 768px) {
  .umf-wrap { padding: 0 10px 130px; margin-top: 12px; }
  .bar-row { grid-template-columns: 1fr 90px; }
  .bar-label { grid-column: 1 / -1; }
  .q-scale-cfg { grid-template-columns: 1fr; }
  .q-preview { max-width: 100%; }
  .umf-title h1 { font-size: 1.4rem; }
  .save-bar-inner { justify-content: space-between; }
}
@media print {
  .save-bar, .umf-tabs, .umf-toolbar { display: none !important; }
  [data-tab-panel][hidden] { display: block !important; }
}
