/* Colours and fonts come from /shared/theme.css */
:root {
  --label-width: 240px;
  --row-height: 46px;
  --bar-height: 32px;
  --accent-2: #7c5cff;
  --print-scale: 1;
  --list-divider: #94969B;
}

:root[data-density="narrow"] {
  --row-height: 32px;
  --bar-height: 18px;
}

:root[data-density="wide"] {
  --row-height: 64px;
  --bar-height: 32px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  padding-top: 34px;
  font-family: var(--font-body);
  background: var(--page-plane);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
}

#page-title {
  padding: 4px 8px;
  margin: -4px -8px;
}

.file-status {
  font-size: 12px;
  color: var(--text-secondary);
}

.file-status.connected { color: var(--success); }
.file-status.error { color: var(--danger); }

.banner {
  margin: 16px 24px 0;
  padding: 10px 14px;
  background: color-mix(in srgb, var(--series-4) 15%, var(--surface-1));
  border: 1px solid var(--series-4);
  color: var(--text-primary);
  border-radius: 8px;
  font-size: 13px;
}

.empty-state {
  padding: 60px 24px;
  text-align: center;
  color: var(--text-primary);
}

.empty-state p { margin: 6px 0; }
.empty-state .muted { color: var(--text-secondary); font-size: 13px; max-width: 480px; margin: 6px auto; }
.empty-state code {
  background: var(--panel-alt);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--gridline);
}

.btn-danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}

.content-row {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
}

.gantt-wrap {
  padding: 0 24px 24px;
  overflow-x: auto;
  overflow-y: auto;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
}

.gantt {
  display: inline-block;
  min-width: 100%;
  background: var(--surface-1);
  border: 1px solid var(--gridline);
  border-radius: 10px;
  position: relative;
  /* No overflow:hidden here — that would make .gantt itself the sticky
     scrollport instead of .gantt-wrap, breaking the frozen label column. */
}

.today-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  border-left: 2px dotted var(--series-1);
  z-index: 6;
  pointer-events: none;
}

.gantt-header-row {
  display: flex;
  border-bottom: 1px solid var(--gridline);
  background: var(--panel-alt);
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
  position: sticky;
  top: 0;
  z-index: 4;
}

.label-col {
  width: var(--label-width);
  min-width: var(--label-width);
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  border-right: 1px solid var(--list-divider);
  position: sticky;
  left: 0;
  z-index: 3;
  background: var(--panel-alt);
  border-top-left-radius: 10px;
}

.col-resize-handle {
  position: absolute;
  top: 0;
  right: -4px;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  z-index: 5;
  touch-action: none;
}

.col-resize-handle:hover,
.col-resize-handle.active {
  background: var(--series-1);
  opacity: 0.5;
}

.timeline-track {
  position: relative;
  display: flex;
}

.timeline-header {
  height: 40px;
}

/* Column cells are sized individually in JS (week/month/quarter widths differ
   by real calendar length), so only the shared box model lives here. */
.grid-col {
  flex: 0 0 auto;
  border-right: 1px solid var(--gridline);
  box-sizing: border-box;
}

.sprint-col {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 4px;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
}

.task-rows {
  position: relative;
}

.task-row {
  display: flex;
  border-bottom: 1px solid var(--gridline);
  height: var(--row-height);
  position: relative;
}

.task-row:last-child { border-bottom: none; }
.task-row:last-child .task-label { border-bottom-left-radius: 10px; }

.task-row.dragging {
  z-index: 50;
  box-shadow: 0 6px 18px rgba(0,0,0,0.45);
  background: var(--panel-alt);
}

.task-label {
  width: var(--label-width);
  min-width: var(--label-width);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 6px 0 4px;
  border-right: 1px solid var(--list-divider);
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface-1);
}

.health-tag {
  flex: 0 0 auto;
  width: 7px;
  height: 18px;
  border-radius: 3px;
  background: transparent;
  cursor: pointer;
}

.phase-icon {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  margin: 0 2px;
  display: block;
  cursor: pointer;
}

.task-name {
  flex: 1;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-primary);
  font-size: 13px;
  padding: 5px 6px;
  border-radius: 4px;
  min-width: 0;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-name:hover {
  border-color: var(--gridline);
  background: var(--surface-1);
}

.edit-btn {
  /* Hidden for now (functionality kept via clicking the name, health tag,
     or phase icon) — remove this to bring the icon back. */
  display: none;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.edit-btn:hover { color: var(--series-1); }

.row-track {
  position: relative;
  flex: 1;
  display: flex;
}

.bar {
  position: absolute;
  top: calc((var(--row-height) - var(--bar-height)) / 2);
  height: var(--bar-height);
  border-radius: 6px;
  background: var(--series-1);
  display: flex;
  align-items: center;
  padding: 0 10px;
  cursor: grab;
  user-select: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.bar:active { cursor: grabbing; }

.bar.dragging {
  opacity: 0.95;
  box-shadow: 0 4px 14px rgba(0,0,0,0.5);
}

.bar-label {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.resize-handle {
  position: absolute;
  top: 0;
  width: 10px;
  height: 100%;
  cursor: ew-resize;
}

.resize-handle.left { left: 0; }
.resize-handle.right { right: 0; }

.resize-handle:hover {
  background: rgba(255,255,255,0.2);
}

.edit-dialog {
  width: 320px;
}

.edit-dialog h2 {
  margin: 0 0 14px;
  font-size: 16px;
}

/* #edit-dialog is rendered as an in-page side panel (not a native <dialog>
   popup) so it sits beside the gantt chart instead of covering it. It keeps
   the shared .edit-dialog field/label/button styling above and only
   overrides the container itself. */
#edit-dialog {
  flex: 0 0 380px;
  width: 380px;
  max-width: 380px;
  border: none;
  border-left: 1px solid var(--gridline);
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
#edit-dialog[hidden] { display: none; }
#edit-dialog #edit-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
#edit-dialog .edit-dialog-scroll {
  overflow-y: auto;
  flex: 1;
  padding: 20px 22px;
}
#edit-dialog .edit-dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
#edit-dialog .edit-dialog-head h2 { margin: 0; }
#edit-dialog .panel-close {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 20px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 6px;
  flex: none;
}
#edit-dialog .panel-close:hover { background: var(--panel-alt); color: var(--text-primary); }
#edit-dialog .edit-dialog-actions {
  margin: 0;
  padding: 14px 22px;
  border-top: 1px solid var(--gridline);
  flex: none;
}

.edit-dialog label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.edit-project-link {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  margin: -4px 0 14px;
}

.edit-project-link-label {
  color: var(--text-secondary);
}

.edit-project-link-name {
  color: var(--text-primary);
  font-weight: 600;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.edit-project-link .btn {
  padding: 4px 10px;
  font-size: 12px;
}

.edit-comments-section {
  margin: -4px 0 14px;
}

.edit-comments-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.edit-comments-hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0;
}

.edit-dialog textarea {
  resize: vertical;
  font-family: inherit;
  box-sizing: border-box;
}

.edit-dialog input[type="color"] {
  display: block;
  margin-top: 4px;
  width: 100%;
  height: 36px;
  border: 1px solid var(--gridline);
  border-radius: 6px;
  background: var(--panel-alt);
  padding: 2px;
  cursor: pointer;
}

.color-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -4px 0 12px;
}

.color-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--gridline);
  cursor: pointer;
  padding: 0;
}

.color-swatch:hover,
.color-swatch:focus-visible {
  transform: scale(1.12);
  outline: 2px solid var(--text-primary);
  outline-offset: 2px;
}

.edit-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.edit-dialog-actions-spacer {
  flex: 1;
}

.display-dialog {
  width: 280px;
}

.display-group {
  margin-bottom: 14px;
}

.display-group-label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.display-group .view-toggle {
  width: fit-content;
}

.display-group .view-btn {
  flex: 1;
}

.filter-hint {
  margin: -6px 0 14px;
  font-size: 12px;
  color: var(--text-secondary);
}

.filter-panel {
  border-bottom: 1px solid var(--gridline);
  background: var(--surface-1);
  flex: 0 0 auto;
}

.filter-toggle-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 24px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}

.filter-toggle-btn:hover { background: var(--hover-bg); }

.filter-toggle-caret {
  display: inline-block;
  font-size: 11px;
  color: var(--text-secondary);
  transition: transform 0.15s ease;
}

.filter-panel.collapsed .filter-toggle-caret { transform: rotate(-90deg); }

.filter-active-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--series-1);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.filter-active-badge[hidden] { display: none; }

.filter-panel-body {
  padding: 2px 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.filter-panel.collapsed .filter-panel-body { display: none; }

.filter-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.filter-row-label {
  flex: 0 0 60px;
  padding-top: 7px;
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.filter-pill-list {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.filter-pill {
  border: 1px solid var(--gridline);
  background: var(--panel-alt);
  color: var(--text-primary);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  line-height: 1.2;
  cursor: pointer;
}

.filter-pill:hover { border-color: var(--series-1); }

.filter-pill.all-pill.active {
  background: var(--series-1);
  border-color: var(--series-1);
  color: #fff;
}

.filter-pill-team.active {
  background: var(--series-1);
  border-color: var(--series-1);
  color: #fff;
}

.filter-pill-phase.active {
  background: var(--accent-2);
  border-color: var(--accent-2);
  color: #fff;
}

.filter-pill-color {
  min-width: 44px;
  height: 28px;
  padding: 0;
  border-color: var(--pill-border, var(--gridline));
}

.filter-pill-color.active {
  outline: 2px solid var(--series-1);
  outline-offset: 2px;
}

.filter-empty {
  font-size: 12px;
  color: var(--text-secondary);
  padding-top: 6px;
}

.filter-clear-btn {
  align-self: flex-start;
  margin-top: 2px;
}

.filter-search-input {
  width: 100%;
}

.filter-search-results {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 4px;
  list-style: none;
  border: 1px solid var(--gridline);
  border-radius: 8px;
  background: var(--surface-1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  max-height: 240px;
  overflow-y: auto;
}

.filter-search-result:hover,
.filter-search-result.active {
  background: var(--series-1);
  color: #fff;
}

.filter-search-empty {
  padding: 7px 10px;
  font-size: 12px;
  color: var(--text-secondary);
}

.export-dialog {
  width: 320px;
}

.export-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}

.export-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px 10px;
  background: var(--panel-alt);
  color: var(--text-primary);
  border: 1px solid var(--gridline);
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
}

.export-option:hover,
.export-option:focus-visible {
  background: var(--hover-bg);
  border-color: var(--series-1);
  outline: none;
}

.export-icon {
  width: 40px;
  height: 40px;
}

.cleanup-dialog {
  width: 380px;
}

.cleanup-warning {
  margin: -6px 0 10px;
  font-size: 13px;
  color: var(--danger);
}

.cleanup-task-list {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 300px;
  overflow-y: auto;
}

.cleanup-task-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: var(--panel-alt);
  border: 1px solid var(--gridline);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
}

.cleanup-task-item .cleanup-task-dates {
  color: var(--text-secondary);
  font-size: 12px;
  white-space: nowrap;
}

@media print {
  @page {
    size: landscape;
    margin: 10mm;
  }

  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  body { background: #fff; display: block; }

  .topbar, .banner, .filter-panel, #empty-state { display: none !important; }

  .gantt-wrap { padding: 0; overflow: visible; height: auto; }

  .gantt {
    border: none;
    zoom: var(--print-scale, 1);
  }

  .edit-btn, .resize-handle, .col-resize-handle { display: none !important; }
}

.view-only .resize-handle { display: none; }
.view-only .bar { cursor: default; }
.view-only .edit-btn { display: none; }
.view-only .phase-icon { cursor: default; }
.view-only .task-name { cursor: default; }
.view-only .health-tag { cursor: default; }

