/* Basis-CSS für hadb – verbessert Layout und Lesbarkeit */

:root {
  --gap: 12px;
  --max-width: 980px;
  --accent: #2b6cb0;
}

html, body {
  height: 100%;
  margin: 0;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  background: #fafafa;
  color: #111;
}

body {
  padding: 72px 16px 32px; /* Platz für fixed topbar */
  display: flex;
  justify-content: center;
}

main, .container {
  width: 100%;
  max-width: var(--max-width);
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

/* Formular */
form#f {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0 16px;
  align-items: center;
  width: 100%;
}
form#f input[type="number"],
form#f input[type="text"],
form#f input {
  padding: 6px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  min-width: 120px;
}
form#f button {
  background: var(--accent);
  color: #fff;
  border: 0;
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
}

/* Notification-System */
.notification {
  position: fixed;
  top: 80px;
  right: 12px;
  padding: 12px 16px;
  border-radius: 4px;
  color: white;
  font-weight: 500;
  z-index: 1001;
  max-width: 300px;
  word-wrap: break-word;
  animation: slideIn 0.3s ease-out;
}

.notification-success {
  background-color: #10b981;
  border-left: 4px solid #059669;
}

.notification-error {
  background-color: #ef4444;
  border-left: 4px solid #dc2626;
}

.notification-warning {
  background-color: #f59e0b;
  border-left: 4px solid #d97706;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Deaktivierte Buttons */
form#f button:disabled {
  background: #ccc;
  color: #666;
  cursor: not-allowed;
}

/* Aktions-Buttons in Tabelle */
table#tbl button {
  background: var(--accent);
  color: #fff;
  border: 0;
  padding: 4px 6px;
  border-radius: 3px;
  cursor: pointer;
  margin-right: 4px;
  font-size: 12px;
}

table#tbl button:hover {
  background: #1e40af;
}

/* Tabelle */
table#tbl {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
table#tbl th,
table#tbl td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid #eee;
}
table#tbl thead th {
  background: #f7f9fb;
  font-weight: 600;
}

/* Topbar */
#topbar {
  position: fixed;
  left: 12px;
  right: 12px;
  top: 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  font-family: sans-serif;
  z-index: 1000;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.topbar-left {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  min-width: 0;
}

#topbarLogo {
  height: 28px;
  width: auto;
  object-fit: contain;
}

.topbar-brand {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  line-height: 1;
  white-space: nowrap;
}

.topbar-brand .brand-short {
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #1f2937;
}

.topbar-brand .brand-sep {
  color: #9ca3af;
  font-weight: 600;
}

.topbar-brand .brand-long {
  align-items: flex-end;
  color: #4b5563;
  font-weight: 600;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
#loginForm input {
  margin-right: 4px;
}
#userInfo {
  display: none;
  align-items: center;
  gap: 8px;
}
#userInfo span {
  font-weight: bold;
}
#topbar button {
  background: var(--accent);
  color: #fff;
  border: 0;
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
}
#topbar input {
  padding: 6px 8px;
  border-radius: 4px;
  border: 1px solid #ccc;
}

/* ===== Probenserie-Name Box ===== */
.series-name-box {
  width: 100%;
  padding: 0;
  margin: 16px 0;
  background: #fff;
  border: 1px solid #ddd;
  border-left: 4px solid #10b981;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.series-name-box .series-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: #f0f4f8;
  font-size: 1.1em;
  font-weight: 600;
  border-radius: 6px 6px 0 0;
}

.series-name-box .series-content {
  padding: 16px;
}

.series-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.series-selector,
.series-input {
  display: flex;
  gap: 8px;
  align-items: center;
}

.series-selector select,
.series-input input {
  flex: 1;
  padding: 10px 12px;
  font-size: 1em;
  border: 1px solid #ccc;
  border-radius: 4px;
}

.series-selector select:focus,
.series-input input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(43, 108, 176, 0.15);
}

.primary-btn,
.secondary-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 4px;
  font-size: 0.95em;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.primary-btn {
  background: #10b981;
  color: white;
}

.primary-btn:hover {
  background: #059669;
}

.secondary-btn {
  background: var(--accent);
  color: white;
}

.secondary-btn:hover {
  background: #1e40af;
}

/* ===== Collapsible Sections ===== */
.collapsible-container {
  margin: 16px 0;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  width: 100%;
}

/* Level 1 - Hauptbereich (z.B. Fügeteil A) */
.collapsible-level1 {
  border-left: 4px solid var(--accent);
  width: 100%;
  box-sizing: border-box;
}

.collapsible-level1 > .collapsible-header {
  background: #f0f4f8;
  font-size: 1.1em;
  font-weight: 600;
}

/* Level 2 - Unterbereich (z.B. Geometrie, Werkstoff) */
.collapsible-level2 {
  margin: 0;
  border: none;
  border-top: 1px solid #eee;
  border-radius: 0;
  box-shadow: none;
}

.collapsible-level2 > .collapsible-header {
  background: #f7f9fb;
  font-size: 1em;
  font-weight: 500;
  padding-left: 24px;
}

/* ===== Level 3 - Unter-Unterbereich (z.B. Isotropie) ===== */
.collapsible-level3 {
  margin: 0;
  border: none;
  border-top: 1px solid #e5e5e5;
  border-radius: 0;
  box-shadow: none;
  background: #f9fafb;
}

.collapsible-level3 > .collapsible-header {
  background: #f0f2f5;
  font-size: 0.95em;
  font-weight: 500;
  padding-left: 40px;
  color: #555;
}

.collapsible-level3 > .collapsible-header:hover {
  background: #e5e8ec;
}

.collapsible-level3 > .collapsible-content {
  padding: 12px 16px 12px 40px;
  background: #f5f7f9;
}

/* Header (Klickbereich) */
.collapsible-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}

.collapsible-header:hover {
  background: #e8eef4;
}

.collapsible-header::after {
  content: '▼';
  font-size: 0.75em;
  color: #666;
  transition: transform 0.3s ease;
}

/* Eingeklappt */
.collapsible-container.collapsed > .collapsible-header::after {
  transform: rotate(-90deg);
}

.collapsible-container.collapsed > .collapsible-content {
  display: none;
}

/* Content-Bereich */
.collapsible-content {
  padding: 16px;
  border-top: 1px solid #eee;
}

.collapsible-level2 > .collapsible-content {
  padding: 12px 16px 12px 24px;
  background: #fafbfc;
}

/* Eingabefelder innerhalb der Sections */
.input-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 8px;
}

.input-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.input-field label {
  font-size: 0.85em;
  font-weight: 500;
  color: #444;
}

.input-field input,
.input-field select {
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.95em;
}

.input-field input:focus,
.input-field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(43, 108, 176, 0.15);
}

/* ===== Input mit Wichtung ===== */
.input-with-weight {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.input-with-weight label {
  font-size: 0.85em;
  font-weight: 500;
  color: #444;
}

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

.input-row input.value-input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.95em;
}

.input-row input.value-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(43, 108, 176, 0.15);
}

.input-row .weight-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: #e0e7ff;
  border: 1px solid #c7d2fe;
  border-radius: 4px;
  font-size: 0.8em;
  color: #4338ca;
  white-space: nowrap;
}

.input-row .weight-badge::before {
  content: 'W:';
  font-weight: 600;
}

/* Wichtigkeits-Farben nach Stufe */
.weight-badge.weight-5 { background: #fee2e2; border-color: #fca5a5; color: #dc2626; }
.weight-badge.weight-4 { background: #ffedd5; border-color: #fdba74; color: #ea580c; }
.weight-badge.weight-3 { background: #fef9c3; border-color: #fde047; color: #ca8a04; }
.weight-badge.weight-2 { background: #d1fae5; border-color: #6ee7b7; color: #059669; }
.weight-badge.weight-1 { background: #e0e7ff; border-color: #c7d2fe; color: #4338ca; }

/* Select-Felder styling */
.input-row select.value-input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.95em;
  background: #fff;
}

.input-row select.value-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(43, 108, 176, 0.15);
}

/* Schritte-Container */
.step-container {
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 12px;
  background: #fff;
}

.step-container h4 {
  margin: 0 0 12px 0;
  font-size: 0.9em;
  color: #6b7280;
  font-weight: 600;
}

/* Dynamische Schritte */
.steps-wrapper {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.add-step-btn {
  align-self: flex-start;
  padding: 8px 16px;
  background: #10b981;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9em;
}

.add-step-btn:hover {
  background: #059669;
}

/* Remove-Button für Schritte */
.remove-step-btn {
  background: #ef4444;
  color: white;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 12px;
  cursor: pointer;
  margin-left: 8px;
  line-height: 1;
}

.remove-step-btn:hover {
  background: #dc2626;
}

/* Form Actions innerhalb Collapsible */
.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #e5e7eb;
}

.form-actions button {
  padding: 10px 20px;
  border: none;
  border-radius: 4px;
  font-size: 0.95em;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.2s;
}

.form-actions button[type="submit"] {
  background: var(--accent);
  color: white;
}

.form-actions button[type="submit"]:hover {
  background: #1e40af;
}

.form-actions #resetBtn {
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #d1d5db;
}

.form-actions #resetBtn:hover {
  background: #e5e7eb;
}

.form-actions #closeBtn {
  background: #6b7280;
  color: white;
}

.form-actions #closeBtn:hover {
  background: #4b5563;
}

/* Responsive: kleine Bildschirme */
@media (max-width: 600px) {
  form#f {
    flex-direction: column;
    align-items: stretch;
  }
  #topbar {
    right: 8px;
    left: 8px;
    justify-content: space-between;
  }

  .topbar-brand .brand-long,
  .topbar-brand .brand-sep {
    display: none;
  }
  
  .form-actions {
    flex-direction: column;
  }
  
  .form-actions button {
    width: 100%;
  }
}