/**
 * NSKit Table Widget CSS v1.0
 *
 * Table with Column Lock support
 *
 * @version 1.0.0
 */

/* ============================================
   Table Container
   ============================================ */

.ns-table {
    position: relative;  /* Lock overlay의 최상위 기준점 */
    width: 100%;
    min-height: 400px;  /* 최소 높이 보장 */
    background: white;
    border: 1px solid var(--nskit-border-color);
    border-radius: var(--nskit-widget-radius);
    overflow: hidden;
}

.table-container {
    position: relative;  /* Lock overlay의 기준점 */
    width: 100%;
    height: 100%;
}

/* ============================================
   Header Overlay (스크롤 시 그림자)
   ============================================ */

.header-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: var(--nskit-table-header-height, 48px);
    pointer-events: none;
    z-index: 5;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    opacity: 0;
    transition: opacity 0.2s;
}

.table-scroll-container.scrolled .header-overlay {
    opacity: 1;
}

/* ============================================
   Lock Overlays
   ============================================ */

.left-lock-overlay,
.right-lock-overlay {
    position: absolute;
    top: 0;
    bottom: 0;
    background: white;
    z-index: 10;
    pointer-events: auto;  /* 클릭 가능 */
    overflow: hidden;
}

.left-lock-overlay {
    left: 0;
    border-right: 2px solid var(--nskit-primary);
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
}

.right-lock-overlay {
    right: 0;
    border-left: 2px solid var(--nskit-primary);
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
}

/* Lock 내부 스크롤 컨테이너 */
.lock-scroll-container {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Lock 영역 스크롤바 숨기기 (선택적) */
.lock-scroll-container::-webkit-scrollbar {
    width: 0;
    display: none;
}

/* ============================================
   Scroll Container
   ============================================ */

.table-scroll-container {
    width: 100%;
    height: 100%;
    overflow-x: auto;
    overflow-y: auto;
}

/* ============================================
   Header
   ============================================ */

.list-table-header {
    display: flex;
    align-items: center;
    height: var(--nskit-table-header-height, 48px);
    background: var(--nskit-bg-secondary);
    border-bottom: 1px solid var(--nskit-border-color);
    position: sticky;
    top: 0;
    z-index: 2;
}

.list-th {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    font-size: var(--nskit-font-size-sm);
    font-weight: var(--nskit-font-weight-semibold);
    color: var(--nskit-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Sortable Column */
.list-th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.list-th.sortable:hover {
    background: rgba(0, 0, 0, 0.03);
}

.list-th.sortable .ns-icon.sort {
    margin-left: 4px;
    font-size: 14px;
    color: var(--nskit-text-disabled);
    transition: color 0.2s;
}

.list-th.sortable.sorted .ns-icon.sort {
    color: var(--nskit-primary);
}

/* Checkbox Column */
.list-th.checkbox {
    width: 40px;
    min-width: 40px;
    max-width: 40px;
    padding: 0;
}

/* ============================================
   Body
   ============================================ */

.list-table-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.list-tr {
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid var(--nskit-border-color);
    transition: background 0.15s;
}

.list-tr:hover {
    background: var(--nskit-bg-hover);
}

.list-tr.selected {
    background: var(--nskit-primary-light);
}

.list-tr:last-child {
    border-bottom: none;
}

.list-td {
    display: flex;
    align-items: center;
    padding: 0 12px;
    font-size: var(--nskit-font-size-sm);
    color: var(--nskit-text-primary);
}

.list-td .table-cell {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Checkbox Cell */
.list-td.checkbox {
    width: 40px;
    min-width: 40px;
    max-width: 40px;
    padding: 0;
    justify-content: center;
}

.nsk-checkbox {
    width: 20px;
    height: 20px;
    border: 1px solid var(--nskit-border-color);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.nsk-checkbox.checked {
    background: var(--nskit-primary);
    border-color: var(--nskit-primary);
}

/* Action Cell */
.list-td.action {
    justify-content: flex-start;
    gap: 8px;
}

.list-td.action button {
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 4px;
    border: 1px solid var(--nskit-border-color);
    background: white;
    cursor: pointer;
    transition: all 0.2s;
}

.list-td.action button:hover {
    background: var(--nskit-bg-secondary);
    border-color: var(--nskit-primary);
    color: var(--nskit-primary);
}

/* ============================================
   Ellipsis
   ============================================ */

.ellipsis-1 {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ellipsis-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ellipsis-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================
   Badge
   ============================================ */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 12px;
}

.badge-success {
    background: #D1FAE5;
    color: #059669;
}

.badge-danger {
    background: #FEE2E2;
    color: #DC2626;
}

.badge-warning {
    background: #FEF3C7;
    color: #D97706;
}

.badge-default {
    background: var(--nskit-bg-tertiary);
    color: var(--nskit-text-secondary);
}

/* ============================================
   Empty State
   ============================================ */

.list-tr.empty-row {
    justify-content: center;
    align-items: center;
    min-height: 200px;
    color: var(--nskit-text-disabled);
    font-size: var(--nskit-font-size-sm);
}
