/* ============================================================
   Lagersystem J & R Hofmann — Stylesheet
   ============================================================ */

:root {
  --blau:      #1F3864;
  --blau-hell: #2E5BA8;
  --gruen:     #1F5C2E;
  --gruen-hell:#2E8B45;
  --rot:       #7B0000;
  --warn:      #D4820A;
  --warn-bg:   #FFF8ED;
  --lila:      #5B3A8E;
  --grau:      #F4F6FA;
  --grau2:     #E8ECF4;
  --grau3:     #BCC5D8;
  --text:      #1A1A2E;
  --text2:     #555570;
  --weiss:     #FFFFFF;
  --radius:    10px;
  --shadow:    0 2px 12px rgba(31,56,100,0.10);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  font-size: 14px;
  background: var(--grau);
  color: var(--text);
  min-height: 100vh;
}

/* ===== NAVBAR ===== */
.navbar {
  background: var(--blau);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  height: 54px;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}

.nav-brand {
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  white-space: nowrap;
  margin-right: 1rem;
}
.nav-brand span { font-weight: 300; opacity: 0.75; }

.nav-links { display: flex; gap: 0.25rem; flex: 1; }
.nav-links a {
  color: rgba(255,255,255,0.80);
  text-decoration: none;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  font-size: 0.88rem;
  transition: background 0.15s;
}
.nav-links a:hover, .nav-links a.active {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

.nav-badge {
  display: inline-block;
  background: var(--warn);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  border-radius: 9px;
  padding: 0.05rem 0.4rem;
  margin-left: 0.3rem;
  vertical-align: middle;
  line-height: 1.4;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: rgba(255,255,255,0.80);
  font-size: 0.85rem;
  white-space: nowrap;
}

.rolle {
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.rolle-master    { background: #D4AF37; color: #1A1A2E; }
.rolle-techniker { background: var(--gruen-hell); color: #fff; }
.rolle-leser     { background: var(--grau3); color: var(--blau); }

.btn-logout {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
  padding: 0.25rem 0.65rem;
  border-radius: 5px;
  text-decoration: none;
  font-size: 0.82rem;
  transition: background 0.15s;
}
.btn-logout:hover { background: rgba(255,255,255,0.22); }

/* ===== STAT CARD LINK ===== */
.stat-link {
  text-decoration: none;
  display: block;
  transition: transform 0.15s, box-shadow 0.15s;
}
.stat-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(31,56,100,0.18);
}

/* ===== MAIN ===== */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
}

/* ===== FLASH ===== */
.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.9rem;
  font-weight: 500;
}
.flash-ok     { background: #E8F5EC; color: var(--gruen); border-left: 4px solid var(--gruen-hell); }
.flash-fehler { background: #FBE9E9; color: var(--rot);   border-left: 4px solid #C0392B; }

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.page-header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--blau);
}
.header-actions { display: flex; gap: 0.6rem; }
.header-sub { font-size: 0.85rem; color: var(--text2); margin-top: 0.2rem; }

/* ===== WARN BANNER ===== */
.warn-banner {
  background: var(--warn-bg);
  border: 1px solid #F0B429;
  border-left: 4px solid var(--warn);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.88rem;
  color: #7A4F00;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.warn-item {
  background: #FEE7A8;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
}

/* ===== STATS GRID ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--weiss);
  border-radius: var(--radius);
  padding: 1.2rem 1rem;
  text-align: center;
  box-shadow: var(--shadow);
  border-top: 3px solid var(--blau);
}
.stat-card.stat-warn { border-top-color: var(--warn); }
.stat-zahl { font-size: 2rem; font-weight: 700; color: var(--blau); }
.stat-card.stat-warn .stat-zahl { color: var(--warn); }
.stat-label { font-size: 0.8rem; color: var(--text2); margin-top: 0.25rem; }

/* ===== SECTION TITLE ===== */
.section-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text2);
  margin: 1.25rem 0 0.6rem;
}

/* ===== TABLE ===== */
.table-wrap {
  background: var(--weiss);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
  margin-bottom: 1.25rem;
}
table { width: 100%; border-collapse: collapse; }
thead { background: var(--blau); }
th {
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.65rem 0.85rem;
  text-align: left;
  white-space: nowrap;
}
td {
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid var(--grau2);
  font-size: 0.88rem;
  color: var(--text);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--grau); }
tr.row-warn td { background: #FFF8ED; }
tr.row-warn:hover td { background: #FEF3D8; }
tr.row-pending td { background: #EEF4FB; }
tr.row-pending:hover td { background: #DCE9F7; }

/* ===== BADGES ===== */
.art-id {
  font-family: monospace;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--blau);
  background: var(--grau2);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}
.mrt-id { color: var(--lila); background: #F0EAF8; }

.typ-badge {
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 600;
}
.typ-eingang { background: #E8F5EC; color: var(--gruen); }
.typ-abgang  { background: #FBE9E9; color: var(--rot); }

.status-badge {
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 600;
}
.status-ok      { background: #E8F5EC; color: var(--gruen); }
.status-warn    { background: #FEE7A8; color: #7A4F00; }
.status-leer    { background: #FBE9E9; color: var(--rot); }
.status-pending { background: #BBDEFB; color: #1565C0; }
.pending-badge  { font-size: 0.72rem; color: #1565C0; background: #BBDEFB;
                  padding: 0.1rem 0.4rem; border-radius: 4px; margin-left: 0.4rem;
                  font-weight: 600; white-space: nowrap; }

.filter-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--blau);
  color: #fff;
  padding: 0.15rem 0.55rem;
  border-radius: 4px;
  margin-left: 0.6rem;
  vertical-align: middle;
}
.filter-badge-warn { background: var(--warn); }

/* ===== BUTTONS ===== */
.btn-primary, .btn-secondary {
  display: inline-block;
  padding: 0.5rem 1.1rem;
  border-radius: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: opacity 0.15s;
}
.btn-primary   { background: var(--blau); color: #fff; }
.btn-secondary { background: var(--grau2); color: var(--blau); }
.btn-primary:hover, .btn-secondary:hover { opacity: 0.85; }
.btn-block { display: block; width: 100%; text-align: center; }

/* ===== FORM ===== */
.form-card {
  background: var(--weiss);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
  max-width: 520px;
}
.form-group { margin-bottom: 1.1rem; }
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 0.35rem;
}
.form-group input,
.form-group select {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1.5px solid var(--grau3);
  border-radius: 6px;
  font-size: 0.92rem;
  color: var(--text);
  background: var(--weiss);
  outline: none;
  transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus { border-color: var(--blau-hell); }
.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* ===== LOGIN ===== */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 54px);
  padding: 2rem 1rem;
}
.login-box {
  background: var(--weiss);
  border-radius: 14px;
  box-shadow: 0 4px 24px rgba(31,56,100,0.13);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
}
.login-logo {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--blau);
  text-align: center;
  margin-bottom: 0.25rem;
}
.login-sub {
  font-size: 0.82rem;
  color: var(--text2);
  text-align: center;
  margin-bottom: 1.75rem;
}

/* ===== LIEFERUNGEN ===== */
.haendler-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}
.haendler-ews      { background: #DCEEFF; color: #1050A0; }
.haendler-krannich { background: #E8F5EC; color: var(--gruen); }
.haendler-sonstig  { background: var(--grau2); color: var(--text2); }

.lief-status {
  padding: 0.15rem 0.55rem;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 600;
}
.lief-ausstehend { background: var(--grau2);  color: var(--text2); }
.lief-unterwegs  { background: #DCEEFF;       color: #1050A0; }
.lief-geliefert  { background: #E8F5EC;       color: var(--gruen); }
.lief-storniert  { background: #FBE9E9;       color: var(--rot); text-decoration: line-through; }

.abw-pos { color: var(--warn);    font-weight: 700; }
.abw-neg { color: var(--rot);     font-weight: 700; }
.abw-ok  { color: var(--gruen);   font-weight: 700; }

.pos-table input[type=number] {
  width: 90px;
  padding: 0.3rem 0.5rem;
  border: 1.5px solid var(--grau3);
  border-radius: 5px;
  font-size: 0.9rem;
  text-align: center;
}
.pos-table input[type=number]:focus { border-color: var(--blau-hell); outline: none; }

.lief-meta {
  background: var(--weiss);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.2rem 1.5rem;
  margin-bottom: 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
}
.lief-meta-item { display: flex; flex-direction: column; gap: 0.2rem; }
.lief-meta-label { font-size: 0.75rem; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; }
.lief-meta-val   { font-size: 0.95rem; color: var(--text); font-weight: 500; }

.storno-box {
  background: #FBE9E9;
  border: 1px solid #E0AAAA;
  border-left: 4px solid var(--rot);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.88rem;
  color: var(--rot);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  .navbar { padding: 0 0.75rem; height: auto; flex-wrap: wrap; padding-top: 0.5rem; padding-bottom: 0.5rem; gap: 0.5rem; }
  .nav-links { flex-wrap: wrap; }
  .nav-links a { font-size: 0.82rem; padding: 0.3rem 0.55rem; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .form-card { padding: 1.25rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ===== CHAT WIDGET ===== */
#chat-btn{position:fixed;bottom:1.5rem;right:1.5rem;width:52px;height:52px;border-radius:50%;background:var(--blau);color:#fff;border:none;cursor:pointer;font-size:1.4rem;box-shadow:0 4px 16px rgba(31,56,100,.35);z-index:999;display:flex;align-items:center;justify-content:center;transition:background .2s,transform .15s}
#chat-btn:hover{background:var(--blau-hell);transform:scale(1.07)}
.chat-unread-badge{position:absolute;top:-2px;right:-2px;background:var(--warn);color:#fff;font-size:.65rem;font-weight:700;border-radius:9px;padding:1px 5px;display:none}
#chat-panel{position:fixed;bottom:4.8rem;right:1.5rem;width:340px;max-height:480px;background:#fff;border-radius:14px;box-shadow:0 8px 32px rgba(31,56,100,.22);z-index:998;display:none;flex-direction:column;overflow:hidden;border:1px solid var(--grau2)}
#chat-panel.open{display:flex}
.chat-header{background:var(--blau);color:#fff;padding:.75rem 1rem;font-weight:600;font-size:.9rem;display:flex;align-items:center;gap:.5rem}
.chat-online-dot{width:8px;height:8px;border-radius:50%;background:#4caf50;flex-shrink:0}
#chat-messages{flex:1;overflow-y:auto;padding:.75rem;display:flex;flex-direction:column;gap:.5rem;background:var(--grau);min-height:100px}
.chat-msg{max-width:85%;padding:.5rem .75rem;border-radius:10px;font-size:.85rem;line-height:1.45;word-break:break-word}
.chat-msg.mine{align-self:flex-end;background:var(--blau);color:#fff;border-bottom-right-radius:3px}
.chat-msg.other{align-self:flex-start;background:#fff;color:var(--text);border-bottom-left-radius:3px;box-shadow:0 1px 4px rgba(0,0,0,.08)}
.chat-meta{font-size:.68rem;opacity:.6;margin-top:.3rem}
.chat-msg.mine .chat-meta{text-align:right}
.chat-msg audio{max-width:200px;display:block;margin-top:.25rem}
.chat-msg a{color:inherit;text-decoration:underline}
.chat-footer{padding:.6rem;background:#fff;border-top:1px solid var(--grau2);display:flex;gap:.4rem;align-items:flex-end}
#chat-input{flex:1;border:1px solid var(--grau3);border-radius:8px;padding:.45rem .7rem;font-size:.85rem;resize:none;max-height:80px;font-family:inherit;outline:none;line-height:1.4}
#chat-input:focus{border-color:var(--blau-hell)}
.chat-icon-btn{width:36px;height:36px;border-radius:50%;border:none;cursor:pointer;display:flex;align-items:center;justify-content:center;font-size:1rem;background:var(--grau2);color:var(--text);flex-shrink:0;transition:background .15s}
.chat-icon-btn:hover{background:var(--grau3)}
#chat-send-btn{background:var(--blau);color:#fff}
#chat-send-btn:hover{background:var(--blau-hell)}
#chat-record-btn.recording{background:#e53935;color:#fff;animation:chat-pulse .7s infinite}
@keyframes chat-pulse{0%,100%{transform:scale(1)}50%{transform:scale(1.15)}}
