/* Obsidian Portal — Sorter: live two-pane workspace */

.app-shell:has(#view-sorter.active) {
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

.app-content:has(#view-sorter.active) {
  padding: 0;
  overflow: hidden;
}

.sorter-view {
  padding: 0;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.sort-head {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 12px;
  padding: 10px 18px 9px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.sort-head .page-header-main {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1 1 auto;
}

.sort-head .page-title {
  flex: 0 0 auto;
  padding-right: 12px;
  border-right: 1px solid var(--border);
  line-height: 1;
  margin: 0;
}

.sort-head .page-header-desc {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
}

.sort-head-aside {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.sort-head-stats {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: nowrap;
}

.sort-head-stats .count-pill {
  font-size: 10px;
  padding: 2px 7px;
  white-space: nowrap;
}

.sort-live-dot {
  width: 7px;
  height: 7px;
  background: var(--dim);
  flex-shrink: 0;
}
.sort-live-dot.on {
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34,197,94,.18);
  animation: sort-pulse 1.2s ease-in-out infinite;
}
@keyframes sort-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}

.sort-board {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sort-composer {
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--bg);
}

.sort-composer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.sort-composer-top .panel-card-title {
  margin: 0;
  font-size: 10px;
  letter-spacing: .08em;
}
.sort-input-ta {
  flex: 1 1 auto;
  min-height: 120px;
  width: 100%;
  box-sizing: border-box;
  resize: none;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  line-height: 1.55;
  padding: 10px 12px;
}
.sort-input-ta:focus {
  outline: none;
  box-shadow: none;
}

.sort-composer-tools {
  flex: 0 0 auto;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.sort-filters {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px 12px;
}
.sort-filter-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  cursor: pointer;
  color: var(--text);
  font-weight: 600;
}

.sort-excl {
  border-top: 1px solid var(--border);
  padding: 0;
}
.sort-excl > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #ef4444;
  user-select: none;
}
.sort-excl > summary::-webkit-details-marker { display: none; }
.sort-excl > summary::after {
  content: '▸';
  margin-left: auto;
  color: var(--dim);
  font-size: 10px;
}
.sort-excl[open] > summary::after { content: '▾'; }
.sort-excl-body { padding: 0 12px 10px; }
.sort-excl-ta {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  min-height: 72px;
  font-size: 10px;
  font-family: 'IBM Plex Mono', monospace;
  line-height: 1.6;
}

.sort-actions {
  border-top: 1px solid var(--border);
  padding: 8px 12px 10px;
  display: flex;
  gap: 6px;
}
.sort-actions #sort-run-btn {
  flex: 1;
  justify-content: center;
}
.sort-actions #sort-clear-btn {
  flex: 0 0 auto;
}

.sort-stage {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.sort-progress {
  flex: 0 0 auto;
  padding: 8px 14px 0;
}
.sort-progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 4px;
}
.sort-progress-track {
  height: 2px;
  background: var(--border);
}
.sort-progress-bar {
  height: 100%;
  width: 0;
  background: var(--blue);
  transition: width .2s linear;
}

.sort-removed-panel {
  flex: 0 0 auto;
  margin: 8px 14px 0;
  border: 1px solid rgba(245,158,11,.35);
  border-left: 3px solid #f59e0b;
  background: var(--surface);
}
.sort-removed-body { padding: 0 12px 10px; }

.sort-cat-grid {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 8px 14px 0;
  min-height: 0;
}
.sort-cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 4px 8px 4px 6px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  line-height: 1;
}
.sort-cat-chip:hover { border-color: var(--border2); }
.sort-cat-chip.is-on {
  border-color: currentColor;
  background: var(--surface2);
}
.sort-cat-chip-count {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  font-weight: 800;
}
.sort-cat-chip-actions {
  display: none;
  gap: 2px;
  margin-left: 2px;
}
.sort-cat-chip:hover .sort-cat-chip-actions,
.sort-cat-chip.is-on .sort-cat-chip-actions {
  display: inline-flex;
}
.sort-cat-chip-actions button {
  background: none;
  border: 0;
  color: var(--dim);
  cursor: pointer;
  font-size: 10px;
  padding: 0 3px;
}
.sort-cat-chip-actions button:hover { color: var(--text); }

.sort-list-card {
  flex: 1;
  min-height: 0;
  margin: 8px 14px 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
}
.sort-list-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.sort-list-head .panel-card-title { margin: 0; }
.sort-list-tools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sort-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--dim);
  text-align: center;
  padding: 24px;
}
.sort-empty-kicker {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}
.sort-empty-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}
.sort-empty-hint { font-size: 12px; color: var(--dim); }
.sort-empty-sample {
  margin-top: 10px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 4px;
  opacity: .7;
}
.sort-empty-sample .sort-dash { color: var(--dim); padding: 0 8px; }

.sort-table-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
}
#sort-email-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
#sort-email-table thead th {
  position: sticky;
  top: 0;
  background: var(--surface);
  padding: 6px 12px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  z-index: 1;
}
.sort-live-tr td {
  padding: 4px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.sort-live-tr:hover td { background: var(--surface2); }
.sort-live-email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  width: 52%;
}
.sort-live-prov {
  width: 42%;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sort-dash {
  color: var(--dim);
  font-weight: 400;
  padding-right: 8px;
  font-family: 'IBM Plex Mono', monospace;
}
.sort-live-copy {
  width: 36px;
  text-align: center;
  padding-left: 0;
  padding-right: 8px;
}
.sort-live-copy button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--dim);
  font-size: 12px;
  padding: 0;
}
.sort-live-copy button:hover { color: var(--text); }

.sort-priority-high   { box-shadow: inset 3px 0 0 #22c55e; }
.sort-priority-medium { box-shadow: inset 3px 0 0 #f59e0b; }
.sort-priority-low    { box-shadow: inset 3px 0 0 var(--border2); }
.sort-priority-unknown{ box-shadow: inset 3px 0 0 var(--border); }

.sort-table-footer {
  padding: 6px 12px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--dim);
  flex: 0 0 auto;
}

@media (max-width: 900px) {
  .sort-board { grid-template-columns: 1fr; }
  .sort-composer {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    max-height: 42vh;
  }
  .sort-head { flex-wrap: wrap; }
  .sort-head .page-header-desc { display: none; }
}
