/* Reset & Variables */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --font: "Red Hat Display", sans-serif;
  --mono: "Red Hat Mono", monospace;
  --bg: #fafaf8;
  --surface: #ffffff;
  --surface-alt: #f5f5f5;
  --border: #e8e6e1;
  --border-light: #f0eeea;
  --text: #192F2B;
  --text-muted: #8a8a85;
  --text-light: #b5b5b0;
  --accent: #989B4B;
  --accent-hover: #2c2c2c;
  --radius: 3px;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 32px;
  --space-xl: 64px;

  /* Brand colours (also available as named tokens) */
  --dark-green: #192F2B;
  --orange: #F84C01;

  /* Semantic status colours */
  --danger: #d32f2f;
  --danger-dark: #b71c1c;
  --danger-bg: #ffebee;
  --danger-border: #ffcdd2;
  --success-color: #2e7d32;
  --success-bg: #e8f5e9;
  --success-border: #c8e6c9;
  --warning-color: #e65100;
  --warning-bg: #fff3e0;
  --warning-btn: #ff9800;
  --warning-btn-hover: #f57c00;
  --overdue-color: #c62828;
  --today-color: #f57f17;

  /* Environment nav indicator colours */
  --nav-env-dev: #a4d9b1;
  --nav-env-dev-prod-db: #f5bcbc;

  /* Published badge */
  --published-bg: #dcfce7;
  --published-color: #166534;

  /* Status tag colours */
  --tag-success-bg: #d4edda;
  --tag-success-color: #155724;
  --tag-fail-bg: #f8d7da;
  --tag-fail-color: #721c24;
}

html { font-size: 14px; }
html, body {
  height: 100%;
}

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* Form elements */
textarea, input[type="text"], input[type="email"], input[type="date"],
input[type="number"], input[type="password"], input[type="search"],
input[type="url"], select {
  padding: var(--space-xs);
  box-sizing: border-box;
}

textarea {
  padding: var(--space-sm);
}

/* Navigation */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

/* Environment-specific nav backgrounds */
.nav-env-dev {
  background: var(--nav-env-dev); /* Light green for dev environment */
}

.nav-env-dev-prod-db {
  background: var(--nav-env-dev-prod-db); /* Light red/pink for dev with prod database */
}

/* Production keeps default background (var(--surface)) */

.nav-links { display: flex; gap: var(--space-md); align-items: center; }
.nav-links a { display: inline-flex; align-items: center; color: var(--text-muted); font-size: 1.2rem; }
.nav-focus-chip a { color: var(--text-light) !important; }
.nav-links a:hover { color: var(--text); }
.nav-icon {
  display: inline-block;
  width: 18px;
  height: 18px;
  margin-right: 4px;
  opacity: 0.35;
  transition: opacity 0.15s;
}
.nav-links a:hover .nav-icon { opacity: 0.7; }
.nav-home { display: flex; align-items: center; margin-right: var(--space-md); }
.nav-logo { height:50px; width: auto; padding: 8px; }
.nav-focus-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px 4px 3px 8px;
  border: 1px solid transparent;
  border-radius: 20px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.nav-focus-chip a {
  font-size: 0.8rem !important;
}
a.nav-focus-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: inherit;
  text-decoration: none;
}
a.nav-focus-link:hover {
  text-decoration: underline;
}
.nav-focus-icon {
  display: inline-flex;
  align-items: center;
  color: inherit;
}
.nav-focus-sep {
  width: 1px;
  height: 16px;
  background: currentColor;
  opacity: 0.25;
  flex-shrink: 0;
}
.nav-focus-name {
  padding: 0 4px;
  color: inherit;
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 500;
}
a.nav-focus-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 1.4rem !important;
  color: inherit;
  text-decoration: none;
  line-height: 1;
  opacity: 0.7;
  color: white !important;
}
.nav-focus-clear:hover {
  background: rgba(0, 0, 0, 0.15);
  opacity: 1;
}

/* Nav item dropdown (for Gatherings menu) */
.nav-item-dropdown {
  position: relative;
  display: inline-block;
}
.nav-dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  font-size: 1.2rem;
  color: var(--text-muted);
  padding: 0;
}
.nav-dropdown-toggle:hover { color: var(--text); }
.nav-dropdown-arrow {
  transition: transform 0.15s;
  flex-shrink: 0;
}
.nav-item-dropdown.open .nav-dropdown-arrow { transform: rotate(180deg); }
.nav-item-dropdown.open .nav-dropdown {
  visibility: visible;
  opacity: 1;
}

/* User menu dropdown */
.nav-user {
  position: relative;
  display: inline-block;
  padding-right: var(--space-md);
}
.nav-user-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--space-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--text);
}
.nav-user-toggle:hover { background: var(--border-light); }
.nav-user-photo {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}
.nav-user-name { color: var(--text-muted); }
.nav-user-arrow {
  transition: transform 0.15s;
  flex-shrink: 0;
}
.nav-user.open .nav-user-arrow { transform: rotate(180deg); }
.nav-dropdown {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 140px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 1000;
  transition: opacity 0.15s, visibility 0.15s;
}
.nav-user.open .nav-dropdown {
  visibility: visible;
  opacity: 1;
}
.nav-dropdown a,
.nav-dropdown button {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  color: var(--text);
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border-light);
  text-align: left;
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
  font-family: var(--font);
  cursor: pointer;
}
.nav-dropdown a:last-child,
.nav-dropdown form:last-child button { border-bottom: none; }
.nav-dropdown a:hover,
.nav-dropdown button:hover {
  background: var(--border-light);
  color: var(--accent-hover);
}
.logout-form { margin: 0; }

/* Layout */
.main {
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--space-lg) max(var(--space-lg), calc(50% - 668px));
  box-sizing: border-box;
}

/* Buttons */
.btn {
  padding: var(--space-sm) var(--space-md);
  background: var(--accent);
  color: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s;

  /* vertically align the text and icon */
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;   /* space between icon and text */
}

.export-btn {
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  margin-left: auto;
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn:hover { background: var(--accent-hover); color: var(--surface); }
.btn-sm { padding: var(--space-xs) var(--space-sm); font-size: 0.8rem; }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--border-light); color: var(--text); }
.btn:disabled {
  background: var(--border-light);
  border-color: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
}
.btn-save-wrapper {
  display: inline-block;
  cursor: not-allowed;
}
.btn-save-wrapper .btn:not(:disabled) {
  cursor: pointer;
}

/* Status badges */
.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 2px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--border-light);
  color: var(--text-muted);
}

/* Follow-up date colors */
.follow-up-overdue {
  color: var(--overdue-color);
  font-weight: 500;
}
.follow-up-today {
  color: var(--today-color);
  font-weight: 500;
}

/* Interest tags */
.interest-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 2px;
  font-size: 0.7rem;
  margin: 1px 2px;
  white-space: nowrap;
  background: var(--border-light);
  color: var(--text-muted);
}

/* Interest tags under person name */
.person-interest-tags {
  margin-top: 2px;
}

/* Membership badges — colored by holon type, see .type-* classes below */
.memberships-cell { white-space: normal; }
.membership-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 2px;
  font-size: 0.7rem;
  margin: 1px 2px;
  white-space: nowrap;
  background: var(--border-light);
  color: var(--text-muted);
}

/* Tags */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 2px;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 2px;
}

/* List header */
.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
  gap: var(--space-md);
}
.list-header h1,
.list-header h2 {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* Filters */
.filters { display: flex; gap: var(--space-sm); align-items: center; flex-wrap: wrap; }

/* Toggle group — pill style */
.toggle-group {
  display: inline-flex;
  background: var(--border-light);
  border-radius: 20px;
  padding: 3px;
}
.toggle-btn {
  padding: 5px 16px;
  background: transparent;
  border: none;
  border-radius: 17px;
  font-family: var(--font);
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}
.toggle-btn:hover {
  color: var(--text);
}
.toggle-btn.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}
.search-input, .filter-select {
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  background: var(--surface);
  color: var(--text);
  outline: none;
}
.search-input:focus, .filter-select:focus {
  border-color: var(--accent);
}
.search-input { width: 260px; }

/* Empty states */
.empty-state {
  color: var(--text-light);
  text-align: center;
  padding: 0;
}
/* Hijack impersonation bar */
.hijack-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--warning-bg);
  border-bottom: 2px solid var(--warning-btn);
  color: var(--warning-color);
  font-size: 0.9rem;
}
.hijack-release-btn {
  padding: var(--space-xs) var(--space-sm);
  background: var(--warning-btn);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-family: var(--font);
  cursor: pointer;
  font-weight: 500;
}
.hijack-release-btn:hover {
  background: var(--warning-btn-hover);
}

/* Type badges */
.type-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
}

/* Relationship badges */
.rel-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 0.7rem;
  margin: 1px 2px;
  background: var(--border-light);
  color: var(--text-muted);
}

/* Hamburger menu button */
.nav-hamburger {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 8px;
}
.nav-hamburger:hover { color: var(--text); }

/* Sidebar navigation */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 1100;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s, visibility 0.25s;
}
.sidebar-overlay.open { opacity: 1; visibility: visible; }
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 300px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 1200;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar.open { transform: translateX(0); }
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-home {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 1rem;
  font-weight: 500;
  text-decoration: none;
}
.sidebar-home:hover { color: var(--accent); }
.sidebar-home-icon { width: 20px; height: 20px; opacity: 0.6; }
.sidebar-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1.4rem;
  padding: 4px;
  line-height: 1;
}
.sidebar-close:hover { color: var(--text); }
.sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 16px;
}

/* Tree component (sidebar + explore page) */
.explore-tree {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 700px;
}
.tree-section-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 16px 6px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.tree-section-label:hover { color: var(--text); }
.tree-section-label:not(:first-child) {
  border-top: 1px solid var(--border-light);
  margin-top: 4px;
}
.tree-section-label .tree-chevron { width: 14px; height: 14px; }
.tree-row {
  display: flex;
  align-items: center;
  padding: 4px 12px;
  gap: 6px;
  transition: background 0.1s;
}
.tree-row:hover { background: var(--border-light); }
.depth-1 { padding-left: 36px; }
.depth-2 { padding-left: 60px; }
.depth-3 { padding-left: 84px; }
.depth-4 { padding-left: 108px; }
.depth-5 { padding-left: 132px; }
.tree-link {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  text-decoration: none;
  color: inherit;
}
.tree-chevron {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-light);
  flex-shrink: 0;
  transition: transform 0.15s, color 0.1s;
  user-select: none;
}
.tree-chevron:hover { color: var(--text-muted); }
.tree-chevron.open { transform: rotate(90deg); }
.tree-spacer { width: 18px; flex-shrink: 0; }
.tree-icon {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.tree-icon img { width: 14px; height: 14px; }
.tree-icon-neutral { background: var(--border-light); }
.tree-name {
  flex: 1;
  min-width: 0;
  font-size: 0.9rem;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tree-link:hover .tree-name { color: var(--accent); }
.tree-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}
.tree-count { font-size: 0.75rem; color: var(--text-light); }
.tree-count a { color: var(--text-muted); }
.tree-count a:hover { color: var(--accent); }
.tree-focus {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: var(--radius);
  opacity: 0;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
.tree-row:hover .tree-focus { opacity: 0.5; }
.tree-focus:hover { opacity: 1 !important; background: var(--border); }
.tree-focus img { width: 14px; height: 14px; }
.tree-children { display: none; }
.tree-children.open { display: block; }
.tree-empty { padding: 12px 16px; color: var(--text-light); font-size: 0.85rem; }

/* Sidebar tree link (Journeys label) */
.tree-section-label a { color: inherit; text-decoration: none; }
.tree-section-label a:hover { text-decoration: underline; }

/* Layout utilities */
.hidden { display: none; }
.d-inline { display: inline; }
.cursor-default { cursor: default; }
.cursor-pointer { cursor: pointer; }
.text-sm { font-size: 0.85em; }

/* Status tags — used for success/fail results */
.tag-success { background: var(--tag-success-bg); color: var(--tag-success-color); }
.tag-fail    { background: var(--tag-fail-bg); color: var(--tag-fail-color); }

/* Agent textarea */
.agent-textarea { min-height: 12rem; width: 100%; box-sizing: border-box; }

/* Agent schedule card */
.schedule-card { margin-bottom: 1.5rem; padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius); }
.schedule-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; }
.schedule-meta { display: flex; align-items: center; gap: var(--space-sm); }
.schedule-description { margin: 0.25rem 0 0.75rem; font-size: 0.85em; color: var(--text-muted); }

/* Task result cell */
.task-result-cell { word-break: break-word; white-space: pre-wrap; font-size: 0.85em; }

/* Error / no-access page */
.error-page { max-width: 480px; margin: 120px auto; text-align: center; }
.error-page h1 { font-size: 1.4rem; margin-bottom: 1rem; }
.error-page p { color: var(--text-muted); margin-bottom: 2rem; }
.error-page a { color: var(--accent); }

