/**
 * registry-compact.css — Redesigned Registry Sidebar Panel
 * Uses design tokens from tokens.css.
 * Compact list layout: header · stats row · search · card list.
 */

/* ════════════════════════════════════════
   PANEL HEADER
   ════════════════════════════════════════ */
.rp-header {
  height: 52px;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-3);
  border-bottom: 1px solid var(--color-outline-subtle);
  background: var(--color-surface);
  flex-shrink: 0;
}

.rp-header-icon {
  font-size: 18px !important;
  color: var(--color-primary);
  flex-shrink: 0;
}

.rp-header-title {
  flex: 1;
  font-size: var(--text-md);
  font-weight: var(--font-semibold);
  color: var(--color-text);
  font-family: var(--font-family);
}

.rp-header-actions {
  display: flex;
  gap: 4px;
}

.rp-btn-icon {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--color-text-muted);
  transition: background var(--transition-fast), color var(--transition-fast);
  padding: 0;
  flex-shrink: 0;
}
.rp-btn-icon:hover {
  background: var(--color-surface-container);
  color: var(--color-text);
}
.rp-btn-icon .material-icons-round { font-size: 18px; }

/* ════════════════════════════════════════
   STATS ROW (inline, always visible)
   ════════════════════════════════════════ */
.rp-stats-row {
  padding: 5px var(--space-3);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  background: var(--color-surface-container);
  border-bottom: 1px solid var(--color-outline-subtle);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-family: var(--font-family);
  white-space: nowrap;
  overflow: hidden;
}
.rp-stats-row strong {
  color: var(--color-text-secondary);
  font-weight: var(--font-semibold);
  font-variant-numeric: tabular-nums;
}
.rp-sep { opacity: 0.35; }

/* ════════════════════════════════════════
   SEARCH BAR
   ════════════════════════════════════════ */
.rp-search-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-outline-subtle);
  flex-shrink: 0;
  background: var(--color-surface);
}

.rp-search-icon {
  font-size: 16px !important;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.rp-search-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: var(--text-sm);
  color: var(--color-text);
  background: transparent;
  font-family: var(--font-family);
  min-width: 0;
}
.rp-search-input::placeholder { color: var(--color-text-muted); }

/* ════════════════════════════════════════
   CARD LIST CONTAINER
   ════════════════════════════════════════ */
.registry-content {
  display: flex !important;
  flex-direction: column !important;
  gap: var(--space-2) !important;
  padding: var(--space-2) !important;
}

/* ════════════════════════════════════════
   COMPACT CARD
   ════════════════════════════════════════ */
.rp-card {
  display: flex;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-outline-subtle);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow var(--transition-fast), transform var(--transition-fast);
  background: var(--color-surface);
}
.rp-card:hover {
  box-shadow: var(--shadow-2);
  transform: translateY(-1px);
}
.rp-card:active { transform: scale(0.99); }

/* Виділення при кліку на ділянку з карти */
.rp-card.rp-selected {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--color-primary) 20%, transparent);
  transform: translateY(-1px);
}
.rp-row.rp-selected {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
  background: var(--color-primary-50) !important;
}

/* Left color accent */
.rp-card-accent {
  width: 4px;
  background: var(--tc, var(--color-primary));
  flex-shrink: 0;
}

.rp-card-body {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  min-width: 0;
}

/* Top: cadnum + status badge */
.rp-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.rp-cadnum {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  font-family: var(--font-family);
}

/* Status badge */
.rp-badge {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  padding: 2px 6px;
  border-radius: var(--radius-full);
  white-space: nowrap;
  flex-shrink: 0;
  font-family: var(--font-family);
}
.rp-badge-success { background: var(--color-primary-50);         color: var(--color-primary); }
.rp-badge-warning { background: var(--color-secondary-50);       color: var(--color-secondary); }
.rp-badge-danger  { background: var(--color-error-50);           color: var(--color-error); }
.rp-badge-neutral { background: var(--color-surface-container);  color: var(--color-text-muted); }

/* Meta: два окремі рядки — власник / орендар */
.rp-card-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 3px;
  min-width: 0;
}
.rp-meta-row {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.rp-owner {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
  font-family: var(--font-family);
}

.rp-sep-dot {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  opacity: 0.4;
  flex-shrink: 0;
}

.rp-tenant-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.rp-tenant {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
  font-family: var(--font-family);
}

/* Bar: progress + area + expiry */
.rp-card-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: 6px;
}

.rp-progress {
  flex: 1;
  height: 4px;
  background: var(--color-outline-subtle);
  border-radius: var(--radius-full);
  overflow: hidden;
  min-width: 28px;
}

.rp-progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

.rp-progress-success  { background: var(--color-primary-400); }
.rp-progress-caution  { background: var(--color-secondary-500); }
.rp-progress-warning  { background: var(--color-secondary); }
.rp-progress-critical { background: var(--color-error-500); }
.rp-progress-expired  { background: var(--color-text-disabled); }
.rp-progress-none     { background: var(--color-outline); width: 0 !important; }

.rp-area {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
  font-family: var(--font-family);
}

.rp-expiry {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
  flex-shrink: 0;
  font-family: var(--font-family);
}

/* Actions: DZK + Notes buttons */
.rp-card-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--color-outline-subtle);
}

.rp-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px var(--space-2);
  border-radius: var(--radius-xs);
  border: 1px solid var(--color-outline-subtle);
  background: var(--color-surface-container);
  color: var(--color-text-secondary);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition-fast), border-color var(--transition-fast);
  font-family: var(--font-family);
  line-height: 1;
}
.rp-action-btn .material-icons-round { font-size: 13px; }
.rp-action-btn:hover {
  background: var(--color-surface-variant);
  border-color: var(--color-outline);
  color: var(--color-text);
  text-decoration: none;
}

/* Кнопка нотаток — є нотатки */
.rp-has-notes {
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.rp-has-notes:hover {
  background: var(--color-primary-50, #f0faf3);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* ════════════════════════════════════════
   CARD VISUAL VARIANTS
   ════════════════════════════════════════ */

/* Free parcel (no tenant) — green tint + dashed accent */
.rp-card--free {
  background: var(--color-primary-50);
  border-color: var(--color-primary-200);
}
.rp-card--free .rp-card-accent {
  background: repeating-linear-gradient(
    to bottom,
    var(--color-primary-400) 0px, var(--color-primary-400) 5px,
    var(--color-primary-100) 5px, var(--color-primary-100) 9px
  );
}
.rp-card--free .rp-cadnum { color: var(--color-primary); }

/* Expired lease — red tint */
.rp-card--expired {
  background: var(--color-error-50);
  border-color: var(--color-error-100);
}
.rp-card--expired .rp-card-accent { background: var(--color-error-500); }

/* Expiring soon (≤ 365 days) — amber tint */
.rp-card--soon {
  background: var(--color-secondary-50);
  border-color: var(--color-secondary-100);
}
.rp-card--soon .rp-card-accent { background: var(--color-secondary-500); }

/* Featured area pill for free parcels (replaces progress bar row) */
.rp-free-area {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  padding: 3px 10px;
  background: var(--color-primary-100);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--color-primary);
  font-family: var(--font-family);
}
.rp-free-area .material-icons-round { font-size: 13px; }

/* ════════════════════════════════════════
   EMPTY STATE
   ════════════════════════════════════════ */
.rp-empty {
  padding: var(--space-8) var(--space-4);
  text-align: center;
  color: var(--color-text-muted);
  font-family: var(--font-family);
}
.rp-empty .material-icons-round {
  font-size: 40px;
  display: block;
  margin: 0 auto var(--space-3);
  opacity: 0.35;
}
.rp-empty-title {
  font-size: var(--text-md);
  font-weight: var(--font-semibold);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-1);
}
.rp-empty-sub {
  font-size: var(--text-sm);
}

/* ════════════════════════════════════════
   EXPANDED PANEL (50vw — table mode)
   ════════════════════════════════════════ */
.registry-panel.expanded {
  width: 50vw !important;
  min-width: 480px;
  max-width: 50vw !important;
}

/* View toggle button active state */
#registry-expand-btn.active {
  background: var(--color-primary-50) !important;
  color: var(--color-primary) !important;
}

/* ════════════════════════════════════════
   TABLE VIEW
   ════════════════════════════════════════ */

/* Remove padding/gap when in table mode */
.registry-content.rp-view-table {
  padding: 0 !important;
  gap: 0 !important;
}

.rp-table-wrap {
  flex: 1;
  overflow: auto;
  min-height: 0;
}

.rp-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-family);
  font-size: var(--text-sm);
}

.rp-table thead th {
  position: sticky;
  top: 0;
  background: var(--color-surface-container);
  border-bottom: 2px solid var(--color-outline-subtle);
  padding: 7px 10px;
  text-align: left;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  z-index: 3;
  user-select: none;
}

.rp-row {
  border-bottom: 1px solid var(--color-outline-subtle);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.rp-row:last-child { border-bottom: none; }

/* Забарвлення рядків таблиці — як у карток */
.rp-row[data-status="free"]     { background: var(--color-primary-50); }
.rp-row[data-status="expired"]  { background: var(--color-error-50); }
.rp-row[data-status="critical"] { background: var(--color-secondary-50); }
.rp-row[data-status="warning"]  { background: color-mix(in srgb, var(--color-secondary-50) 50%, transparent); }

/* Hover трохи темніший за базовий фон рядка */
.rp-row:hover                          { background: var(--color-surface-container); }
.rp-row[data-status="free"]:hover     { background: var(--color-primary-100); }
.rp-row[data-status="expired"]:hover  { background: var(--color-error-100); }
.rp-row[data-status="critical"]:hover { background: var(--color-secondary-100); }
.rp-row[data-status="warning"]:hover  { background: var(--color-secondary-50); }

/* Sortable header */
.rp-th-sort {
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
.rp-th-sort:hover { color: var(--color-text); }
.rp-th-sorted { color: var(--color-primary) !important; }

.rp-sort-icon {
  font-size: 13px !important;
  vertical-align: middle;
  opacity: 0.45;
  margin-left: 2px;
}
.rp-th-sort:hover .rp-sort-icon,
.rp-th-sorted .rp-sort-icon { opacity: 1; }

/* Колонка дати реєстрації */
.rp-cell-regdate {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
  width: 90px;
}

/* Дата реєстрації на картці */
.rp-regdate {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.rp-table td {
  padding: 7px 10px;
  vertical-align: middle;
}

/* Left accent column */
.rp-cell-accent {
  width: 3px;
  padding: 0 !important;
}

.rp-cell-cadnum {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--color-text);
  white-space: nowrap;
  width: 145px;
}

.rp-cell-owner {
  color: var(--color-text-secondary);
  font-size: var(--text-xs);
  min-width: 100px;
  white-space: normal;
  word-break: break-word;
  line-height: 1.3;
}

.rp-cell-tenant {
  min-width: 100px;
  white-space: normal;
}

.rp-cell-tenant-inner {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
}
.rp-cell-tenant-inner span:last-child {
  word-break: break-word;
  line-height: 1.3;
}

.rp-cell-area {
  white-space: nowrap;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--color-text);
  text-align: right;
  width: 60px;
}

.rp-cell-expiry {
  width: 110px;
  vertical-align: middle;
}

.rp-expiry-date {
  display: block;
  font-size: 10px;
  color: var(--color-text-muted);
  margin-top: 2px;
  white-space: nowrap;
}

.rp-cell-actions {
  white-space: nowrap;
  width: 1px; /* shrink to content */
}

.rp-cell-actions .rp-action-btn {
  padding: 0;
  width: 26px;
  height: 26px;
  justify-content: center;
}
.rp-cell-actions .rp-action-btn .material-icons-round {
  font-size: 15px;
}
.rp-cell-actions .rp-action-btn .rp-btn-label {
  display: none;
}

/* ════════════════════════════════════════
   TABLE COLUMN FILTERS
   ════════════════════════════════════════ */

.rp-table .rp-filter-row th {
  padding: 4px 6px;
  background: var(--color-surface-container);
  border-bottom: 2px solid var(--color-outline-subtle);
  position: sticky;
  top: 35px;
  z-index: 2;
}

.rp-filter-input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--color-outline-subtle);
  border-radius: var(--radius-xs);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 11px;
  font-family: var(--font-family);
  padding: 3px 6px;
  outline: none;
  transition: border-color var(--transition-fast);
  box-sizing: border-box;
}
.rp-filter-input:focus { border-color: var(--color-primary); }
.rp-filter-input::placeholder { color: var(--color-text-disabled); }

.rp-filter-select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--color-outline-subtle);
  border-radius: var(--radius-xs);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 11px;
  font-family: var(--font-family);
  padding: 3px 4px;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition-fast);
}
.rp-filter-select:focus { border-color: var(--color-primary); }

.rp-filter-clear-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  background: var(--color-error-50);
  border-radius: var(--radius-xs);
  color: var(--color-error);
  cursor: pointer;
  padding: 0;
  transition: background var(--transition-fast);
}
.rp-filter-clear-btn:hover { background: var(--color-error-100); }
.rp-filter-clear-btn .material-icons-round { font-size: 14px; }

/* ────────────────────────────────────────
   TENANT MULTI-SELECT
   ──────────────────────────────────────── */
.rp-multi-select {
  position: relative;
  width: 100%;
}

.rp-ms-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2px;
  width: 100%;
  border: 1px solid var(--color-outline-subtle);
  border-radius: var(--radius-xs);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 11px;
  font-family: var(--font-family);
  padding: 3px 4px 3px 6px;
  cursor: pointer;
  text-align: left;
  outline: none;
  transition: border-color var(--transition-fast);
  white-space: nowrap;
  overflow: hidden;
}
.rp-ms-trigger:focus,
.rp-ms-open .rp-ms-trigger { border-color: var(--color-primary); }

.rp-ms-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rp-ms-arrow {
  font-size: 14px !important;
  color: var(--color-text-muted);
  flex-shrink: 0;
  transition: transform var(--transition-fast);
}
.rp-ms-open .rp-ms-arrow { transform: rotate(180deg); }

/* Панель виходить за межі overflow:auto через position:fixed */
.rp-ms-panel {
  position: fixed;
  z-index: 9200;
  background: var(--color-surface);
  border: 1px solid var(--color-outline-subtle);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
  display: none;
  flex-direction: column;
  max-height: 280px;
  overflow: hidden;
}
.rp-ms-open .rp-ms-panel { display: flex; }

.rp-ms-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: var(--text-xs);
  font-family: var(--font-family);
  color: var(--color-text);
  transition: background var(--transition-fast);
  user-select: none;
}
.rp-ms-item:hover { background: var(--color-surface-container); }
.rp-ms-item input[type="checkbox"] {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  accent-color: var(--color-primary);
  cursor: pointer;
  margin: 0;
}

.rp-ms-all {
  border-bottom: 1px solid var(--color-outline-subtle);
  font-weight: var(--font-semibold);
  background: var(--color-surface-container);
  flex-shrink: 0;
}

.rp-ms-list {
  overflow-y: auto;
  flex: 1;
}

.rp-ms-item-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ════════════════════════════════════════
   DATE RANGE FILTER
   ════════════════════════════════════════ */
.rp-date-range {
  position: relative;
  width: 100%;
}

/* Панель виходить за межі overflow:auto через position:fixed */
.rp-dr-panel {
  min-width: 240px !important;
  padding: 10px;
  gap: 8px;
}

.rp-dr-presets {
  display: flex;
  gap: 4px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--color-outline-subtle);
}

.rp-dr-preset {
  flex: 1;
  border: 1px solid var(--color-outline-subtle);
  border-radius: var(--radius-xs);
  background: var(--color-surface-container);
  color: var(--color-text-muted);
  font-size: 10px;
  font-family: var(--font-family);
  padding: 3px 4px;
  cursor: pointer;
  text-align: center;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
  white-space: nowrap;
}
.rp-dr-preset:hover {
  background: var(--color-primary-50, #f0faf3);
  color: var(--color-primary);
  border-color: var(--color-primary);
}
.rp-dr-preset-active {
  background: var(--color-primary) !important;
  color: #fff !important;
  border-color: var(--color-primary) !important;
}

.rp-dr-row {
  display: flex;
  gap: 8px;
}

.rp-dr-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  cursor: default;
}

.rp-dr-lbl {
  font-size: 10px;
  color: var(--color-text-muted);
  font-weight: var(--font-medium);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.rp-dr-from,
.rp-dr-to {
  border: 1px solid var(--color-outline-subtle);
  border-radius: var(--radius-xs);
  background: var(--color-surface-container);
  color: var(--color-text);
  font-size: 11px;
  font-family: var(--font-family);
  padding: 3px 5px;
  outline: none;
  width: 100%;
  transition: border-color var(--transition-fast);
}
.rp-dr-from:focus,
.rp-dr-to:focus { border-color: var(--color-primary); }

.rp-dr-clear-btn {
  align-self: flex-end;
  background: none;
  border: 1px solid var(--color-outline-subtle);
  border-radius: var(--radius-xs);
  color: var(--color-text-muted);
  font-size: 11px;
  font-family: var(--font-family);
  padding: 3px 8px;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.rp-dr-clear-btn:hover {
  background: var(--color-error-50, #fef2f2);
  color: var(--color-error);
  border-color: var(--color-error);
}

/* Кнопка розгортання до таблиці — тільки десктоп */
@media (max-width: 768px) {
  #registry-expand-btn { display: none !important; }
}

/* ════════════════════════════════════════
   HIDE LEGACY PANEL ELEMENTS
   (replaced by rp-* equivalents above)
   ════════════════════════════════════════ */
.registry-panel-header,
.registry-stats-section,
.registry-search-container {
  display: none !important;
}
