/* ==========================================================================
   Planara — work packages module (list, cards, detail page, forms)
   Uses only the theme variables from app.css so dark mode works.
   ========================================================================== */

/* ---------- Sidebar views navigation ---------- */
.sidebar-subnav .wp-nav-title { font-size: .7rem; text-transform: uppercase; letter-spacing: .6px; color: var(--text-faint); font-weight: 600; padding: 10px 8px 3px; }
.sidebar-subnav .wp-nav-title:first-child { padding-top: 4px; }
.sidebar-subnav .wp-view-link { gap: 7px; min-width: 0; }
.sidebar-subnav .wp-view-link .icon { width: 14px; height: 14px; opacity: .7; }
.sidebar-subnav .wp-view-link.active { background: var(--sidebar-active-bg); color: var(--sidebar-active-text); font-weight: 600; }
.wp-star-icon { color: var(--warning); fill: currentColor; }

/* ---------- List header & toolbar ---------- */
.wp-list-header { margin-bottom: 6px; }
.wp-list-title h1 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.wp-list-title h1 .badge { font-weight: 500; }
.wp-list-title h1 .badge .icon { width: 12px; height: 12px; }
.wp-star-btn .icon { color: var(--text-faint); }
.wp-star-btn.starred .icon { color: var(--warning); fill: currentColor; }
.wp-create .wp-create-toggle { width: 30px; border-left: 1px solid color-mix(in srgb, var(--primary-text) 30%, transparent); }
.wp-create.dropdown { display: inline-flex; }
.wp-toolbar { gap: 8px; padding-top: 6px; }
.wp-toolbar .counter { background: var(--primary); color: var(--primary-text); min-width: 18px; height: 18px; }
.wp-filter-toggle.has-filters { border-color: var(--primary); color: var(--primary); }
.wp-filter-toggle.active { background: var(--bg-active); }
.wp-quick-search { position: relative; width: 240px; max-width: 100%; }
.wp-quick-search .icon { position: absolute; left: 9px; top: 6px; color: var(--text-faint); pointer-events: none; }
.wp-quick-search input { padding-left: 30px; }
.wp-filter-chips { min-width: 0; }
.wp-filter-chips .chip { max-width: 320px; }
.wp-filter-chips .chip strong { font-weight: 600; }
.wp-more-menu .menu-btn, .wp-more-menu form button { display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 10px; border: 0; background: none; border-radius: var(--radius-sm); color: var(--text); font: inherit; cursor: pointer; text-align: left; }
.wp-more-menu .menu-btn:hover, .wp-more-menu form button:hover { background: var(--bg-hover); }
.wp-more-menu .menu-btn.danger { color: var(--danger); }
.wp-more-menu .inline-form { display: block; }

/* ---------- Bulk bar ---------- */
.wp-bulk-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 12px; margin-bottom: 10px;
  border: 1px solid color-mix(in srgb, var(--primary) 35%, var(--border)); background: var(--primary-soft); border-radius: var(--radius-lg);
  position: sticky; top: calc(var(--header-h) + 6px); z-index: 5; box-shadow: var(--shadow-sm);
}
.wp-bulk-bar .spacer { flex: 1; }
.wp-bulk-bar .btn { background: var(--surface); }

/* ---------- Table ---------- */
.wp-table-wrap { overflow: auto; max-height: calc(100vh - var(--header-h) - 40px); }
.wp-table { font-size: .94rem; }
.wp-table th { z-index: 2; }
.wp-table th[draggable="true"] { cursor: grab; }
.wp-table th.dragging { opacity: .45; }
.wp-table th.drop-target { box-shadow: inset 3px 0 0 var(--primary); }
.wp-table th sup { font-size: .65em; margin-left: 1px; }
.wp-table td { white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.wp-table td.wp-cell-subject { white-space: normal; max-width: none; min-width: 260px; width: 40%; }
.wp-table td.wp-check, .wp-table th.wp-check { width: 34px; padding-right: 0; }
.wp-table tr.wp-row { cursor: pointer; }
.wp-table tr.wp-row:focus { outline: none; background: var(--bg-active); box-shadow: inset 3px 0 0 var(--primary); }
.wp-table tr.wp-row.wp-ctx-active { background: var(--bg-active); }
.wp-table tr.wp-closed .wp-subject-link { color: var(--text-muted); }
.wp-table tr.wp-saving { opacity: .55; pointer-events: none; }
.wp-table tr.wp-row .wp-row-actions .btn { opacity: 0; }
.wp-table tr.wp-row:hover .wp-row-actions .btn, .wp-table tr.wp-row:focus .wp-row-actions .btn, .wp-table tr.wp-row.wp-ctx-active .wp-row-actions .btn { opacity: 1; }
.wp-subject-cell { display: flex; align-items: center; gap: 4px; padding-left: calc(var(--depth, 0) * 20px); min-width: 0; }
.wp-subject-cell .wp-subject-link { color: var(--text); font-weight: 500; overflow-wrap: anywhere; }
.wp-subject-cell .wp-subject-link:hover { color: var(--link); }
.wp-tree-toggle .icon { width: 14px; height: 14px; transition: transform .12s; }
.wp-tree-toggle.collapsed .icon, [data-group-toggle].collapsed .icon { transform: rotate(-90deg); }
.wp-tree-spacer { display: inline-block; width: 18px; flex-shrink: 0; }
.wp-milestone-icon .icon { width: 12px; height: 12px; color: var(--warning); fill: currentColor; }
.wp-has-children .icon { width: 13px; height: 13px; color: var(--text-faint); }
.wp-table td.wp-editable { position: relative; }
.wp-table td.wp-editable:hover { box-shadow: inset 0 0 0 1px var(--border-strong); background: var(--surface); cursor: text; border-radius: 3px; }
.wp-table td.wp-cell-subject.wp-editable:hover { box-shadow: none; background: transparent; }
.wp-empty-cell { color: var(--text-faint); }
.wp-group-row td { padding-top: 7px; padding-bottom: 7px; }
.wp-group-row .wp-group-label { margin-left: 4px; }
.wp-group-sums { margin-left: 14px; display: inline-flex; gap: 14px; font-weight: 400; }
.wp-sum-row td { border-top: 2px solid var(--border-strong); }
.wp-table tfoot td { position: sticky; bottom: 0; }

/* ---------- Popovers (context menu, cell editors) ---------- */
.wp-pop { position: fixed; z-index: 450; min-width: 220px; max-height: calc(100vh - 16px); overflow-y: auto; }
.wp-pop.wp-cell-pop { min-width: 200px; }
.wp-pop.wp-cell-pop-wide { min-width: 360px; }
.wp-pop .wp-picker-list { max-height: 300px; overflow-y: auto; }
.wp-pop .wp-picker-list button.active { background: var(--bg-active); }
.wp-pop .wp-picker-list .avatar { margin-right: 2px; }
.wp-cell-editor { padding: 4px; }
.wp-cell-editor .row { gap: 4px; }
.wp-context-menu .wp-submenu-trigger .icon:last-child { margin-left: auto; transition: transform .12s; }
.wp-context-menu .wp-submenu-trigger.open .icon:last-child { transform: rotate(90deg); }
.wp-context-menu .wp-submenu { margin: 2px 0 4px 18px; padding-left: 6px; border-left: 1px solid var(--border); max-height: 240px; overflow-y: auto; }
.wp-context-menu .wp-submenu button.active { background: var(--bg-active); }

/* ---------- Cards ---------- */
.wp-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.wp-card {
  display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); cursor: pointer; transition: box-shadow .12s, border-color .12s; min-width: 0;
}
.wp-card:hover { box-shadow: var(--shadow); border-color: var(--border-strong); }
.wp-card:focus { outline: 2px solid color-mix(in srgb, var(--primary) 55%, transparent); }
.wp-card.selected { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 5%, var(--surface)); }
.wp-card.wp-closed .wp-card-subject { color: var(--text-muted); }
.wp-card-top { display: flex; align-items: center; gap: 8px; }
.wp-card-top .spacer { flex: 1; }
.wp-card-check input { width: 15px; height: 15px; accent-color: var(--primary); margin: 0; }
.wp-card-id { color: var(--text-muted); font-size: .88rem; }
.wp-card-subject { font-weight: 600; color: var(--text); line-height: 1.35; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.wp-card-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: .9rem; }
.wp-card-bottom { display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 6px; border-top: 1px dashed var(--border); }
.wp-card-dates { display: inline-flex; align-items: center; gap: 4px; flex: 1; min-width: 0; white-space: nowrap; }
.wp-card-dates .nowrap { white-space: nowrap; }
.wp-card-dates .icon { width: 13px; height: 13px; }
.wp-card-progress { display: flex; align-items: center; gap: 6px; }
.wp-card-progress .progress { flex: 1; width: auto; height: 5px; }
.wp-card-project .icon { width: 13px; height: 13px; }

/* ---------- Configure modal ---------- */
.wp-col-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 46vh; overflow-y: auto; }
.wp-col-item { display: flex; align-items: center; gap: 6px; padding: 5px 8px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); cursor: grab; }
.wp-col-item.dragging { opacity: .5; border-style: dashed; }
.wp-col-item .wp-drag-handle { color: var(--text-faint); display: inline-flex; }
.wp-sort-row { margin-bottom: 8px; flex-wrap: wrap; }
.wp-sort-n { width: 18px; color: var(--text-muted); }
.wp-sort-row select { min-width: 200px; }

/* ---------- Detail page ---------- */
.wp-show-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.wp-show-heading { flex: 1 1 420px; min-width: 0; }
.wp-show-typeline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 2px; }
.wp-show-id { color: var(--text-muted); font-weight: 600; }
.wp-subject { font-size: 1.55rem; margin: 2px 0 6px; overflow-wrap: anywhere; }
.wp-subject .wp-subject-edit { font-size: 1.35rem; font-weight: 600; }
.wp-show-meta { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.wp-show-meta .icon { width: 13px; height: 13px; }
.wp-show-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.wp-status-btn { border-color: color-mix(in srgb, var(--c) 60%, var(--border)); background: color-mix(in srgb, var(--c) 14%, var(--surface)); font-weight: 600; }
.wp-status-btn:hover { background: color-mix(in srgb, var(--c) 22%, var(--surface)); }
.wp-status-btn:disabled { opacity: 1; cursor: default; }
.wp-status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.wp-status-dropdown .dropdown-menu form button { justify-content: space-between; }
.btn.wp-watching { background: var(--bg-active); border-color: var(--primary); color: var(--primary); }

.wp-show-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 44%); gap: 28px; align-items: start; }
.wp-show-main { min-width: 0; }
.wp-show-side { min-width: 0; position: sticky; top: calc(var(--header-h) + 12px); max-height: calc(100vh - var(--header-h) - 24px); overflow-y: auto; padding-right: 2px; }
.wp-section { margin-bottom: 22px; }
.wp-section-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin: 0 0 8px; font-weight: 700; }
.wp-description { min-height: 40px; }
.wp-description .wp-inline-display { padding: 8px 10px; margin: -8px -10px; border-radius: var(--radius); }
.wp-attr-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 28px; }
.wp-attr-group-box { min-width: 0; }
.wp-attr { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 10px; align-items: start; padding: 4px 0; min-height: 32px; }
.wp-attr.wp-attr-wide { grid-template-columns: 1fr; gap: 2px; }
.wp-attr-label { color: var(--text-muted); font-size: .92rem; padding-top: 5px; }
.wp-attr-value { min-width: 0; padding: 4px 8px; margin: 0 -8px; border-radius: var(--radius-sm); overflow-wrap: anywhere; }
.wp-attr-value .user-link { vertical-align: middle; }
.wp-attr-empty { color: var(--text-faint); }
.wp-attr-hint { font-size: .82rem; color: var(--text-muted); margin-top: 2px; }
.wp-derived { color: var(--text-muted); font-size: .88rem; }
.wp-derived-progress { margin-top: 3px; }
.wp-inline { cursor: pointer; transition: background .1s, box-shadow .1s; }
.wp-inline:not(.editing):hover, .wp-inline:not(.editing):focus-visible { background: var(--bg-hover); box-shadow: inset 0 0 0 1px var(--border); outline: none; }
.wp-subject.wp-inline { border-radius: var(--radius); padding: 0 6px; margin-left: -6px; }
.wp-inline.editing { cursor: default; background: transparent; }
.wp-inline-form { min-width: 0; }
.wp-inline-form.wp-saving { opacity: .6; pointer-events: none; }
.wp-inline-form .input-sm { min-height: 30px; }
.wp-inline-form .checkbox { margin: 0; }
.wp-inline-form select[multiple] { min-height: 90px; }
.wp-ac-field { position: relative; }
.wp-ac-field .input { padding-right: 30px; }
.wp-ac-field .wp-ac-clear { position: absolute; right: 3px; top: 50%; transform: translateY(-50%); }

.wp-tabs { margin-bottom: 14px; position: sticky; top: 0; background: var(--bg); z-index: 3; }
.wp-tabs a { padding: 9px 10px; gap: 5px; font-size: .94rem; }
.wp-tabs a .icon { width: 15px; height: 15px; }
.wp-tab-panel { min-width: 0; }
.wp-subtitle { font-size: .95rem; display: flex; align-items: center; gap: 6px; margin: 0 0 10px; }
.wp-activity-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.wp-activity-toolbar .spacer { flex: 1; }
.wp-journal { scroll-margin-top: calc(var(--header-h) + 60px); }
.wp-journal.no-notes { padding: 8px 0; }
.wp-journal.no-notes .journal-header { margin-bottom: 0; }
.wp-journal.no-notes .journal-details { font-size: .9rem; }
.wp-journal.wp-highlight .journal-main { animation: wp-flash 2.4s ease; border-radius: var(--radius); }
@keyframes wp-flash { 0%, 40% { background: var(--primary-soft); box-shadow: 0 0 0 6px var(--primary-soft); } 100% { background: transparent; box-shadow: none; } }
.wp-journals.only-comments .wp-journal.no-notes { display: none; }
.wp-journals.only-comments .wp-journal .journal-details { display: none; }
.journal-header .journal-actions .btn { font-size: .8rem; }
.wp-comment-form { margin: 12px 0; }
.wp-comment-box { display: flex; gap: 10px; align-items: flex-start; }
.wp-comment-actions { gap: 8px; }
.wp-comment-actions .spacer { flex: 1; }
.wp-comment-actions kbd { font-size: .75rem; }
.wp-internal-toggle .icon { width: 13px; height: 13px; color: var(--warning); }
.wp-journal-edit { margin-top: 6px; }
.mt-sm { margin-top: 8px; }
.row .spacer { flex: 1; }

.wp-rel-section { margin-bottom: 22px; }
.wp-rel-group { margin-bottom: 12px; }
.wp-rel-group-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .4px; color: var(--text-muted); font-weight: 700; margin: 10px 0 4px; display: flex; align-items: center; gap: 6px; }
.wp-rel-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin-bottom: 4px; min-width: 0; }
.wp-rel-item .grow { min-width: 0; }
.wp-rel-item.wp-closed a { color: var(--text-muted); text-decoration: line-through; }
.wp-rel-item .inline-form { display: inline-flex; }
.wp-rel-kind { font-size: .78rem; color: var(--text-muted); text-transform: uppercase; font-weight: 600; }
.wp-rel-progress .progress { width: 50px; }
.wp-rel-progress .progress-label { font-size: .78rem; }
.wp-rel-desc { margin: -2px 0 6px 10px; }
.wp-rel-edit { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 6px 8px 10px; }
.wp-add-relation { margin-top: 10px; }
.wp-add-relation summary { list-style: none; display: inline-flex; }
.wp-add-relation summary::-webkit-details-marker { display: none; }
.wp-add-relation[open] summary { margin-bottom: 10px; }
.wp-relation-form { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 14px 4px; background: var(--bg-subtle); }
.wp-relation-form .form-row { grid-template-columns: 120px minmax(0, 1fr); margin-bottom: 10px; }
.wp-relation-form .form-label { padding-top: 4px; }
.wp-inline-add { display: flex; gap: 6px; align-items: center; flex: 1 1 260px; min-width: 0; }
.wp-inline-add .input { flex: 1; min-width: 0; }
.wp-child-actions { gap: 8px; }
.wp-watchers li { gap: 8px; padding: 6px 0; }
.wp-time-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.wp-time-summary .stat { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); padding: 12px; }
.wp-time-summary .stat-value { font-size: 1.35rem; }
.wp-meeting-item { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 6px; background: var(--surface); }
.wp-meeting-notes, .wp-meeting-outcome { margin-top: 6px; color: var(--text-muted); }

/* ---------- Forms ---------- */
.wp-form-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 28px; align-items: start; }
.wp-form-grid.wp-saving { opacity: .6; pointer-events: none; }
.wp-form-main { min-width: 0; }
.wp-form-typeline { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
select.input.wp-type-select { width: auto; min-width: 160px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; font-size: .88rem; color: color-mix(in srgb, var(--c) 85%, var(--text)); border-color: color-mix(in srgb, var(--c) 45%, var(--border-strong)); }
.wp-form-id { color: var(--text-muted); font-weight: 600; }
.wp-subject-input { font-size: 1.3rem; font-weight: 600; min-height: 44px; }
.form-stacked-row { display: block; margin-bottom: 18px; }
.wp-form-section { margin-bottom: 20px; }
.wp-form-section h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin-bottom: 8px; }
.wp-form-side { min-width: 0; }
.wp-attr-group { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px 14px 2px; margin: 0 0 14px; background: var(--surface); min-width: 0; }
.wp-attr-group legend { font-size: .8rem; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); font-weight: 700; padding: 0 4px; }
.wp-attr-group .form-row { grid-template-columns: 120px minmax(0, 1fr); gap: 4px 12px; margin-bottom: 10px; }
.wp-attr-group .form-label { font-size: .92rem; padding-top: 6px; }
.wp-attr-group .checkbox { margin-right: 10px; }
.wp-unit-input .input { border-radius: var(--radius) 0 0 var(--radius); }
.wp-unit { display: inline-flex; align-items: center; padding: 0 10px; border: 1px solid var(--border-strong); border-left: 0; border-radius: 0 var(--radius) var(--radius) 0; background: var(--bg-subtle); color: var(--text-muted); font-size: .9rem; }
.wp-form-actions { position: sticky; bottom: 0; background: var(--bg); border-top: 1px solid var(--border); padding: 12px 0; z-index: 4; }
.wp-watcher-choices .avatar { margin: 0 2px; }
.wp-form-notes { max-width: calc(100% - 408px); }
.wp-project-picker { max-width: 760px; }
.wp-project-tiles { display: flex; flex-direction: column; gap: 2px; }
.wp-project-tile { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px calc(8px + var(--depth, 0) * 20px); border-radius: var(--radius); color: var(--text); }
.wp-project-tile:hover { background: var(--bg-hover); text-decoration: none; }
.wp-delete-list li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.wp-reassign { max-width: 420px; margin-left: 24px; }
.wp-bulk-list li { padding: 6px 0; }
.wp-bulk-list { max-height: 60vh; overflow-y: auto; padding-top: 6px; padding-bottom: 6px; }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .wp-attr-groups { grid-template-columns: 1fr; }
}
@media (max-width: 1100px) {
  .wp-show-body { grid-template-columns: 1fr; }
  .wp-show-side { position: static; max-height: none; overflow: visible; }
  .wp-form-grid { grid-template-columns: 1fr; }
  .wp-form-notes { max-width: none; }
}
@media (max-width: 700px) {
  .wp-hide-sm { display: none; }
  .wp-quick-search { width: 100%; order: 5; }
  .wp-toolbar .spacer { display: none; }
  .wp-attr { grid-template-columns: 110px minmax(0, 1fr); }
  .wp-subject { font-size: 1.3rem; }
  .wp-time-summary { grid-template-columns: 1fr; }
  .wp-relation-form .form-row, .wp-attr-group .form-row { grid-template-columns: 1fr; }
  .wp-table td.wp-cell-subject { min-width: 200px; }
  .wp-tabs a { padding: 8px 8px; }
  .wp-show-actions { width: 100%; gap: 6px; }
  .wp-show-actions .btn:not(.btn-icon) { padding: 0 9px; gap: 4px; }
}

/* ---------- Print ---------- */
@media print {
  .wp-toolbar, .wp-bulk-bar, .wp-filters, .wp-row-actions, .wp-check, .wp-show-actions, .wp-tabs, .wp-comment-form, .journal-actions, .reactions,
  .wp-add-relation, .wp-child-actions, .wp-inline-add, .pagination, .wp-activity-toolbar, .breadcrumbs, .page-actions, #wp-filters { display: none !important; }
  .wp-show-body { grid-template-columns: 1fr; }
  .wp-show-side { position: static; max-height: none; overflow: visible; }
  .wp-tab-panel[hidden] { display: none !important; }
  .wp-tab-panel[data-wp-panel="activity"], .wp-tab-panel[data-wp-panel="relations"] { display: block !important; }
  .wp-table-wrap { max-height: none; overflow: visible; border: 0; }
  .wp-table td { white-space: normal; }
  .wp-table th { position: static; }
  .wp-inline:hover { background: none !important; box-shadow: none !important; }
}
