/* Custom site-wide styles for DRCT app */
:root {
  --brand-primary: #0d6efd;
  --brand-primary-hover: #0b5ed7;
  --brand-light: #cfe2ff;
  --surface-primary: #ffffff;
  --surface-secondary: #f8f9fa;
  --surface-tertiary: #e9ecef;
  --border-color: #dee2e6;
  --text-primary: #212529;
  --text-secondary: #6c757d;
  --text-muted: #adb5bd;
  --shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
  --shadow-md: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 1rem 3rem rgba(0, 0, 0, 0.175);
  --radius-sm: 0.25rem;
  --radius-md: 0.375rem;
  --radius-lg: 0.5rem;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--surface-secondary);
  color: var(--text-primary);
  padding: 0;
}

/* Links */
a {
  color: var(--brand-primary);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--brand-primary-hover);
  text-decoration: underline;
}

/* Navbar */
.navbar {
  background-color: var(--surface-primary);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.navbar-brand {
  color: var(--text-primary);
  font-weight: 700;
  font-size: 1.25rem;
}

.nav-link {
  color: var(--text-secondary);
  font-weight: 500;
  transition: color 0.15s ease;
}

.nav-link:hover {
  color: var(--text-primary);
}

/* Cards */
.glass-card {
  background: var(--surface-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

/* Sidebar */
.sidebar-card {
  background: var(--surface-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  transition: box-shadow 0.2s ease;
}

.sidebar-card:hover {
  box-shadow: var(--shadow-md);
}

/* Buttons */
.btn-primary {
  background-color: var(--brand-primary);
  border-color: var(--brand-primary);
  font-weight: 500;
  transition: all 0.15s ease;
}

.btn-primary:hover {
  background-color: var(--brand-primary-hover);
  border-color: var(--brand-primary-hover);
}

.btn-glass {
  background: var(--surface-primary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-weight: 500;
  transition: all 0.15s ease;
}

.btn-glass:hover {
  background: var(--surface-tertiary);
  color: var(--text-primary);
}

.btn-outline-primary {
  border-color: var(--border-color);
  color: var(--text-secondary);
  background: var(--surface-primary);
}

.btn-outline-primary:hover {
  background-color: var(--brand-light);
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.btn-outline-primary.active,
.btn-primary {
  background-color: var(--brand-primary);
  border-color: var(--brand-primary);
  color: white;
}

/* Badges */
.badge-glass {
  background: var(--surface-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-weight: 500;
}

/* Pills */
.pill {
  display: inline-block;
  padding: .25rem .75rem;
  border-radius: 999px;
  font-size: .875rem;
  font-weight: 500;
  border: 1px solid;
}

.pill.primary {
  color: #084298;
  border-color: #b6d4fe;
  background: #cfe2ff;
}

.pill.warning {
  color: #997404;
  border-color: #ffecb5;
  background: #fff3cd;
}

.pill.danger {
  color: #842029;
  border-color: #f5c2c7;
  background: #f8d7da;
}

.pill.success {
  color: #0f5132;
  border-color: #badbcc;
  background: #d1e7dd;
}

.pill.info {
  color: #055160;
  border-color: #b6effb;
  background: #cff4fc;
}

.pill.secondary {
  color: #41464b;
  border-color: #d3d6d8;
  background: #e2e3e5;
}

/* Form Controls */
.form-control-glass {
  background: var(--surface-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  transition: all 0.15s ease;
}

.form-control-glass:focus {
  background: var(--surface-primary);
  border-color: #86b7fe;
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
  outline: none;
}

.input-group-text {
  background: var(--surface-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

/* List Group */
.list-group-item {
  background: var(--surface-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  transition: background-color 0.15s ease;
  margin-bottom: 0.5rem;
  border-radius: var(--radius-md);
}

.list-group-item:hover {
  background: var(--surface-tertiary);
}

.list-group-item-action:active {
  background: var(--brand-light);
  color: var(--brand-primary);
}

/* Timeline */
.timeline-header {
  background: var(--surface-primary);
  border-bottom: 2px solid var(--border-color);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow-sm);
}

.timeline-day {
  min-width: 60px;
  padding: 0.75rem;
  font-weight: 500;
  color: var(--text-primary);
}

/* Project Bars - Force white background with colored left border */
.project-bar {
  background: var(--surface-primary) !important;
  border: 1px solid var(--border-color) !important;
  border-left: 5px solid !important;
  border-radius: var(--radius-md);
  padding: 1rem;
  color: var(--text-primary) !important;
  font-weight: 600;
  cursor: move;
  transition: box-shadow 0.2s ease;
  box-shadow: var(--shadow-sm);
  position: relative;
  font-size: 0.95rem;
}

.project-bar:hover {
  box-shadow: var(--shadow-md);
}

.project-bar strong {
  font-size: 1rem;
  display: block;
  margin-bottom: 0.25rem;
  color: var(--text-primary) !important;
}

.project-bar small {
  color: var(--text-secondary) !important;
  font-weight: 400;
}

/* Bootstrap standard colors for project bar left borders */
.project-bar-blue {
  border-left-color: #0d6efd !important;
}

.project-bar-purple {
  border-left-color: #6f42c1 !important;
}

.project-bar-green {
  border-left-color: #198754 !important;
}

.project-bar-orange {
  border-left-color: #fd7e14 !important;
}

.project-bar-pink {
  border-left-color: #d63384 !important;
}

.project-bar-cyan {
  border-left-color: #0dcaf0 !important;
}

.project-bar-violet {
  border-left-color: #6610f2 !important;
}

.project-bar-red {
  border-left-color: #dc3545 !important;
}

.project-bar-indigo {
  border-left-color: #6610f2 !important;
}

.project-bar-teal {
  border-left-color: #20c997 !important;
}

.project-bar-yellow {
  border-left-color: #ffc107 !important;
}

.project-bar-gray {
  border-left-color: #6c757d !important;
}

/* Default border color if no class specified */
.project-bar:not([class*="project-bar-"]) {
  border-left-color: var(--brand-primary) !important;
}

/* Resize Handles */
.resize-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 8px;
  cursor: ew-resize;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 10;
}

.project-bar:hover .resize-handle {
  opacity: 1;
}

.resize-handle-left {
  left: 0;
  background: linear-gradient(to right, rgba(0,0,0,0.1), transparent);
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.resize-handle-right {
  right: 0;
  background: linear-gradient(to left, rgba(0,0,0,0.1), transparent);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

/* Tables */
.table {
  border-collapse: collapse;
  width: 100%;
  background: var(--surface-primary);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.table th,
.table td {
  border: 1px solid var(--border-color);
  padding: 0.75rem;
  vertical-align: middle;
}

.table th {
  background: var(--surface-tertiary);
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
}

.table-compact tr:nth-child(even) {
  background: var(--surface-secondary);
}

/* Status Indicators */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.status-ok {
  background: #198754;
}

.status-warn {
  background: #ffc107;
}

.status-err {
  background: #dc3545;
}

/* Utilities */
.text-muted {
  color: var(--text-muted);
}

.meta {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* Modal */
.modal-content {
  background: var(--surface-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.modal-header {
  border-bottom: 1px solid var(--border-color);
}

.modal-footer {
  border-top: 1px solid var(--border-color);
}

/* Dropdown */
.dropdown-menu {
  background: var(--surface-primary);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-md);
}

.dropdown-item {
  color: var(--text-primary);
  transition: all 0.15s ease;
}

.dropdown-item:hover {
  background: var(--surface-tertiary);
  color: var(--brand-primary);
}

.dropdown-divider {
  border-top: 1px solid var(--border-color);
}

/* Theme Toggle - Hide */
.theme-toggle,
#theme-toggle {
  display: none !important;
}

/* Dark Theme Support */
[data-bs-theme="dark"] {
  --surface-primary: #212529;
  --surface-secondary: #343a40;
  --surface-tertiary: #495057;
  --border-color: #495057;
  --text-primary: #f8f9fa;
  --text-secondary: #adb5bd;
  --text-muted: #6c757d;
}

[data-bs-theme="dark"] body {
  background: var(--surface-secondary);
}

[data-bs-theme="dark"] .navbar,
[data-bs-theme="dark"] .glass-card,
[data-bs-theme="dark"] .sidebar-card {
  background: var(--surface-primary);
}

[data-bs-theme="dark"] .project-bar {
  background: var(--surface-primary) !important;
  color: var(--text-primary) !important;
}

/* Smooth Transitions */
* {
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

/* Responsive adjustments */
@media (min-width: 992px) {
  body {
    padding: 0;
  }
}

/* Simple fade/slide animation for timeline updates */
.fade-slide {
  animation: slideFade 250ms ease-out;
}
@keyframes slideFade {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Code blocks */
pre.code-block {
  white-space: pre-wrap;
  max-height: 500px;
  overflow: auto;
  background: var(--surface-tertiary);
  padding: 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
}

/* Page title styling */
.page-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

/* Toolbar */
.toolbar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

/* Remove all backdrop filters and glassmorphism */
.glass-nav,
.glass-card,
.sidebar-card,
.btn-glass,
.form-control-glass,
.badge-glass {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}
.timeline-grid-wrapper {
  position: relative; /* contain absolute children like today-line */
  overflow-x: auto;
  overflow-y: hidden;
}

.timeline-grid {
  display: grid;
  grid-auto-rows: minmax(56px, auto);
  align-items: stretch;
  position: relative;
  /* Map raw width from template to effective width; default to 40px if absent */
  --unit-width: var(--unit-width-raw, 40px);
  /* Two-layer background: mask left leading columns, then draw grid lines to the right */
  background-image:
    linear-gradient(
      to right,
      var(--surface-tertiary, #fff) 0,
      var(--surface-tertiary, #fff) var(--leading-cols-offset, 0),
      transparent var(--leading-cols-offset, 0)
    ),
    repeating-linear-gradient(
      to right,
      rgba(0,0,0,0.05),
      rgba(0,0,0,0.05) 1px,
      transparent 1px,
      transparent calc(var(--unit-width))
    );
  background-size: auto 100%, auto 100%;
}

/* Left columns styles for tasks/assignees */
.task-cell { background: transparent; }
.task-cell.task-main span { font-weight: 600; color: var(--text-primary, #212529); }
.task-cell.task-sub { background: #ffffff; }
.task-cell.task-sub span { color: #6c757d; }
.assignee-cell { background: transparent; }
.assignee-cell.task-sub { background: #ffffff; }

/* Vertical divider utility for column borders */
.v-divider-right { border-right: 1px solid var(--border-color, #dee2e6); }

/* Project detail: variable-width columns based on header content */
.timeline-grid.variable-cols {
  /* Disable background grid lines that assume uniform column widths */
  background-image: none;
}
/* Prevent header text from wrapping so columns size to content width (scoped to variable-cols) */
.timeline-grid.variable-cols .tg-header-label {
  white-space: nowrap;
}

/* Add right border for timeline unit headers so top grid lines are visible */
.timeline-grid.variable-cols .tg-header:not(.v-divider-right) {
  border-right: 1px solid var(--border-color, #dee2e6);
}

.tg-header {
  position: sticky;
  top: 0;
  z-index: 2;
  background: rgba(248, 249, 250, 0.95);
  border-bottom: 1px solid #dee2e6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0.5rem 0.25rem;
}

.tg-header-sublabel { display: block; }

.tg-project {
  position: relative;
  margin: 0.25rem 0.125rem;
  border-left: 4px solid currentColor;
  color: #333;
  border-radius: 0.5rem;
  padding: 0.75rem;
  overflow: hidden;
}

/* Overflow indicators for clipped projects: subtle small arrows */
/* Arrow base */
.tg-over-left,
.tg-over-right {
  width: 0; height: 0;
  pointer-events: none;
  opacity: 0.6; /* subtle */
}
/* Left arrow in normal flow before content */
.tg-over-left {
  position: static;
  display: inline-block;
  margin-right: 8px;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 8px solid currentColor;
}
/* Right arrow absolutely positioned inside content row */
.tg-over-right {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 8px solid currentColor;
}

/* Remove rounded corners on the clipped side(s) */
.tg-project.overflow-left { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.tg-project.overflow-right { border-top-right-radius: 0; border-bottom-right-radius: 0; }

.resize-handle {
  position: absolute;
  top: 0; bottom: 0;
  width: 8px;
}
.resize-handle-left { left: -4px; cursor: ew-resize; }
.resize-handle-right { right: -4px; cursor: ew-resize; }

/* Add inner padding to resource lanes so resource end caps (rounded corners) are visible at project edges */
.tg-resources {
  padding: 0 6px;
  box-sizing: border-box;
}

/* Ensure rounded right caps are visible when a resource ends at the project's last column */
.tg-res-block.ends-at-right {
  margin-right: 6px; /* tiny breathing room at the right edge */
}

/* Ensure readability for week scope (day-unit) by enforcing a minimum column width */
.timeline-grid[data-unit="day"] {
  /* Min 48px per day, cap at 160px */
  --unit-width: clamp(48px, var(--unit-width-raw, 48px), 160px);
}

/* Resources page layout tweaks */
.resource-sections .section-header {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.resource-sections .section-header h4 {
  margin: 0;
}
/* Accents based on project_planning colors */
.section-header.personnel {
  background: #E6F4FF;
  border-color: #5AA9FF;
}
.section-header.machines {
  background: #F2F4F7;
  border-color: #98A2B3;
}

/* Card list: enforce 1 per row inside each section column */
.resource-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0; /* use card margins for vertical spacing */
}

/* Vertical breathing room for cards */
.resource-sections .resource-card {
  margin: 0.5rem 0; /* space above and below each card */
}

/* Card accents */
.resource-card.personnel { border-left: 4px solid #5AA9FF; }
.resource-card.machines { border-left: 4px solid #98A2B3; }

/* Ensure tables inside cards don't overflow */
.resource-card .table { background: transparent; }
.resource-card .table thead th { border-top: 0; }


/* Overview: 3-column layout for project cards */
.upcoming-columns {
  column-count: 3;
  column-gap: 1rem;
}

/* Ensure cards do not split across columns */
.upcoming-columns > .glass-card {
  -webkit-column-break-inside: avoid;
  -moz-column-break-inside: avoid;
  break-inside: avoid;
  display: inline-block; /* helps some browsers keep the block intact */
  width: 100%;
  margin-bottom: 1rem; /* extra spacing between items in columns */
}

/* Responsive fallbacks */
@media (max-width: 1200px) {
  .upcoming-columns { column-count: 2; }
}
@media (max-width: 768px) {
  .upcoming-columns { column-count: 1; }
}

/* Timeline grid dividers for variable-width columns */
.tg-col-divider {
  border-left: 1px solid var(--border-color, #dee2e6);
  pointer-events: none;
}

.tg-row-divider {
  border-bottom: 1px solid var(--border-color, #dee2e6);
  pointer-events: none;
}


/* Equal-width button group for toolbars (used on project_detail) */
.btn-group-equal .btn {
  min-width: 160px;
}


/* Left-align Bootstrap tooltip content for tg-project elements */
.tooltip.tt-left .tooltip-inner {
  text-align: left;
}

/* Current time unit header styling */
.tg-header .tg-header-label {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
  color: var(--text-primary);
  background: transparent;
}
.tg-header.current .tg-header-label {
  background: var(--label-purple);
  color: #fff;
}
.tg-header .tg-header-sublabel { color: var(--text-secondary); }
.tg-header.current .tg-header-sublabel { color: var(--text-muted); }

/* Custom site-wide styles for DRCT app */
:root {
  --brand-primary: #0d6efd;
  --brand-primary-hover: #0b5ed7;
  --brand-light: #cfe2ff;
  --surface-primary: #ffffff;
  --surface-secondary: #f8f9fa;
  --surface-tertiary: #e9ecef;
  --border-color: #dee2e6;
  --text-primary: #212529;
  --text-secondary: #6c757d;
  --text-muted: #adb5bd;
  --shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
  --shadow-md: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 1rem 3rem rgba(0, 0, 0, 0.175);
  --radius-sm: 0.25rem;
  --radius-md: 0.375rem;
  --radius-lg: 0.5rem;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--surface-secondary);
  color: var(--text-primary);
  padding: 0;
}

/* Links */
a {
  color: var(--brand-primary);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--brand-primary-hover);
  text-decoration: underline;
}

/* Navbar */
.navbar {
  background-color: var(--surface-primary);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.navbar-brand {
  color: var(--text-primary);
  font-weight: 700;
  font-size: 1.25rem;
}

.nav-link {
  color: var(--text-secondary);
  font-weight: 500;
  transition: color 0.15s ease;
}

.nav-link:hover {
  color: var(--text-primary);
}

/* Cards */
.glass-card {
  background: var(--surface-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

/* Sidebar */
.sidebar-card {
  background: var(--surface-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  transition: box-shadow 0.2s ease;
}

.sidebar-card:hover {
  box-shadow: var(--shadow-md);
}

/* Buttons */
.btn-primary {
  background-color: var(--brand-primary);
  border-color: var(--brand-primary);
  font-weight: 500;
  transition: all 0.15s ease;
}

.btn-primary:hover {
  background-color: var(--brand-primary-hover);
  border-color: var(--brand-primary-hover);
}

.btn-glass {
  background: var(--surface-primary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-weight: 500;
  transition: all 0.15s ease;
}

.btn-glass:hover {
  background: var(--surface-tertiary);
  color: var(--text-primary);
}

.btn-outline-primary {
  border-color: var(--border-color);
  color: var(--text-secondary);
  background: var(--surface-primary);
}

.btn-outline-primary:hover {
  background-color: var(--brand-light);
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.btn-outline-primary.active,
.btn-primary {
  background-color: var(--brand-primary);
  border-color: var(--brand-primary);
  color: white;
}

/* Badges */
.badge-glass {
  background: var(--surface-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-weight: 500;
}

/* Pills */
.pill {
  display: inline-block;
  padding: .25rem .75rem;
  border-radius: 999px;
  font-size: .875rem;
  font-weight: 500;
  border: 1px solid;
}

.pill.primary {
  color: #084298;
  border-color: #b6d4fe;
  background: #cfe2ff;
}

.pill.warning {
  color: #997404;
  border-color: #ffecb5;
  background: #fff3cd;
}

.pill.danger {
  color: #842029;
  border-color: #f5c2c7;
  background: #f8d7da;
}

.pill.success {
  color: #0f5132;
  border-color: #badbcc;
  background: #d1e7dd;
}

.pill.info {
  color: #055160;
  border-color: #b6effb;
  background: #cff4fc;
}

.pill.secondary {
  color: #41464b;
  border-color: #d3d6d8;
  background: #e2e3e5;
}

/* Form Controls */
.form-control-glass {
  background: var(--surface-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  transition: all 0.15s ease;
}

.form-control-glass:focus {
  background: var(--surface-primary);
  border-color: #86b7fe;
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
  outline: none;
}

.input-group-text {
  background: var(--surface-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

/* List Group */
.list-group-item {
  background: var(--surface-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  transition: background-color 0.15s ease;
  margin-bottom: 0.5rem;
  border-radius: var(--radius-md);
}

.list-group-item:hover {
  background: var(--surface-tertiary);
}

.list-group-item-action:active {
  background: var(--brand-light);
  color: var(--brand-primary);
}

/* Timeline */
.timeline-header {
  background: var(--surface-primary);
  border-bottom: 2px solid var(--border-color);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow-sm);
}

.timeline-day {
  min-width: 60px;
  padding: 0.75rem;
  font-weight: 500;
  color: var(--text-primary);
}

/* Project Bars - Force white background with colored left border */
.project-bar {
  background: var(--surface-primary) !important;
  border: 1px solid var(--border-color) !important;
  border-left: 5px solid !important;
  border-radius: var(--radius-md);
  padding: 1rem;
  color: var(--text-primary) !important;
  font-weight: 600;
  cursor: move;
  transition: box-shadow 0.2s ease;
  box-shadow: var(--shadow-sm);
  position: relative;
  font-size: 0.95rem;
}

.project-bar:hover {
  box-shadow: var(--shadow-md);
}

.project-bar strong {
  font-size: 1rem;
  display: block;
  margin-bottom: 0.25rem;
  color: var(--text-primary) !important;
}

.project-bar small {
  color: var(--text-secondary) !important;
  font-weight: 400;
}

/* Bootstrap standard colors for project bar left borders */
.project-bar-blue {
  border-left-color: #0d6efd !important;
}

.project-bar-purple {
  border-left-color: #6f42c1 !important;
}

.project-bar-green {
  border-left-color: #198754 !important;
}

.project-bar-orange {
  border-left-color: #fd7e14 !important;
}

.project-bar-pink {
  border-left-color: #d63384 !important;
}

.project-bar-cyan {
  border-left-color: #0dcaf0 !important;
}

.project-bar-violet {
  border-left-color: #6610f2 !important;
}

.project-bar-red {
  border-left-color: #dc3545 !important;
}

.project-bar-indigo {
  border-left-color: #6610f2 !important;
}

.project-bar-teal {
  border-left-color: #20c997 !important;
}

.project-bar-yellow {
  border-left-color: #ffc107 !important;
}

.project-bar-gray {
  border-left-color: #6c757d !important;
}

/* Default border color if no class specified */
.project-bar:not([class*="project-bar-"]) {
  border-left-color: var(--brand-primary) !important;
}

/* Resize Handles */
.resize-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 8px;
  cursor: ew-resize;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 10;
}

.project-bar:hover .resize-handle {
  opacity: 1;
}

.resize-handle-left {
  left: 0;
  background: linear-gradient(to right, rgba(0,0,0,0.1), transparent);
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.resize-handle-right {
  right: 0;
  background: linear-gradient(to left, rgba(0,0,0,0.1), transparent);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

/* Tables */
.table {
  border-collapse: collapse;
  width: 100%;
  background: var(--surface-primary);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.table th,
.table td {
  border: 1px solid var(--border-color);
  padding: 0.75rem;
  vertical-align: middle;
}

.table th {
  background: var(--surface-tertiary);
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
}

.table-compact tr:nth-child(even) {
  background: var(--surface-secondary);
}

/* Status Indicators */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.status-ok {
  background: #198754;
}

.status-warn {
  background: #ffc107;
}

.status-err {
  background: #dc3545;
}

/* Utilities */
.text-muted {
  color: var(--text-muted);
}

.meta {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* Modal */
.modal-content {
  background: var(--surface-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.modal-header {
  border-bottom: 1px solid var(--border-color);
}

.modal-footer {
  border-top: 1px solid var(--border-color);
}

/* Dropdown */
.dropdown-menu {
  background: var(--surface-primary);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-md);
}

.dropdown-item {
  color: var(--text-primary);
  transition: all 0.15s ease;
}

.dropdown-item:hover {
  background: var(--surface-tertiary);
  color: var(--brand-primary);
}

.dropdown-divider {
  border-top: 1px solid var(--border-color);
}

/* Theme Toggle - Hide */
.theme-toggle,
#theme-toggle {
  display: none !important;
}

/* Dark Theme Support */
[data-bs-theme="dark"] {
  --surface-primary: #212529;
  --surface-secondary: #343a40;
  --surface-tertiary: #495057;
  --border-color: #495057;
  --text-primary: #f8f9fa;
  --text-secondary: #adb5bd;
  --text-muted: #6c757d;
}

[data-bs-theme="dark"] body {
  background: var(--surface-secondary);
}

[data-bs-theme="dark"] .navbar,
[data-bs-theme="dark"] .glass-card,
[data-bs-theme="dark"] .sidebar-card {
  background: var(--surface-primary);
}

[data-bs-theme="dark"] .project-bar {
  background: var(--surface-primary) !important;
  color: var(--text-primary) !important;
}

/* Smooth Transitions */
* {
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

/* Responsive adjustments */
@media (min-width: 992px) {
  body {
    padding: 0;
  }
}

/* Simple fade/slide animation for timeline updates */
.fade-slide {
  animation: slideFade 250ms ease-out;
}
@keyframes slideFade {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Code blocks */
pre.code-block {
  white-space: pre-wrap;
  max-height: 500px;
  overflow: auto;
  background: var(--surface-tertiary);
  padding: 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
}

/* Page title styling */
.page-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

/* Toolbar */
.toolbar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

/* Remove all backdrop filters and glassmorphism */
.glass-nav,
.glass-card,
.sidebar-card,
.btn-glass,
.form-control-glass,
.badge-glass {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}
.timeline-grid-wrapper {
  position: relative; /* contain absolute children like today-line */
  overflow-x: auto;
  overflow-y: hidden;
}

.timeline-grid {
  display: grid;
  grid-auto-rows: minmax(56px, auto);
  align-items: stretch;
  position: relative;
  /* Map raw width from template to effective width; default to 40px if absent */
  --unit-width: var(--unit-width-raw, 40px);
  /* Two-layer background: mask left leading columns, then draw grid lines to the right */
  background-image:
    linear-gradient(
      to right,
      var(--surface-tertiary, #fff) 0,
      var(--surface-tertiary, #fff) var(--leading-cols-offset, 0),
      transparent var(--leading-cols-offset, 0)
    ),
    repeating-linear-gradient(
      to right,
      rgba(0,0,0,0.05),
      rgba(0,0,0,0.05) 1px,
      transparent 1px,
      transparent calc(var(--unit-width))
    );
  background-size: auto 100%, auto 100%;
}

/* Left columns styles for tasks/assignees */
.task-cell { background: transparent; }
.task-cell.task-main span { font-weight: 600; color: var(--text-primary, #212529); }
.task-cell.task-sub { background: #ffffff; }
.task-cell.task-sub span { color: #6c757d; }
.assignee-cell { background: transparent; }
.assignee-cell.task-sub { background: #ffffff; }

/* Vertical divider utility for column borders */
.v-divider-right { border-right: 1px solid var(--border-color, #dee2e6); }

/* Project detail: variable-width columns based on header content */
.timeline-grid.variable-cols {
  /* Disable background grid lines that assume uniform column widths */
  background-image: none;
}
/* Prevent header text from wrapping so columns size to content width (scoped to variable-cols) */
.timeline-grid.variable-cols .tg-header-label {
  white-space: nowrap;
}

/* Add right border for timeline unit headers so top grid lines are visible */
.timeline-grid.variable-cols .tg-header:not(.v-divider-right) {
  border-right: 1px solid var(--border-color, #dee2e6);
}

.tg-header {
  position: sticky;
  top: 0;
  z-index: 2;
  background: rgba(248, 249, 250, 0.95);
  border-bottom: 1px solid #dee2e6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0.5rem 0.25rem;
}

.tg-header-sublabel { display: block; }

.tg-project {
  position: relative;
  margin: 0.25rem 0.125rem;
  border-left: 4px solid currentColor;
  color: #333;
  border-radius: 0.5rem;
  padding: 0.75rem;
  overflow: hidden;
}

/* Overflow indicators for clipped projects: subtle small arrows */
/* Arrow base */
.tg-over-left,
.tg-over-right {
  width: 0; height: 0;
  pointer-events: none;
  opacity: 0.6; /* subtle */
}
/* Left arrow in normal flow before content */
.tg-over-left {
  position: static;
  display: inline-block;
  margin-right: 8px;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 8px solid currentColor;
}
/* Right arrow absolutely positioned inside content row */
.tg-over-right {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 8px solid currentColor;
}

/* Remove rounded corners on the clipped side(s) */
.tg-project.overflow-left { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.tg-project.overflow-right { border-top-right-radius: 0; border-bottom-right-radius: 0; }

.resize-handle {
  position: absolute;
  top: 0; bottom: 0;
  width: 8px;
}
.resize-handle-left { left: -4px; cursor: ew-resize; }
.resize-handle-right { right: -4px; cursor: ew-resize; }

/* Add inner padding to resource lanes so resource end caps (rounded corners) are visible at project edges */
.tg-resources {
  padding: 0 6px;
  box-sizing: border-box;
}

/* Ensure rounded right caps are visible when a resource ends at the project's last column */
.tg-res-block.ends-at-right {
  margin-right: 6px; /* tiny breathing room at the right edge */
}

/* Ensure readability for week scope (day-unit) by enforcing a minimum column width */
.timeline-grid[data-unit="day"] {
  /* Min 48px per day, cap at 160px */
  --unit-width: clamp(48px, var(--unit-width-raw, 48px), 160px);
}

/* Resources page layout tweaks */
.resource-sections .section-header {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.resource-sections .section-header h4 {
  margin: 0;
}
/* Accents based on project_planning colors */
.section-header.personnel {
  background: #E6F4FF;
  border-color: #5AA9FF;
}
.section-header.machines {
  background: #F2F4F7;
  border-color: #98A2B3;
}

/* Card list: enforce 1 per row inside each section column */
.resource-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0; /* use card margins for vertical spacing */
}

/* Vertical breathing room for cards */
.resource-sections .resource-card {
  margin: 0.5rem 0; /* space above and below each card */
}

/* Card accents */
.resource-card.personnel { border-left: 4px solid #5AA9FF; }
.resource-card.machines { border-left: 4px solid #98A2B3; }

/* Ensure tables inside cards don't overflow */
.resource-card .table { background: transparent; }
.resource-card .table thead th { border-top: 0; }


/* Overview: 3-column layout for project cards */
.upcoming-columns {
  column-count: 3;
  column-gap: 1rem;
}

/* Ensure cards do not split across columns */
.upcoming-columns > .glass-card {
  -webkit-column-break-inside: avoid;
  -moz-column-break-inside: avoid;
  break-inside: avoid;
  display: inline-block; /* helps some browsers keep the block intact */
  width: 100%;
  margin-bottom: 1rem; /* extra spacing between items in columns */
}

/* Responsive fallbacks */
@media (max-width: 1200px) {
  .upcoming-columns { column-count: 2; }
}
@media (max-width: 768px) {
  .upcoming-columns { column-count: 1; }
}

/* Timeline grid dividers for variable-width columns */
.tg-col-divider {
  border-left: 1px solid var(--border-color, #dee2e6);
  pointer-events: none;
}

.tg-row-divider {
  border-bottom: 1px solid var(--border-color, #dee2e6);
  pointer-events: none;
}


/* Equal-width button group for toolbars (used on project_detail) */
.btn-group-equal .btn {
  min-width: 160px;
}


/* Left-align Bootstrap tooltip content for tg-project elements */
.tooltip.tt-left .tooltip-inner {
  text-align: left;
}

/* Current-unit header text colors are handled by the new palette rules above.
   Label text stays white on the purple pill; sublabel remains muted per palette. */

/* Edit column hover styles */
.edit-cell {
  background: transparent;
  transition: background-color 0.15s ease;
}
.edit-cell:hover {
  background: rgba(0,0,0,0.04);
}
.edit-cell .btn-edit {
  color: var(--text-secondary);
  opacity: 0.7;
  transition: opacity 0.15s ease, color 0.15s ease;
}
.edit-cell:hover .btn-edit {
  opacity: 1;
  color: var(--text-primary);
}


/* =========================
   Unified Layout Utilities
   ========================= */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.5rem; /* roomier like /projecten (p-4) */
  border-radius: var(--radius-lg);
}
.page-header.glass-card {
  background: var(--surface-primary);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}
.page-header .title {
  display: flex;
  align-items: center;
  gap: .75rem;
}
.btn-bar {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
}
.btn-bar .btn {
  --btn-padding-y: 0.5rem;
  --btn-padding-x: 0.9rem;
  padding: var(--btn-padding-y) var(--btn-padding-x);
}
/* Inline action buttons: smaller than regular buttons, consistent size */
.btn-inline {
  --btn-padding-y: 0.25rem;
  --btn-padding-x: 0.5rem;
  padding: var(--btn-padding-y) var(--btn-padding-x);
  font-size: 0.875rem;
  line-height: 1.2;
}
.btn-inline i { font-size: 0.95em; }


/* Align bars to grid lines on non-variable timelines (/projects and /resources) */
.timeline-grid:not(.variable-cols) .tg-project {
  margin-left: 0;
  margin-right: 0;
}

/* When using element-based dividers, disable painted background grid */
.timeline-grid.with-dividers {
  background-image: none;
}

/* Ensure bar borders are contained within grid tracks to avoid visual misalignment */
.tg-project, .tg-task-block, .tg-res-block {
  box-sizing: border-box;
}

/* Light vertical today line inside timeline grids */
.timeline-grid .today-line {
  border-left: 2px solid rgba(13, 110, 253, 0.35); /* bootstrap primary, subtle */
  pointer-events: none;
  z-index: 1; /* below sticky headers (z=2) and below task bars (z>=2) */
}

/* Ensure inner task grid matches project bar geometry exactly */
.tg-tasks { box-sizing: border-box; }
.tg-task-block { box-sizing: border-box; margin: 0; }


/* Overview: rounded main task boxes inside list-group-flush */
.main-task-box {
  position: relative;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md); /* subtle rounding on all sides */
  background: var(--surface-primary);
  overflow: hidden; /* clip the left accent to the rounded corners */
  padding: 0.5rem 0; /* vertical padding; horizontal via inner margins */
  min-height: 2.5rem;
}

.main-task-box .accent-left {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 6px;
  background: var(--surface-tertiary); /* subtle left accent */
}

@media (hover: hover) {
  .main-task-box:hover {
    box-shadow: var(--shadow-sm);
    background: var(--surface-primary);
  }
}


/* =========================
   UXdesign010 Palette & Navigation Overrides
   ========================= */
:root {
  /* Primary brand (Purple) from UX palette */
  --brand-primary: #4a3b8f;
  --brand-primary-hover: #3d3177;
  --brand-light: #ede9fe;
  /* Label accent (violet) used for today markers, small tags */
  --label-purple: #4a3b8f;
  --label-purple-bg: #f3e8ff;
  /* Surfaces */
  --surface-primary: #ffffff;
  --surface-secondary: #f5f5f7;
  --surface-tertiary: #f9fafb;
  --border-color: #e5e7eb;
  /* Text */
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
}

/* Main Navigation (top bar) */
.navbar.main-nav {
  background: linear-gradient(135deg, #4a3b8f 0%, #5b4ba3 100%);
  border-bottom: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  z-index: 1030; /* above .subnav (sticky-top default 1020) so dropdowns overlay */
}
.navbar.main-nav .navbar-brand,
.navbar.main-nav .nav-link {
  color: rgba(255,255,255,0.9);
}
.navbar.main-nav .nav-link:hover,
.navbar.main-nav .nav-link.active {
  color: #fff;
  background: rgba(255,255,255,0.14);
  border-radius: 6px;
}
.navbar.main-nav .dropdown-menu {
  border-radius: 10px;
  z-index: 1100; /* ensure dropdown appears above sticky subnav (z=1020) */
}

/* Secondary Action Bar */
.subnav {
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
}
.subnav .container-fluid { padding: 12px 16px; }

/* Buttons align with new palette */
.btn-primary { background-color: var(--brand-primary); border-color: var(--brand-primary); }
.btn-primary:hover { background-color: var(--brand-primary-hover); border-color: var(--brand-primary-hover); }
.btn-outline-primary { color: var(--brand-primary); border-color: var(--brand-primary); }
.btn-outline-primary:hover { color: #fff; background-color: var(--brand-primary); border-color: var(--brand-primary); }

/* Timeline: Today indicator changes from blue to purple label style */
.timeline-grid .today-line {
  border-left: 2px solid rgba(74, 59, 143, 0.35); /* purple (brand-primary) subtle */
}
/* Header cell when current (today visible in this header) */
.tg-header.current {
  position: sticky;
}
.tg-header.current .tg-header-sublabel {
  color: var(--text-primary);
}

/* Badges and accents aligned to palette */
.badge-glass, .badge { border-radius: 999px; }
.badge.bg-primary-subtle { background-color: var(--brand-light) !important; color: var(--brand-primary) !important; }

/* Card and page header keep consistent surfaces */
.glass-card { background: var(--surface-primary); border: 1px solid var(--border-color); }
.page-header.glass-card { background: var(--surface-primary); }
