/* ===============================
   목록장부 (엑셀형 매물 목록)
   PC/모바일: 모두 풀스크린 오버레이
   =============================== */

.listing-page {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 5000;
}

.listing-page.open {
  display: flex;
}

/* PC: 풀스크린 오버레이 + 배경 어둡게 */
@media (min-width: 901px) {
  .listing-page.open {
    align-items: stretch;
    justify-content: stretch;
  }

  .listing-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    cursor: pointer;
  }

  .listing-panel {
    position: relative;
    z-index: 1;
    width: 100%;
    max-height: none;
    height: 100%;
    background: #f8f9fb;
    box-shadow: none;
    border-radius: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: none;
  }

  .listing-table .col-addr {
    min-width: 160px;
    max-width: 220px;
  }
}

/* 모바일: 풀스크린 (mobile.css에서 .listing-page.open 처리) */
@media (max-width: 900px) {
  .listing-page.open {
    flex-direction: column;
    background: #f8f9fb;
  }

  .listing-backdrop {
    display: none;
  }

  .listing-panel {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    width: 100%;
  }
}

/* -------- 헤더 -------- */
.listing-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid #e5e5e5;
  min-height: 52px;
}

.listing-header__back {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #333;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.listing-header__back:hover {
  background: #f0f0f0;
}

.listing-header__title {
  flex: 1;
  font-size: 18px;
  font-weight: 700;
  color: #111;
}

.listing-header__count {
  font-size: 14px;
  font-weight: 600;
  color: #666;
}

.listing-header__edit {
  flex-shrink: 0;
  padding: 6px 14px;
  border: 1px solid #2563eb;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  background: #fff;
  color: #2563eb;
  cursor: pointer;
}

.listing-header__edit:hover {
  background: #eff6ff;
}

.listing-edit-mode .listing-header__edit {
  background: #2563eb;
  color: #fff;
}

.listing-edit-mode .listing-header__edit:hover {
  background: #1d4ed8;
}

/* 수정 모드가 아닐 때는 거래상태 클릭 시 세부내역서로 이동 (커서 기본) */
.listing-panel:not(.listing-edit-mode) .listing-table .col-status .listing-status-badge {
  cursor: default;
}

.listing-panel.listing-edit-mode .listing-table .col-status .listing-status-badge {
  cursor: pointer;
}

/* -------- 툴바 (검색·정렬) -------- */
.listing-toolbar {
  flex-shrink: 0;
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid #eee;
}

.listing-scope-tabs {
  display: flex;
  gap: 6px;
  align-items: center;
  overflow-x: auto;
}

.listing-scope-tab {
  height: 34px;
  padding: 0 10px;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  background: #fff;
  color: #374151;
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
}

.listing-scope-tab.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.listing-search-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

.listing-search {
  width: 100%;
  height: 40px;
  padding: 0 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
}

/* 목록 검색 자동완성 (건물이름·상호·주소) */
.listing-search-autocomplete {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  max-height: 240px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  z-index: 100;
}

.listing-search-autocomplete.open {
  display: block;
}

.listing-search-autocomplete__item {
  padding: 10px 14px;
  font-size: 14px;
  color: #333;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
}

.listing-search-autocomplete__item:last-child {
  border-bottom: none;
}

.listing-search-autocomplete__item:hover,
.listing-search-autocomplete__item.selected {
  background: #f0f7ff;
}

.listing-search::placeholder {
  color: #999;
}

.listing-toolbar__filter {
  flex-shrink: 0;
  height: 40px;
  padding: 0 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  background: #fff;
  color: #333;
  cursor: pointer;
}

.listing-toolbar__filter:hover {
  background: #f5f5f5;
  border-color: #ccc;
}

.listing-toolbar__favorite {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 18px;
  background: #fff;
  color: #f59e0b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.listing-toolbar__favorite:hover {
  background: #fff7ed;
  border-color: #fbbf24;
}

.listing-toolbar__favorite.active {
  background: #f59e0b;
  border-color: #f59e0b;
  color: #fff;
}

.listing-sort-wrap {
  flex-shrink: 0;
}

.listing-sort {
  height: 40px;
  padding: 0 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  background: #fff;
  cursor: pointer;
}

.listing-table .col-name {
  display: flex;
  align-items: center;
  gap: 6px;
}

.listing-fav-btn {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  color: #d1d5db;
}

.listing-fav-btn--on {
  color: #f59e0b;
}

.listing-fav-btn:focus-visible,
.listing-toolbar__favorite:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

/* -------- 세분화 필터 (대분류 · 거래유형) -------- */
.listing-filters {
  flex-shrink: 0;
  padding: 10px 16px 12px;
  background: #fafbfc;
  border-bottom: 1px solid #eee;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: baseline;
}

.listing-filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.listing-filter-label {
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  flex-shrink: 0;
}

.listing-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.listing-filter-chip {
  padding: 6px 12px;
  border: 1px solid #d1d5db;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: #374151;
  background: #fff;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.listing-filter-chip:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
}

.listing-filter-chip.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.listing-filter-chip.active:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
  color: #fff;
}

/* -------- 테이블 -------- */
.listing-table-wrap {
  flex: 1;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.listing-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.listing-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f0f2f5;
}

.listing-table th {
  padding: 10px 12px;
  text-align: left;
  font-weight: 700;
  color: #374151;
  border-bottom: 2px solid #e5e7eb;
  white-space: nowrap;
}

.listing-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #eee;
  vertical-align: middle;
}

.listing-table tbody tr {
  cursor: pointer;
  transition: background 0.15s;
}

.listing-table tbody tr:hover {
  background: #e8f0fe;
}

.listing-table tbody tr:active {
  background: #d2e3fc;
}

/* 컬럼 너비 */
.listing-table .col-id {
  width: 48px;
  color: #6b7280;
}

.listing-table .col-name {
  min-width: 100px;
  max-width: 180px;
}

.listing-table .col-status {
  min-width: 90px;
  max-width: 110px;
}

.listing-table .listing-status-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.listing-table .listing-status-badge--dealable {
  background: #dcfce7;
  color: #166534;
}

.listing-table .listing-status-badge--hold {
  background: #fef3c7;
  color: #92400e;
}

.listing-table .listing-status-badge--completed {
  background: #e5e7eb;
  color: #374151;
}

.listing-table .listing-status-badge--checking {
  background: #dbeafe;
  color: #1e40af;
}

.listing-table .col-status .listing-status-badge {
  cursor: pointer;
}

.listing-table .col-status .listing-status-badge:hover {
  filter: brightness(0.95);
}

/* 수정 모드: 개별 삭제 버튼 (작게) */
.listing-panel:not(.listing-edit-mode) .listing-col-delete {
  display: none;
}

.listing-table .col-delete {
  width: 32px;
  padding: 2px 4px;
  vertical-align: middle;
  text-align: center;
}

.listing-row-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  background: #fff;
  color: #6b7280;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.listing-row-delete:hover {
  background: #fef2f2;
  color: #dc2626;
  border-color: #fecaca;
}

.listing-row-delete:active {
  background: #fee2e2;
}

/* 거래상태 즉시 수정 드롭다운 */
.listing-status-dropdown {
  display: none;
  position: absolute;
  z-index: 100;
  min-width: 120px;
  padding: 6px 0;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.listing-status-dropdown.open {
  display: block;
}

/* 목록 페이지네이션 */
.listing-pagination {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: #fff;
  border-top: 1px solid #eee;
}

.listing-pagination.hidden {
  display: none;
}

.listing-pagination__info {
  font-size: 13px;
  color: #666;
  font-weight: 500;
}

.listing-pagination__btns {
  display: flex;
  gap: 8px;
}

.listing-pagination__btn {
  padding: 6px 14px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  background: #fff;
  color: #374151;
  cursor: pointer;
}

.listing-pagination__btn:hover:not(:disabled) {
  background: #f3f4f6;
  border-color: #9ca3af;
}

.listing-pagination__btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.listing-status-dropdown__item {
  display: block;
  width: 100%;
  padding: 8px 14px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 500;
  color: #374151;
  text-align: left;
  cursor: pointer;
}

.listing-status-dropdown__item:hover {
  background: #f3f4f6;
}

.listing-table .col-addr {
  min-width: 140px;
  max-width: 200px;
}

.listing-table .col-cat {
  min-width: 110px;
}


.listing-table .col-price {
  min-width: 130px;
}

.listing-table .col-area {
  width: 56px;
}

.listing-table .col-shortmemo {
  min-width: 120px;
  max-width: 200px;
}

.listing-table .shortmemo-cell {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #6b7280;
  font-size: 12px;
}

/* 셀 텍스트 */
.listing-table .addr-cell {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.listing-table .price-cell {
  font-weight: 700;
  color: #111;
}

.listing-table .badge-cell {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  background: #f3f4f6;
  color: #374151;
  font-size: 11px;
  font-weight: 700;
}

/* 분류: 상위 + 하위 작은 배너 */
.cat-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.cat-badge {
  display: inline-block;
  padding: 3px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.cat-badge--top {
  background: #e0e7ff;
  color: #3730a3;
}

.cat-badge--sub {
  background: #f3f4f6;
  color: #4b5563;
}

.cat-badge--deal {
  background: #d1fae5;
  color: #065f46;
}

/* -------- 빈 상태 -------- */
.listing-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: #6b7280;
}

.listing-empty.hidden {
  display: none;
}

.listing-empty__icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.listing-empty p {
  margin: 0;
  font-size: 15px;
}

/* -------- 변경 로그 (asset_logs) -------- */
.log-toolbar {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  padding: 12px 16px;
  background: #fafbfc;
  border-bottom: 1px solid #eee;
}

.log-search-wrap {
  flex: 1;
  min-width: 140px;
}

.log-filters {
  display: flex;
  gap: 8px;
  align-items: center;
}

.log-action-filter {
  height: 40px;
  padding: 0 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  background: #fff;
  cursor: pointer;
}

.log-panel .log-loading,
.log-panel .log-content,
.log-panel .log-empty,
.log-panel .log-error {
  flex: 1;
  min-height: 0;
}

.log-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px;
  color: #6b7280;
}

.log-loading p {
  margin: 0;
  font-size: 14px;
}

.log-loading__spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #e5e7eb;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: log-spin 0.8s linear infinite;
}

@keyframes log-spin {
  to { transform: rotate(360deg); }
}

.log-content {
  overflow: auto;
}

.log-empty .log-empty__hint {
  margin: 8px 0 0;
  font-size: 13px;
  color: #9ca3af;
}

.log-error {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px;
  color: #6b7280;
}

.log-error p {
  margin: 0;
  font-size: 14px;
}

.log-error__retry {
  padding: 10px 20px;
  border: 1px solid #3b82f6;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  background: #eff6ff;
  color: #2563eb;
  cursor: pointer;
}

.log-error__retry:hover {
  background: #dbeafe;
}

.log-table .col-date {
  width: 120px;
  white-space: nowrap;
  color: #6b7280;
  font-size: 13px;
}

.log-table .col-action {
  width: 80px;
}

.log-action-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}

.log-action--create {
  background: #d1fae5;
  color: #047857;
}

.log-action--update {
  background: #dbeafe;
  color: #1d4ed8;
}

.log-action--delete {
  background: #fee2e2;
  color: #b91c1c;
}

.log-action--status_change {
  background: #fef3c7;
  color: #b45309;
}

.log-table .col-addr {
  min-width: 140px;
  max-width: 220px;
  color: #374151;
}

.log-table .col-note {
  min-width: 120px;
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #4b5563;
}

.log-table tbody tr[role="button"] {
  cursor: pointer;
}

.log-table tbody tr[role="button"]:hover {
  background: #f0f7ff;
}
