/* ===== ERP 系统布局样式 ===== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Microsoft YaHei', Arial, sans-serif;
    color: #333;
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== 顶部标签页栏 ===== */
.tab-bar {
    display: flex;
    align-items: center;
    background-color: #f8f9fa;
    border-bottom: 1px solid #ddd;
    height: 36px;
    flex-shrink: 0;
}

.tab-list {
    display: flex;
    align-items: center;
    flex: 1;
    height: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
}

.tab-list::-webkit-scrollbar {
    height: 4px;
}

.tab-list::-webkit-scrollbar-thumb {
    background: #c0c0c0;
    border-radius: 2px;
}

.tab-list::-webkit-scrollbar-track {
    background: transparent;
}

.tab-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 10px;
    height: 100%;
    min-width: 100px;
    max-width: 220px;
    cursor: pointer;
    border-right: 1px solid #e5e5e5;
    color: #555;
    font-size: 13px;
    transition: background-color 0.15s, color 0.15s;
    flex-shrink: 0;
}

.tab-item:hover {
    background-color: #eef2f7;
}

.tab-item.active {
    background-color: #ffffff;
    color: #165DFF;
    border-bottom: 2px solid #165DFF;
    margin-bottom: -1px;
}

.tab-icon {
    font-size: 12px;
    color: inherit;
    flex-shrink: 0;
}

.tab-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tab-close {
    width: 16px;
    height: 16px;
    line-height: 14px;
    text-align: center;
    border-radius: 50%;
    font-size: 10px;
    color: #999;
    flex-shrink: 0;
    transition: background-color 0.15s, color 0.15s;
}

.tab-close:hover {
    background-color: #d9534f;
    color: #fff;
}

/* 首页固定标签：不可关闭 */
.tab-fixed .tab-close {
    display: none !important;
}

/* 右键菜单禁用项 */
.ctx-item.ctx-disabled,
.ctx-item.ctx-disabled:hover {
    color: #bbb !important;
    cursor: not-allowed;
    background-color: transparent !important;
}

.tab-bar-actions {
    position: relative;  /* 为子元素（如测色仪面板）提供定位上下文 */
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 12px;
    border-left: 1px solid #e5e5e5;
    height: 100%;
    flex-shrink: 0;
    background-color: #f8f9fa;
}

/* ===== 顶栏版本切换菜单（仅管理员可见） ===== */
.edition-switch-container {
    position: relative;
    display: flex;
    align-items: center;
}

.edition-switch-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    cursor: pointer;
    border-radius: 16px;
    background-color: #f0f4f8;
    border: 1px solid #d0d7de;
    transition: all 0.2s ease;
    font-size: 13px;
    color: #374151;
    white-space: nowrap;
}

.edition-switch-btn:hover,
.edition-switch-container.open .edition-switch-btn {
    background-color: #e3ebf3;
    border-color: #b0b8c4;
}

.edition-switch-btn .edition-current {
    font-size: 12px;
    color: #165DFF;
    font-weight: 500;
}

.edition-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 132px;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.12);
    display: none;
    z-index: 1200;
    overflow: hidden;
}

.edition-switch-container.open .edition-menu {
    display: block;
}

.edition-menu-item {
    padding: 8px 14px;
    font-size: 13px;
    color: #374151;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    white-space: nowrap;
}

.edition-menu-item:hover {
    background-color: #eef2f7;
    color: #165DFF;
}

.edition-menu-item.active {
    color: #165DFF;
    font-weight: 500;
    background-color: #f0f6ff;
}

.edition-menu-item .fa-check {
    font-size: 12px;
}

/* ===== 子菜单容器（用户头像下拉等） ===== */
.submenu {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 160px;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 2px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: none;
    z-index: 1000;
}

.submenu-item {
    padding: 6px 16px;
    cursor: pointer;
    white-space: nowrap;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 6px;
}

.submenu-item:hover {
    background-color: #e9ecef;
}

.user-info-container:hover .submenu {
    display: block;
}

.user-info-container {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    cursor: pointer;
    position: relative;
    border-radius: 2px;
}

.user-info-container:hover {
    background-color: #e9ecef;
}

.user-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: #4a6fa5;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.user-name {
    font-size: 14px;
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    cursor: pointer;
    border-radius: 2px;
    color: #333;
}

.logout-btn:hover {
    background-color: #e9ecef;
    color: #d9534f;
}

.enter-mall-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    cursor: pointer;
    border-radius: 2px;
    color: #333;
}

.enter-mall-btn:hover {
    background-color: #e9ecef;
    color: #2563eb;
}

/* ===== 主内容区 ===== */
.main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* ===== 侧边栏展开/收起按钮 ===== */
.sidebar-toggle-btn {
    position: absolute;
    left: 200px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 80px;
    cursor: pointer;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #e8e8e8;
    clip-path: polygon(0 15px, 100% 0, 100% 100%, 0 65px);
    border: 1px solid #d0d0d0;
    border-right: none;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-toggle-btn::before {
    content: '';
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-right: 8px solid #333;
    transition: all 0.3s ease;
}

.sidebar-toggle-btn:hover {
    background-color: #d8d8d8;
}

.sidebar-toggle-btn:hover::before {
    border-right-color: #000;
}

/* ===== 左侧导航 ===== */
.sidebar {
    width: 200px;
    background-color: #f8f9fa;
    border-right: 1px solid #ddd;
    overflow-y: auto;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.sidebar.collapsed {
    width: 0;
    border-right: none;
    overflow: hidden;
    padding: 0;
}

.sidebar.collapsed ~ .sidebar-toggle-btn {
    left: 0;
    clip-path: polygon(100% 15px, 0 0, 0 100%, 100% 65px);
    border: 1px solid #d0d0d0;
    border-left: none;
}

.sidebar.collapsed ~ .sidebar-toggle-btn::before {
    border-right: none;
    border-left: 8px solid #333;
}

.sidebar.collapsed ~ .right-content {
    margin-left: 0;
    border-left: none;
}

.sidebar-section {
    margin-bottom: 1px;
}

.sidebar-title {
    padding: 10px 16px;
    font-weight: 600;
    font-size: 13px;
    color: #333;
    background-color: #e9ecef;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s;
}

.sidebar-title:hover {
    background-color: #dde2e8;
}

.sidebar-title .toggle-icon {
    transition: transform 0.2s ease;
}

.sidebar-section.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.sidebar-subitems {
    display: block;
    transition: max-height 0.3s ease, padding 0.3s ease;
    max-height: 500px;
    overflow: hidden;
}

.sidebar-section.collapsed .sidebar-subitems {
    max-height: 0;
    padding: 0;
}

.sheet-item {
    padding: 9px 24px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.sheet-item:hover {
    background-color: #f1f3f5;
    padding-left: 28px;
}

.sheet-item.active {
    background-color: #a5c8ff !important;
    font-weight: 500;
    border-left: 3px solid #4a6fa5;
    color: #2c3e50;
}

/* ===== 右侧内容容器 ===== */
.right-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-left: 1px solid #ddd;
}

/* ===== 内容区域（iframe 容器） ===== */
.content-area {
    flex: 1;
    position: relative;
    overflow: hidden;
    background-color: #fff;
}

.tab-iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    background-color: #fff;
}

/* ===== 空状态提示（无 tab 时显示） ===== */
.right-empty-area {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 14px;
    pointer-events: none;
}

/* ===== 标签页右键菜单 ===== */
.tab-context-menu {
    position: fixed;
    display: none;
    min-width: 140px;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 10000;
    padding: 4px 0;
}

.ctx-item {
    padding: 6px 16px;
    cursor: pointer;
    font-size: 13px;
    color: #333;
    white-space: nowrap;
}

.ctx-item:hover {
    background-color: #f1f3f5;
    color: #165DFF;
}

/* ===== 界面选择子菜单 ===== */
.interface-options {
    padding: 8px;
}

.interface-option {
    padding: 6px 12px;
    border-radius: 2px;
    margin-bottom: 4px;
    cursor: pointer;
}

.interface-option:hover {
    background-color: #e9ecef;
}

.interface-option.active {
    background-color: #a5c8ff !important;
    font-weight: 500;
}

/* ===== 登录拦截遮罩 ===== */
.login-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.95);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-overlay .login-box {
    text-align: center;
}

.login-overlay .login-box .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e9ecef;
    border-top-color: #4a6fa5;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== 搜索框布局 ===== */
:root {
    --search-category-width: 80px;
    --search-elastic-width: 80px;
    --search-fabric-width: 95px;
    --search-keyword-min-width: 80px;
    --search-btn-width: 60px;
    --search-gap: 6px;
}

/* 下拉菜单隐藏滚动条但保留滚动功能 */
[class$="-dropdown"],
[id$="-dropdown"] {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

[class$="-dropdown"]::-webkit-scrollbar,
[id$="-dropdown"]::-webkit-scrollbar {
    display: none;
}

/* 搜索栏容器 */
.search-bar {
    display: flex;
    gap: var(--search-gap);
    align-items: center;
}

/* 固定宽度的筛选框容器 */
.search-filter {
    flex-shrink: 0;
}

/* 分类搜索框 */
.search-filter-category {
    width: var(--search-category-width);
}

/* 弹力搜索框 */
.search-filter-elastic {
    width: var(--search-elastic-width);
}

/* 织物组织搜索框 */
.search-filter-fabric {
    width: var(--search-fabric-width);
}

/* 关键词搜索框 - 自适应剩余宽度 */
.search-keyword {
    flex: 1;
    min-width: var(--search-keyword-min-width);
}

/* 搜索按钮 - 固定宽度 */
.search-action-btn {
    flex-shrink: 0;
    min-width: var(--search-btn-width);
    padding-left: 8px;
    padding-right: 8px;
    justify-content: center;
}
