/* ═══════════════════════════════════════════════════════════════════════════
   MASTER_PLAN.CSS — Premium Jira-Style Interactive Timeline
   Design: Theme-paritied, glassmorphism, responsive split tree/Gantt
═══════════════════════════════════════════════════════════════════════════ */

/* ── Tab Container ── */
#tab-master-plan {
  padding: 0;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 70px);
  overflow: hidden;
  background: var(--bg-body, #0f172a);
}

.mp-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--bg-card, #1e293b);
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  flex-shrink: 0;
  z-index: 10;
}

.mp-header-bar h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary, #f1f5f9);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mp-north-star {
  font-size: 0.75rem;
  color: var(--text-secondary, #94a3b8);
  padding: 3px 10px;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 12px;
}

.mp-updated {
  font-size: 0.72rem;
  color: var(--text-secondary, #94a3b8);
}

/* ── View Switcher ── */
.mp-view-switcher {
  display: flex;
  gap: 6px;
  padding: 10px 24px;
  background: var(--bg-card, #1e293b);
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  flex-shrink: 0;
  z-index: 10;
}

.mp-view-btn {
  padding: 6px 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 6px;
  color: var(--text-secondary, #94a3b8);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.mp-view-btn:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text-primary, #f1f5f9);
}
.mp-view-btn.active {
  background: rgba(99,102,241,0.15);
  border-color: #6366f1;
  color: #a5b4fc;
  font-weight: 600;
}

/* ── Main Layout: Split Tree / Gantt Timeline ── */
.mp-timeline-container {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* Left tree pane */
.mp-tree-pane {
  width: 380px;
  min-width: 380px;
  max-width: 380px;
  border-right: 1px solid var(--border-color, #e2e8f0);
  background: var(--bg-card, #1e293b);
  overflow-y: hidden; /* Scroll sync with Gantt */
  display: flex;
  flex-direction: column;
  z-index: 5;
}

.mp-tree-header {
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--text-secondary, #94a3b8);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(255,255,255,0.01);
}

.mp-tree-body {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: none; /* Hide default scrollbar to keep sync clean */
}
.mp-tree-body::-webkit-scrollbar { display: none; }

/* Tree nodes */
.mp-tree-row {
  height: 44px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  font-size: 0.82rem;
  color: var(--text-primary, #f1f5f9);
  cursor: pointer;
  position: relative;
  transition: background 0.15s;
}
.mp-tree-row:hover {
  background: rgba(99, 102, 241, 0.04);
}
.mp-tree-row.active {
  background: rgba(99, 102, 241, 0.08);
}

/* Tree indentation & symbols */
.mp-tree-indent { display: inline-flex; }
.mp-tree-indent-level { width: 18px; flex-shrink: 0; }

.mp-tree-toggle {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 4px;
  color: var(--text-secondary, #94a3b8);
  font-size: 0.65rem;
  cursor: pointer;
  border-radius: 3px;
}
.mp-tree-toggle:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text-primary);
}

.mp-tree-icon {
  margin-right: 6px;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.mp-tree-title-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}
.mp-tree-row-track .mp-tree-title-text { font-weight: 700; color: #a5b4fc; }
.mp-tree-row-epic .mp-tree-title-text { font-weight: 600; }
.mp-tree-row-task .mp-tree-title-text { font-weight: 400; color: var(--text-secondary, #cbd5e1); }

/* Task status indicator */
.mp-tree-status {
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
  font-weight: 600;
  text-transform: uppercase;
}
.mp-tree-status.status-done { background: rgba(16,185,129,0.15); color: #34d399; }
.mp-tree-status.status-in_progress { background: rgba(245,158,11,0.15); color: #f59e0b; }
.mp-tree-status.status-todo { background: rgba(148,163,184,0.1); color: #94a3b8; }
.mp-tree-status.status-blocked { background: rgba(239,68,68,0.15); color: #fca5a5; }

/* Inline task addition trigger */
.mp-tree-add-btn {
  opacity: 0;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(99,102,241,0.15);
  border: 1px solid rgba(99,102,241,0.3);
  border-radius: 4px;
  color: #a5b4fc;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.mp-tree-row:hover .mp-tree-add-btn { opacity: 1; }
.mp-tree-add-btn:hover {
  background: #6366f1;
  color: #fff;
}

/* ── Right Gantt Pane ── */
.mp-gantt-pane {
  flex: 1;
  overflow: auto;
  position: relative;
  background: var(--bg-body, #0f172a);
}

.mp-gantt-grid {
  position: relative;
  min-width: 1200px; /* Force minimum width to align timeline scales */
}

/* Gantt Calendar Scale Headers */
.mp-gantt-scale-header {
  height: 56px;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  background: var(--bg-card, #1e293b);
  position: sticky;
  top: 0;
  z-index: 6;
}

.mp-gantt-months {
  display: flex;
  height: 28px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.mp-gantt-month-cell {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-secondary, #94a3b8);
  border-right: 1px solid rgba(255, 255, 255, 0.04);
  text-transform: uppercase;
}

.mp-gantt-weeks {
  display: flex;
  height: 28px;
}
.mp-gantt-week-cell {
  width: calc(100% / 12); /* Assuming 12 columns for Q3 weeks/months scale */
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-secondary, #64748b);
  border-right: 1px solid rgba(255, 255, 255, 0.04);
}

/* Gantt rows layout */
.mp-gantt-body {
  position: relative;
}

.mp-gantt-row {
  height: 44px;
  position: relative;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  display: flex;
  align-items: center;
}
.mp-gantt-row:hover {
  background: rgba(99, 102, 241, 0.02);
}

/* Verticals grid column lines overlay */
.mp-gantt-grid-columns {
  position: absolute;
  top: 56px; bottom: 0; left: 0; right: 0;
  display: flex;
  pointer-events: none;
  z-index: 1;
}
.mp-gantt-grid-col {
  width: calc(100% / 12);
  height: 100%;
  border-right: 1px solid rgba(255, 255, 255, 0.03);
  flex-shrink: 0;
}

/* Today line marker */
.mp-gantt-today-line {
  position: absolute;
  top: 56px; bottom: 0;
  width: 2px;
  background: rgba(16, 185, 129, 0.6);
  border-left: 1px dashed rgba(16, 185, 129, 0.8);
  pointer-events: none;
  z-index: 4;
}
.mp-gantt-today-badge {
  position: absolute;
  top: 60px;
  left: 6px;
  font-size: 0.65rem;
  font-weight: 700;
  color: #34d399;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 1px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

/* Milestone Flags in header scale */
.mp-milestone-flag {
  position: absolute;
  top: 6px;
  z-index: 7;
  cursor: pointer;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.mp-flag-marker {
  width: 14px;
  height: 14px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: #6366f1;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.mp-milestone-flag.rag-red .mp-flag-marker { background: #ef4444; }
.mp-milestone-flag.rag-amber .mp-flag-marker { background: #f59e0b; }
.mp-milestone-flag.rag-green .mp-flag-marker { background: #10b981; }

.mp-flag-line {
  width: 1px;
  height: 38px;
  border-left: 1px dotted rgba(255,255,255,0.25);
  pointer-events: none;
}
.mp-flag-label {
  position: absolute;
  top: 18px;
  background: rgba(15,23,42,0.9);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.6rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
}

/* ── Gantt Scheduled Bars ── */
.mp-gantt-bar-wrapper {
  position: absolute;
  height: 26px; /* Row height is 44px, bar is vertically centered */
  top: 9px;
  display: flex;
  align-items: center;
  z-index: 3;
}

.mp-gantt-bar {
  width: 100%;
  height: 100%;
  border-radius: 6px;
  background: rgba(99, 102, 241, 0.2);
  border: 1px solid rgba(99, 102, 241, 0.4);
  position: relative;
  cursor: grab;
  user-select: none;
  display: flex;
  align-items: center;
  padding: 0 10px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.mp-gantt-bar:active { cursor: grabbing; }
.mp-gantt-bar:hover {
  border-color: #6366f1;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

.mp-gantt-bar-title {
  font-size: 0.74rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

/* Permanent Milestone ID on Gantt Bar */
.mp-gantt-bar-id {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.12);
  margin-right: 6px;
  color: rgba(255, 255, 255, 0.85);
  pointer-events: none;
}

/* Drag & Resize handlers */
.mp-drag-handle {
  position: absolute;
  top: 0; bottom: 0;
  width: 6px;
  cursor: w-resize;
  background: transparent;
  transition: background 0.15s;
  z-index: 5;
}
.mp-drag-handle:hover {
  background: rgba(255, 255, 255, 0.3);
}
.mp-drag-handle-left { left: 0; border-top-left-radius: 6px; border-bottom-left-radius: 6px; }
.mp-drag-handle-right { right: 0; border-top-right-radius: 6px; border-bottom-right-radius: 6px; }

/* Bar tooltips */
.mp-gantt-tooltip {
  position: absolute;
  bottom: 34px;
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.72rem;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.15s ease;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  z-index: 100;
  text-align: left;
  backdrop-filter: blur(8px);
}
.mp-gantt-bar-wrapper:hover .mp-gantt-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}
.mp-gantt-tooltip strong { display: block; color: #fff; margin-bottom: 2px; }
.mp-gantt-tooltip span { color: #94a3b8; }

/* ── Dependency SVGs Layer ── */
.mp-gantt-svg-layer {
  position: absolute;
  top: 56px; left: 0;
  width: 100%; height: calc(100% - 56px);
  pointer-events: none;
  z-index: 2;
}

.mp-dependency-line {
  stroke: rgba(148, 163, 184, 0.45);
  stroke-width: 1.5;
  fill: none;
  marker-end: url(#arrow);
  transition: stroke 0.15s, stroke-width 0.15s;
}
.mp-dependency-line.highlighted {
  stroke: #6366f1;
  stroke-width: 2.2;
  z-index: 10;
}

/* ── Inline Task Creation Form (Modal Dialog) ── */
.mp-modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
}
.mp-modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.mp-modal {
  background: var(--bg-card, #1e293b);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 12px;
  width: 480px;
  max-width: 90%;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.25s ease;
}
.mp-modal-overlay.show .mp-modal {
  transform: scale(1);
}

.mp-modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  background: rgba(255,255,255,0.01);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.mp-modal-header h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}
.mp-modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
}
.mp-modal-close:hover { color: var(--text-primary); }

.mp-modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mp-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.mp-form-group label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary, #94a3b8);
  text-transform: uppercase;
}
.mp-form-input, .mp-form-select {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
}
.mp-form-input:focus, .mp-form-select:focus {
  border-color: #6366f1;
  outline: none;
}

.mp-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.mp-modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color, #e2e8f0);
  background: rgba(255,255,255,0.01);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.mp-btn {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.mp-btn-cancel {
  background: none;
  border: 1px solid var(--border-color, #e2e8f0);
  color: var(--text-primary);
}
.mp-btn-cancel:hover { background: rgba(255,255,255,0.05); }

.mp-btn-primary {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border: none;
  color: #fff;
}
.mp-btn-primary:hover { opacity: 0.9; }

/* ── Board & Drill View Compatibility adjustments ── */
/* Timeline split view is default under timeline. Board and Drill are standard cards */
.mp-board, .mp-drill {
  height: calc(100vh - 122px);
  overflow-y: auto;
}
