/* ── Reset & Variablen ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f1f5f9;
  --sidebar: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-active: #3b82f6;
  --sidebar-text: #94a3b8;
  --white: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --accent: #3b82f6;
  --accent-dark: #2563eb;
  --success: #22c55e;
  --error: #ef4444;
  --warning: #f59e0b;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* ── Sidebar ────────────────────────────────────────────────────── */
.sidebar {
  width: 220px;
  min-height: 100vh;
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  padding: 0 0 24px;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 20px 20px;
  color: #ffffff;
  font-size: 16px;
  font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: 12px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  border-radius: 6px;
  margin: 2px 10px;
  transition: background .15s, color .15s;
  font-size: 13.5px;
}
.nav-link:hover { background: var(--sidebar-hover); color: #fff; }
.nav-link.active { background: var(--accent); color: #fff; }

/* ── Main Layout ────────────────────────────────────────────────── */
.main {
  margin-left: 220px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
}

.topbar-right {
  font-size: 13px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

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

/* ── Karten ─────────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 18px;
  color: var(--text);
}

.card-desc {
  color: var(--text-muted);
  margin-bottom: 18px;
  font-size: 13px;
}

/* ── Drucker-Grid ───────────────────────────────────────────────── */
.printer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.printer-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  border-left: 4px solid var(--border);
  transition: border-color .3s;
}
.printer-card.online  { border-left-color: var(--success); }
.printer-card.offline { border-left-color: var(--error); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.printer-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
  transition: background .3s;
}
.status-dot.online  { background: var(--success); box-shadow: 0 0 0 3px rgba(34,197,94,.2); }
.status-dot.offline { background: var(--error); }
.status-dot.checking { background: var(--warning); animation: pulse 1s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}

.printer-name {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
}

.printer-ip {
  font-size: 12px;
  color: var(--text-muted);
  font-family: monospace;
}

.printer-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.status-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}
.status-label.online  { color: var(--success); }
.status-label.offline { color: var(--error); }

.card-meta {
  display: flex;
  gap: 24px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}

.meta-item { display: flex; flex-direction: column; gap: 2px; }
.meta-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.meta-value { font-size: 13px; font-weight: 500; }

.card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: background .15s, opacity .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: default; }

.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover  { background: var(--accent-dark); }
.btn-secondary { background: #e0e7ff; color: #3730a3; }
.btn-secondary:hover { background: #c7d2fe; }
.btn-outline  { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover  { background: var(--bg); }
.btn-danger   { background: #fee2e2; color: var(--error); }
.btn-danger:hover   { background: #fecaca; }
.btn-link     { background: none; color: var(--error); padding: 0; font-size: 13px; }
.btn-link:hover     { text-decoration: underline; }
.btn-sm       { padding: 5px 10px; font-size: 12px; }

/* ── Formulare ──────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-full { grid-column: 1 / -1; }

.form-row {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
  min-width: 130px;
}
.form-group-btn { flex: 0; min-width: auto; }

label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.optional { font-weight: 400; text-transform: none; }

input[type="text"], input[type="time"], select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  background: var(--white);
  width: 100%;
  transition: border .15s;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
small { font-size: 11px; color: var(--text-muted); }

/* ── Zeitplan ───────────────────────────────────────────────────── */
.schedule-block { padding: 16px 0; }
.schedule-block h3 { font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.schedule-status {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  font-size: 13px;
}
.divider { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

/* ── Tabellen ───────────────────────────────────────────────────── */
.printer-table { display: flex; flex-direction: column; gap: 2px; }
.table-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
}
.table-row:hover { background: var(--bg); }
.table-cell { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.log-card { padding: 0; overflow: hidden; }
.log-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.log-table th {
  background: var(--bg);
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
}
.log-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.log-table tr:last-child td { border-bottom: none; }
.log-table tr.row-error td { background: #fff5f5; }
.td-time { white-space: nowrap; }

/* ── Log-Liste (Dashboard) ──────────────────────────────────────── */
.log-section { margin-top: 8px; }
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.section-header h2 { font-size: 15px; font-weight: 600; }
.link-more { font-size: 13px; color: var(--accent); text-decoration: none; }
.link-more:hover { text-decoration: underline; }

.log-list { display: flex; flex-direction: column; gap: 4px; }
.log-entry {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 12px;
  background: var(--white);
  border-radius: 6px;
  border-left: 3px solid var(--success);
  box-shadow: var(--shadow);
  font-size: 13px;
}
.log-entry.log-error { border-left-color: var(--error); }
.log-icon { font-size: 13px; color: var(--success); font-weight: 700; flex-shrink: 0; }
.log-entry.log-error .log-icon { color: var(--error); }
.log-body { display: flex; flex-direction: column; gap: 2px; }
.log-msg { color: var(--text); }
.log-meta { font-size: 11px; color: var(--text-muted); }

/* ── Badges ─────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.badge-ok     { background: #dcfce7; color: #15803d; }
.badge-error  { background: #fee2e2; color: #b91c1c; }
.badge-active { background: #dbeafe; color: #1d4ed8; }

/* ── Toolbar & Filter ───────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 12px;
}
.filter-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filter-chip {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  background: var(--white);
  color: var(--text-muted);
  border: 1px solid var(--border);
  transition: background .15s;
}
.filter-chip:hover { background: var(--bg); }
.filter-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Empty State ────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 60px 20px;
  color: var(--text-muted);
  text-align: center;
}
.empty-state svg { opacity: .4; }

/* ── Modal ──────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal {
  background: var(--white);
  border-radius: var(--radius);
  padding: 28px;
  width: 400px;
  max-width: 90vw;
  box-shadow: var(--shadow-md);
}
.modal h3 { font-size: 16px; font-weight: 600; margin-bottom: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.file-label {
  display: block;
  padding: 32px;
  border: 2px dashed var(--border);
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  transition: border-color .15s, background .15s;
}
.file-label:hover { border-color: var(--accent); background: #f0f7ff; }
.file-label input { display: none; }

/* ── Toast ──────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  z-index: 300;
  transform: translateY(80px);
  opacity: 0;
  transition: transform .25s, opacity .25s;
  max-width: 340px;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: #dcfce7; color: #15803d; }
.toast.error   { background: #fee2e2; color: #b91c1c; }
.toast.info    { background: #dbeafe; color: #1d4ed8; }

/* ── Format-Selector ────────────────────────────────────────────── */
.format-select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text);
  background: var(--bg);
  flex-shrink: 0;
}

/* ── Edit-Formular ──────────────────────────────────────────────── */
.edit-form {
  background: var(--bg);
  border-radius: 8px;
  padding: 16px;
  margin: 4px 0 8px;
}

/* ── Hilfstextklassen ───────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
