/* APM-T-163: copy MealPlanner's style (dark header, soft rounded cards,
   diffuse shadows, Inter font) but based on blue rather than MealPlanner's
   green - this app's accent colour was already blue (#2563eb etc) so those
   are kept as-is; only the structural/neutral tokens are new. */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --ajpm-bg: #f5f7fa;
  --ajpm-ink: #0f172a;
  --ajpm-muted: #64748b;
  --ajpm-line: #cbd5f5;
  --ajpm-panel: #f8fafc;
  --ajpm-shadow: 0 16px 40px rgba(15, 23, 42, 0.12);
  --ajpm-radius-lg: 20px;
  --ajpm-header-bg: #16233a;
  --ajpm-header-btn: #223454;
  --ajpm-header-text: #dbe7f5;
}

body {
  background: var(--ajpm-bg);
  color: var(--ajpm-ink);
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.tab-bar {
  background: var(--ajpm-header-bg);
}

.tab-bar .title,
.tab-bar .title span {
  color: var(--ajpm-header-text);
}

.dashboard {
  margin-top: 1.5rem;
}

.dashboard-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.dashboard-header h2 {
  margin: 0;
}

.dashboard-actions {
  display: flex;
  gap: 0.75rem;
}

.btn {
  background: #2563eb;
  color: #fff;
  padding: 0.55rem 1.2rem;
  border-radius: 8px;
  border: none;
  font-weight: 600;
  cursor: pointer;
}

.btn:hover {
  background: #1e40af;
}

.btn.secondary {
  background: #e2e8f0;
  color: #0f172a;
}

.btn.secondary:hover {
  background: #cbd5f5;
}

.btn.danger {
  background: #dc2626;
  margin-right: auto;
}

.btn.danger:hover {
  background: #b91c1c;
}

.item-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.item-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: #f8fafc;
  margin-bottom: 0.6rem;
  cursor: pointer;
  transition: background 0.15s ease;
}

.item-list li:hover {
  background: #eef2ff;
}

.sort-toolbar {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.6rem;
}

.sort-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 7px;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
}

.sort-icon:hover {
  background: #f1f5f9;
}

.sort-icon.active {
  background: #e0e7ff;
  border-color: #6366f1;
}

.item-list li.dragging {
  opacity: 0.4;
}

.sprint-badge {
  font-size: 0.9rem;
  margin-right: 0.4rem;
}

.card-sprint-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.size-badge {
  background: #eef2ff;
  color: #3730a3;
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  margin-right: 0.4rem;
}

.priority-badge {
  background: #fff1f2;
  color: #9f1239;
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  margin-right: 0.4rem;
}

.status-badge {
  background: #e2e8f0;
  color: #334155;
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: capitalize;
}

.back-link {
  display: inline-block;
  margin-bottom: 1rem;
  color: #2563eb;
  cursor: pointer;
  text-decoration: none;
}

.back-link:hover {
  text-decoration: underline;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
}

.card {
  background: #ffffff;
  border-radius: var(--ajpm-radius-lg);
  box-shadow: var(--ajpm-shadow);
  padding: 1.25rem;
}

.card.project-card {
  border: 1px solid transparent;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.card.project-card:hover {
  border-color: rgba(37, 99, 235, 0.4);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.12);
}

.card.project-card.selected {
  border-color: #2563eb;
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.2);
}

.card.empty {
  text-align: center;
  color: #64748b;
}

.card h3,
.card h4 {
  margin-top: 0;
  margin-bottom: 0.5rem;
}

.card .meta {
  color: #64748b;
  margin: 0.15rem 0;
}

.card .counts {
  margin-top: 0.75rem;
  color: #475569;
  font-size: 0.9rem;
}

.select-project {
  margin-top: 0.75rem;
}

.requirements-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin: 1.5rem 0 1rem;
}

.requirements-layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

.panel {
  background: #f8fafc;
  border-radius: var(--ajpm-radius-lg);
  padding: 1rem;
}

.panel > label {
  display: block;
  font-weight: 600;
  margin-top: 0.75rem;
  margin-bottom: 0.35rem;
}

.panel > input[type="text"],
.panel > select {
  width: 100%;
  max-width: 420px;
  border: 1px solid #cbd5f5;
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  font-size: 0.95rem;
}

.panel > button {
  margin-top: 1rem;
}

.panel > .search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  max-width: 520px;
}

.panel > .search-input-wrap > input[type="text"] {
  flex: 1;
  min-width: 0;
  max-width: none;
  padding-left: 2.25rem;
}

.search-input-wrap > .search-input-btn {
  flex-shrink: 0;
}

.panel > .search-archived-toggle {
  display: block;
  margin-top: 0.5rem;
  font-weight: 400;
  font-size: 0.85rem;
  color: #64748b;
  cursor: pointer;
}

.search-archived-toggle input[type="checkbox"] {
  margin-right: 0.35rem;
  vertical-align: middle;
}

.search-input-wrap > .search-input-icon {
  position: absolute;
  left: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1rem;
  height: 1rem;
  color: #94a3b8;
  pointer-events: none;
}

.type-badge {
  background: #e0e7ff;
  color: #3730a3;
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  margin-right: 0.5rem;
}

.board {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1rem;
  overflow-x: auto;
  padding: 1rem;
}

.column {
  background: #f3f4f6;
  border-radius: var(--ajpm-radius-lg);
  padding: 1rem;
  min-height: 300px;
}

.column h3 {
  text-align: center;
  margin-bottom: 1rem;
}

.column .card {
  margin-bottom: 1rem;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.card-label {
  flex: 1;
}

.card-archive-btn,
.list-archive-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0.15rem 0.3rem;
  border-radius: 6px;
  flex-shrink: 0;
}

.card-archive-btn:hover,
.list-archive-btn:hover {
  background: rgba(15, 23, 42, 0.08);
}

.list-archive-btn {
  margin-left: 0.5rem;
}

.drag-over {
  border: 2px dashed #2563eb;
  background: #e0e7ff;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 200;
}

.modal.show {
  display: flex;
}

.popover-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 2000;
}

.popover-overlay.show {
  display: flex;
}

.popover-panel {
  background: #ffffff;
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 10px 40px rgba(15, 23, 42, 0.25);
}

.popover-message {
  margin-bottom: 1rem;
  line-height: 1.4;
  white-space: pre-wrap;
}

.popover-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.modal-card {
  background: #ffffff;
  border-radius: var(--ajpm-radius-lg);
  padding: 1.5rem;
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--ajpm-shadow);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-header h3 {
  margin: 0;
}

.modal-close {
  background: transparent;
  border: none;
  color: #0f172a;
  font-size: 1.5rem;
  cursor: pointer;
}

.modal-body label {
  display: block;
  font-weight: 600;
  margin-top: 0.75rem;
  margin-bottom: 0.35rem;
}

.modal-body input,
.modal-body select,
.modal-body textarea {
  width: 100%;
  border: 1px solid #cbd5f5;
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  font-size: 0.95rem;
}

.modal-body .simple-html-editor,
.modal-body .simple-html-surface {
  min-height: 160px;
}

.description-preview {
  margin: 0 0 0.5rem;
}

.rich-field-view {
  border: 1px solid #cbd5f5;
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  min-height: 2.5rem;
}

.rich-field-empty {
  color: #64748b;
  font-style: italic;
}

.rich-field-edit-btn {
  margin-top: 0.5rem;
}

.rich-field-done-btn {
  margin-top: 0.5rem;
}

.modal-actions {
  margin-top: 1.25rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.account-summary {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.account-avatar {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: #eef2f7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.account-name {
  font-size: 1.15rem;
  font-weight: 600;
}

.account-details {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 1rem;
  margin: 0;
}

.account-details dt {
  color: #6b7280;
  font-size: 0.9rem;
}

.relationships-widget {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 1rem;
}

.relationship-list {
  margin-bottom: 0.75rem;
}

.relationship-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid #f3f4f6;
}

.relationship-row:last-child {
  border-bottom: none;
}

.relationship-label {
  font-weight: 600;
  color: #4b5563;
  white-space: nowrap;
}

.relationship-target {
  flex: 1;
  color: #1d4ed8;
}

.relationship-target.archived {
  color: #9ca3af;
  text-decoration: line-through;
}

.relationship-remove-btn {
  background: transparent;
  border: none;
  color: #ef4444;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 0.25rem;
}

.relationship-add {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.relationship-add select,
.relationship-add input {
  width: 100%;
}

.relationship-search-results {
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  max-height: 150px;
  overflow-y: auto;
}

.relationship-search-result {
  padding: 0.4rem 0.6rem;
  cursor: pointer;
}

.relationship-search-result:hover {
  background: #f3f4f6;
}

.relationship-selected {
  font-size: 0.85rem;
  color: #4b5563;
}

.relationship-new-type {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.qa-widget {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 1rem;
}

.qa-list {
  margin-bottom: 0.75rem;
}

.qa-row {
  padding: 0.5rem 0;
  border-bottom: 1px solid #f3f4f6;
}

.qa-row:last-child {
  border-bottom: none;
}

.qa-question {
  position: relative;
  padding-right: 1.5rem;
}

.qa-answer {
  margin-top: 0.35rem;
  padding-left: 1rem;
  color: #374151;
}

.qa-remove-btn {
  position: absolute;
  right: 0;
  top: 0;
  background: transparent;
  border: none;
  color: #ef4444;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 0.25rem;
}

.qa-answer-btn {
  margin-top: 0.35rem;
}

.qa-answer-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.35rem;
  padding-left: 1rem;
}

.qa-answer-form input {
  flex: 1;
  min-width: 150px;
}

.qa-add {
  display: flex;
  gap: 0.4rem;
}

.qa-add input {
  flex: 1;
}

.account-details dd {
  margin: 0;
}

.panel-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.panel-header-row h3 {
  margin: 0;
}

.sprint-board-link {
  color: #1d4ed8;
  text-decoration: none;
  font-weight: 600;
}

.sprint-board-link:hover {
  text-decoration: underline;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  align-items: center;
  justify-content: center;
  z-index: 9000;
}

.loading-overlay-box {
  background: #ffffff;
  border-radius: var(--ajpm-radius-lg);
  padding: 1.5rem 2rem;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.25);
  text-align: center;
  max-width: 320px;
}

.loading-overlay-spinner {
  width: 2.25rem;
  height: 2.25rem;
  margin: 0 auto 0.9rem;
  border: 3px solid #e2e8f0;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: loading-overlay-spin 0.8s linear infinite;
}

@keyframes loading-overlay-spin {
  to { transform: rotate(360deg); }
}

.loading-overlay-message {
  color: #0f172a;
  font-weight: 600;
}

/* APM-T-151 / APM-T-200: Task ticket form field settings - a read-only sample of
   the real board Edit Task form with a show/hide checkbox on each optional field */
.task-form-sample {
  margin: 1rem 0;
}

.task-form-sample .modal-card {
  max-height: none;
  overflow: visible;
  border: 1px solid #cbd5f5;
  box-shadow: none;
}

/* Disabled only so the sample can't be typed in - keep the real form's look. */
.task-form-sample .modal-body input:disabled,
.task-form-sample .modal-body select:disabled {
  background-color: #ffffff;
  color: #0f172a;
  cursor: default;
}

.task-form-sample .modal-actions button:disabled,
.task-form-sample .modal-header button:disabled {
  cursor: default;
  opacity: 1;
}

/* Foundation restyles disabled buttons - keep the app's own colours on the sample. */
.task-form-sample .modal-actions .btn:disabled {
  background: #2563eb;
  color: #fff;
}

.task-form-sample .modal-actions .btn.secondary:disabled,
.task-form-sample .modal-header .btn.secondary:disabled {
  background: #e2e8f0;
  color: #0f172a;
}

.task-form-sample .modal-actions .btn.danger:disabled {
  background: #dc2626;
  color: #fff;
}

.task-form-sample .modal-header .modal-close:disabled {
  background: transparent;
  color: #0f172a;
}

.task-form-sample .sample-field label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.task-form-sample .sample-field-toggle {
  width: auto;
  margin: 0;
  cursor: pointer;
}

.task-form-sample .sample-field-off label {
  color: #94a3b8;
}

.task-form-sample .modal-body .sample-field-off > *:not(label) {
  opacity: 0.4;
}

/* ---------- Gantt Chart view (APM-R-013 / APM-T-179..182) ---------- */
#ganttApp {
  display: flex;
  flex-direction: column;
  height: 72vh;
  min-height: 480px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
#ganttToolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
  flex: 0 0 auto;
}
.gantt-zoom-label { font-size: 0.8rem; color: #64748b; margin-right: 0.2rem; }
.gantt-zoom-btn {
  font-size: 0.8rem;
  padding: 0.35rem 0.65rem;
  border: 1px solid #cbd5f5;
  border-left-width: 0;
  background: #fff;
  color: #0f172a;
  cursor: pointer;
}
.gantt-zoom-btn:first-of-type { border-radius: 6px 0 0 6px; border-left-width: 1px; }
.gantt-zoom-btn:last-of-type { border-radius: 0 6px 6px 0; }
.gantt-zoom-btn.active { background: #2563eb; color: #fff; border-color: #2563eb; }
#ganttOuter { flex: 1; min-height: 0; overflow: auto; position: relative; }
#ganttInner { display: flex; width: max-content; }
#ganttListCol {
  position: sticky;
  left: 0;
  z-index: 3;
  background: #fff;
  flex: 0 0 300px;
  border-right: 2px solid #e2e8f0;
}
#ganttListHeader {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  height: 44px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  font-size: 0.72rem;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.gc-col-name { flex: 1 1 auto; padding: 0 0.5rem; display: flex; align-items: center; gap: 0.35rem; min-width: 0; }
.gc-col-start, .gc-col-due { flex: 0 0 92px; padding: 0 0.3rem; }
.gc-col-status { flex: 0 0 90px; padding: 0 0.3rem; }
.gantt-row {
  display: flex;
  align-items: center;
  height: 34px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.8rem;
}
.gantt-row:nth-child(even) { background: #f8fafc; }
.gantt-name-link {
  color: #0f172a;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
  min-width: 0;
}
.gantt-name-link:hover { text-decoration: underline; color: #2563eb; }
.gantt-ref { color: #94a3b8; font-size: 0.72rem; flex: 0 0 auto; white-space: nowrap; }
#ganttChartCol { position: relative; }
#ganttChartHeader {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 44px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}
.gantt-hdr-top, .gantt-hdr-bottom {
  position: absolute;
  top: 0;
  height: 22px;
  box-sizing: border-box;
  border-right: 1px solid #e2e8f0;
  font-size: 0.7rem;
  color: #475569;
  padding-left: 4px;
  line-height: 22px;
  white-space: nowrap;
  overflow: hidden;
}
.gantt-hdr-bottom { top: 22px; font-size: 0.65rem; color: #64748b; }
.gantt-hdr-bottom.weekend { background: #f1f5f9; }
#ganttSvg { display: block; }
.gantt-gridline { stroke: #f1f5f9; stroke-width: 1; }
.gantt-gridline-strong { stroke: #e2e8f0; stroke-width: 1; }
.gantt-today-line { stroke: #dc2626; stroke-width: 1.5; stroke-dasharray: 3,2; }
.gantt-bar-bg { cursor: grab; }
.gantt-bar-bg.link-hover { stroke: #2563eb; stroke-width: 2; }
.gantt-bar-label { font-size: 0.68rem; fill: #1e293b; pointer-events: none; dominant-baseline: middle; }
.gantt-resize-handle { fill: transparent; cursor: ew-resize; }
.gantt-link-handle { fill: #fff; stroke: #2563eb; stroke-width: 1.5; cursor: crosshair; opacity: 0.45; }
.gantt-bar-group:hover .gantt-link-handle { opacity: 1; }
.gantt-dep-path { fill: none; stroke: #94a3b8; stroke-width: 1.5; }
.gantt-link-preview { fill: none; stroke: #2563eb; stroke-width: 1.5; stroke-dasharray: 4,3; pointer-events: none; }

/* APM-T-116: Sub-tasks section */
.subtasks-widget { border: 1px solid #cbd5f5; border-radius: 8px; padding: 0.5rem 0.65rem; }
.subtask-parent { background: #eef2ff; border-radius: 6px; padding: 0.3rem 0.6rem; margin-bottom: 0.4rem; font-weight: 600; }
.subtask-row { padding: 0.3rem 0; border-bottom: 1px solid #f1f5f9; display: flex; align-items: center; gap: 0.4rem; }
.subtask-row:last-child { border-bottom: none; }
.subtask-ref { font-size: 0.8rem; font-weight: 600; color: #2563eb; }
.subtask-add { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin-top: 0.5rem; }
.subtasks-widget .subtask-add input.subtask-name { flex: 1; min-width: 10rem; width: auto; margin: 0; }
.subtasks-widget .subtask-add select.subtask-size { width: auto; margin: 0; }
.subtasks-widget .subtask-add .btn { margin: 0; }
