/* 基础样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    min-height: 100vh;
    overflow-x: hidden;
}

/* 顶部导航栏 */
.top-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    z-index: 1001;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

/* Auto-hiding top header */
.top-header.auto-hide {
    transform: translateY(-100%);
}

.top-header.auto-hide:hover {
    transform: translateY(0);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-left .logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: #1e3c72;
}

.header-left .logo i {
    font-size: 24px;
    color: #2a5298;
}

.header-right {
    display: flex;
    align-items: center;
}

/* Auto-hiding logout button */
.logout-container {
    position: relative;
    transition: all 0.3s ease;
    opacity: 0.7;
    transform: translateX(20px);
}

.logout-container.auto-hide {
    opacity: 0;
    transform: translateX(30px);
}

.logout-container.auto-hide:hover {
    opacity: 1;
    transform: translateX(0);
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(231, 76, 60, 0.1);
    border: 1px solid rgba(231, 76, 60, 0.3);
    border-radius: 20px;
    color: #e74c3c;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
}

.logout-btn:hover {
    background: rgba(231, 76, 60, 0.2);
    transform: scale(1.05);
}

.logout-btn i {
    font-size: 16px;
}

/* 导航按钮 */
.nav-toggle {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    background: rgba(30, 60, 114, 0.1);
    color: #1e3c72;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.3s ease;
}

.nav-toggle:hover {
    background: rgba(30, 60, 114, 0.2);
    transform: scale(1.05);
}

/* 遮罩层 */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.overlay.active {
    opacity: 1;
    visibility: visible;
}

/* 左侧导航菜单 - 自动隐藏样式 */
.nav-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 250px;
    height: 100vh;
    background: linear-gradient(135deg, #ffb88c 0%, #de6262 100%);
    z-index: 999;
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transform: translateX(-100%);
}

/* Auto-hiding navigation menu */
.nav-popup.auto-hide {
    transform: translateX(-230px);
    transition: transform 0.3s ease;
}

.nav-popup.auto-hide:hover {
    transform: translateX(0);
}

.nav-popup.active {
    transform: translateX(0);
}

/* 导航头部 */
.nav-header {
    padding: 25px 20px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-logo {
    display: flex;
    align-items: center;
    color: white;
}

.nav-logo i {
    font-size: 24px;
    margin-right: 10px;
    color: #4ecca3;
}

.nav-logo h2 {
    font-size: 18px;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    border-radius: 3px;
    transition: background 0.3s ease;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* 导航菜单 */
.nav-menu {
    list-style: none;
    padding: 20px 0;
    flex-grow: 1; /* Allow the menu to grow and take available space */
}

.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    padding: 15px 20px;
    color: #a85d3c;
    cursor: pointer;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: linear-gradient(90deg, #ffd6a0 0%, #ffb88c 100%);
    color: #fff;
    transform: translateX(5px);
}

.nav-item.active {
    background: linear-gradient(90deg, #ffd6a0 0%, #ffb88c 100%);
    color: #fff;
    border-left-color: #4ecca3;
}

.nav-item i {
    font-size: 16px;
    margin-right: 12px;
    width: 20px;
    text-align: center;
}

.nav-item span {
    font-weight: 500;
    flex-grow: 1;
}

.submenu-arrow {
    font-size: 12px;
    transition: transform 0.3s ease;
    color: #ff7e5f;
}

.nav-item.nav-submenu.expanded .submenu-arrow {
    transform: rotate(90deg);
}

/* 子菜单 */
.nav-submenu-list {
    display: none;
    list-style: none;
    padding: 0;
    margin: 0;
    background: rgba(255, 255, 255, 0.1);
    max-height: 300px; /* Add a maximum height */
    overflow-y: auto; /* Allow scrolling if needed */
}

.nav-submenu-list li {
    padding: 12px 20px 12px 40px;
    color: white;
    cursor: pointer;
    font-size: 14px;
    border-left: 3px solid transparent;
    transition: all 0.3s ease;
    white-space: nowrap; /* Prevent text wrapping */
    overflow: hidden;
    text-overflow: ellipsis; /* Add ellipsis for long text */
}

.nav-submenu-list li:hover {
    background: rgba(255, 255, 255, 0.2);
    border-left-color: #4ecca3;
    transform: translateX(3px);
}

.nav-submenu.expanded > .nav-submenu-list {
    display: block;
}

/* 导航底部 */
.nav-footer {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: auto;
}

.system-info {
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
}

.system-info p {
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.system-info .fa-circle.online {
    color: #4ecca3;
    font-size: 8px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.last-update {
    opacity: 0.6;
}

/* 主内容区域 */
.content-area {
    margin-top: 0px; /* Changed from 5px to 0px to reduce total top margin */
    min-height: calc(100vh - 5px);
    padding: 30px 20px;
    transition: margin-left 0.3s ease;
    margin-left: 20px;
}

.content-area.shifted {
    margin-left: 270px;
}

/* 页面样式 */
.page {
    display: none;
    animation: fadeIn 0.5s ease-in-out;
    max-width: 1400px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.page.active-page {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 页面标题 */
.page-title {
    margin-bottom: 30px;
    text-align: center;
}

.page-title h1 {
    font-size: 2.2rem;
    color: #1e3c72;
    margin-bottom: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.page-title p {
    font-size: 1rem;
    color: #666;
    font-weight: 400;
}

/* 统计卡片网格 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border-left: 4px solid;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.stat-card.primary { border-left-color: #ff7e5f; }
.stat-card.success { border-left-color: #4ecca3; }
.stat-card.warning { border-left-color: #f39c12; }
.stat-card.danger { border-left-color: #e74c3c; }

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
}

.stat-card.primary .stat-icon { background: linear-gradient(45deg, #ff7e5f, #feb47b); }
.stat-card.success .stat-icon { background: linear-gradient(45deg, #4ecca3, #44a08d); }
.stat-card.warning .stat-icon { background: linear-gradient(45deg, #f39c12, #e67e22); }
.stat-card.danger .stat-icon { background: linear-gradient(45deg, #e74c3c, #c0392b); }

.stat-content h3 {
    font-size: 2rem;
    font-weight: 700;
    color: #1e3c72;
    margin-bottom: 5px;
}

.stat-content p {
    font-size: 1rem;
    color: #666;
    margin-bottom: 8px;
}

.stat-change {
    font-size: 0.85rem;
    color: #4ecca3;
    font-weight: 500;
}

/* 图表网格 */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.chart-card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.chart-header h3 {
    color: #1e3c72;
    font-size: 1.2rem;
}

.chart-controls {
    display: flex;
    gap: 10px;
}

.btn-sm {
    padding: 6px 12px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-sm.active,
.btn-sm:hover {
    background: #2a5298;
    color: white;
    border-color: #2a5298;
}

.help-icon {
    color: #999;
    cursor: help;
}

/* 饼图 */
.pie-chart {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    margin: 0 auto 20px;
    background: conic-gradient(
        from 0deg,
        #4ecca3 0deg calc(var(--safe-percentage, 65) * 3.6deg),
        #f39c12 calc(var(--safe-percentage, 65) * 3.6deg) calc((var(--safe-percentage, 65) + var(--warning-percentage, 25)) * 3.6deg),
        #e74c3c calc((var(--safe-percentage, 65) + var(--warning-percentage, 25)) * 3.6deg) 360deg
    );
}

.chart-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.legend-color.safe { background: #4ecca3; }
.legend-color.warning { background: #f39c12; }
.legend-color.danger { background: #e74c3c; }

/* 柱状图 */
.bar-chart {
    display: flex;
    align-items: end;
    justify-content: space-around;
    height: 200px;
    padding: 20px 0;
    margin-bottom: 10px;
}

.bar {
    width: 40px;
    background: linear-gradient(to top, #2a5298, #4ecca3);
    border-radius: 4px 4px 0 0;
    display: flex;
    align-items: start;
    justify-content: center;
    padding-top: 10px;
    color: white;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.bar:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(42, 82, 152, 0.3);
}

.chart-labels {
    display: flex;
    justify-content: space-around;
    font-size: 12px;
    color: #666;
}

/* 地图区域 */
.map-section {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.map-header {
    margin-bottom: 20px;
}

.map-header h3 {
    color: #1e3c72;
    font-size: 1.2rem;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.map-header p {
    color: #666;
    font-size: 14px;
}

.map-placeholder {
    height: 400px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.map-mock {
    text-align: center;
    color: #666;
}

.map-mock i {
    font-size: 3rem;
    margin-bottom: 15px;
    color: #2a5298;
}

.map-dots {
    position: absolute;
    width: 100%;
    height: 100%;
}

.dot {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #e74c3c;
    border-radius: 50%;
    box-shadow: 0 0 20px rgba(231, 76, 60, 0.6);
    animation: pulse 2s infinite;
}

/* iframe容器样式 */
.iframe-container {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    animation: fadeIn 0.5s ease;
    height: calc(100vh - 10px);
    min-height: 600px;
    display: flex;
    flex-direction: column;
    margin-top: 5px; /* This will now create exactly 5px distance from browser top */
    position: relative;
}

.iframe-header {
    background: linear-gradient(45deg, #2a5298, #1e3c72);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

/* Auto-hiding iframe header */
.iframe-header.auto-hide {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    transform: translateY(-100%);
    z-index: 10;
}

.iframe-header.auto-hide:hover,
.iframe-container:hover .iframe-header.auto-hide {
    transform: translateY(0);
}

/* Add a hover detection area to make the header easier to access */
.iframe-container:hover .iframe-header.auto-hide::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 20px; /* Extended hover area */
    background: transparent;
}

.iframe-title {
    font-weight: 600;
    font-size: 16px;
}

.iframe-controls {
    display: flex;
    gap: 10px;
}

.iframe-controls .btn-sm {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.iframe-controls .btn-sm:hover {
    background: rgba(255, 255, 255, 0.3);
}

#externalFrame {
    width: 100%;
    height: 100%;
    flex-grow: 1;
    border: none;
    display: block;
    margin-top: 0; /* Remove any default margin */
}

/* 响应式设计 */
@media (max-width: 768px) {
    .nav-popup {
        width: 280px;
        left: -300px;
    }
    
    .content-area.shifted {
        margin-left: 0;
    }
    
    .top-header {
        padding: 0 15px;
    }
    
    .header-left .logo span {
        display: none;
    }
    
    .page {
        padding: 20px 15px;
        margin: 10px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .charts-grid {
        grid-template-columns: 1fr;
    }
    
    .map-placeholder {
        height: 300px;
    }
    
    .iframe-container {
        height: calc(100vh - 10px);
        min-height: 500px;
    }
    
    #externalFrame {
        height: 400px;
    }
}

@media (max-width: 480px) {
    .nav-toggle {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }
    
    .page-title h1 {
        font-size: 1.8rem;
    }
    
    .stat-card {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }
    
    .chart-controls {
        flex-direction: column;
    }
}