/* ═══════════════════════════════════════════════════
   PLANNING BOARD — stylesheet
   ═══════════════════════════════════════════════════ */

:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface2: #1c2333;
  --surface3: #21262d;
  --border: #30363d;
  --border-week: #3d4f6e;
  --text: #c9d1d9;
  --text-dim: #6e7681;
  --text-bright: #f0f6fc;
  --today-bg: rgba(56, 139, 253, 0.08);
  --today-border: #388bfd;
  --holiday-bg: rgba(120, 53, 15, 0.12);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
}

html {
  overflow: hidden;
}

body {
  font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.layout-shell {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 100vh;
}

main[role="main"] {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.page-main-scroll {
  overflow-y: auto;
  min-height: 0;
}

body.page-planning-board {
  overflow: hidden;
}

body.page-planning-board main[role="main"] {
  overflow: hidden;
}

/* ─── HEADER ─── */
.app-header {
  display: flex;
  align-items: center;
  padding: 0 20px;
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 14px;
}

.app-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-bright);
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.header-sep { width: 1px; height: 20px; background: var(--border); }

.filter-buttons { display: flex; gap: 6px; }

.board-team-group {
  min-width: 190px;
}

.board-team-group select {
  min-width: 190px;
}

.board-range-controls {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-left: 50px;
}

.spacer { flex: 1; }

.range-nav-btn {
  height: 31px;
  min-width: 31px;
  padding: 0 8px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.12s;
}

.range-nav-btn:hover {
  border-color: var(--today-border);
  color: #8fd3ff;
}

.range-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.range-group label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.range-group select {
  min-width: 82px;
  padding: 5px 28px 5px 10px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background-color: var(--surface2);
  color: var(--text);
  font-family: inherit;
  font-size: 11px;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236e7681' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.range-group select:focus {
  border-color: var(--today-border);
}

.filter-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-btn .av {
  width: 16px; height: 16px;
  border-radius: 50%;
  font-size: 8px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
}

.filter-btn.active {
  border-color: var(--border-week);
  background: var(--surface2);
  color: var(--text);
}

.loading-indicator {
  font-size: 10px;
  color: var(--text-dim);
  opacity: 0.6;
  font-style: italic;
  transition: opacity 0.3s;
}

.loading-indicator.hidden { opacity: 0; pointer-events: none; }

.today-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.today-btn:hover { border-color: var(--today-border); color: var(--today-border); }

.add-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 5px;
  border: 1px solid #238636;
  background: #1a2e20;
  color: #3fb950;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.add-btn:hover { background: #2a3e2a; }

/* ─── BOARD WRAPPER ─── */
.board-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  position: relative;
}

.board-wrap::-webkit-scrollbar { width: 7px; height: 7px; }
.board-wrap::-webkit-scrollbar-track { background: var(--bg); }
.board-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

table.board {
  border-collapse: collapse;
  min-width: max-content;
}

/* ─── STICKY HEADERS ─── */
thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
}

thead th.row2 { top: 32px; }

.sticky-left {
  position: sticky;
  left: 0;
  z-index: 5;
  background: var(--surface);
  border-right: 1px solid var(--border);
  width: 148px;
  min-width: 148px;
}

thead th.sticky-left { z-index: 20; }

/* ─── WEEK HEADER ─── */
.th-week {
  height: 32px;
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  border-right: 2px solid var(--border-week);
  padding: 0 8px;
  white-space: nowrap;
}

.th-week-label {
  text-align: left;
  padding-left: 16px;
  font-size: 10px;
  letter-spacing: 0.06em;
}

/* ─── DAY HEADER ─── */
.th-day {
  height: 36px;
  width: 108px;
  min-width: 108px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 4px 6px;
  vertical-align: middle;
}

.th-day.week-last { border-right: 2px solid var(--border-week); }
.th-day.is-today  { background: var(--today-bg); border-bottom: 2px solid var(--today-border); }

.th-day .dn {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  line-height: 1;
}

.th-day.is-today .dn { color: #58a6ff; }

.th-day .dd {
  display: block;
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 2px;
  font-family: 'IBM Plex Mono', monospace;
}

.th-day .dh {
  display: block;
  font-size: 10px;
  margin-top: 4px;
  color: #8fd3ff;
  font-family: 'IBM Plex Mono', monospace;
}

.th-day .dh.is-empty {
  color: var(--text-dim);
  opacity: 0.55;
}

.th-day-label {
  text-align: left;
  padding-left: 16px;
  font-size: 10px;
  color: var(--text-dim);
}

/* ─── PERSON ROW ─── */
tr.person-row td {
  height: 38px;
  background: var(--surface3);
  border-bottom: 1px solid var(--border);
}

tr.person-row td.sticky-left { background: var(--surface3); }

.person-day-total {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #8fd3ff;
  font-family: 'IBM Plex Mono', monospace;
}

.person-day-total-empty {
  color: var(--text-dim);
  opacity: 0.8;
}

.person-day-summary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 100%;
}

.planning-board-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.16);
}

.planning-board-status-booked {
  background: #3fb950;
  box-shadow: 0 0 0 1px rgba(63,185,80,0.32), 0 0 10px rgba(63,185,80,0.28);
}

.planning-board-status-fri {
  background: #f85149;
  box-shadow: 0 0 0 1px rgba(248,81,73,0.32), 0 0 10px rgba(248,81,73,0.24);
}

.planning-board-status-empty {
  background: #d29922;
  box-shadow: 0 0 0 1px rgba(210,153,34,0.32), 0 0 10px rgba(210,153,34,0.24);
}

.planning-board-status-off {
  background: #f85149;
  box-shadow: 0 0 0 1px rgba(248,81,73,0.32), 0 0 10px rgba(248,81,73,0.24);
}

.person-cell {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 16px;
}

.person-avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.person-name-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-bright);
}

/* ─── LANE ROW ─── */
tr.lane-row td {
  height: 34px;
  border-bottom: 1px solid rgba(48, 54, 61, 0.6);
  padding: 3px 4px;
  vertical-align: middle;
}

tr.lane-row td.sticky-left {
  padding: 0 14px 0 20px;
  font-size: 10.5px;
  color: var(--text-dim);
  white-space: nowrap;
}

tr.lane-row td.is-today   { background: var(--today-bg); }
tr.lane-row td.week-last  { border-right: 2px solid var(--border-week); }
tr.lane-row td.is-holiday { background: var(--holiday-bg); }

tr.lane-row-empty td.sticky-left {
  color: #f59e0b;
  font-style: italic;
}

.lane-empty-message {
  padding: 0 16px;
  color: var(--text-dim);
  font-size: 11px;
  font-style: italic;
  background: rgba(245, 158, 11, 0.06);
}

tr.lane-row td.drop-cell {
  position: relative;
  transition: background-color 0.12s, box-shadow 0.12s;
}

body.dragging-brick tr.lane-row td.drop-cell:not(.is-holiday) {
  cursor: copy;
}

tr.lane-row td.drop-target-active {
  background: rgba(35, 134, 54, 0.18);
  box-shadow: inset 0 0 0 1px rgba(63, 185, 80, 0.55);
}

tr.lane-row td.drop-target-invalid {
  background: rgba(218, 54, 51, 0.14);
  box-shadow: inset 0 0 0 1px rgba(248, 81, 73, 0.45);
}

/* ─── CHIP ─── */
.chip {
  display: flex;
  align-items: center;
  height: 26px;
  border-radius: 4px;
  padding: 0 7px;
  font-size: 10.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  letter-spacing: 0.015em;
  transition: filter 0.12s, transform 0.1s;
  user-select: none;
  overflow: hidden;
  color: #fff;
  outline: 2px solid transparent;
  outline-offset: 1px;
}

.chip:hover { filter: brightness(1.2); transform: translateY(-1px); z-index: 2; position: relative; }
.chip.editing { outline: 2px solid rgba(255, 255, 255, 0.7); filter: brightness(1.15); }
.chip.dragging { opacity: 0.45; transform: scale(0.98); }
.chip.selected {
  outline-color: rgba(88, 166, 255, 0.95);
  box-shadow: 0 0 0 1px rgba(88, 166, 255, 0.45), 0 0 0 3px rgba(56, 139, 253, 0.18);
  filter: brightness(1.08);
}

.chip.selected:hover {
  filter: brightness(1.22);
}

body.dragging-brick .chip:not(.dragging) {
  cursor: grab;
}

.chip-label  { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.chip-hours  { margin-left: 5px; font-family: 'IBM Plex Mono', monospace; font-size: 9.5px; opacity: 0.75; flex-shrink: 0; }

/* ─── HOLIDAY OVERLAY ─── */
.holiday-overlay {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  color: rgba(251, 191, 36, 0.82);
}

tr.spacer-row td { height: 10px; background: var(--bg); }

/* ─── TOOLTIP ─── */
#tooltip {
  position: fixed;
  z-index: 9999;
  background: #1c2333;
  border: 1px solid var(--border-week);
  border-radius: 8px;
  padding: 13px 15px;
  width: 260px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s;
}

#tooltip.show { opacity: 1; }

.tt-header  { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.tt-dot     { width: 9px; height: 9px; border-radius: 2px; flex-shrink: 0; }
.tt-name    { font-size: 13px; font-weight: 600; color: var(--text-bright); flex: 1; }
.tt-id      { font-family: 'IBM Plex Mono', monospace; font-size: 10px; color: var(--text-dim); background: rgba(255,255,255,0.06); padding: 2px 6px; border-radius: 3px; }
.tt-row     { display: flex; justify-content: space-between; font-size: 11px; margin-bottom: 5px; }
.tt-row .tl { color: var(--text-dim); }
.tt-row .tv { color: var(--text); font-weight: 500; }
.tt-divider { height: 1px; background: var(--border); margin: 9px 0; }
.tt-desc    { font-size: 11px; color: var(--text-dim); line-height: 1.55; }
.tt-hint    { margin-top: 9px; font-size: 10px; color: var(--text-dim); opacity: 0.55; display: flex; align-items: center; gap: 5px; }

.tt-hint kbd {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 3px;
  padding: 1px 5px;
  font-family: inherit;
  font-size: 9px;
}

/* ─── MODAL ─── */
.modal-bg {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s;
}

.modal-bg.open { opacity: 1; pointer-events: all; }

.modal {
  background: #161b22;
  border: 1px solid var(--border-week);
  border-radius: 12px;
  width: 460px;
  max-width: 95vw;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7);
  transform: translateY(14px) scale(0.97);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}

.modal-bg.open .modal { transform: translateY(0) scale(1); }

.modal-bar { height: 4px; width: 100%; transition: background 0.2s; }

.modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--border);
}

.modal-dot    { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; transition: background 0.2s; }
.modal-title  { font-size: 14px; font-weight: 600; color: var(--text-bright); }
.modal-subtitle { font-size: 10.5px; color: var(--text-dim); margin-top: 1px; }

.modal-close {
  width: 26px; height: 26px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; line-height: 1;
  transition: all 0.12s;
}

.modal-close:hover { background: var(--surface3); color: var(--text); }

.modal-body { padding: 18px 20px; }

.form-row        { display: grid; gap: 12px; margin-bottom: 12px; }
.form-row.cols-1 { grid-template-columns: 1fr; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

.field label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  padding: 7px 10px;
  transition: border-color 0.12s;
  outline: none;
  appearance: none;
}

.field input:focus,
.field select:focus,
.field textarea:focus { border-color: #4d7cbc; }

.field textarea { resize: vertical; min-height: 64px; line-height: 1.5; }

.field-hint {
  margin-top: 6px;
  font-size: 10px;
  color: var(--text-dim);
  line-height: 1.4;
}

.field select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236e7681' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.color-row    { display: flex; align-items: center; gap: 14px; }
.color-preview { width: 32px; height: 32px; border-radius: 6px; flex-shrink: 0; border: 2px solid rgba(255,255,255,0.15); transition: background 0.15s; }
.color-swatches { display: flex; gap: 5px; flex-wrap: wrap; }

.swatch {
  width: 20px; height: 20px;
  border-radius: 4px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.12s, border-color 0.12s;
  flex-shrink: 0;
}

.swatch:hover { transform: scale(1.2); }
.swatch.selected { border-color: rgba(255, 255, 255, 0.8); transform: scale(1.1); }

.modal-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--border);
}

.btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 15px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.12s;
}

.btn-save   { background: #1a2e20; border-color: #238636; color: #3fb950; }
.btn-save:hover { background: #22372a; }
.btn-cancel { background: transparent; border-color: var(--border); color: var(--text-dim); }
.btn-cancel:hover { color: var(--text); border-color: var(--text-dim); }

.btn-delete {
  background: transparent;
  border-color: #6b2020;
  color: #f85149;
  margin-left: auto;
  transition: all 0.2s;
}
.btn-delete:hover { background: #2d1b1b; border-color: #f85149; }
.btn-delete.confirming {
  background: #3d1212;
  border-color: #f85149;
  animation: pulse-red 0.6s ease;
}

@keyframes pulse-red {
  0%, 100% { box-shadow: none; }
  50%       { box-shadow: 0 0 0 3px rgba(248, 81, 73, 0.25); }
}

/* Show / hide based on modal mode */
.edit-only { display: flex; }
.new-only  { display: grid; }
.modal-bg.new-mode .edit-only  { display: none; }
.modal-bg:not(.new-mode) .new-only { display: none; }
.modal-bg.new-mode .modal-bar  { background: #238636 !important; }

/* ─── ERROR TOAST ─── */
.error-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: #3d1212;
  border: 1px solid #f85149;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 12px;
  color: #f85149;
  z-index: 9998;
  transition: transform 0.3s;
  pointer-events: none;
}

.error-toast.visible { transform: translateX(-50%) translateY(0); }

/* ─── SCHEDULE STATUS DOTS ─── */
.planning-board-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  position: relative;
  flex-shrink: 0;
}

.planning-board-status-dot::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  transition: transform 0.2s;
}

.planning-board-status-booked {
  background: #3fb950;
}

.planning-board-status-empty {
  background: #6e7681;
}

.planning-board-status-off {
  background: #f85149;
}

/* Scale up the dot on hover for effect */
td.person-cell:hover .planning-board-status-dot::before {
  transform: translate(-50%, -50%) scale(1);
}

/* ═══════════════════════════════════════════════════
   BRICK CONTEXT MENU
   ═══════════════════════════════════════════════════ */
.brick-ctx-menu {
  position: fixed;
  z-index: 9000;
  min-width: 210px;
  background: #1c2333;
  border: 1px solid #30363d;
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
  display: none;
  flex-direction: column;
  gap: 2px;
}

.brick-ctx-menu.open {
  display: flex;
}

.brick-ctx-header {
  padding: 6px 10px 8px;
  font-size: 12px;
  font-weight: 700;
  color: #8b949e;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 198px;
}

.brick-ctx-divider {
  height: 1px;
  background: #30363d;
  margin: 4px 0;
}

.brick-ctx-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  border: none;
  background: none;
  color: #c9d1d9;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background .12s, color .12s;
}

.brick-ctx-item:hover {
  background: rgba(88,166,255,.1);
  color: #58a6ff;
}

.brick-ctx-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: .75;
}

.brick-ctx-item:hover svg {
  opacity: 1;
}

.brick-ctx-item.disabled {
  opacity: .35;
  cursor: default;
  pointer-events: none;
}

.brick-ctx-item-danger {
  color: #f85149;
}

.brick-ctx-item-danger:hover {
  background: rgba(248,81,73,.12);
  color: #ff7b72;
}
