/* grid.css — AG Grid 커스텀 */

.ag-theme-alpine {
  --ag-font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, sans-serif;
  --ag-font-size: var(--font-size);
  --ag-row-height: 28px;
  --ag-header-height: 28px;
  --ag-cell-horizontal-padding: 6px;
  --ag-border-color: var(--c-border);
  --ag-header-background-color: var(--c-bg-sub);
  --ag-header-foreground-color: var(--c-text-sub);
  --ag-row-hover-color: var(--c-bg-hover);
  --ag-selected-row-background-color: #e8f0fe;
  --ag-background-color: var(--c-bg);
  --ag-foreground-color: var(--c-text);
  --ag-border-radius: 0;
  --ag-input-focus-border-color: var(--c-border-strong);
  --ag-range-selection-border-color: var(--c-border-strong);
  --ag-range-selection-background-color: var(--c-bg-hover);
  --ag-selected-row-background-color: var(--c-bg-hover);
  --ag-cell-editing-border: solid 1px var(--c-border-strong);
  --ag-input-border-color: var(--c-border);
  border: none !important;
}

/* 외곽 보더 완전 제거 — 패널 리사이즈 핸들(1px)이 구분선 역할 */
.ag-theme-alpine .ag-root-wrapper { border: none !important; }
.ag-theme-alpine .ag-root { border: none !important; }
.ag-theme-alpine .ag-body-viewport { border: none !important; }
.ag-theme-alpine .ag-header { border-bottom: 1px solid var(--c-border) !important; }

/* 세로줄 강제 + 엑셀식 말줄임표 */
.ag-theme-alpine .ag-cell {
  border-right: 1px solid var(--c-border) !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}
.ag-theme-alpine .ag-header-cell {
  border-right: 1px solid var(--c-border) !important;
}

/* 폰트 강제 */
.ag-theme-alpine .ag-root-wrapper,
.ag-theme-alpine .ag-header-cell-label,
.ag-theme-alpine .ag-cell {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, sans-serif !important;
  font-size: var(--font-size) !important;
}
.ag-theme-alpine .ag-header-cell-label {
  font-weight: 500 !important;
}

/* 셀 포커스/선택 파란색 제거 */
.ag-theme-alpine .ag-cell-focus,
.ag-theme-alpine .ag-cell-range-selected,
.ag-theme-alpine .ag-cell-range-single-cell {
  border-color: var(--c-border-strong) !important;
  background: var(--c-bg-hover) !important;
}
.ag-theme-alpine .ag-ltr .ag-cell-focus:not(.ag-cell-range-selected) {
  border: 1px solid var(--c-border-strong) !important;
}
.ag-theme-alpine .ag-row-selected {
  background: var(--c-bg-hover) !important;
}
.ag-theme-alpine .ag-cell-inline-editing {
  border-color: var(--c-border-strong) !important;
  box-shadow: none !important;
}

/* 기본 필터/메뉴/정렬아이콘 완전 숨김 — 커스텀 필터만 사용 */
.ag-theme-alpine .ag-header-cell-menu-button { display: none !important; }
.ag-theme-alpine .ag-floating-filter { display: none !important; }
.ag-theme-alpine .ag-sort-indicator-icon { display: none !important; }
.ag-theme-alpine .ag-filter-icon { display: none !important; }
.ag-theme-alpine .ag-header-cell-filter-button { display: none !important; }

/* 헤더 클릭 가능 느낌 */
.ag-theme-alpine .ag-header-cell-label { cursor: pointer; }

/* 필터 활성 뱃지 */
.gf-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--r-lg);
  background: var(--c-primary);
  color: #fff;
  font-size: var(--font-size-xs);
  font-weight: 600;
  margin-left: 4px;
}

/* 커스텀 필터 드롭다운 */
.grid-filter-popup {
  position: fixed;
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  min-width: 160px;
  max-height: 300px;
  overflow-y: auto;
  z-index: var(--z-modal);
  font-size: var(--font-size-sm);
}
.grid-filter-popup .gf-search {
  width: 100%;
  padding: 6px 10px;
  border: none;
  border-bottom: 1px solid var(--c-border);
  font-size: var(--font-size-sm);
  outline: none;
}
.grid-filter-popup .gf-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 10px;
  cursor: pointer;
}
.grid-filter-popup .gf-item:hover { background: var(--c-bg-hover); }
.grid-filter-popup .gf-item.is-active { background: var(--c-primary-bg); color: var(--c-primary); font-weight: 500; }
.grid-filter-popup .gf-count { color: var(--c-text-muted); font-size: var(--font-size-xs); }
.grid-filter-popup {
  display: flex;
  flex-direction: column;
}
.grid-filter-popup .gf-list {
  flex: 1;
  overflow-y: auto;
}
.grid-filter-popup .gf-footer {
  display: flex;
  gap: 4px;
  padding: 6px 8px;
  border-top: 1px solid var(--c-border);
  flex-shrink: 0;
}
.grid-filter-popup .gf-footer .btn {
  flex: 1;
  font-size: var(--font-size-xs);
  justify-content: center;
}

/* 컬럼 리사이즈 핸들 — 보이지 않지만 클릭 영역 넓게 (호버 시만 표시) */
.ag-theme-alpine .ag-header-cell-resize {
  width: 8px !important;
  right: -4px !important;
  cursor: col-resize !important;
  background: transparent;
  opacity: 1;
  z-index: 2;
}
.ag-theme-alpine .ag-header-cell-resize::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 0;
  background: var(--c-primary);
  transition: width var(--t-fast);
}
.ag-theme-alpine .ag-header-cell-resize:hover::after {
  width: 2px;
}

/* 보험관리 · 핵심 컬럼 그룹 헤더 강조 */
.ag-theme-alpine .ag-header-group-cell.grp-coverage,
.ag-theme-alpine .ag-header-group-cell.grp-payment {
  background: var(--c-primary-bg);
  color: var(--c-primary);
  font-weight: 700;
  border-bottom: 2px solid var(--c-primary);
}
.ag-theme-alpine .ag-header-group-cell.grp-basic,
.ag-theme-alpine .ag-header-group-cell.grp-holder,
.ag-theme-alpine .ag-header-group-cell.grp-car {
  background: var(--c-bg-sub);
  font-weight: 600;
}
