/* Dispo Web App – basiert auf FSD Web Portal Look */
* { box-sizing: border-box; }
body { margin: 0; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); min-height: 100vh; }

/* Einsatzplan "Plan-only" (neuer Tab): ohne Portal-Look, maximal stabil fürs Layout */
body.plan-bare { background: #fff; }
body.plan-bare .portal-container { max-width: none; margin: 0; padding: 10px; }
body.plan-bare .glass-card { border-radius: 0; box-shadow: none; padding: 10px; }

.portal-container { max-width: 1200px; margin: 24px auto; padding: 18px; }
.glass-card { background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(10px); border-radius: 15px; padding: 20px; box-shadow: 0 8px 32px rgba(0,0,0,0.10); }
.brand-title { color: #2c3e50; font-weight: 800; margin: 0 0 14px; letter-spacing: .2px; }

/* Actionbar */
.actionbar { display: flex; gap: 10px; padding: 10px; border-radius: 14px; background: rgba(255,255,255,0.95); box-shadow: 0 6px 24px rgba(0,0,0,.12); align-items: center; margin-bottom: 14px; position: sticky; top: 12px; z-index: 5; }
.ab-spacer { flex: 1; }
.ab-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 14px; border: none; border-radius: 10px; background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%); color: #6c757d; cursor: pointer; font-weight: 700; transition: all .25s ease; text-decoration: none; box-shadow: 0 2px 10px rgba(0,0,0,.06); }
.ab-btn:hover { transform: translateY(-2px); background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #fff; box-shadow: 0 8px 26px rgba(102,126,234,.35); }
.ab-btn.danger:hover { background: linear-gradient(135deg, #ff5f6d 0%, #ffc371 100%); }
.ab-btn .icon { font-size: 18px; }

/* Cards/sections */
.section { margin-top: 16px; }
.section h2 { margin: 0 0 10px; color:#ffffff; font-size: 1.1rem; text-shadow: 0 1px 2px rgba(0,0,0,.25); }
.card { background: rgba(255,255,255,0.95); border-radius: 12px; padding: 14px; box-shadow: 0 4px 18px rgba(0,0,0,.08); }
.v-gap-small { height: 12px; }

/* Messages */
.message { padding: 10px 12px; border-radius: 10px; margin: 10px 0; box-shadow: 0 6px 18px rgba(0,0,0,.08); }
.message.success { background: #eafaf1; border: 1px solid #bfead0; color: #155724; }
.message.error { background: #fdecec; border: 1px solid #f5c6cb; color: #721c24; }

/* Forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 860px){ .form-grid { grid-template-columns: 1fr; } }
.form-row { display: grid; gap: 6px; }
.form-row label { font-weight: 700; color: #2c3e50; font-size: 13px; }
.form-row input, .form-row select, .form-row textarea { width: 100%; padding: 10px 12px; border: 2px solid #e1e5e9; border-radius: 10px; font-size: 14px; transition: border-color .2s ease; background: #fff; }
.form-row textarea { min-height: 84px; resize: vertical; }
.form-row input:focus, .form-row select:focus, .form-row textarea:focus { outline: none; border-color: #667eea; box-shadow: 0 0 0 3px rgba(102,126,234,.15); }

.btn { display:inline-flex; align-items:center; gap:8px; border:none; border-radius: 10px; padding: 10px 14px; cursor:pointer; font-weight: 800; text-decoration:none; }
.btn-primary { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color:#fff; }
.btn-primary:hover { filter: brightness(1.05); box-shadow: 0 8px 20px rgba(102,126,234,.35); }
.btn-success { background: linear-gradient(135deg, #56ab2f 0%, #a8e6cf 100%); color:#0b3b1a; }
.btn-success:hover { filter: brightness(1.02); box-shadow: 0 8px 20px rgba(86,171,47,.25); }
.btn-danger { background: linear-gradient(135deg, #ff5f6d 0%, #ffc371 100%); color:#3b0b11; }
.btn-secondary { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); color:#fff; }
.btn-ghost { background: #f3f4f6; color:#374151; border: 1px solid #e5e7eb; }

.toolbar { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.toolbar .spacer { flex: 1; }

/* Table */
.table-wrap { overflow:auto; border-radius: 12px; border: 1px solid #e5e7eb; }
table { width: 100%; border-collapse: collapse; min-width: 780px; }
th, td { padding: 10px 10px; border-bottom: 1px solid #edf2f7; text-align: left; vertical-align: top; }
th { background: #f8fafc; position: sticky; top: 0; z-index: 1; font-weight: 900; color:#111827; }
tr:hover td { background: #fafbff; }
.pill { display:inline-flex; align-items:center; gap:6px; padding: 4px 8px; border-radius: 999px; background: #eef2ff; color:#374151; font-size: 12px; font-weight: 800; }
.pill.off { background:#fee2e2; }

.muted { color:#6b7280; font-size: 12px; }
.right { text-align:right; }
.nowrap { white-space: nowrap; }

/* Login */
.login-card { max-width: 440px; margin: 60px auto; }
.divider { height:1px; background:linear-gradient(90deg, transparent, rgba(0,0,0,.08), transparent); margin: 12px 0; }
.login-actions { display:flex; justify-content:flex-end; margin-top:8px; }

/* Gantt / Balkenplan */
.backlog { display:flex; gap:10px; flex-wrap:wrap; padding: 10px; border-radius: 12px; border: 1px dashed rgba(17,24,39,0.18); background: rgba(255,255,255,0.75); }
.backlog .title { font-weight: 900; margin-right: 6px; }
.backlog-item { display:inline-flex; align-items:center; gap:8px; padding: 8px 10px; border-radius: 999px; background:#f3f4f6; border: 1px solid #e5e7eb; cursor: grab; user-select:none; font-weight: 900; }
.backlog-item:active { cursor: grabbing; }
.backlog-item .meta { font-size: 12px; font-weight: 800; color:#6b7280; }
.backlog-item:hover { background:#eef2ff; border-color:#c7d2fe; }
.backlog-item.used { opacity: .55; }
.backlog-hint { color:#6b7280; font-size: 12px; }

.gantt { border:1px solid #e5e7eb; border-radius: 12px; overflow: auto; background: rgba(255,255,255,0.92); position: relative; }

/* Einsatzplanung: eigene vertikale Scrollbar im Planbereich (statt nur Page-Scroll) */
#planRoot .gantt{
  height: 70vh;
  overflow-y: auto;
  overflow-x: auto;
}

/* Kein horizontaler Page-Scroll – horizontal soll im Plan stattfinden */
body{ overflow-x: hidden; }

/* (Top-Scrollbar entfernt) */

/* Im "Fenster füllen"-Modus: Höhe wird über Flex geregelt (siehe unten: flex:1 + min-height:0).
   Eine feste height:100% kann je nach Container-Höhe die Scrollbars kaputt machen. */
body.plan-max #planRoot .gantt{ height: auto; }
.gantt-grid { min-width: 980px; }
.gantt-grid::after { content:""; display:block; height: 140px; } /* echter Spacer unten, damit nichts abgeschnitten wird */
.gantt-header { position: sticky; top: 0; z-index: 3; background: rgba(248,250,252,0.98); border-bottom: 1px solid #e5e7eb; }

/* Fix: Im Vollbildmodus kann `position: sticky` je nach Browser/Scroll-Container zu horizontalen Offsets
   zwischen Zeitachse und Balken führen. Daher im plan-max/plan-bare die Header-Achse normal mitscrollen lassen. */
body.plan-max .gantt-header,
body.plan-bare .gantt-header{
  position: relative;
  top: auto;
}
.gantt-header-inner { display:flex; align-items: stretch; }
.gantt-header .left { width:260px; flex: 0 0 260px; padding: 10px; font-weight: 900; color:#111827; border-right: 1px solid #e5e7eb; }
.gantt-header .axis { flex: 0 0 auto; }
.gantt-header .axis { position: relative; overflow: hidden; } /* verhindert Überlauf in linke Spalte */
.gantt-axis { position: relative; height: 44px; }
.gantt-axis .tick { position:absolute; top:0; bottom:0; width:1px; background: rgba(17,24,39,0.08); }
.gantt-axis .tick.minor { opacity: .5; top: 22px; bottom: 0; }
.gantt-axis .label { position:absolute; top: 10px; transform: translateX(-50%); font-size: 12px; font-weight: 900; color:#111827; }

.gantt-lane { display:flex; border-bottom: 1px solid rgba(17,24,39,0.06); }
.gantt-lane:last-child { border-bottom: none; }
.gantt-lane .label { width:260px; flex: 0 0 260px; position: sticky; left: 0; z-index: 2; background: rgba(255,255,255,0.98); border-right: 1px solid #e5e7eb; padding: 10px; }
.gantt-lane .label .name { font-weight: 900; color:#111827; }
.gantt-lane .label .sub { margin-top:4px; font-size: 12px; color:#6b7280; }
.gantt-lane .track { flex: 0 0 auto; position: relative; min-height: 78px; padding-bottom: 18px; }
.bars-layer{ position: relative; }

/* NEUE VERSION: Track für Unverplant mit synchroner Positionierung zur Zeitachse */
.track-unplanned {
  position: relative;
  overflow: visible;
}

.bars-layer-new {
  position: relative;
  width: 100%;
  height: 100%;
}

/* NEUE VERSION: Balken mit Prozent-basierter Positionierung - skaliert automatisch mit der Zeitachse */
.gantt-bar-new {
  position: absolute;
  top: 12px;
  height: 44px;
  border-radius: 10px;
  padding: 7px 10px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  line-height: 1.1;
  background: linear-gradient(135deg, rgba(102,126,234,0.95) 0%, rgba(118,75,162,0.95) 100%);
  color: #fff;
  font-weight: 900;
  box-shadow: 0 10px 22px rgba(102,126,234,.25);
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.35);
  min-width: 6px;
}

.gantt-bar-new:hover {
  filter: brightness(1.05);
  box-shadow: 0 14px 28px rgba(102,126,234,.35);
}

.gantt-bar-new .meta {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  opacity: .92;
  font-weight: 700;
  line-height: 1.1;
}

.gantt-bar-new.unassigned {
  background: linear-gradient(135deg, rgba(240,147,251,0.95) 0%, rgba(245,87,108,0.95) 100%);
  box-shadow: 0 10px 22px rgba(245,87,108,.20);
}

.gantt-bar-new.backlog {
  background: linear-gradient(135deg, rgba(56,189,248,0.95) 0%, rgba(99,102,241,0.95) 100%);
  box-shadow: 0 10px 22px rgba(99,102,241,.22);
}

.gantt-bar-new[draggable="true"] {
  cursor: grab;
}

.gantt-bar-new[draggable="true"]:active {
  cursor: grabbing;
}

/* (keine Spezial-Container mehr nötig) */
/* Unverplant/Woche: pro Tag eigener Container, damit jeder Tag oben startet */
#planRoot .track[data-lane-type="unplanned-static"] .unplanned-day{
  position: absolute;
  top: 0;
  bottom: 0;
}

/* Unverplant: wie Zeitstrahl, aber kompakt gepackt (per Tag eigene Reihen) */

/* Grid je Modus (damit z.B. 06:30 sichtbar „passt“) */
.gantt[data-mode="day"] .gantt-lane .track{
  background-image:
    repeating-linear-gradient(to right, rgba(17,24,39,0.06) 0px, rgba(17,24,39,0.06) 1px, transparent 1px, transparent 120px),
    repeating-linear-gradient(to right, rgba(17,24,39,0.03) 0px, rgba(17,24,39,0.03) 1px, transparent 1px, transparent 30px);
}
.gantt[data-mode="week"] .gantt-lane .track{
  background-image:
    repeating-linear-gradient(to right, rgba(17,24,39,0.06) 0px, rgba(17,24,39,0.06) 1px, transparent 1px, transparent 60px),
    repeating-linear-gradient(to right, rgba(17,24,39,0.03) 0px, rgba(17,24,39,0.03) 1px, transparent 1px, transparent 30px);
}
.gantt-bar { position:absolute; top: 12px; height: 44px; border-radius: 10px; padding: 7px 10px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; line-height: 1.1;
  background: linear-gradient(135deg, rgba(102,126,234,0.95) 0%, rgba(118,75,162,0.95) 100%);
  color: #fff; font-weight: 900; box-shadow: 0 10px 22px rgba(102,126,234,.25);
  cursor: pointer; border: 1px solid rgba(255,255,255,0.35);
}
.gantt-bar:hover { filter: brightness(1.05); box-shadow: 0 14px 28px rgba(102,126,234,.35); }
.gantt-bar .meta { display:block; margin-top: 2px; font-size: 11px; opacity: .92; font-weight: 700; line-height: 1.1; }
.gantt-bar.unassigned { background: linear-gradient(135deg, rgba(240,147,251,0.95) 0%, rgba(245,87,108,0.95) 100%); box-shadow: 0 10px 22px rgba(245,87,108,.20); }
.gantt-bar.conflict { outline: 3px solid rgba(255,95,109,0.85); }
.gantt-bar.backlog { background: linear-gradient(135deg, rgba(56,189,248,0.95) 0%, rgba(99,102,241,0.95) 100%); box-shadow: 0 10px 22px rgba(99,102,241,.22); }
.gantt-bar[draggable="true"] { cursor: grab; }
.gantt-bar[draggable="true"]:active { cursor: grabbing; }

.gantt-dayline { position:absolute; top:0; bottom:0; width:2px; background: rgba(17,24,39,0.10); }
.gantt-daylabel { position:absolute; top: 2px; transform: translateX(-50%); font-size: 11px; font-weight: 900; color:#111827; background: rgba(255,255,255,0.85); padding: 2px 6px; border-radius: 999px; border: 1px solid rgba(17,24,39,0.10); }
.gantt-drop { outline: 3px dashed rgba(102,126,234,0.6); outline-offset: -3px; }

/* Fenster füllen (ohne Browser-Fullscreen) – nur auf Einsatzplan */
body.plan-max { overflow: hidden; }
body.plan-max .portal-container { max-width: none; margin: 0; padding: 10px; height: 100vh; }
body.plan-max .glass-card { height: calc(100vh - 20px); display: flex; flex-direction: column; padding: 12px; }
body.plan-max .card { box-shadow: none; }
/* Wichtig: Plan steckt in .section > .card – diese müssen im plan-max ebenfalls flexen,
   sonst bekommt der Gantt keine definierte Höhe und man erreicht unten nicht alle Fahrer. */
body.plan-max .section{ flex: 1; display:flex; flex-direction:column; min-height: 0; }
body.plan-max .section > .card{ flex: 1; display:flex; flex-direction:column; min-height: 0; }
body.plan-max #planRoot { flex: 1; display: flex; flex-direction: column; min-height: 0; }
body.plan-max #planRoot .backlog { position: sticky; top: 70px; z-index: 6; }
body.plan-max #planRoot .gantt { flex: 1; min-height: 0; }

@media (prefers-color-scheme: dark){
  body { background: linear-gradient(135deg, #0b1220 0%, #2b1b3a 100%); }
  .glass-card { background: rgba(20, 26, 39, 0.85); }
  .brand-title { color:#e8ecf3; }
  .card { background: rgba(20, 26, 39, 0.85); }
  .form-row label { color:#e8ecf3; }
  .form-row input, .form-row select, .form-row textarea { background: rgba(255,255,255,0.06); color:#e8ecf3; border-color:#2b3346; }
  th { background: rgba(255,255,255,0.06); color:#e8ecf3; }
  td { color:#e8ecf3; }
  tr:hover td { background: rgba(255,255,255,0.04); }
  .gantt { background: rgba(20, 26, 39, 0.80); border-color:#2b3346; }
  .gantt-header { background: rgba(20, 26, 39, 0.92); border-color:#2b3346; }
  .gantt-header .left { color:#e8ecf3; border-color:#2b3346; }
  .gantt-axis .tick { background: rgba(232,236,243,0.08); }
  .gantt-axis .tick.minor { opacity: .55; }
  .gantt-axis .label { color:#e8ecf3; }
  .gantt-lane .label { background: rgba(20, 26, 39, 0.92); border-color:#2b3346; }
  .gantt-lane .label .name { color:#e8ecf3; }
  .gantt-lane .track { background:
    none;
  }
  .gantt[data-mode="day"] .gantt-lane .track{
    background-image:
      repeating-linear-gradient(to right, rgba(232,236,243,0.10) 0px, rgba(232,236,243,0.10) 1px, transparent 1px, transparent 120px),
      repeating-linear-gradient(to right, rgba(232,236,243,0.06) 0px, rgba(232,236,243,0.06) 1px, transparent 1px, transparent 30px);
  }
  .gantt[data-mode="week"] .gantt-lane .track{
    background-image:
      repeating-linear-gradient(to right, rgba(232,236,243,0.10) 0px, rgba(232,236,243,0.10) 1px, transparent 1px, transparent 60px),
      repeating-linear-gradient(to right, rgba(232,236,243,0.06) 0px, rgba(232,236,243,0.06) 1px, transparent 1px, transparent 30px);
  }
  .backlog { background: rgba(20, 26, 39, 0.45); border-color: rgba(232,236,243,0.16); }
  .backlog-item { background: rgba(255,255,255,0.06); border-color:#2b3346; color:#e8ecf3; }
  .backlog-item:hover { background: rgba(102,126,234,0.18); border-color: rgba(102,126,234,0.45); }
  .backlog-item .meta { color: rgba(232,236,243,0.72); }
  .gantt-dayline { background: rgba(232,236,243,0.10); }
  .gantt-daylabel { color:#e8ecf3; background: rgba(20, 26, 39, 0.85); border-color:#2b3346; }
}


