/* ============ Astrea ResourceTable 样式 ============ */
/* 类名前缀 ast-rt-，避免与其他组件/宿主样式冲突（REQ-F-005 样式影响范围）。 */

/* ------------ 容器与主题变量 ------------ */
.ast-resource-table {
    --ast-rt-font-family: sans-serif;
    --ast-rt-font-size: 14px;
    --ast-rt-color-text: #333;
    --ast-rt-color-bg: #fff;
    --ast-rt-color-header-bg: #f5f5f5;
    --ast-rt-color-border: #ddd;
    --ast-rt-color-border-strong: #989ca4;
    --ast-rt-color-accent: #268cda;
    --ast-rt-color-hover-bg: #e0eef9;
    --ast-rt-color-selected-bg: #c3c3ff;
    --ast-rt-color-resize: #d0d7de;
    --ast-rt-color-resizing-bg: #f8f9fa;
    --ast-rt-color-scroll-thumb: #c1c1c1;
    --ast-rt-color-scroll-track: #f1f1f1;
    --ast-rt-radius: 4px;
    --ast-rt-icon-size: 14px;
    --ast-rt-btn-size: 24px;
    --ast-rt-toolbar-gap: 14px;
    --ast-rt-btn-group-gap: 10px;
    --ast-rt-th-content-padding: 16px;
    --ast-rt-resize-width: 24px;
    --ast-rt-disabled-opacity: 0.45;
    --ast-rt-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    --ast-rt-shadow-hover: 0 2px 4px rgba(0, 0, 0, 0.15);
    --ast-rt-header-shadow: 0 2px 2px -1px rgba(0, 0, 0, 0.1);

    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    padding-left: 5px;
    color: var(--ast-rt-color-text);
    font-family: var(--ast-rt-font-family);
    font-size: var(--ast-rt-font-size);
}

/* ------------ 工具栏 ------------ */
.ast-rt-toolbar {
    display: flex;
    align-items: center;
    gap: var(--ast-rt-toolbar-gap);
    padding: 8px 0;
    white-space: nowrap;
    width: 100%;
    flex-wrap: wrap;
    row-gap: 8px;
}

.ast-rt-btn-group {
    display: flex;
    gap: var(--ast-rt-btn-group-gap);
    flex-shrink: 1;
    flex-basis: auto;
    align-items: center;
    min-width: fit-content;
}

.ast-rt-btn {
    width: var(--ast-rt-btn-size);
    height: var(--ast-rt-btn-size);
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--ast-rt-color-bg) !important;
    border: 1px solid var(--ast-rt-color-border);
    border-radius: var(--ast-rt-radius);
    box-shadow: var(--ast-rt-shadow);
    transition: all 0.2s ease;
    color: var(--ast-rt-color-text);
    flex-shrink: 0;
    padding: 0;
}

.ast-rt-btn:hover {
    background-color: var(--ast-rt-color-hover-bg);
    border-color: var(--ast-rt-color-accent);
    box-shadow: var(--ast-rt-shadow-hover);
}

.ast-rt-btn:active {
    transform: translateY(1px);
    box-shadow: none;
}

.ast-rt-btn:disabled {
    opacity: var(--ast-rt-disabled-opacity);
    cursor: not-allowed;
    transform: none;
    box-shadow: var(--ast-rt-shadow);
}

.ast-rt-divider {
    width: 1px;
    align-self: stretch;
    margin: 2px 0;
    background-color: var(--ast-rt-color-border);
}

/* 内联 SVG 图标（stroke=currentColor，跟随按钮颜色） */
.ast-rt-icon {
    width: var(--ast-rt-icon-size);
    height: var(--ast-rt-icon-size);
    display: block;
    pointer-events: none;
}

/* ------------ 表格滚动区 ------------ */
.ast-rt-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    border: 1px solid var(--ast-rt-color-border-strong);
    background-color: var(--ast-rt-color-bg);
    scrollbar-width: thin;
    scrollbar-color: var(--ast-rt-color-scroll-thumb) var(--ast-rt-color-scroll-track);
}

/* 禁止表格中文本选中 */
.ast-rt-no-select {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* ------------ 固定表头表格 ------------ */
.ast-rt-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
}

.ast-rt-table thead {
    position: sticky;
    top: 0;
    background-color: var(--ast-rt-color-header-bg);
    z-index: 1;
    box-shadow: var(--ast-rt-header-shadow);
}

.ast-rt-table thead tr {
    height: 28px;
    line-height: 28px;
}

.ast-rt-table th,
.ast-rt-table td {
    border: 1px solid var(--ast-rt-color-border);
    text-align: center;
    font-family: var(--ast-rt-font-family);
    font-size: var(--ast-rt-font-size);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0;
    box-sizing: border-box;
}

.ast-rt-table th {
    font-weight: 600;
    color: var(--ast-rt-color-text);
    border-top: none !important;
    position: relative;
}

.ast-rt-table tbody td {
    position: relative;
    height: 20px;
    line-height: 20px;
}

/* 应用在行上添加的选中样式 */
.ast-rt-table .ast-rt-row-selected {
    background-color: var(--ast-rt-color-selected-bg) !important;
}

/* ------------ 可调整列宽 ------------ */
.ast-rt-th {
    position: relative;
    min-width: 50px;
}

/* 覆盖 `.ast-rt-table th` 的 overflow: hidden，让扩大后的手柄命中区跨列边界可见 */
.ast-rt-table th.ast-rt-th {
    overflow: visible;
}

.ast-rt-th-content {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: var(--ast-rt-th-content-padding);
}

.ast-rt-resize-handle {
    position: absolute;
    top: 0;
    right: 0;
    width: var(--ast-rt-resize-width);
    height: 100%;
    cursor: col-resize;
    z-index: 2;
    transform: translateX(50%);
    touch-action: none;
}

.ast-rt-resize-handle::after {
    content: '';
    position: absolute;
    top: 10%;
    bottom: 10%;
    right: 11px;
    width: 2px;
    background-color: var(--ast-rt-color-resize);
}

.ast-rt-resize-handle:hover::after,
.ast-rt-resize-handle:focus-visible::after {
    background-color: var(--ast-rt-color-accent);
}

.ast-rt-resize-handle:focus-visible {
    outline: 2px solid var(--ast-rt-color-accent);
    outline-offset: 1px;
}

/* 拖动时的视觉反馈 */
.ast-rt-th.ast-rt-resizing {
    background-color: var(--ast-rt-color-resizing-bg);
}
