/**
 * 权限管理模块样式
 * @author ACube Team
 * @date 2025-12-05
 */

/* 权限管理视图容器 */
.permission-management-view {
    padding: 16px;
}

/* 统计卡片 */
.perm-stats-card {
    background: white;
    border-radius: 8px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid #e8e8e8;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.perm-stats-card .icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.perm-stats-card .icon.purple { background: #f3e8ff; color: #7c3aed; }
.perm-stats-card .icon.pink { background: #fce7f3; color: #db2777; }
.perm-stats-card .icon.blue { background: #e0f2fe; color: #0284c7; }
.perm-stats-card .icon.green { background: #dcfce7; color: #16a34a; }

.perm-stats-card .info {
    flex: 1;
    min-width: 0;
}

.perm-stats-card .value {
    font-size: 24px;
    font-weight: 600;
    color: #1a1a2e;
    line-height: 1.2;
}

.perm-stats-card .label {
    font-size: 13px;
    color: #8c8c8c;
    margin-top: 2px;
}

/* 标签页容器 - Flex 自适应布局 */
.perm-tabs-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 16px 24px;
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.perm-tabs-container .ant-tabs {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.perm-tabs-container .ant-tabs-nav {
    flex-shrink: 0;
}

.perm-tabs-container .ant-tabs-content-holder {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.perm-tabs-container .ant-tabs-content {
    height: 100%;
}

.perm-tabs-container .ant-tabs-tabpane {
    height: 100%;
    overflow: hidden;
}

.perm-tabs-container .ant-tabs-tabpane-active {
    display: flex;
    flex-direction: column;
}

/* 空状态 */
.perm-empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #8c8c8c;
}

.perm-empty-state .icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* 角色列表 - Flex 自适应 */
.perm-role-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

/* 角色卡片 */
.perm-role-card {
    background: white;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid #e8e8e8;
    transition: all 0.3s ease;
    cursor: pointer;
}

.perm-role-card:hover {
    border-color: #1890ff;
    box-shadow: 0 2px 12px rgba(24, 144, 255, 0.15);
}

.perm-role-card.active {
    border-color: #1890ff;
    background: #f0f7ff;
}

.perm-role-card .role-name {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a2e;
    margin-bottom: 4px;
}

.perm-role-card .role-code {
    font-size: 12px;
    color: #8c8c8c;
    font-family: monospace;
}

.perm-role-card .role-meta {
    display: flex;
    gap: 16px;
    margin-top: 12px;
    font-size: 12px;
    color: #666;
}

.perm-role-card .system-tag {
    background: #722ed1;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    margin-left: 8px;
}

.perm-role-card .global-tag {
    background: #1890ff;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    margin-left: 8px;
}

/* C8 席位标识（胶囊形 + 减饱和色，Linear 风格）：admin=管理席 / field=现场席 */
.perm-role-card .seat-tag-admin {
    background: #fff7e6;
    color: #d46b08;
    border: 1px solid #ffd591;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 11px;
    margin-left: 8px;
}

.perm-role-card .seat-tag-field {
    background: #f6ffed;
    color: #389e0d;
    border: 1px solid #b7eb8a;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 11px;
    margin-left: 8px;
}

.perm-role-card .tenant-tag {
    background: #52c41a;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    margin-left: 8px;
}

/* 权限树 - Flex 自适应 */
.perm-permission-tree {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 12px;
    background: #fafafa;
    border-radius: 8px;
}

.perm-permission-tree .module-section {
    margin-bottom: 16px;
}

.perm-permission-tree .module-header {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: white;
    border-radius: 6px;
    margin-bottom: 8px;
    cursor: pointer;
}

.perm-permission-tree .module-header:hover {
    background: #f0f7ff;
}

.perm-permission-tree .module-permissions {
    padding-left: 24px;
}

.perm-permission-tree .permission-item {
    display: inline-flex;
    align-items: center;
    background: #f5f5f5;
    border-radius: 4px;
    padding: 4px 12px;
    margin: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.perm-permission-tree .permission-item:hover {
    background: #e6f7ff;
}

.perm-permission-tree .permission-item.selected {
    background: #1890ff;
    color: white;
}

.perm-permission-tree .permission-item.mobile {
    border-left: 3px solid #52c41a;
}

/* 标签空间 */
.tag-space {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

/* ========== 我的权限页签样式 ========== */

/* 信息卡片 */
.my-perm-info-card,
.my-perm-list-card {
    background: white;
    border-radius: 12px;
    border: 1px solid #e8e8e8;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    margin-bottom: 16px;
    overflow: hidden;
}

.my-perm-info-card .card-header,
.my-perm-list-card .card-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(135deg, #f8f9fa 0%, #f0f2f5 100%);
    border-bottom: 1px solid #e8e8e8;
}

.my-perm-info-card .card-header .icon,
.my-perm-list-card .card-header .icon {
    font-size: 18px;
    margin-right: 8px;
}

.my-perm-info-card .card-header .title,
.my-perm-list-card .card-header .title {
    font-size: 15px;
    font-weight: 600;
    color: #1a1a2e;
}

.my-perm-list-card .card-header .count {
    margin-left: auto;
    font-size: 13px;
    color: #52c41a;
    font-weight: 500;
}

.my-perm-info-card .card-body,
.my-perm-list-card .card-body {
    padding: 16px;
}

/* 基本信息行 */
.my-perm-info-card .info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px dashed #f0f0f0;
}

.my-perm-info-card .info-row:last-child {
    border-bottom: none;
}

.my-perm-info-card .info-row .label {
    font-size: 14px;
    color: #8c8c8c;
}

.my-perm-info-card .info-row .value {
    font-size: 14px;
    color: #1a1a2e;
    font-weight: 500;
}

.my-perm-info-card .info-row .value.code {
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    background: #f5f5f5;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 13px;
}

/* 角色标签 */
.my-perm-info-card .role-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.my-perm-info-card .empty-hint {
    color: #bfbfbf;
    font-size: 14px;
    text-align: center;
    padding: 20px 0;
}

/* 权限标签网格 */
.my-perm-list-card .permission-tag-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 400px;
    overflow-y: auto;
    padding: 4px;
}

.my-perm-list-card .permission-tag-grid .ant-tag {
    margin: 0;
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 4px;
}

/* 我的权限 - 模块分类显示 */
.my-perm-module-section {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #f0f0f0;
}

.my-perm-module-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.my-perm-module-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding: 8px 12px;
    background: linear-gradient(135deg, #f6f8fa 0%, #eef1f5 100%);
    border-radius: 6px;
    border-left: 3px solid #1890ff;
}

.my-perm-module-header .module-name {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a2e;
}

.my-perm-module-header .module-count {
    font-size: 12px;
    color: #8c8c8c;
    background: white;
    padding: 2px 8px;
    border-radius: 10px;
}

.my-perm-module-items {
    display: flex;
    flex-wrap: wrap;
    padding-left: 4px;
}

.my-perm-module-items .ant-tag {
    margin: 4px 8px 4px 0;
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.my-perm-module-items .ant-tag:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(82, 196, 26, 0.2);
}

/* ========== 数据权限分组卡片样式 ========== */
.data-rule-groups {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
}

.data-rule-group-card {
    background: #ffffff;
    border: 1px solid #e8e8e8;
    border-radius: 10px;
    overflow: hidden;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.data-rule-group-card:hover {
    border-color: #1890ff;
    box-shadow: 0 2px 8px rgba(24, 144, 255, 0.12);
}

.data-rule-group-card .group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 1px solid #f0f0f0;
}

.data-rule-group-card .group-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.data-rule-group-card .group-name {
    font-weight: 600;
    font-size: 15px;
    color: #1a1a2e;
}

.data-rule-group-card .group-target {
    color: #666;
    font-size: 13px;
}

.data-rule-group-card .group-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.data-rule-group-card:hover .group-actions {
    opacity: 1;
}

.data-rule-group-card .group-body {
    padding: 14px 16px;
}

.data-rule-group-card .group-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.data-rule-group-card .group-row:last-child {
    margin-bottom: 0;
}

.data-rule-group-card .row-label {
    color: #8c8c8c;
    font-size: 13px;
    min-width: 80px;
    flex-shrink: 0;
}

.data-rule-group-card .condition-hint {
    color: #999;
    font-size: 12px;
    margin-left: 4px;
}

.data-rule-group-card .resource-tags {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.data-rule-group-card .resource-tags .ant-tag {
    margin: 0;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .perm-stats-card {
        padding: 12px 16px;
    }
    
    .perm-stats-card .value {
        font-size: 20px;
    }
    
    .perm-tabs-container {
        padding: 12px 16px;
    }
    
    .perm-role-list,
    .perm-permission-tree {
        min-height: 200px;
    }
    
    .my-perm-list-card .permission-tag-grid {
        max-height: 250px;
    }
    
    .my-perm-module-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .my-perm-module-header .module-count {
        margin-left: 0;
    }
    
    .data-rule-group-card .group-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .data-rule-group-card .group-actions {
        opacity: 1;
    }
    
    .data-rule-group-card .group-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
    
    .data-rule-group-card .row-label {
        min-width: auto;
    }
}

/* ========== Flex 自适应表格样式 ========== */
.perm-flex-table {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}
.perm-flex-table .ant-spin-nested-loading,
.perm-flex-table .ant-spin-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}
.perm-flex-table .ant-table {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.perm-flex-table .ant-table-container {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.perm-flex-table .ant-table-header {
    flex-shrink: 0;
    overflow: hidden !important;
}
.perm-flex-table .ant-table-content,
.perm-flex-table .ant-table-body {
    flex: 1;
    min-height: 0;
    overflow: auto !important;
}
.perm-flex-table .ant-table-wrapper {
    overflow: hidden !important;
}
.perm-flex-table .ant-table-sticky-scroll,
.perm-flex-table .ant-table-sticky-scroll-bar {
    display: none !important;
}
.perm-flex-table .ant-table-pagination {
    flex-shrink: 0;
    margin: 8px 0 0 0;
}

/* 标签页内容区 flex 布局 */
.perm-tab-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    padding: 16px 0;
    overflow: hidden;
}

/* a-spin 容器在权限管理中保持 flex 高度，保证内部滚动生效 */
.perm-tab-content .ant-spin-nested-loading,
.perm-tab-content .ant-spin-container,
.perm-role-panel .ant-spin-nested-loading,
.perm-role-panel .ant-spin-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

/* 角色管理左右分栏 - 填满高度 */
.perm-role-row {
    flex: 1;
    min-height: 0;
    display: flex;
}

.perm-role-row > .ant-col {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* 角色列表面板 */
.perm-role-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

/* 权限配置面板 */
.perm-config-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

/* 权限树容器 - 填满剩余空间 */
.perm-tree-container {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    background: #f5f5f5;
    padding: 16px;
    border-radius: 8px;
}

/* 我的权限卡片 - 填满高度 */
.my-perm-list-card .card-body.flex-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    max-height: none;
}
