/* =====================================================
   Bauteile-Verwaltung - Stylesheet v4.1
   Kompatibel mit Original-Header (.topbar, .mainnav, .userinfo)
   + v4-Features (Paginierung, Multi-Select, Sortier-Icons)
   ===================================================== */

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  background: #f4f6f8;
  color: #2c3e50;
  line-height: 1.45;
}

/* === Topbar (Original-Stil) =========================== */
.topbar {
  background: #2c3e50;
  color: #ecf0f1;
  padding: .75rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  flex-wrap: wrap;
  gap: 1rem;
}
.topbar .brand { font-weight: 600; font-size: 1.05rem; }
.mainnav { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.mainnav a {
  color: #ecf0f1;
  text-decoration: none;
  padding: .25rem .5rem;
  border-radius: 4px;
}
.mainnav a:hover { background: rgba(255,255,255,.12); text-decoration: none; }
.userinfo { color: #bdc3c7; font-size: .9rem; margin-right: .5rem; }

/* Hauptcontainer: volle Browserbreite */
main {
  width: 100%;
  max-width: none;
  padding: 1.25rem 1.5rem;
  margin: 0;
}

h1, h2, h3 { color: #2c3e50; }
h1 { margin-top: 0; font-size: 1.5rem; margin-bottom: 1rem; }
h2 { font-size: 1.15rem; margin: 1rem 0 .6rem; }

.muted { color: #7f8c8d; }
.hint-inline { font-weight: normal; font-size: .75rem; color: #7f8c8d; }
.site-footer { padding: 1rem 1.5rem; }

/* === Karten und Forms ================================ */
.card {
  background: #fff;
  border: 1px solid #e1e5ea;
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}

label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .25rem; }
input[type=text], input[type=password], input[type=number],
input[type=search], input[type=file], input[type=email],
textarea, select {
  width: 100%;
  padding: .45rem .55rem;
  border: 1px solid #cdd5dd;
  border-radius: 4px;
  font: inherit;
  background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid #3498db;
  outline-offset: 1px;
}
textarea { resize: vertical; }

/* Form-Grid für edit.php */
.form-grid { padding: 1.5rem; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem 1.25rem;
}
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem 1.25rem;
}
.grid-2 .full { grid-column: 1 / -1; }

/* === Buttons ========================================= */
button, .btn {
  background: #3498db;
  color: #fff;
  border: none;
  padding: .5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
  text-decoration: none;
  display: inline-block;
  white-space: nowrap;
}
button:hover, .btn:hover { background: #2980b9; text-decoration: none; color: #fff; }
button:disabled, .btn:disabled { background: #95a5a6; cursor: not-allowed; opacity: .6; }
.btn-secondary { background: #95a5a6; }
.btn-secondary:hover { background: #7f8c8d; }
.btn-danger { background: #e74c3c; }
.btn-danger:hover { background: #c0392b; }
.btn-sm, .btn-small { padding: .25rem .6rem; font-size: .85rem; }
.btn-active { background: #1f5f8b; box-shadow: inset 0 1px 3px rgba(0,0,0,.25); }

/* === Filterbar ======================================= */
.filterbar {
  background: #fff;
  border: 1px solid #e1e5ea;
  border-radius: 8px;
  padding: .85rem 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: .6rem 1rem;
  align-items: flex-end;
  margin-bottom: 1rem;
}
.filterbar > div { display: flex; flex-direction: column; gap: .25rem; min-width: 130px; }
.filterbar label {
  font-size: .75rem;
  font-weight: 600;
  color: #7f8c8d;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 0;
}

/* === Multiselect-Dropdown ============================ */
.ms-wrap { position: relative; }
.ms-btn {
  width: 100%;
  padding: .45rem .55rem;
  border: 1px solid #cdd5dd;
  border-radius: 4px;
  background: #fff;
  color: #2c3e50;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
  min-width: 130px;
  font: inherit;
}
.ms-btn:hover { border-color: #3498db; background: #fff; }
.ms-panel {
  background: #fff;
  border: 1px solid #cdd5dd;
  border-radius: 4px;
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  padding: .4rem 0;
  max-height: 280px;
  overflow-y: auto;
  min-width: 160px;
}
.ms-item {
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: .3rem .75rem;
  cursor: pointer;
  white-space: nowrap;
  font-weight: normal;
  font-size: .9rem;
  text-transform: none;
  letter-spacing: 0;
  color: #2c3e50;
}
.ms-item:hover { background: #f4f6f8; }
.ms-item input[type=checkbox] { width: auto; cursor: pointer; }
.ms-empty { display: block; padding: .4rem .75rem; color: #7f8c8d; font-size: .85rem; }

/* === Tabelle ========================================= */
.table-wrap {
  overflow-x: auto;
  background: #fff;
  border: 1px solid #e1e5ea;
  border-radius: 8px;
}
table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}
thead th {
  background: #ecf0f1;
  border-bottom: 2px solid #cdd5dd;
  padding: .55rem .65rem;
  text-align: left;
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
  color: #2c3e50;
}
thead th a {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: .3rem;
}
thead th a:hover { color: #3498db; }
.sort-icon { opacity: .4; font-size: .85em; }
thead th a:hover .sort-icon { opacity: 1; }
.sort-asc, .sort-desc { opacity: 1; color: #3498db; }

tbody tr { border-bottom: 1px solid #e1e5ea; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f8faff; }
td {
  padding: .5rem .65rem;
  vertical-align: middle;
}

/* Schmale Anzahl-Spalte */
.col-anzahl {
  width: 56px;
  min-width: 56px;
  max-width: 56px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}
.stock-zero { color: #e74c3c; background: #fdf2f2; }

/* Beschreibung max 2 Zeilen */
.desc-cell {
  max-width: 280px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: default;
  line-height: 1.4;
}

/* === Paginierung ===================================== */
.pagination-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem 1.5rem;
  align-items: center;
  justify-content: space-between;
  margin-top: .8rem;
  padding: .6rem .2rem;
}
.pag-nav { display: flex; flex-wrap: wrap; gap: .25rem; align-items: center; }
.pag-ellipsis { padding: 0 .3rem; color: #7f8c8d; }
.pag-pp {
  display: flex;
  align-items: center;
  gap: .5rem;
  color: #7f8c8d;
  font-size: .88rem;
}
.pag-pp select {
  width: auto;
  padding: .2rem .4rem;
  font-size: .88rem;
}

/* === Badges ========================================== */
.badge {
  display: inline-block;
  padding: .15rem .45rem;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 700;
  background: #e1e5ea;
  color: #7f8c8d;
  text-transform: uppercase;
  letter-spacing: .05em;
  vertical-align: middle;
}
.badge-admin    { background: #dbeafe; color: #1e40af; }
.badge-readonly { background: #f3f4f6; color: #6b7280; }
.badge-inactive { background: #fee2e2; color: #991b1b; }

/* Inaktive Benutzer-Zeile gedimmt darstellen */
tr.user-inactive td { opacity: .55; }
tr.user-inactive td:first-child { opacity: 1; }  /* Username bleibt lesbar */

/* === Flash =========================================== */
.flash {
  padding: .65rem 1rem;
  border-radius: 4px;
  margin-bottom: .9rem;
  font-weight: 500;
}
.flash-ok    { background: #d4edda; color: #155724; border-left: 4px solid #28a745; }
.flash-error { background: #f8d7da; color: #721c24; border-left: 4px solid #dc3545; }

/* === Login =========================================== */
.login-box { max-width: 360px; margin: 4rem auto; }

/* === Responsive ====================================== */
@media (max-width: 700px) {
  .topbar { flex-wrap: wrap; gap: .4rem; }
  main { padding: .8rem; }
  .filterbar { flex-direction: column; align-items: stretch; }
}
