/* ==========================================================================
   VOPA Teams - application styles (on top of Bootstrap 5)
   ========================================================================== */

/* ---- Layout ------------------------------------------------------------- */
.sidebar { width: 220px; flex-shrink: 0; min-height: calc(100vh - 56px); }
@media (min-width: 992px) {
  .sidebar { position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto; }
}
.sidebar .nav-link { color: var(--bs-body-color); border-radius: .375rem; margin: 0 .5rem; }
.sidebar .nav-link:hover { background: var(--bs-secondary-bg); }
.sidebar .nav-link.active { background: var(--bs-primary); color: #fff; }
.sidebar .nav-link .bi { width: 1.4em; display: inline-block; }
.main-content { min-width: 0; }  /* allow wide tables to scroll inside flexbox */
.login-box { max-width: 380px; }

/* ---- Small components --------------------------------------------------- */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.75rem; height: 1.75rem; border-radius: 50%; flex-shrink: 0;
  color: #fff; font-size: .7rem; font-weight: 600; vertical-align: middle;
}
.tag-badge { font-weight: 500; }
.tag-dot { display: inline-block; width: .7em; height: .7em; border-radius: 50%; }
.clickable-row { cursor: pointer; }
.stat-card { transition: box-shadow .15s; color: inherit; }
.stat-card:hover { box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .1); }
.note-card .note-preview { max-height: 6em; overflow: hidden; }

/* ---- Kanban board --------------------------------------------------------- */
.kanban { display: flex; gap: 1rem; overflow-x: auto; padding-bottom: 1rem; align-items: flex-start; }
.kanban-column {
  flex: 1 1 0; min-width: 210px; max-width: 360px; background: var(--bs-tertiary-bg);
  border-radius: .5rem; display: flex; flex-direction: column;
}
.kanban-header { display: flex; align-items: center; padding: .6rem .75rem; border-radius: .5rem .5rem 0 0; }
.kanban-list { min-height: 120px; padding: 0 .5rem .5rem; display: flex; flex-direction: column; gap: .5rem; }
.kanban-card { cursor: grab; }
.kanban-card:active { cursor: grabbing; }
.kanban-ghost { opacity: .4; }
.kanban-card.saving { opacity: .6; }
/* Customer - project label on a card: wraps onto a second line when it is
   long, so the full name stays readable (project number in the tooltip). */
.kanban-project { max-width: 100%; white-space: normal; text-align: left; line-height: 1.3; font-weight: 500; }

/* ---- Team planning board (templates/team/overview.html) ---------------
   Every team member is one CSS grid row-block with the same column template
   (--planning-columns), so day columns line up across members. Bars span
   several day columns; --lanes is the number of stacked bars in a row. */
.planning-scroll { overflow-x: auto; }
/* min-width is set inline (sum of the minimum column widths) */
.planning-row {
  display: grid;
  grid-template-columns: var(--planning-columns);
  /* One 1.5rem lane per stacked bar, with equal flexible space above and
     below, so the bars are centred vertically and there is room to click. */
  grid-template-rows: minmax(.5rem, 1fr) repeat(var(--lanes, 1), 1.5rem) minmax(.5rem, 1fr);
  border-bottom: 1px solid var(--bs-border-color);
  padding: 0;
}
.planning-head { grid-template-rows: auto; font-weight: 600; background: var(--bs-tertiary-bg); }
.planning-row > .pl-name, .planning-row > .pl-meta { grid-row: 1 / -1; padding: .4rem .5rem; display: flex; align-items: center; }
.planning-row > .pl-meta { justify-content: center; font-size: .85rem; border-left: 1px solid var(--bs-border-color); }
.planning-row > .pl-name { position: sticky; left: 0; z-index: 3; background: var(--bs-body-bg); gap: .35rem; }
.planning-head > .pl-name { background: var(--bs-tertiary-bg); }
.pl-day { text-align: center; font-size: .8rem; padding: .3rem .1rem; border-left: 1px solid var(--bs-border-color); }
.pl-day.weekend { color: var(--bs-secondary-color); }
.pl-day.today { background: var(--bs-primary-bg-subtle); }
/* Month view: narrow columns, day number with a small weekday above it. */
.planning-compact .pl-day { font-size: .75rem; padding: .25rem 0; }
.planning-compact .pl-weekday { font-size: .62rem; color: var(--bs-secondary-color); }
.planning-compact .planning-chip { font-size: .7rem; padding: 0 .3rem; margin-left: .1rem; margin-right: .1rem; }
.planning-cell {
  grid-row: 1 / -1; min-height: 3rem; cursor: copy; user-select: none;
  border-left: 1px solid var(--bs-border-color);
}
.planning-cell.today { box-shadow: inset 0 0 0 2px var(--bs-primary); }
.planning-grid .week-start { border-left: 2px solid var(--bs-secondary); }

/* One bar per run of consecutive planned days, in the employee's colour. */
.planning-chip {
  position: relative; z-index: 2;
  margin: .1rem .2rem; padding: 0 .45rem;
  border-radius: .6rem;
  font-size: .75rem; line-height: 1.3rem; text-decoration: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .15);
  /* Bars can be dragged (move) - a plain click still opens the popup. */
  cursor: grab; touch-action: none;
}
.planning-chip:hover { filter: brightness(.92); }
/* "Ingepland": planning on a project the viewer is not linked to. */
.planning-chip.locked { cursor: default; opacity: .75; }
.planning-chip.locked:hover { filter: none; }
/* Resize handles on the outer edges of a bar (static/js/team.js). */
.bar-handle {
  position: absolute; top: 0; bottom: 0; width: .55rem; cursor: ew-resize; z-index: 1;
}
.bar-handle.start { left: 0; }
.bar-handle.end { right: 0; }
.planning-chip:hover .bar-handle::after {
  content: ""; position: absolute; top: 25%; bottom: 25%; left: 40%; width: 2px;
  background: currentColor; opacity: .6; border-radius: 1px;
}
/* While dragging: the original bar fades, a preview ("ghost") shows the result. */
.planning-chip.drag-source { opacity: .3; }
.planning-chip.drag-ghost { opacity: .9; z-index: 4; pointer-events: none; box-shadow: 0 2px 8px rgba(0, 0, 0, .35); outline: 2px dashed rgba(0, 0, 0, .45); }
.planning-grid.dragging, .planning-grid.dragging * { cursor: grabbing !important; }
.planning-grid.resizing, .planning-grid.resizing * { cursor: ew-resize !important; }
/* Project page: planning of other projects / absences in grey (not draggable). */
.planning-chip.muted { background-color: #ced4da; color: #495057; cursor: pointer; box-shadow: none; }
/* Absences: same colour, striped, so they stand out from project work. */
.planning-chip.absence {
  background-image: repeating-linear-gradient(45deg, rgba(255, 255, 255, .28) 0 6px, transparent 6px 12px);
}
/* The assignment runs on before/after the visible period: square, flush edge. */
.planning-chip.continues-before { margin-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.planning-chip.continues-after { margin-right: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }

/* Load colours of the background cells. */
.level-free    { background: var(--bs-body-bg); }
.level-weekend { background: #f1f3f5; }
.level-partial { background: #fff3cd; }
.level-full    { background: #d1e7dd; }
.level-over    { background: #f8d7da; }
.level-absent  { background: repeating-linear-gradient(45deg, #e9ecef, #e9ecef 6px, #f8f9fa 6px, #f8f9fa 12px); }
.legend { display: inline-block; width: 1em; height: 1em; border: 1px solid #ccc; vertical-align: middle; }

/* ---- Wiki & notes ----------------------------------------------------------- */
/* Wiki tree navigation (templates/wiki/_tree.html). */
.wiki-tree { list-style: none; margin: 0; padding-left: 1rem; border-left: 1px solid var(--bs-border-color); }
.wiki-tree.wiki-tree-root { padding-left: 0; border-left: 0; }
.wiki-tree li { margin: 0; }
.wiki-node { display: flex; align-items: center; gap: .25rem; padding: .15rem .35rem; border-radius: .3rem; font-size: .9rem; }
.wiki-node a { flex: 1; min-width: 0; color: var(--bs-body-color); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wiki-node a .bi { margin-right: .35rem; color: var(--bs-secondary-color); }
.wiki-node:hover { background: var(--bs-tertiary-bg); }
.wiki-node.current { background: var(--bs-primary-bg-subtle); }
.wiki-node.current a { color: var(--bs-primary-text-emphasis); font-weight: 600; }
/* Branch toggle: a chevron that turns when the branch is open. */
.wiki-tree summary { list-style: none; cursor: pointer; }
.wiki-tree summary::-webkit-details-marker { display: none; }
.wiki-tree summary::before {
  content: "\F285"; font-family: "bootstrap-icons"; font-size: .7rem; width: .9rem;
  color: var(--bs-secondary-color); transition: transform .15s;
}
.wiki-tree details[open] > summary::before { transform: rotate(90deg); }
.wiki-leaf { padding-left: 1.25rem; }
.wiki-count { font-size: .7rem; color: var(--bs-secondary-color); background: var(--bs-tertiary-bg); border-radius: 1rem; padding: 0 .4rem; }
.wiki-tree-card .card-body { max-height: 70vh; overflow-y: auto; }
.markdown-body { line-height: 1.6; }
.markdown-body table { border-collapse: collapse; margin-bottom: 1rem; }
.markdown-body th, .markdown-body td { border: 1px solid var(--bs-border-color); padding: .3rem .6rem; }
.markdown-body th { background: var(--bs-tertiary-bg); }
.markdown-body pre { background: var(--bs-tertiary-bg); padding: .75rem; border-radius: .375rem; }
.markdown-body blockquote { border-left: 4px solid var(--bs-border-color); padding-left: 1rem; color: var(--bs-secondary-color); }
.markdown-body img { max-width: 100%; }
.toastui-editor-defaultUI { background: var(--bs-body-bg); }

/* Day selection by click-and-drag in the planning grid (static/js/team.js). */
.planning-cell.selecting {
  background-image: linear-gradient(rgba(13, 110, 253, .28), rgba(13, 110, 253, .28));
  outline: 2px solid var(--bs-primary);
  outline-offset: -2px;
}

/* Supplier catalogue: import bar stays visible at the bottom of the screen. */
.catalog-import-bar { position: sticky; bottom: .75rem; z-index: 10; }
.catalog-table tbody tr { cursor: pointer; }

/* Instant tooltip on planning bars (static/js/team.js). */
.planning-tooltip .tooltip-inner { max-width: 22rem; text-align: left; padding: .45rem .6rem; font-size: .8rem; }
.planning-tooltip .tooltip-inner .bi { opacity: .7; margin-right: .2rem; }
body.planning-dragging .tooltip { display: none !important; }

/* Live log of fetching Rexel details (static/js/article_details.js). */
.details-log li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Outlook (Microsoft 365) appointments in the planning (services/outlook.py):
   white bar with an edge in the employee's colour; out-of-office striped. */
.planning-chip.outlook-bar {
  background: var(--bs-body-bg); color: var(--bs-body-color); cursor: default;
  border: 1px solid var(--user-color); border-left-width: 4px; line-height: 1.15rem;
}
.planning-chip.outlook-bar .bi { color: var(--user-color); }
.planning-chip.outlook-bar.oof {
  background-image: repeating-linear-gradient(45deg, rgba(0, 0, 0, .05) 0 6px, transparent 6px 12px);
}
.planning-chip.outlook-bar:hover { filter: none; }
.outlook-marker {
  position: absolute; right: 2px; bottom: 1px; z-index: 3;
  font-size: .65rem; color: var(--bs-secondary-color); background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color); border-radius: .5rem; padding: 0 .25rem; line-height: 1rem;
}
.outlook-marker .bi { margin-right: .1rem; }
.planning-cell { position: relative; }

/* Company logo in the title bar (white logo, made for a dark background). */
.brand-logo { height: 28px; width: auto; display: block; }
.brand-name { border-left: 1px solid rgba(255,255,255,.35); padding-left: .6rem; font-weight: 400; letter-spacing: .02em; }

/* Colour picker on the Outlook link page. */
.color-swatch { width: 28px; height: 28px; border-radius: 6px; background: var(--swatch); cursor: pointer;
  border: 1px solid rgba(0,0,0,.15); margin: 0; }
.btn-check:checked + .color-swatch { outline: 3px solid var(--bs-primary); outline-offset: 2px; }
.btn-check:focus-visible + .color-swatch { outline: 3px solid var(--bs-primary); outline-offset: 2px; }
