/* 全局滚动条样式 */
/* Webkit 浏览器 (Chrome, Safari, Edge) */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #1a2a3a;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb {
    background: #3c5472;
    border-radius: 5px;
    border: 2px solid #1a2a3a;
}

::-webkit-scrollbar-thumb:hover {
    background: #4a6a8a;
}

::-webkit-scrollbar-thumb:active {
    background: #00bcd4;
}

::-webkit-scrollbar-corner {
    background: #1a2a3a;
}

/* Firefox 浏览器 */
* {
    scrollbar-width: thin;
    scrollbar-color: #3c5472 #1a2a3a;
}

/* 基本重置 */
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #1a2a3a; /* 深蓝色背景 */
    color: #e0e6ed; /* 浅色文本 */
    line-height: 1.6;
}

.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* 顶部栏 */
.app-header {
    background-color: #2a3d54; /* 稍亮的深蓝色 */
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #3c5472;
    z-index: 1000;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
}

.logo {
    font-size: 24px;
    font-weight: bold;
    color: #00bcd4; /* 青色强调色 */
    margin-right: 15px;
}

.system-title {
    font-size: 18px;
    color: #a7bed3;
}

.user-info {
    margin-right: 20px;
    color: #666;
    display: flex;
    align-items: center;
}
.user-info i {
    margin-right: 8px;
    font-size: 1.2em;
    color: #00bcd4; /* 青色强调色 */
}

.icon-button {
    background: none;
    border: none;
    font-size: 1.2em;
    color: #a7bed3;
    cursor: pointer;
    margin-left: 15px;
    position: relative;
    padding: 5px;
}
.icon-button:hover {
    color: #00bcd4;
}
.icon-button .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: #e74c3c; /* 红色 */
    color: white;
    font-size: 0.7em;
    border-radius: 50%;
    padding: 3px 6px;
    min-width: 10px;
    text-align: center;
}

/* 主体区域 */
.main-wrapper {
    display: flex;
    flex: 1;
}

/* 侧边栏 */
.app-sidebar {
    width: 250px;
    background-color: #213245; /* 深侧边栏背景色 */
    color: #e0e6ed;
    padding: 20px 0;
    box-shadow: 2px 0 10px rgba(0,0,0,0.3);
    flex-shrink: 0;
}

.main-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-item a {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    color: #b0c4de; /* 浅蓝色文本 */
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500; /* 提升一级菜单字体粗细 */
    position: relative;
    border-radius: 6px;
    margin: 2px 8px;
    user-select: none;
    cursor: pointer;
}

.nav-item a:active {
    transform: translateX(2px) scale(0.98);
    transition: transform 0.1s ease;
}

.nav-item a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    background-color: #00bcd4;
    border-radius: 0 3px 3px 0;
    transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item a i {
    margin-right: 10px;
    font-size: 1.1em;
    color: #b0c4de; /* 一级菜单图标与文字颜色一致 */
    vertical-align: middle; /* 垂直居中对齐 */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item.active > a {
    background-color: #2a3d54; /* 激活背景色 */
    color: #00bcd4; /* 青色强调色 */
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 188, 212, 0.15);
}

.nav-item.active > a::before {
    height: 60%;
}

.nav-item > a:hover {
    background-color: #253447; /* hover背景色，比激活稍浅 */
    color: #00bcd4; /* 青色强调色 */
    transform: translateX(2px);
}

.nav-item.active > a i,
.nav-item > a:hover i {
    color: #00bcd4; /* 激活/hover图标颜色 */
    transform: scale(1.1);
}

.nav-item a .fa-analytics {
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    display: inline-block;
    /* 可以根据需要调整颜色和大小，以确保显示 */
    color: #b0c4de; /* 保持与其他一级菜单图标一致 */
    font-size: 1.1em; /* 保持与其他一级菜单图标一致 */
}

.main-nav ul ul {
    list-style: none;
    padding: 0;
    margin: 0;
    background-color: #1e2d3c; /* 二级菜单背景色，比一级深 */
    max-height: 0; /* 默认折叠 */
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    opacity: 0;
    border-left: 2px solid transparent;
    margin-left: 8px;
}

.main-nav ul ul.active {
    max-height: 1000px; /* 展开足够大的高度 */
    opacity: 1;
    border-left-color: #00bcd4;
    padding-top: 4px;
    padding-bottom: 4px;
}

.nav-item-sub a {
    padding: 12px 20px 12px 50px; /* 二级菜单更深的缩进 */
    color: #a7bed3; /* 二级菜单文字颜色 */
    text-decoration: none;
    display: flex;
    align-items: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    border-radius: 6px;
    margin: 2px 8px;
    font-size: 14px;
    user-select: none;
    cursor: pointer;
}

.nav-item-sub a:active {
    transform: translateX(4px) scale(0.98);
    transition: transform 0.1s ease;
}


.nav-item-sub a:hover {
    background-color: #253447; /* hover背景色 */
    color: #00bcd4;
    transform: translateX(4px);
}

.nav-item-sub.active > a {
    background-color: #2a3d54; /* 二级菜单激活背景色 */
    color: #00bcd4;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 188, 212, 0.15);
}


.nav-item-sub a i {
    margin-right: 10px;
    font-size: 0.95em;
    color: #a7bed3; /* 二级菜单图标与文字颜色一致 */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item-sub.active > a i,
.nav-item-sub > a:hover i {
    color: #00bcd4; /* 二级菜单激活/hover图标颜色 */
    transform: scale(1.1);
}

.submenu-inner {
    list-style: none;
    padding: 0;
    margin: 0;
    background-color: #1a2a3a; /* 三级菜单背景色，与主背景色相同 */
    max-height: 0; /* 默认折叠 */
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    opacity: 0;
    border-left: 2px solid transparent;
    margin-left: 20px;
}

.submenu-inner.active {
    max-height: 500px; /* 展开足够大的高度 */
    opacity: 1;
    border-left-color: #00bcd4;
    padding-top: 4px;
    padding-bottom: 4px;
}

.nav-item-sub-inner a {
    padding: 10px 20px 10px 70px; /* 三级菜单更深的缩进 */
    color: #b0c4de;
    text-decoration: none;
    display: flex;
    align-items: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    border-radius: 6px;
    margin: 2px 8px;
    font-size: 13px;
    user-select: none;
    cursor: pointer;
}

.nav-item-sub-inner a:active {
    transform: translateX(4px) scale(0.98);
    transition: transform 0.1s ease;
}

.nav-item-sub-inner a::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 3px;
    background-color: #5d7d9a;
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item-sub-inner a:hover {
    background-color: #213245; /* hover背景色 */
    color: #00bcd4;
    transform: translateX(4px);
    padding-left: 74px;
}

.nav-item-sub-inner.active > a {
    background-color: #213245; /* 三级菜单激活背景色 */
    color: #00bcd4;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 188, 212, 0.15);
    padding-left: 74px;
}

.nav-item-sub-inner.active > a::before {
    background-color: #00bcd4;
    width: 5px;
    height: 5px;
    left: 6px;
}

.nav-item-sub-inner a i {
    margin-right: 10px;
    font-size: 0.9em;
    color: #b0c4de; /* 三级菜单图标与文字颜色一致 */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item-sub-inner.active > a i,
.nav-item-sub-inner > a:hover i {
    color: #00bcd4; /* 三级菜单激活/hover图标颜色 */
    transform: scale(1.1);
}

.nav-link.has-sub, .nav-link-sub.has-sub {
    position: relative;
}

.nav-link.has-sub::after, .nav-link-sub.has-sub::after {
    content: '\f107'; /* Font Awesome chevron-down icon */
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    color: #5d7d9a; /* 下拉箭头颜色 */
    font-size: 0.85em;
}

.nav-item.active > .nav-link.has-sub::after, .nav-item-sub.active > .nav-link-sub.has-sub::after {
    transform: translateY(-50%) rotate(180deg);
    color: #00bcd4; /* 激活时下拉箭头颜色 */
}

.nav-link.has-sub:hover::after, .nav-link-sub.has-sub:hover::after {
    color: #00bcd4;
}

/* 主内容区域 */
.app-content {
    flex: 1;
    padding: 30px;
    overflow-y: auto; /* 允许滚动 */
    overflow-x: hidden; /* 隐藏横向滚动条 */
    position: relative; /* 确保定位上下文 */
    z-index: 1; /* 低于弹窗 */
}

.content-container {
    background-color: #2a3d54; /* 深色内容区背景 */
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    margin-bottom: 20px;
    display: none; /* 默认隐藏所有内容区 */
    min-height: 600px; /* 最小高度 */
}
.content-container.active {
    display: block; /* 显示激活的内容区 */
}

.embedded-page-frame {
    width: 100%;
    min-height: 900px;
    border: none;
    display: block;
    background-color: #0a1929;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

h2 {
    color: #00bcd4; /* 青色标题 */
    margin-top: 0;
    margin-bottom: 25px;
    border-bottom: 2px solid #3c5472;
    padding-bottom: 15px;
    display: flex;
    align-items: center;
}
h2 i {
    margin-right: 15px;
    color: #00bcd4;
}

/* 卡片样式 */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.card {
    background-color: #2a3d54; /* 卡片背景色 */
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.4);
}

.card-title {
    font-size: 1.1em;
    font-weight: bold;
    color: #e0e6ed; /* 浅色卡片标题 */
    margin-bottom: 15px;
    display: flex;
    align-items: center;
}
.card-title i {
    margin-right: 10px;
    color: #00bcd4;
}

.kpi-value {
    font-size: 2.5em;
    font-weight: bold;
    color: #00bcd4; /* 青色强调 */
    margin-bottom: 5px;
}

.kpi-unit {
    font-size: 0.9em;
    color: #a7bed3;
    margin-bottom: 15px;
}

.kpi-trend {
    font-size: 0.9em;
    display: flex;
    align-items: center;
}
.kpi-trend.positive {
    color: #4CAF50; /* 绿色 */
}
.kpi-trend.negative {
    color: #FF5252; /* 红色 */
}
.kpi-trend i {
    margin-right: 5px;
}

/* 告警卡片 */
.alert-card {
    background-color: #422a30; /* 深红背景 */
    border-left: 5px solid #FF5252; /* 红色边框 */
    color: #FF5252;
}

.alert-card .card-title {
    color: #FF5252;
}
.alert-card .card-title i {
    color: #FF5252;
}

/* 数据表格 */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.data-table th, .data-table td {
    border: 1px solid #3c5472;
    padding: 12px 15px;
    text-align: left;
}

.data-table th {
    background-color: #3c5472;
    color: #e0e6ed;
    font-weight: 600;
}

.data-table tr:nth-child(even) {
    background-color: #2a3d54; /* 偶数行背景 */
}

.data-table tr:hover {
    background-color: #3c5472; /* 悬停效果 */
}

/* 筛选器 */
.filter-bar {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-bar label {
    font-weight: 600;
    color: #a7bed3;
    margin-right: 5px;
}

.filter-bar select, .filter-bar input[type="date"], .filter-bar input[type="text"], .filter-bar button {
    padding: 10px 15px;
    border: 1px solid #3c5472;
    background-color: #2a3d54;
    color: #e0e6ed;
    border-radius: 5px;
    font-size: 0.9em;
}

.filter-bar button {
    background-color: #00bcd4;
    color: white;
    cursor: pointer;
    transition: background-color 0.3s ease;
}
.filter-bar button:hover {
    background-color: #0097a7;
}

/* 图表容器 */
.chart-container {
    height: 350px; /* 默认图表高度，可以被内联样式覆盖 */
    margin-bottom: 30px;
    background-color: #2a3d54; /* 图表背景色 */
    border: 1px solid #3c5472;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    color: #a7bed3; /* 提示文字颜色 */
    font-style: italic;
    min-height: auto;
    max-height: none;
    box-sizing: border-box;
}

.data-point {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    transform: translate(-50%, -50%); /* 精确居中数据点 */
    z-index: 10;
}

/* 警告/危险颜色 */
.color-warning { color: #f39c12; } /* 橙色 */
.color-danger { color: #e74c3c; } /* 红色 */
.color-success { color: #27ae60; } /* 绿色 */


/* Tab 导航样式 */
.tab-nav {
    display: flex;
    border-bottom: 2px solid #3c5472;
    margin-bottom: 25px;
    overflow-x: auto; /* 确保在小屏幕下可以滚动 */
}

.tab-button {
    background: none;
    border: none;
    padding: 12px 20px;
    font-size: 1em;
    cursor: pointer;
    color: #a7bed3;
    white-space: nowrap; /* 防止按钮文字换行 */
    border-bottom: 2px solid transparent;
    transition: color 0.3s ease, border-bottom-color 0.3s ease;
}

.tab-button:hover {
    color: #00bcd4;
}

.tab-button.active {
    color: #00bcd4;
    border-bottom-color: #00bcd4;
    font-weight: bold;
}

.tab-content {
    display: none; /* 默认隐藏所有 tab 内容 */
}

.tab-content.active {
    display: block; /* 显示激活的 tab 内容 */
}

.action-button {
    background-color: #00bcd4;
    color: white;
    padding: 8px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    margin-left: 10px;
}
.action-button:hover {
    background-color: #0097a7;
}

.control-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-width: 400px;
    margin-top: 20px;
}
.control-form label {
    font-weight: 600;
    color: #a7bed3;
}
.control-form select {
    padding: 10px;
    border: 1px solid #3c5472;
    background-color: #2a3d54;
    color: #e0e6ed;
    border-radius: 5px;
    font-size: 1em;
}

.dimension-tag {
    display: inline-flex;
    align-items: center;
    background-color: #1e2d3c;
    color: #00bcd4;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.9em;
    margin-right: 8px;
    border: 1px solid #00bcd4;
}

.dimension-tag i {
    margin-left: 8px;
    cursor: pointer;
    color: #a7bed3;
}
.dimension-tag i:hover {
    color: #FF5252;
}

/* 响应式设计（简化版）*/
@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        align-items: flex-start;
        padding: 10px 15px;
    }
    .header-right {
        margin-top: 10px;
    }
    .main-wrapper {
        flex-direction: column;
    }
    .app-sidebar {
        width: 100%;
        padding: 10px 0;
        box-shadow: none;
        border-bottom: 1px solid #333;
    }
    .main-nav ul {
        display: flex;
        overflow-x: auto; /* 菜单在小屏下可横向滚动 */
        padding: 0 10px;
    }
    .main-nav li {
        flex: 0 0 auto;
        margin-right: 10px;
    }
    .app-content {
        padding: 15px;
    }
    .card-grid {
        grid-template-columns: 1fr;
    }
    .filter-bar {
        flex-direction: column;
        align-items: flex-start;
    }
    .filter-bar select, .filter-bar input, .filter-bar button {
        width: 100%;
        box-sizing: border-box; /* 包含内边距和边框在宽度内 */
    }
    .tab-nav {
        flex-wrap: nowrap;
    }
    .tab-button {
        flex-shrink: 0; /* 防止按钮缩小 */
    }
}

/* 统一的模态框（弹窗）样式 */
.modal-overlay {
    display: none;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background-color: rgba(0, 0, 0, 0.7) !important;
    z-index: 999999 !important;
    align-items: center !important;
    justify-content: center !important;
    backdrop-filter: blur(4px) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 0 !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    /* 确保在最上层，不被遮挡 */
    pointer-events: auto !important;
}

.modal-overlay.active {
    display: flex !important;
}

/* 在iframe环境中，使用绝对定位确保弹窗正确显示 */
iframe ~ .modal-overlay,
body > .modal-overlay {
    position: fixed;
}

/* 如果弹窗在iframe内，确保它能覆盖整个iframe视口 */
.sub-menu-content-container .modal-overlay,
.kpi-model-config-container .modal-overlay,
[class*="-container"] .modal-overlay {
    position: fixed;
    z-index: 999999;
}

.modal-content,
.modal-dialog {
    background: linear-gradient(135deg, #2a3d54 0%, #1a2a3a 100%) !important;
    border: 1px solid #3c5472 !important;
    border-radius: 12px !important;
    padding: 0 !important;
    width: 90% !important;
    max-width: min(800px, 90vw) !important;
    max-height: 90vh !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5) !important;
    animation: modalSlideIn 0.3s ease;
    position: relative !important;
    margin: 20px auto !important;
    z-index: 1000000 !important;
    /* 确保在flex容器中完全居中 */
    align-self: center !important;
    flex-shrink: 0 !important;
    /* 完全依赖flexbox居中，确保内容完整显示 */
    box-sizing: border-box !important;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #3c5472;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #1a2a3a 0%, #2a3d54 100%);
    border-radius: 12px 12px 0 0;
}

.modal-title {
    font-size: 20px;
    color: #00bcd4;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.modal-close {
    background: transparent;
    border: none;
    color: #a7bed3;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
    line-height: 1;
}

.modal-close:hover {
    background: rgba(244, 67, 54, 0.2);
    color: #f44336;
    transform: rotate(90deg);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 15px 24px;
    border-top: 1px solid #3c5472;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: linear-gradient(135deg, #1a2a3a 0%, #2a3d54 100%);
    border-radius: 0 0 12px 12px;
}

/* 表单样式 */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-label {
    color: #a7bed3;
    font-size: 14px;
    margin-bottom: 8px;
    font-weight: 500;
}

.form-label.required::after {
    content: ' *';
    color: #f44336;
}

.form-input,
.form-select {
    background-color: #1a2a3a;
    border: 1px solid #3c5472;
    color: #e0e6ed;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s ease;
    width: 100%;
    box-sizing: border-box;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: #00bcd4;
    box-shadow: 0 0 0 3px rgba(0, 188, 212, 0.1);
}

.form-textarea {
    background-color: #1a2a3a;
    border: 1px solid #3c5472;
    color: #e0e6ed;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 14px;
    min-height: 80px;
    resize: vertical;
    font-family: inherit;
    transition: all 0.2s ease;
    width: 100%;
    box-sizing: border-box;
}

.form-textarea:focus {
    outline: none;
    border-color: #00bcd4;
    box-shadow: 0 0 0 3px rgba(0, 188, 212, 0.1);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 20px;
    border-top: 1px solid #3c5472;
    margin-top: 20px;
}