/* ============================================================
   Bahnwagen Einsatzplanung -- CSS
   ============================================================ */

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

:root {
  --navy:    #1a3a5c;
  --navy-lt: #2a527a;
  --blue:    #3a7bd5;
  --blue-lt: #5a9be0;
  --bg:      #f0f4f8;
  --surface: #ffffff;
  --border:  #dde3ea;
  --text:    #1e2a38;
  --muted:   #5a6a7a;
  --ok:      #1d9e75;
  --ok-bg:   #e1f5ee;
  --warn:    #c07a00;
  --warn-bg: #fef3d0;
  --danger:  #c0392b;
  --danger-bg:#fdecea;
  --info:    #185fa5;
  --info-bg: #e6f1fb;
  --sidebar-w: 220px;
  --header-h:  54px;
}

body { font-family: 'Segoe UI', system-ui, sans-serif; font-size: 14px;
       background: var(--bg); color: var(--text); line-height: 1.5; }

/* ---- Login ---- */
#login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-lt) 100%);
  padding: 20px;
}
.login-box {
  background: var(--surface); border-radius: 16px; padding: 40px 36px;
  width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-logo { text-align: center; margin-bottom: 16px; }
.login-box h1 { text-align:center; font-size: 22px; font-weight: 600; color: var(--navy); }
.login-sub { text-align:center; color: var(--muted); font-size: 13px; margin-bottom: 28px; }
.form-group { margin-bottom: 16px; }
.form-group label { display:block; font-size:12px; font-weight:600;
  color: var(--muted); text-transform:uppercase; letter-spacing:.05em; margin-bottom:6px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: 14px; color: var(--text);
  background: var(--surface); transition: border-color .15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--blue);
}
.error-msg { background: var(--danger-bg); color: var(--danger);
  padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }

/* ---- Buttons ---- */
.btn-primary { background: var(--blue); color: #fff; border: none; border-radius: 8px;
  padding: 10px 20px; font-size: 14px; font-weight: 500; cursor: pointer; transition: background .15s; }
.btn-primary:hover { background: var(--blue-lt); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1.5px solid var(--border);
  border-radius: 8px; padding: 8px 16px; font-size: 14px; cursor: pointer; }
.btn-secondary:hover { background: var(--bg); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border: none;
  border-radius: 8px; padding: 8px 16px; font-size: 14px; cursor: pointer; }
.btn-icon { background: none; border: none; cursor: pointer; color: var(--muted);
  padding: 6px; border-radius: 6px; display: inline-flex; align-items:center; }
.btn-icon:hover { background: var(--bg); color: var(--text); }
.btn-full { width: 100%; padding: 12px; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ---- App Layout ---- */
#app { display: flex; min-height: 100vh; }
#sidebar {
  width: var(--sidebar-w); min-height: 100vh; background: var(--navy);
  display: flex; flex-direction: column; position: fixed; left: 0; top: 0;
  z-index: 100; transition: transform .25s;
}
#main { margin-left: var(--sidebar-w); flex: 1; padding: 24px; min-height: 100vh; }
#menu-btn { display: none; position: fixed; top: 12px; left: 12px; z-index: 200;
  background: var(--navy); color: #fff; border: none; border-radius: 8px;
  padding: 8px; cursor: pointer; }

/* ---- Sidebar ---- */
.sidebar-header { display: flex; align-items: center; gap: 10px;
  padding: 20px 16px 16px; border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar-title { color: #fff; font-weight: 600; font-size: 15px; }
.nav-links { flex: 1; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-radius: 8px; color: rgba(255,255,255,.7); cursor: pointer;
  font-size: 14px; text-decoration: none; transition: all .15s; }
.nav-item:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.15); color: #fff; font-weight: 500; }
.sidebar-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,.1);
  display: flex; align-items: center; justify-content: space-between; }
.user-chip { color: rgba(255,255,255,.8); font-size: 13px; }
.sidebar-footer .btn-icon { color: rgba(255,255,255,.6); }
.sidebar-footer .btn-icon:hover { color: #fff; background: rgba(255,255,255,.1); }

/* ---- Page Elements ---- */
.page-header { display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.page-header h2 { font-size: 20px; font-weight: 600; color: var(--navy); }
.page { animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ---- Cards ---- */
.card { background: var(--surface); border-radius: 12px; border: 1px solid var(--border); padding: 18px 20px; }
.card + .card { margin-top: 14px; }
.card-title { font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 14px; }

/* ---- Metrics ---- */
.metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 16px; }
.metric { background: var(--surface); border-radius: 10px; border: 1px solid var(--border); padding: 14px 16px; }
.metric .m-label { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.metric .m-value { font-size: 26px; font-weight: 700; color: var(--navy); line-height: 1; }
.metric .m-sub { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* ---- Table ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { background: var(--bg); font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em; padding: 9px 12px;
  text-align: left; position: sticky; top: 0; white-space: nowrap; }
tbody td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafd; }
.mono { font-family: 'Consolas', 'Courier New', monospace; font-size: 12px; }

/* ---- Badges ---- */
.badge { display: inline-flex; align-items: center; padding: 2px 9px;
  border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.b-ok      { background: var(--ok-bg); color: var(--ok); }
.b-warn    { background: var(--warn-bg); color: var(--warn); }
.b-danger  { background: var(--danger-bg); color: var(--danger); }
.b-info    { background: var(--info-bg); color: var(--info); }
.b-neutral { background: var(--bg); color: var(--muted); }

/* ---- Filter Bar ---- */
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filter-bar select, .filter-bar input {
  padding: 7px 10px; border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 13px; background: var(--surface); color: var(--text); }
.filter-bar select:focus, .filter-bar input:focus { outline: none; border-color: var(--blue); }
.filter-count { font-size: 12px; color: var(--muted); margin-left: 4px; }

/* ---- Standorte Grid ---- */
.standort-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 10px; }
.standort-card { background: var(--bg); border-radius: 10px; padding: 14px;
  border: 1px solid var(--border); cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.standort-card:hover { border-color: var(--blue); box-shadow: 0 2px 10px rgba(58,123,213,.1); }
.standort-card .sc-ort { font-weight: 600; font-size: 13px; color: var(--navy); }
.standort-card .sc-count { font-size: 28px; font-weight: 700; color: var(--blue); line-height: 1.2; }
.standort-card .sc-sub { font-size: 11px; color: var(--muted); }

/* ---- Gantt ---- */
.gantt-container { overflow-x: auto; }
.gantt-header { display: flex; margin-left: 160px; }
.gantt-month { font-size: 10px; font-weight: 600; color: var(--muted);
  text-align: center; border-left: 1px solid var(--border); padding: 4px 0; }
.gantt-row { display: flex; align-items: center; height: 30px; margin-bottom: 3px; }
.gantt-label { width: 160px; min-width: 160px; font-size: 12px; color: var(--text);
  padding-right: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gantt-track { flex: 1; background: var(--bg); border-radius: 4px;
  height: 22px; position: relative; border: 1px solid var(--border); }
.gantt-bar { position: absolute; height: 22px; border-radius: 4px;
  display: flex; align-items: center; padding: 0 6px;
  font-size: 11px; font-weight: 500; white-space: nowrap; overflow: hidden; cursor: default; }
.gantt-today { position: absolute; width: 2px; background: #e74c3c; height: 100%; opacity: .6; top: 0; }

/* ---- Modal ---- */
#modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; }
#modal { background: var(--surface); border-radius: 14px; width: 100%;
  max-width: 520px; max-height: 90vh; overflow-y: auto; padding: 24px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-header h3 { font-size: 17px; font-weight: 600; color: var(--navy); }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ---- Hinweis-Liste ---- */
.hinweis-row { display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border); }
.hinweis-row:last-child { border-bottom: none; }
.hinweis-row .h-nr { font-family: monospace; font-size: 12px; color: var(--navy);
  font-weight: 600; min-width: 140px; }
.hinweis-row .h-note { font-size: 12px; color: var(--muted); }

/* ---- Loading ---- */
.loading { text-align: center; padding: 40px; color: var(--muted); font-size: 14px; }
.loading::after { content: ''; display: inline-block; width: 18px; height: 18px;
  border: 2px solid var(--border); border-top-color: var(--blue);
  border-radius: 50%; animation: spin .7s linear infinite; margin-left: 8px; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Toast ---- */
#toast { position: fixed; bottom: 24px; right: 24px; background: var(--navy); color: #fff;
  padding: 12px 18px; border-radius: 10px; font-size: 13px; font-weight: 500;
  z-index: 9999; transform: translateY(80px); opacity: 0; transition: all .25s; pointer-events: none; }
#toast.show { transform: translateY(0); opacity: 1; }

/* ---- Gleisbelegung ---- */
.gleis-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px,1fr)); gap: 12px; }
.gleis-card { background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.gleis-card:hover { border-color: var(--blue); box-shadow: 0 2px 10px rgba(58,123,213,.1); }
.gc-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 8px; }
.gc-name { font-weight: 600; font-size: 14px; color: var(--navy); }
.gc-richtung { font-size: 11px; color: var(--muted); margin-top: 2px; }
.gc-stats { display: flex; gap: 12px; font-size: 12px; color: var(--muted); margin-bottom: 8px; flex-wrap: wrap; }
.gc-bar-wrap { background: var(--border); border-radius: 4px; height: 8px; margin-bottom: 4px; overflow: hidden; }
.gc-bar { height: 8px; border-radius: 4px; transition: width .4s; }
.gc-pct { font-size: 11px; font-weight: 600; margin-bottom: 6px; }
.gc-hint { font-size: 11px; color: var(--blue); }

/* Gleis-Visualisierung */
.gleis-visual { display: flex; align-items: center; gap: 8px; margin: 12px 0; }
.gv-label { font-size: 11px; color: var(--muted); white-space: nowrap; min-width: 70px; }
.gv-right { text-align: right; }
.gv-track { flex: 1; display: flex; height: 28px; background: var(--bg);
  border-radius: 4px; border: 1px solid var(--border); overflow: hidden; gap: 1px; padding: 2px; }
.gv-wagen { height: 100%; border-radius: 3px; display: flex; align-items: center;
  justify-content: center; font-size: 10px; font-weight: 600; color: #fff;
  min-width: 18px; cursor: default; transition: opacity .15s; }
.gv-wagen:hover { opacity: .8; }

@media (max-width: 480px) {
  .gleis-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  #sidebar { transform: translateX(-100%); }
  #sidebar.open { transform: translateX(0); }
  #main { margin-left: 0; padding: 16px; padding-top: 60px; }
  #menu-btn { display: flex; align-items: center; justify-content: center; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .gantt-label { width: 100px; min-width: 100px; font-size: 10px; }
  .gantt-header { margin-left: 100px; }
  table { font-size: 12px; }
  thead th, tbody td { padding: 7px 8px; }
}
@media (max-width: 480px) {
  .metrics-grid { grid-template-columns: 1fr 1fr; }
  .standort-grid { grid-template-columns: 1fr 1fr; }
}

/* ---- Toggle Switch ---- */
.toggle-switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; inset: 0;
  background: var(--border); border-radius: 24px; transition: .2s; }
.toggle-slider:before { content: ''; position: absolute; width: 18px; height: 18px;
  left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: .2s; }
.toggle-switch input:checked + .toggle-slider { background: var(--blue); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(18px); }

/* ---- Drag & Drop ---- */
.dnd-row { transition: background .15s; }
.dnd-row.dnd-over { background: var(--info-bg) !important; outline: 2px dashed var(--blue); }
.dnd-row[draggable="true"]:active { cursor: grabbing; }

/* ---- Disposition ---- */
.dispo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.dispo-card { border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-bottom: 10px; background: var(--surface); }
.dispo-card:last-child { margin-bottom: 0; }
.dispo-unterwegs { border-left: 4px solid var(--blue); }
.dispo-geplant   { border-left: 4px solid var(--warn); }
.dispo-dringend  { border-left: 4px solid var(--danger); background: #fffaf8; }
.dispo-card-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 8px; }
.dispo-wagen  { font-family: monospace; font-size: 13px; font-weight: 600; color: var(--navy); }
.dispo-projekt { font-size: 12px; color: var(--muted); margin-top: 2px; }
.dispo-meta   { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--text); margin-bottom: 10px; }
.dispo-actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 768px) { .dispo-grid { grid-template-columns: 1fr; } }

/* ---- Gleis-Transfer ---- */
.tr-wagen-chip { display:flex; flex-direction:column; gap:2px; padding:8px 10px;
  margin-bottom:5px; background:var(--surface); border:1px solid var(--border);
  border-radius:8px; cursor:grab; user-select:none; transition:box-shadow .15s, opacity .15s; }
.tr-wagen-chip:hover { box-shadow:0 2px 8px rgba(58,123,213,.15); border-color:var(--blue); }
.tr-wagen-chip:active { cursor:grabbing; opacity:.6; }
