/* ============================================================
   KAI-GAPEKA Train Graph Editor — style.css
   ============================================================ */

/* Override body layout for train graph — use all space */
body {
  overflow: hidden;
}

/* Full-height wrapper below header */
.tg-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  height: calc(100vh - 52px);
}

/* ── Left sidebar ────────────────────────────────────────── */
.tg-sidebar {
  width: 200px;
  background: #fff;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.tg-sidebar-logo {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.tg-sidebar-logo .sidebar-brand {
  font-size: 0.875rem;
  font-weight: 800;
}
.tg-sidebar-logo .sidebar-brand span {
  color: var(--kai-red);
}
.tg-sidebar-logo .sidebar-sub {
  font-size: 0.6rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Reuse sidebar nav styles */
.tg-sidebar .nav-sec   { padding: 12px 16px 4px; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; font-weight: 700; }
.tg-sidebar .nav-item  { display: flex; align-items: center; gap: 10px; padding: 8px 16px; font-size: 12px; color: var(--muted); cursor: pointer; transition: all 0.15s; font-weight: 500; text-decoration: none; }
.tg-sidebar .nav-item:hover { background: rgba(0,0,0,0.04); color: var(--text); }
.tg-sidebar .nav-item.active { background: rgba(220,38,38,0.1); color: var(--kai-red); border-right: 3px solid var(--kai-red); }
.tg-sidebar .nav-item i { width: 16px; text-align: center; font-size: 13px; }
.tg-sidebar .nav-badge { margin-left: auto; background: var(--red); color: #fff; padding: 0.1rem 0.375rem; border-radius: 100px; font-size: 0.5625rem; font-weight: 700; }

/* Trip list in sidebar */
.tg-trip-list {
  padding: 0.5rem 0;
  flex: 1;
  overflow-y: auto;
}
.tg-trip-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  cursor: pointer;
  transition: background 0.12s;
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}
.tg-trip-item:hover {
  background: rgba(0,0,0,0.04);
  color: var(--text);
}
.tg-trip-item.selected {
  background: rgba(220,38,38,0.08);
  color: var(--kai-red);
}
.tg-trip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.tg-trip-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tg-trip-class {
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 100px;
  font-weight: 600;
  flex-shrink: 0;
}
.cls-eks  { background: rgba(37,99,235,0.12); color: #1E40AF; }
.cls-bis  { background: rgba(249,115,22,0.12); color: #9A3412; }
.cls-eko  { background: rgba(100,116,139,0.12); color: #475569; }

.tg-sidebar .sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.tg-sidebar .sidebar-avatar {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, var(--kai-red), var(--orange));
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.6875rem; font-weight: 700; color: #fff; flex-shrink: 0;
}
.tg-sidebar .sidebar-user-name { font-size: 0.75rem; font-weight: 600; color: var(--text); }
.tg-sidebar .sidebar-user-role { font-size: 0.625rem; color: var(--muted); }
.tg-sidebar .sidebar-logout { margin-left: auto; color: var(--muted); cursor: pointer; font-size: 12px; }
.tg-sidebar .sidebar-logout:hover { color: var(--red); }

/* ── Main area ───────────────────────────────────────────── */
.tg-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── Toolbar ─────────────────────────────────────────────── */
.tg-toolbar {
  height: 48px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1rem;
  gap: 0.5rem;
  flex-shrink: 0;
  flex-wrap: nowrap;
  overflow-x: auto;
}
.tg-toolbar .sep-v {
  width: 1px;
  height: 24px;
  background: var(--border);
  flex-shrink: 0;
}
.tg-toolbar select,
.tg-toolbar input[type="date"] {
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.75rem;
  color: var(--text);
  background: var(--bg);
  cursor: pointer;
  font-family: inherit;
  height: 30px;
}
.tg-toolbar select:focus,
.tg-toolbar input[type="date"]:focus {
  outline: none;
  border-color: var(--accent);
}
.tg-toolbar .lbl {
  font-size: 0.6875rem;
  color: var(--muted);
  white-space: nowrap;
  font-weight: 600;
}
.tg-zoom-btn {
  width: 30px; height: 30px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text);
  transition: all 0.15s;
  flex-shrink: 0;
}
.tg-zoom-btn:hover { border-color: var(--accent); color: var(--accent); }
.tg-zoom-level {
  font-size: 0.6875rem;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  min-width: 32px;
  text-align: center;
}
.btn-conflict-toggle {
  height: 30px;
  padding: 0 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  display: flex; align-items: center; gap: 0.375rem;
  background: rgba(239,68,68,0.08);
  color: var(--red);
  border-color: rgba(239,68,68,0.3);
  transition: all 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-conflict-toggle:hover { background: rgba(239,68,68,0.15); }
.btn-conflict-toggle.off { background: none; color: var(--muted); border-color: var(--border); }

/* ── Canvas wrap ─────────────────────────────────────────── */
.tg-canvas-wrap {
  flex: 1;
  overflow: hidden;
  background: #F8FAFC;
  position: relative;
  cursor: crosshair;
}
.tg-canvas {
  width: 100%;
  height: 100%;
  display: block;
}
/* SVG inside canvas wrap */
#tgSvg {
  width: 100%;
  height: 100%;
  display: block;
  user-select: none;
}

/* Train lines in SVG */
.train-line {
  stroke-width: 2.5;
  fill: none;
  cursor: pointer;
  transition: stroke-width 0.15s, opacity 0.15s;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.train-line:hover {
  stroke-width: 5;
}
.train-line.selected {
  stroke-width: 5;
  filter: drop-shadow(0 0 4px currentColor);
}
.train-line.dimmed {
  opacity: 0.2;
}

/* Stop dots */
.stop-dot {
  cursor: pointer;
  transition: r 0.15s;
}
.stop-dot:hover {
  r: 6;
}

/* Conflict markers */
.conflict-marker {
  cursor: pointer;
  animation: conflict-pulse 2s infinite;
}
@keyframes conflict-pulse {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

/* Station labels */
.station-label {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 600;
  fill: var(--text);
  dominant-baseline: middle;
}
.station-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  fill: var(--muted);
  dominant-baseline: middle;
}

/* Time labels */
.time-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  fill: var(--muted);
  text-anchor: middle;
}

/* Today line */
.today-line {
  stroke: var(--kai-red);
  stroke-width: 1.5;
  stroke-dasharray: 6 4;
  opacity: 0.7;
}
.today-label {
  font-family: 'Inter', sans-serif;
  font-size: 9px;
  font-weight: 700;
  fill: var(--kai-red);
  text-anchor: middle;
}

/* Tooltip overlay */
.tg-tooltip {
  position: absolute;
  background: #1E293B;
  color: #F1F5F9;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font-size: 0.75rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 50;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  max-width: 260px;
  white-space: normal;
}
.tg-tooltip.visible {
  opacity: 1;
}
.tg-tooltip-title {
  font-weight: 700;
  margin-bottom: 4px;
  color: #fff;
}
.tg-tooltip-row {
  font-size: 0.6875rem;
  color: #94A3B8;
  display: flex;
  gap: 6px;
}
.tg-tooltip-row strong {
  color: #CBD5E1;
}

/* SVG animation: draw on load */
.train-line {
  stroke-dashoffset: 0;
}

/* ── Status bar ──────────────────────────────────────────── */
.tg-statusbar {
  height: 28px;
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1rem;
  gap: 1.25rem;
  font-size: 0.6875rem;
  color: var(--muted);
  flex-shrink: 0;
}
.tg-statusbar .sb-item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}
.tg-statusbar .sb-item i {
  font-size: 10px;
}
.sb-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.tg-statusbar .sep-v {
  width: 1px; height: 16px;
  background: var(--border);
}
.sb-live-clock {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: var(--text);
}

/* ── Right panel (trip details) ──────────────────────────── */
.tg-panel {
  width: 280px;
  background: #fff;
  border-left: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}
.tg-panel-hdr {
  padding: 0.875rem 1rem 0.75rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.tg-panel-title {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.tg-panel-body {
  padding: 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.tg-panel-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 200px;
  color: var(--muted);
  font-size: 0.8125rem;
}
.tg-panel-empty i {
  font-size: 2rem;
  opacity: 0.3;
}

/* Trip detail sections */
.detail-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.detail-section-title {
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding-bottom: 0.375rem;
  border-bottom: 1px solid var(--border);
}
.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8125rem;
}
.detail-label {
  color: var(--muted);
  font-size: 0.75rem;
}
.detail-value {
  font-weight: 600;
  color: var(--text);
  font-size: 0.8125rem;
  text-align: right;
}
.detail-value.mono {
  font-family: 'JetBrains Mono', monospace;
}

/* Stop timeline in panel */
.stop-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.stop-timeline-item {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  position: relative;
  padding-bottom: 0.75rem;
}
.stop-timeline-item:last-child {
  padding-bottom: 0;
}
.stop-tl-dot-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  width: 16px;
}
.stop-tl-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 2px solid;
  flex-shrink: 0;
  background: #fff;
  margin-top: 3px;
}
.stop-tl-line {
  width: 2px;
  flex: 1;
  background: var(--border);
  min-height: 20px;
  margin-top: 2px;
}
.stop-tl-body {
  flex: 1;
  min-width: 0;
}
.stop-tl-station {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text);
}
.stop-tl-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6875rem;
  color: var(--muted);
  margin-top: 1px;
}

/* Train color indicator bar */
.train-color-bar {
  height: 4px;
  border-radius: 2px;
  margin-bottom: 0.75rem;
}

/* Conflict badge in panel */
.conflict-badge-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.5rem 0.625rem;
  background: rgba(239,68,68,0.06);
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: 7px;
  font-size: 0.75rem;
}
.conflict-badge-item i {
  color: var(--red);
  margin-top: 1px;
  flex-shrink: 0;
}
