/* R+S Schadstoffbericht-Generator – Stylesheet */

:root {
  --primary: #1F3A5F;
  --primary-light: #2c5282;
  --accent: #c53030;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --border: #d6dde6;
  --text: #1a202c;
  --muted: #718096;
  --success: #38a169;
  --warning: #d69e2e;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);
  --radius: 8px;
}

* { box-sizing: border-box; }

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

/* ---------- Topbar ---------- */
.topbar {
  background: var(--primary);
  color: white;
  padding: 0.8rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
}

.brand { display: flex; align-items: center; gap: 1rem; }
.logo {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 48px; height: 48px;
  background: white;
  color: var(--primary);
  font-weight: 800; font-size: 1.2rem;
  border-radius: 6px;
}
.topbar h1 { margin: 0; font-size: 1.2rem; }
.topbar p  { margin: 0; font-size: 0.85rem; opacity: 0.85; }

.header-actions { display: flex; gap: 0.5rem; }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: calc(100vh - 72px);
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.5rem 1rem;
  position: sticky;
  top: 0;
  height: calc(100vh - 72px);
  overflow-y: auto;
}
.sidebar h3 { margin-top: 0; color: var(--primary); }
.step-nav { list-style: none; padding: 0; margin: 0; }
.step-nav li { margin: 0; }
.step-nav a {
  display: block;
  padding: 0.5rem 0.7rem;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.92rem;
  transition: all 0.15s;
}
.step-nav a:hover { background: #edf2f7; }
.step-nav a.active {
  background: var(--primary);
  color: white;
  font-weight: 500;
}
.step-nav a.completed::after {
  content: " ✓";
  color: var(--success);
  font-weight: bold;
}
.step-nav a.active.completed::after { color: white; }

.project-status {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}
.project-status p { margin: 0.2rem 0; }
.project-status #current-project-name { font-weight: 600; color: var(--primary); }

.content {
  padding: 2rem;
  max-width: 1100px;
}

/* ---------- Steps ---------- */
.step { display: none; animation: fadeIn 0.2s ease; }
.step.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.step h2 {
  color: var(--primary);
  border-bottom: 2px solid var(--primary);
  padding-bottom: 0.5rem;
  margin-top: 0;
}
.step h3 {
  color: var(--primary-light);
  margin-top: 1.5rem;
}
.step h4 { margin-top: 1rem; color: var(--muted); }

.muted { color: var(--muted); font-size: 0.9rem; }

/* ---------- Forms ---------- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem 1.2rem;
  margin: 1rem 0;
}
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text);
}
.form-grid label.full { grid-column: 1 / -1; }
input[type="text"], input[type="number"], textarea, select {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 58, 95, 0.15);
}
textarea.full { width: 100%; resize: vertical; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center; gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  background: white;
  color: var(--text);
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-light); }
.btn-secondary {
  background: white;
  color: var(--primary);
  border-color: var(--border);
}
.btn-small { padding: 0.4rem 0.8rem; font-size: 0.85rem; }
.btn-large { padding: 0.9rem 2rem; font-size: 1.05rem; }
.btn-add {
  background: #edf2f7;
  color: var(--primary);
  margin-top: 0.5rem;
}

/* ---------- Tables ---------- */
.dyn-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin: 1rem 0;
}
.dyn-table thead { background: var(--primary); color: white; }
.dyn-table th, .dyn-table td {
  padding: 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.dyn-table th { font-weight: 600; font-size: 0.88rem; }
.dyn-table tr:nth-child(even) td { background: #f7fafc; }
.dyn-table input {
  width: 100%;
  padding: 0.35rem 0.5rem;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  font-size: 0.9rem;
}
.dyn-table .btn-row-del {
  background: transparent;
  color: var(--accent);
  border: none;
  cursor: pointer;
  padding: 0.3rem 0.5rem;
  font-size: 1.1rem;
}

/* ---------- Upload Area ---------- */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  text-align: center;
  background: var(--surface);
  margin: 1rem 0;
  transition: all 0.2s;
}
.upload-area.dragover {
  border-color: var(--primary);
  background: #ebf4ff;
}
.upload-area p { margin: 0; color: var(--muted); }
.upload-area label { color: var(--primary); cursor: pointer; font-weight: 600; }
.upload-area label:hover { text-decoration: underline; }

/* ---------- Photo Grid ---------- */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.photo-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.photo-card img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  display: block;
}
.photo-card .photo-meta {
  padding: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.photo-card input {
  font-size: 0.85rem;
  padding: 0.3rem 0.5rem;
}
.photo-card .photo-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.6rem;
  background: #f7fafc;
}
.photo-card .photo-label-tag {
  background: var(--primary);
  color: white;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.85rem;
}

/* ---------- Plan Editor ---------- */
.plan-editor { margin-top: 1rem; }
.plan-editor.hidden { display: none; }
.plan-toolbar {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  margin-bottom: 0.8rem;
}
.plan-canvas-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  max-height: 70vh;
  cursor: crosshair;
}
#plan-canvas { display: block; max-width: 100%; }

/* ---------- File List ---------- */
.file-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
}
.file-list li {
  background: var(--surface);
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  box-shadow: var(--shadow);
}
.file-list .file-name { font-weight: 500; }
.file-list .file-size { color: var(--muted); font-size: 0.85rem; }
.file-list .btn-row-del {
  background: transparent;
  color: var(--accent);
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
}

/* ---------- Checklist ---------- */
.checklist {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--surface);
  padding: 1rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin: 1rem 0;
}
.checklist label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
}

.download-actions { margin: 1.5rem 0; text-align: center; }
.single-downloads { margin-top: 1rem; }
.single-downloads summary { cursor: pointer; color: var(--muted); }
.single-downloads button { margin: 0.3rem; }

.status-box {
  background: var(--surface);
  border-left: 4px solid var(--primary);
  padding: 1rem;
  border-radius: 6px;
  margin: 1rem 0;
}
.status-box.success { border-left-color: var(--success); }
.status-box.error   { border-left-color: var(--accent); }
.hidden { display: none !important; }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-content {
  background: var(--surface);
  padding: 2rem;
  border-radius: var(--radius);
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}
.modal-actions { margin-top: 1rem; text-align: right; }
.project-list { list-style: none; padding: 0; margin: 1rem 0; }
.project-list li {
  padding: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: all 0.15s;
}
.project-list li:hover {
  background: #ebf4ff;
  border-color: var(--primary);
}
.project-list .proj-title { font-weight: 600; color: var(--primary); }
.project-list .proj-meta { font-size: 0.85rem; color: var(--muted); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 2rem; right: 2rem;
  background: var(--primary);
  color: white;
  padding: 0.8rem 1.5rem;
  border-radius: 6px;
  box-shadow: var(--shadow);
  z-index: 200;
  animation: slideUp 0.2s ease;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--accent); }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .form-grid { grid-template-columns: 1fr; }
}
