/* =========================================
   1. 全局与 Grid 容器布局
   ========================================= */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #f5f7fa;
}

/* 统一滚动条样式 */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 3px; }

.custom-report-container {
    display: flex;
    width: 100%;
    height: 100%;
    background-color: #f5f7fa;
}

/* =========================================
   2. 第一列：维度列表 (固定宽度)
   ========================================= */
.col-dimension {
    width: 300px;
    min-width: 300px;
    background: #fff;
    border-right: 1px solid #e6e6e6;
    display: flex;
    flex-direction: column;
    z-index: 10;
    flex-shrink: 0;
    overflow: auto;
    padding: 15px;
}

/* =========================================
   3. 第二列：报表列表 (可折叠)
   ========================================= */
.col-report-list {
    width: 250px;
    min-width: 250px;
    background: #fff;
    border-right: 1px solid #e6e6e6;
    display: flex;
    flex-direction: column;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), margin 0.3s ease;
    position: relative;
    flex-shrink: 0;
    z-index: 9;
}
.col-report-list-btn {
    width: 0;
    background: #fff;
    border-right: 1px solid #e6e6e6;
    display: flex;
    flex-direction: column;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), margin 0.3s ease;
    position: relative;
    flex-shrink: 0;
    z-index: 9;
}

/* 折叠状态：宽度变为 0，隐藏内容 */
.col-report-list.collapsed {
    width: 0;
    min-width: 0;
    margin-right: 0;
    padding: 0;
    overflow: hidden;
    border-right: none;
}

/* 折叠按钮 (悬浮在第二列右侧) */
.list-collapse-btn {
    position: absolute;
    top: 50%;
    left: -5px; /* 悬浮在边框外 */
    transform: translateY(-50%);
    width: 24px;
    height: 48px;
    background: #fff;
    border: 1px solid #e6e6e6;
    border-left: none;
    border-radius: 0 4px 4px 0;
    color: #409EFF;
    cursor: pointer;
    z-index: 100;
    font-size: 14px;
    line-height: 48px;
    text-align: center;
    box-shadow: -2px 0 6px rgba(0,0,0,0.05);
    transition: all 0.2s;
}
.list-collapse-btn:hover {
    background: #f0f9ff;
    color: #409EFF;
}
/* 当列表折叠时，按钮翻转箭头 */
.col-report-list.collapsed .list-collapse-btn {
    transform: translateY(-50%) rotate(180deg);
}

/* 第二列内部结构 */
.report-list-header {
    padding: 15px;
    border-bottom: 1px solid #f0f0f0;
    background: #fff;
    flex-shrink: 0;
}
.report-list-header h4 { margin: 0; font-size: 14px; font-weight: 600; color: #333; }

.report-list-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    background: #fff;
}

/* =========================================
   4. 第三列：配置与预览 (自适应)
   ========================================= */
.col-config-preview {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f5f7fa;
    min-width: 0; /* 防止内容撑开 */
    position: relative;
}

/* 配置区域 (上方) */
.config-area {
    background: #fff;
    border-bottom: 1px solid #e6e6e6;
    padding: 15px;
    overflow-y: auto;
    /* 初始状态：展开 */
    max-height: 40vh;
    transition: max-height 0.3s ease;
    position: relative;
    flex-shrink: 0; /* 防止被压缩 */
}

/* 配置区域折叠时的样式 */
.config-area.collapsed {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-top: 0;
    margin-bottom: 0;
    border-bottom: none;
    overflow: hidden;
}

/* 展开/收起按钮 (悬浮在配置区域顶部) */
.config-toggle-btn {
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    height: 30px;
    background: rgba(255, 255, 255, 0.9);
    border-bottom: 1px solid #e6e6e6;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #409EFF;
    font-size: 12px;
    font-weight: bold;
    z-index: 5;
    transition: all 0.3s;
    opacity: 0; /* 默认隐藏，鼠标悬停显示 */
}
.config-area:hover .config-toggle-btn {
    opacity: 1;
}
.config-area.collapsed .config-toggle-btn {
    opacity: 1; /* 折叠时始终显示 */
}

/* 预览区域 (下方，自适应) */
.preview-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f5f7fa;
    padding: 0 15px 15px 0;
    overflow: hidden;
}

.preview-container {
    flex: 1;
    background: #fff;
    border: 1px solid #e6e6e6;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 300px;
}

.preview-header {
    padding: 10px 15px;
    background: #f9f9f9;
    border-bottom: 1px solid #e6e6e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.preview-content {
    flex: 1;
    overflow: auto;
    padding: 15px;
    min-width: 0; /* 关键：允许内部表格滚动 */
}

/* =========================================
   5. 通用组件样式 (复用与优化)
   ========================================= */
/* 维度列表项 */
.dim-list .dim-item {
    display: flex; align-items: center;
    padding: 10px 12px; margin: 6px 0;
    background: #f5f7fa; border: 1px solid #ebeef5;
    border-radius: 4px; cursor: move; font-size: 14px;
    transition: all 0.2s;
    user-select: none;
}
.dim-item:hover {
    background: #ecf5ff; border-color: #409EFF; transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(64, 158, 255, 0.15);
}
.dim-item:active { cursor: grabbing; }

/* 标签颜色 */
.dim-tag {
    display: inline-block; width: 36px; height: 20px; line-height: 20px;
    text-align: center; border-radius: 3px; margin-right: 8px; font-size: 12px; color: #fff; flex-shrink: 0;
}
.dim-tag-row { background: #409eff; }
.dim-tag-col { background: #67c23a; }
.dim-tag-zhibiao { background: #f5222d; }
.dim-tag-rowcol { background: #faad14; }

/* 下拉框 */
.custom-select { position: relative; width: 100%; margin-bottom: 15px; }
.select-trigger {
    display: flex; justify-content: space-between;
    padding: 8px 12px; border: 1px solid #dcdfe6; border-radius: 6px;
    background: #fff; cursor: pointer; font-size: 14px;
}
.select-trigger:hover { border-color: #409EFF; }
.arrow { color: #999; font-size: 12px; }
.dropdown-menu {
    position: absolute; top: 100%; left: 0; right: 0;
    background: #fff; border: 1px solid #e4e7ed; border-radius: 6px;
    box-shadow: 0 2px 12px 0 rgba(0,0,0,0.1);
    list-style: none; padding: 6px 0; z-index: 1001;
    max-height: 200px; overflow-y: auto;
}
.dropdown-menu li { padding: 8px 12px; cursor: pointer; }
.dropdown-menu li:hover { background: #f0f9ff; color: #409EFF; }

/* 报表列表项 */
.report-item {
    padding: 10px 15px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 0 0 4px 4px;
}
.report-item:last-child { border-bottom: none; }
.report-item:hover { background: #f5f7fa; }
.report-item .report-actions button {
    border: none; width: 38px;padding: 0;background: none;cursor: pointer;font-size: 12px;
}
.report-item .edit-btn { color: #409EFF; }
.report-item .delete-btn { color: #f5222d; }
.report-item .edit-btn:hover { background: #ecf5ff; }
.report-item .delete-btn:hover { background: #fef0f0; }

.empty-state {
    text-align: center; padding: 30px 0; color: #999; font-size: 13px;
}

/* 拖拽区域 */
.drop-area {
    min-width: 300px; max-width: 500px; border: 1px dashed #dcdfe6; border-radius: 6px;
    padding: 8px; background: #fafafa; color: #909399; font-size: 14px;
    display: flex; flex-wrap: wrap; gap: 6px;
    transition: all 0.2s;
}
.drop-area.drag-over { border-color: #409EFF; background: #ecf5ff; color: #409EFF; }
.drop-area strong { display: block; width: 100%; pointer-events: none; }

/* 拖入标签 */
.drag-item {
    display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 4px;
    font-size: 13px; cursor: move; background: #c6ecff; color: #1890ff;
    border: 1px solid #91d5ff; box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.drag-item .dim-tag { width: 24px; height: 18px; line-height: 18px; margin-right: 5px; font-size: 10px; }
.drag-item .close { margin-left: 6px; font-size: 14px; color: #909399; cursor: pointer; border-radius: 50%; width: 18px; height: 18px; line-height: 18px; text-align: center; background: rgba(255,255,255,0.5); }
.drag-item .close:hover { color: #f56c6c; background: #fef0f0; }

/* 表单控件 */
.dim-row { display: flex; align-items: center; margin-bottom: 14px; font-size: 14px;}
.dim-label { width: 80px; text-align: right; color: #606266; font-weight: 600; padding-right: 10px; flex-shrink: 0; line-height: 30px; }
/*
input[type="text"], input[type="date"], select {
    flex: 1; padding: 6px 10px; border: 1px solid #dcdfe6; border-radius: 4px;
    font-size: 14px; outline: none; height: 36px; box-sizing: border-box;
}
input[type="text"]:focus, input[type="date"]:focus, select:focus { border-color: #409EFF; box-shadow: 0 0 0 2px rgba(64, 158, 255, 0.1); }
*/
.action-buttons { display: flex; gap: 8px; }
.action-buttons button {
    padding: 6px 16px; border: none; border-radius: 4px; font-size: 14px; cursor: pointer; font-weight: 500;
}
.btn-save { background: #67c23a; color: #fff; }
.btn-save:hover { background: #529b2e; box-shadow: 0 2px 4px rgba(103, 194, 58, 0.3); }
.btn-reset { background: #fff; color: #606266; border: 1px solid #dcdfe6; }
.btn-reset:hover { background: #f5f7fa; border-color: #c0c4cc; }

/* Switch */
.switch { position: relative; display: inline-block; width: 36px; height: 20px; margin-left: 5px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .3s; border-radius: 20px; }
.slider:before { position: absolute; content: ""; height: 14px; width: 14px; left: 3px; bottom: 3px; background-color: white; transition: .3s; border-radius: 50%; box-shadow: 0 1px 2px rgba(0,0,0,0.2); }
input:checked + .slider { background-color: #409EFF; }
input:checked + .slider:before { transform: translateX(16px); }

.date-group { display: flex; align-items: center; gap: 8px; }
.line { color: #909399; font-size: 16px; margin: 0 4px; }

/* 响应式 */
@media (max-width: 1400px) {
    .col-dimension { width: 250px; min-width: 250px; }
    .col-report-list { width: 220px; min-width: 220px; }
    .col-report-list-btn { width: 20px }
    .dim-label { width: 70px; }
}