/* ========================================
 * DataListView - 테이블/카드 전환 공통 컴포넌트
 * 계층: components (head.jsp 전역 로드)
 * 네임스페이스: sfn-dlv-
 * ======================================== */

/* ===== 컨테이너 ===== */
.sfn-dlv {
    position: relative;
}

/* ===== 툴바 ===== */
.sfn-dlv-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 12px;
    gap: 4px;
}

.sfn-dlv-view-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--bs-border-color);
    border-radius: 6px;
    background: #fff;
    background: oklch(100% 0 0);
    color: var(--bs-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 1.1rem;
    padding: 0;
}

.sfn-dlv-view-btn:hover {
    border-color: var(--bs-primary);
    color: var(--bs-primary);
}

.sfn-dlv-view-btn.active {
    background: var(--bs-primary);
    border-color: var(--bs-primary);
    color: #fff;
}

/* ===== 테이블 뷰 ===== */
.sfn-dlv-table {
    display: block;
}

.sfn-dlv-table table {
    width: 100%;
    margin-bottom: 0;
}

.sfn-dlv-col-no {
    width: 50px;
}

.sfn-dlv-table th {
    font-size: 0.875rem;
    font-weight: 600;
    white-space: nowrap;
}

.sfn-dlv-table td {
    vertical-align: middle;
}

/* ===== 카드 뷰 ===== */
.sfn-dlv-cards {
    display: none;
    flex-direction: column;
    gap: 12px;
}

.sfn-dlv-card {
    border: 1px solid var(--bs-border-color);
    border-radius: 8px;
    padding: 16px;
    background: #fff;
    background: oklch(100% 0 0);
    box-shadow: 0 2px 4px rgb(0 0 0 / 0.05);
    box-shadow: 0 2px 4px oklch(0% 0 0 / 0.05);
}

.sfn-dlv-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--bs-border-color);
}

.sfn-dlv-card-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.sfn-dlv-card-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sfn-dlv-card-field {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
}

.sfn-dlv-card-field-label {
    color: var(--bs-secondary);
    font-weight: 600;
    flex-shrink: 0;
    margin-right: 12px;
}

.sfn-dlv-card-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid var(--bs-border-color);
}

/* ===== 클릭 가능 행 ===== */
.sfn-dlv--clickable .sfn-dlv-table tbody tr,
.sfn-dlv--clickable .sfn-dlv-card {
    cursor: pointer;
}

/* ===== 빈 상태 ===== */
.sfn-dlv-empty {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 16px;
    color: var(--bs-secondary);
}

.sfn-dlv-empty .sfn-dlv-empty-icon {
    font-size: 2.5rem;
    margin-bottom: 8px;
}

/* ===== 뷰 전환 로직 (data-view 속성) ===== */

/* table 뷰: 테이블 표시, 카드 숨김 */
.sfn-dlv[data-view="table"] .sfn-dlv-table { display: block; }
.sfn-dlv[data-view="table"] .sfn-dlv-cards { display: none; }

/* card 뷰: 카드 표시, 테이블 숨김 */
.sfn-dlv[data-view="card"] .sfn-dlv-table { display: none; }
.sfn-dlv[data-view="card"] .sfn-dlv-cards { display: flex; }

/* empty 상태 */
.sfn-dlv.sfn-dlv--empty .sfn-dlv-table,
.sfn-dlv.sfn-dlv--empty .sfn-dlv-cards { display: none; }
.sfn-dlv.sfn-dlv--empty .sfn-dlv-empty { display: flex; }
.sfn-dlv.sfn-dlv--empty .sfn-dlv-toolbar { display: none; }

/* auto 뷰: PC→테이블, 모바일→카드 */
.sfn-dlv[data-view="auto"] .sfn-dlv-table { display: block; }
.sfn-dlv[data-view="auto"] .sfn-dlv-cards { display: none; }

@media (max-width: 768px) {
    .sfn-dlv[data-view="auto"] .sfn-dlv-table { display: none; }
    .sfn-dlv[data-view="auto"] .sfn-dlv-cards { display: flex; }

    /* 모바일에서는 auto일 때 토글 숨김 */
    .sfn-dlv[data-view="auto"] .sfn-dlv-toolbar { display: none; }
}
