/* =========================================================
   SWC PMO · schedule.css — Sprint 7
   Gantt profissional estilo ProjectLibre:
   Split panel, setas de dependência, WBS, scroll sincronizado.
========================================================= */

/* ── Layout raiz do módulo ────────────────────────────── */
.sched-root {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

/* ── Toolbar ──────────────────────────────────────────── */
.sched-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 8px 14px;
  background: #161b27;
  border-bottom: 1px solid #263247;
  flex-shrink: 0;
  min-height: 46px;
}
.sched-toolbar-sep {
  width: 1px;
  height: 20px;
  background: #263247;
  margin: 0 2px;
}
.sched-toolbar-spacer { flex: 1; }

.sched-tb-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid #263247;
  background: transparent;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
  line-height: 1;
}
.sched-tb-btn:hover { background: #1e2535; border-color: #3d5070; color: #e2e8f0; }
.sched-tb-btn--gold {
  background: rgba(214,168,79,.12);
  border-color: rgba(214,168,79,.5);
  color: #f59e0b;
}
.sched-tb-btn--gold:hover { background: rgba(214,168,79,.22); border-color: #f59e0b; }
.sched-tb-btn--danger { color: #f87171; border-color: rgba(248,113,113,.3); }
.sched-tb-btn--danger:hover { background: rgba(248,113,113,.1); border-color: #f87171; }
.sched-tb-btn svg { flex-shrink: 0; }

.sched-zoom-wrap {
  display: flex;
  align-items: center;
  gap: 3px;
}
.sched-zoom-lbl {
  font-size: 10.5px;
  font-weight: 700;
  color: #4b5563;
  text-transform: uppercase;
  letter-spacing: .06em;
  min-width: 38px;
  text-align: center;
}

/* Project selector */
.sched-proj-sel {
  background: #0f1520;
  border: 1px solid #263247;
  border-radius: 6px;
  color: #e2e8f0;
  font-size: 12.5px;
  padding: 4px 10px;
  height: 30px;
  outline: none;
  cursor: pointer;
  max-width: 240px;
}
.sched-proj-sel:focus { border-color: #f59e0b; }

/* ── Split panel body ─────────────────────────────────── */
.sched-split {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Left pane — WBS table */
.sched-pane-left {
  width: 420px;
  min-width: 280px;
  max-width: 700px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  border-right: none; /* divider handles it */
}

/* Draggable divider */
.sched-divider {
  width: 5px;
  background: #1a2232;
  border-left: 1px solid #263247;
  border-right: 1px solid #263247;
  cursor: col-resize;
  flex-shrink: 0;
  transition: background .12s;
  position: relative;
  z-index: 10;
}
.sched-divider:hover,
.sched-divider--dragging { background: #f59e0b; border-color: #f59e0b; }

/* Right pane — Gantt */
.sched-pane-right {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Table pane header (column labels) ────────────────── */
.sched-th-row {
  display: flex;
  align-items: stretch;
  background: #0c1120;
  border-bottom: 2px solid #263247;
  height: 34px;
  flex-shrink: 0;
  user-select: none;
  overflow: hidden;
}
.sched-th {
  padding: 0 6px;
  font-size: 10px;
  font-weight: 800;
  color: #4b5563;
  text-transform: uppercase;
  letter-spacing: .08em;
  display: flex;
  align-items: center;
  border-right: 1px solid #1a2232;
  white-space: nowrap;
  overflow: hidden;
  flex-shrink: 0;
}
.sched-th:last-child { border-right: none; }
.sched-th--wbs   { width: 40px; justify-content: center; }
.sched-th--name  { flex: 1; min-width: 100px; }
.sched-th--dur   { width: 48px; justify-content: center; }
.sched-th--start { width: 80px; }
.sched-th--end   { width: 80px; }
.sched-th--pred  { width: 56px; }
.sched-th--resp  { width: 72px; }
.sched-th--pp    { width: 38px; justify-content: center; }
.sched-th--pr    { width: 38px; justify-content: center; }

/* ── Table body scroll area ───────────────────────────── */
.sched-table-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}
.sched-table-body::-webkit-scrollbar { width: 5px; }
.sched-table-body::-webkit-scrollbar-track { background: #0c1120; }
.sched-table-body::-webkit-scrollbar-thumb { background: #263247; border-radius: 3px; }

/* ── Table rows ───────────────────────────────────────── */
.sched-row {
  display: flex;
  align-items: stretch;
  height: 32px;
  border-bottom: 1px solid #131c2b;
  cursor: default;
  transition: background .08s;
}
.sched-row:hover { background: rgba(255,255,255,.025); }
.sched-row--selected { background: rgba(214,168,79,.1) !important; }
.sched-row--phase {
  background: rgba(255,255,255,.02);
  font-weight: 700;
}
.sched-row--phase .sched-cell { font-weight: 700; color: #e2e8f0; }
.sched-row--milestone .sched-cell--wbs { color: #f59e0b; }

.sched-cell {
  padding: 0 5px;
  font-size: 11.5px;
  color: #94a3b8;
  display: flex;
  align-items: center;
  border-right: 1px solid #131c2b;
  overflow: hidden;
  white-space: nowrap;
  flex-shrink: 0;
}
.sched-cell:last-child { border-right: none; }
.sched-cell--wbs   { width: 40px; justify-content: center; font-size: 10px; font-weight: 800; color: #4b5563; }
.sched-cell--name  { flex: 1; min-width: 100px; gap: 4px; overflow: hidden; }
.sched-cell--dur   { width: 48px; justify-content: center; }
.sched-cell--start { width: 80px; font-size: 11px; }
.sched-cell--end   { width: 80px; font-size: 11px; }
.sched-cell--pred  { width: 56px; font-size: 11px; color: #60a5fa; }
.sched-cell--resp  { width: 72px; overflow: hidden; text-overflow: ellipsis; }
.sched-cell--pp    { width: 38px; justify-content: center; }
.sched-cell--pr    { width: 38px; justify-content: center; }

/* Inline editing */
.sched-cell input.sched-inline {
  width: 100%;
  background: #0f1824;
  border: 1px solid #f59e0b;
  border-radius: 3px;
  color: #e2e8f0;
  font-size: 11.5px;
  padding: 1px 4px;
  outline: none;
  font-family: inherit;
  min-width: 0;
}
.sched-cell--dur   input.sched-inline,
.sched-cell--pp    input.sched-inline,
.sched-cell--pr    input.sched-inline { text-align: center; }

/* Toggle / expand button */
.sched-toggle {
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  cursor: pointer;
  color: #4b5563;
  font-size: 9px;
  padding: 0;
  flex-shrink: 0;
  border-radius: 3px;
  transition: color .12s, background .12s;
}
.sched-toggle:hover { color: #e2e8f0; background: #1e2535; }

/* Name text */
.sched-name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #cbd5e1;
  font-size: 11.5px;
}
.sched-row--phase .sched-name-text { color: #e2e8f0; font-weight: 700; }
.sched-row--milestone .sched-name-text { color: #f59e0b; }

/* Status badge small */
.sched-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-right: 2px;
}

/* ── Gantt pane ───────────────────────────────────────── */
.sched-gantt-header {
  height: 52px;
  background: #0c1120;
  border-bottom: 2px solid #263247;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}
.sched-gantt-hd-months {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 26px;
  overflow: hidden;
}
.sched-gantt-hd-ticks {
  position: absolute;
  top: 26px; left: 0; right: 0;
  height: 26px;
  overflow: hidden;
}
.sched-gantt-hd-cell {
  position: absolute;
  top: 0; bottom: 0;
  display: flex;
  align-items: center;
  padding-left: 5px;
  font-size: 10px;
  font-weight: 700;
  color: #4b5563;
  border-left: 1px solid #1a2232;
  white-space: nowrap;
  overflow: hidden;
}
.sched-gantt-hd-cell--month {
  font-size: 10.5px;
  color: #6b7280;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
  border-left-color: #263247;
}
.sched-gantt-hd-cell--today {
  color: #f59e0b;
  border-left-color: #f59e0b;
}
.sched-gantt-hd-today-label {
  position: absolute;
  top: 2px;
  transform: translateX(-50%);
  font-size: 9px;
  font-weight: 800;
  color: #f59e0b;
  background: #0c1120;
  padding: 0 3px;
  white-space: nowrap;
  letter-spacing: .04em;
}

/* Gantt canvas area (scrollable) */
.sched-gantt-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
  position: relative;
}
.sched-gantt-scroll::-webkit-scrollbar { width: 5px; height: 5px; }
.sched-gantt-scroll::-webkit-scrollbar-track { background: #0c1120; }
.sched-gantt-scroll::-webkit-scrollbar-thumb { background: #263247; border-radius: 3px; }

/* Inner canvas — has a fixed pixel width set via JS */
.sched-gantt-canvas {
  position: relative;
  min-height: 100%;
}

/* Row in Gantt (mirrors table row height) */
.sched-gantt-row {
  height: 32px;
  border-bottom: 1px solid #131c2b;
  position: relative;
  transition: background .08s;
}
.sched-gantt-row:hover { background: rgba(255,255,255,.02); }
.sched-gantt-row--selected { background: rgba(214,168,79,.06) !important; }
.sched-gantt-row--phase { background: rgba(255,255,255,.01); }

/* Grid lines */
.sched-gl {
  position: absolute;
  top: 0; bottom: 0;
  width: 1px;
  background: #131c2b;
  pointer-events: none;
}
.sched-gl--month { background: #1e2b3d; }
.sched-gl--today {
  background: rgba(214,168,79,.35);
  width: 2px;
  z-index: 1;
}

/* Today line label */
.sched-today-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(214,168,79,.4);
  z-index: 2;
  pointer-events: none;
}

/* ── Gantt bars ───────────────────────────────────────── */
.sched-bar-wrap {
  position: absolute;
  top: 3px; bottom: 3px;
  min-width: 3px;
  pointer-events: auto;
  cursor: pointer;
}

/* LBO — thin strip at very top */
.sched-bar--lbo {
  position: absolute;
  left: 0; right: 0;
  top: 0; height: 4px;
  background: rgba(59,130,246,.3);
  border: 1px solid rgba(59,130,246,.55);
  border-radius: 3px;
}
/* LBP — thin strip below LBO */
.sched-bar--lbp {
  position: absolute;
  left: 0; right: 0;
  top: 5px; height: 4px;
  background: rgba(100,116,139,.3);
  border: 1px solid rgba(100,116,139,.5);
  border-radius: 3px;
}
/* Main planned bar */
.sched-bar--plan {
  position: absolute;
  left: 0; right: 0;
  top: 10px; bottom: 2px;
  border-radius: 4px;
  background: rgba(148,163,184,.18);
  border: 1px solid rgba(148,163,184,.25);
}
/* Progress fill inside planned bar */
.sched-bar--progress {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  border-radius: 3px;
  opacity: .9;
  min-width: 2px;
}
/* Actual bar (when has real dates, overlaid) */
.sched-bar--real {
  position: absolute;
  left: 0; right: 0;
  top: 10px; bottom: 2px;
  border-radius: 4px;
  opacity: .85;
}

/* Colors by status */
.sched-bar--c-concluido    { background: #34d399; }
.sched-bar--c-atrasado     { background: #f87171; }
.sched-bar--c-em_andamento { background: #f59e0b; }
.sched-bar--c-bloqueado    { background: #fbbf24; }
.sched-bar--c-cancelado    { background: #6b7280; }
.sched-bar--c-planejado    { background: #60a5fa; }

/* Bar without baselines — full height */
.sched-bar--solo {
  top: 4px !important;
  bottom: 4px !important;
  border-radius: 5px;
}

/* Milestone diamond */
.sched-milestone {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%) rotate(45deg);
  width: 13px; height: 13px;
  z-index: 3;
}

/* Bar label */
.sched-bar-label {
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  padding-left: 5px;
  font-size: 10px;
  font-weight: 700;
  color: #6b7280;
  white-space: nowrap;
  pointer-events: none;
}

/* ── Dependency SVG overlay ───────────────────────────── */
.sched-dep-svg {
  position: absolute;
  top: 0; left: 0;
  pointer-events: none;
  overflow: visible;
  z-index: 5;
}
.sched-dep-path {
  fill: none;
  stroke: #3d5070;
  stroke-width: 1.5;
}
.sched-dep-path:hover { stroke: #f59e0b; }
.sched-dep-arrow {
  fill: #3d5070;
}

/* ── Tooltip ──────────────────────────────────────────── */
.sched-tooltip {
  position: fixed;
  z-index: 9999;
  background: #1a2232;
  border: 1px solid #263247;
  border-radius: 10px;
  padding: 10px 13px;
  font-size: 11.5px;
  color: #e2e8f0;
  pointer-events: none;
  max-width: 270px;
  box-shadow: 0 8px 28px rgba(0,0,0,.55);
  display: none;
}
.sched-tooltip.visible { display: block; }
.sched-tooltip__title {
  color: #f59e0b;
  font-weight: 800;
  font-size: 12.5px;
  margin-bottom: 7px;
  display: block;
}
.sched-tt-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 11px;
  color: #64748b;
  margin-top: 3px;
}
.sched-tt-row span:last-child { color: #e2e8f0; font-weight: 600; }
.sched-tt-sep {
  border-top: 1px solid #1e2b3d;
  margin: 6px 0;
}

/* ── Context menu ─────────────────────────────────────── */
.sched-ctx-menu {
  position: fixed;
  z-index: 10000;
  background: #1a2232;
  border: 1px solid #263247;
  border-radius: 9px;
  padding: 5px 0;
  min-width: 190px;
  box-shadow: 0 8px 28px rgba(0,0,0,.6);
  font-size: 12.5px;
}
.sched-ctx-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  color: #94a3b8;
  cursor: pointer;
  transition: background .1s, color .1s;
  white-space: nowrap;
}
.sched-ctx-item:hover { background: #1e2b3d; color: #e2e8f0; }
.sched-ctx-item--danger { color: #f87171; }
.sched-ctx-item--danger:hover { background: rgba(248,113,113,.1); }
.sched-ctx-sep {
  height: 1px;
  background: #1e2b3d;
  margin: 4px 0;
}

/* ── KPI bar (bottom) ─────────────────────────────────── */
.sched-kpi-bar {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 16px;
  height: 38px;
  background: #0c1120;
  border-top: 1px solid #263247;
  flex-shrink: 0;
  overflow: hidden;
}
.sched-kpi-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  border-right: 1px solid #1a2232;
  height: 100%;
  white-space: nowrap;
}
.sched-kpi-item:first-child { padding-left: 0; }
.sched-kpi-item:last-child { border-right: none; }
.sched-kpi-lbl {
  font-size: 10px;
  font-weight: 700;
  color: #4b5563;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.sched-kpi-val {
  font-size: 13px;
  font-weight: 800;
  color: #e2e8f0;
}
.sched-kpi-sub { font-size: 10px; color: #4b5563; }

/* ── Empty state ──────────────────────────────────────── */
.sched-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 200px;
  color: #4b5563;
  font-size: 13px;
}
.sched-empty svg { opacity: .4; }

/* ── Baselines toolbar row ────────────────────────────── */
.sched-bl-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 14px;
  background: #0c1120;
  border-bottom: 1px solid #1a2232;
  flex-shrink: 0;
}
.sched-bl-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid rgba(59,130,246,.35);
  background: rgba(59,130,246,.07);
  color: #93c5fd;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.sched-bl-btn:hover { background: rgba(59,130,246,.16); border-color: rgba(59,130,246,.6); }
.sched-bl-btn--lbp {
  border-color: rgba(100,116,139,.35);
  background: rgba(100,116,139,.07);
  color: #94a3b8;
}
.sched-bl-btn--lbp:hover { background: rgba(100,116,139,.16); border-color: rgba(100,116,139,.6); }
.sched-lbo-frozen-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 99px;
  background: rgba(59,130,246,.08);
  border: 1px solid rgba(59,130,246,.3);
  color: #93c5fd;
  font-size: 11px;
  font-weight: 700;
}

/* ── Legend ───────────────────────────────────────────── */
.sched-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 4px 14px;
  background: #0c1120;
  border-bottom: 1px solid #1a2232;
  flex-shrink: 0;
}
.sched-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: #4b5563;
  font-weight: 600;
}
.sched-legend-sw { display: inline-block; border-radius: 2px; }
.sched-legend-sw--lbo { width: 18px; height: 4px; background: rgba(59,130,246,.5); border: 1px solid rgba(59,130,246,.7); }
.sched-legend-sw--lbp { width: 18px; height: 4px; background: rgba(100,116,139,.5); border: 1px solid rgba(100,116,139,.7); }
.sched-legend-sw--plan { width: 18px; height: 8px; background: rgba(148,163,184,.25); border: 1px solid rgba(148,163,184,.35); border-radius: 3px; }
.sched-legend-sw--real { width: 18px; height: 8px; background: #f59e0b; border-radius: 3px; }

/* ── KPIs section (top) ───────────────────────────────── */
.sched-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  padding: 12px 14px;
  background: #0a0f1c;
  border-bottom: 1px solid #1a2232;
  flex-shrink: 0;
}
.sched-kpi-card {
  background: #161b27;
  border: 1px solid #1e2b3d;
  border-radius: 12px;
  padding: 12px 14px;
  border-left: 3px solid var(--kc, #60a5fa);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.sched-kpi-card__lbl { font-size: 10px; font-weight: 800; color: #4b5563; text-transform: uppercase; letter-spacing: .1em; }
.sched-kpi-card__val { font-size: 26px; font-weight: 900; color: var(--kc, #e2e8f0); line-height: 1.1; }
.sched-kpi-card__sub { font-size: 10.5px; color: #4b5563; }

/* ── Print ────────────────────────────────────────────── */
.sched-print-hd { display: none; }
.sched-print-hd h1 { font-size: 18px; margin: 0 0 4px; }
.sched-print-hd p  { font-size: 12px; color: #555; margin: 0; }

@media print {
  .swm-sidebar,
  .sched-toolbar,
  .sched-bl-row,
  .sched-legend,
  .sched-kpi-bar,
  .sched-divider,
  .sched-pane-right { display: none !important; }
  .sched-print-hd { display: block !important; margin-bottom: 16px; }
  .sched-root { display: block; height: auto; overflow: visible; }
  .sched-split { display: block; }
  .sched-pane-left { width: 100% !important; max-width: 100%; }
  .sched-table-body { overflow: visible; }
  body { background: #fff; color: #000; }
}

/* ── Mobile: hide Gantt, show table only ─────────────── */
@media (max-width: 767px) {
  .sched-pane-right,
  .sched-divider { display: none !important; }
  .sched-pane-left {
    width: 100% !important;
    max-width: 100% !important;
    flex: 1;
  }
  .sched-mobile-gantt-btn {
    display: flex !important;
  }
}
.sched-mobile-gantt-btn { display: none; }

/* ── Modal / confirm overrides ────────────────────────── */
.sched-modal { width: min(720px, 94vw); }
.sched-two-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 8px 0 12px;
}
@media (max-width: 720px) { .sched-two-cols { grid-template-columns: 1fr; } }
.sched-fieldset {
  border: 1px solid rgba(255,255,255,.08);
  border-left: 3px solid var(--c, #60a5fa);
  border-radius: 10px;
  padding: 10px 14px 4px;
  background: rgba(255,255,255,.015);
}
.sched-fieldset legend {
  padding: 0 8px;
  color: var(--c, #60a5fa);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

/* ── Scroll sync shimmer during drag ──────────────────── */
.sched-syncing .sched-table-body,
.sched-syncing .sched-gantt-scroll { pointer-events: none; }

/* ── Legacy compat (KPI cards, baselines, badges) ─────── */
.sched-kpi { display: none; } /* replaced by sched-kpi-card */
