/* ==========================================
   全局及布局样式
   ========================================== */

/* 基础布局 */
body {
    font-family: 'Microsoft YaHei', sans-serif;
    margin: 0;
    padding: 0;
    display: flex;
    height: 100vh;
    background-color: #f4f7f6;
}

/* ==========================================
   左侧菜单栏
   ========================================== */
.sidebar {
    width: 220px;
    background-color: #2c3e50;
    color: white;
    display: flex;
    flex-direction: column;
}

.menu-title {
    padding: 20px;
    text-align: center;
    font-size: 18px;
    font-weight: bold;
    border-bottom: 1px solid #34495e;
}

.menu-group {
    padding: 10px 0;
}

.menu-item {
    padding: 15px 20px;
    cursor: pointer;
    transition: 0.3s;
}

.menu-item:hover,
.menu-item.active {
    background-color: #34495e;
}

.submenu {
    display: none;
    background-color: #22303f;
}

.submenu .sub-item {
    padding: 10px 30px;
    cursor: pointer;
}

.submenu .sub-item:hover,
.submenu .sub-item.active {
    background-color: #1a252f;
}

/* ==========================================
   右侧主内容区
   ========================================== */
.main-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.panel {
    display: none;
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.panel.active {
    display: block;
}

/* ==========================================
   控件样式（按钮、输入框、选择框）
   ========================================== */
.controls {
    margin-bottom: 20px;
    text-align: center;
}

select,
button {
    padding: 8px 15px;
    margin: 0 10px;
    border-radius: 4px;
    border: 1px solid #ccc;
}

button {
    background-color: #007bff;
    color: white;
    border: none;
    cursor: pointer;
}

button:hover {
    background-color: #0056b3;
}

.btn-success {
    background-color: #28a745;
}

#status {
    margin-top: 10px;
    font-weight: bold;
    text-align: center;
}

#container {
    border: 1px solid #ddd;
    margin-top: 20px;
    background-color: #fafafa;
    margin: 0 auto;
}

/* 表格样式（用户管理、系统查询等使用） */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

th,
td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}

th {
    background-color: #f2f2f2;
}

input[type="text"],
input[type="number"] {
    width: 100%;
    padding: 5px;
    box-sizing: border-box;
}

/* ==========================================
   弹窗样式（登录、编辑、地图）
   ========================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 20px;
    border-radius: 8px;
    width: 90%;
    max-width: 1200px;
    height: 85vh;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    position: relative;
    display: flex;
    flex-direction: column;

    /* ★ 新增：限制高度并允许内部滚动 */
    max-height: 80vh;
    overflow-y: auto;
}

/* 最大化状态 */
.modal-content.maximized {
    width: 98vw;
    height: 98vh;
    max-width: 100%;
    border-radius: 0;
}

#map {
    flex: 1;
    width: 100%;
    border-radius: 4px;
    margin-top: 10px;
}

/* 摄像头表格缩略图与预览样式 */
.thumb-box {
    position: relative;
    display: inline-block;
    cursor: pointer;
}

.thumb-img {
    width: 80px;
    height: 45px; /* 16:9 比例 */
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #ddd;
    display: block;
}

.preview-popup {
    display: none;
    position: fixed; /* 使用fixed防止被表格或容器overflow裁剪 */
    z-index: 9999;
    width: 640px;
    height: 360px;
    background: #fff;
    border: 2px solid #ccc;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    pointer-events: none; /* 防止鼠标移动到弹窗后触发闪烁/消失 */
    overflow: hidden;
}

.preview-popup img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* 完整显示640x360图片 */
}

/* 地图弹窗必须保持最高层级，防止被其他弹窗遮挡 */
#mapModal {
    z-index: 5000 !important;
}

/* 摄像头悬浮/点击弹窗样式 */
.cam-count {
    color: #007bff;
    cursor: pointer;
    text-decoration: underline;
    position: relative;
    display: inline-block;
}

.cam-tooltip {
    display: none;
    width: 320px;
    background-color: #fff;
    border: 1px solid #ccc;
    color: #333;
    text-align: left;
    border-radius: 6px;
    padding: 8px;
    position: absolute;
    z-index: 100;
    bottom: 125%;
    left: 0;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* 按钮容器：让复制和关闭并排 */
.tooltip-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.cam-tooltip .copy-btn,
.cam-tooltip .close-btn {
    background-color: #007bff;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 12px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
}

.cam-tooltip .close-btn {
    background-color: #dc3545; /* 关闭按钮设为红色 */
}

.cam-tooltip .tooltip-scroll {
    overflow-y: auto;
    max-height: 150px;
    line-height: 1.5;
    font-size: 13px;
    word-break: break-all;
    display: block;
}

/* ★ 放大并变蓝树状展开/收起图标（+/-号） */
#statsResult span[onclick="toggleStatsRow(this)"] {
    font-size: 22px;          /* 放大字体 */
    font-weight: bold;        /* 加粗 */
    color: #007bff;           /* 变成蓝色 */
    cursor: pointer;          /* 鼠标放上去变成小手 */
    margin-right: 8px;        /* 与文字的距离稍微加大 */
    line-height: 1;
    user-select: none;        /* 防止双击选中 */
}
/* ==========================================
   美化红框区域（主内容区与默认仪表盘）
   ========================================== */

/* 1. 优化主内容区背景（红框区域） */
.main-content {
    flex: 1;
    padding: 30px; /* 增加内边距，让内容不贴边 */
    overflow-y: auto;
    background: linear-gradient(135deg, #e0f7fa 0%, #ffffff 100%); /* 浅蓝色渐变背景 */
    box-sizing: border-box;
}

/* 2. 美化默认仪表盘容器（主体） */
.default-dashboard {
    padding: 40px;
    background: rgba(255, 255, 255, 0.85);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    /* 修改：取消强制撑满高度，让其自适应内容并居中 */
    min-height: auto;

    /* 新增：使白色区域水平居中，并限制最大宽度 */
    width: calc(100% - 60px);
    max-width: 1200px;
    margin: 0 auto;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center; /* 新增：让标题和网格整体垂直居中 */
    gap: 50px; /* 新增：标题和卡片之间留出合适的间距 */
    animation: fadeInDown 0.8s ease-out;
}

/* 3. 优化标题区 */
.dashboard-header {
    text-align: center;
    margin-bottom: 50px;
}

.dashboard-header h1 {
    font-size: 3rem;
    color: #333;
    margin-bottom: 10px;
    background: linear-gradient(45deg, #007bff, #00c6ff, #28a745);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
    letter-spacing: 2px; /* 增加字间距，更显大气 */
}

.dashboard-header p {
    color: #666;
    font-size: 1.1rem;
    font-weight: 500;
}

/* 4. 优化卡片网格（间距更舒服） */
.dashboard-grid {
    display: grid;
    /* ★ 强制为4列布局，避免7个卡片导致留白 */
    grid-template-columns: repeat(4, 1fr);
    gap: 25px;
    width: 100%;
    max-width: 1100px;
}

/* ★ 新增：退出登录卡片的特殊样式 */
.dashboard-card.exit-card {
    border: 1px solid #ffebeb;
}
.dashboard-card.exit-card:hover {
    background: #fff5f5;
    border-color: #ff4d4f;
    box-shadow: 0 10px 20px rgba(255, 77, 79, 0.15);
}
.dashboard-card.exit-card .card-icon {
    background: linear-gradient(135deg, #ffebeb, #fff0f0);
    color: #ff4d4f;
}
.dashboard-card.exit-card:hover .card-icon {
    background: linear-gradient(135deg, #ff4d4f, #ff7875);
    color: #ffffff;
}

/* 5. 美化卡片本体（边框、阴影、微交互） */
.dashboard-card {
    background: #ffffff;
    border-radius: 16px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    animation: fadeInUp 0.5s ease-out;
    animation-fill-mode: backwards;
    border: 1px solid rgba(255,255,255,0.8);
}

.dashboard-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 30px rgba(0, 123, 255, 0.15); /* 悬停时带浅蓝色高级阴影 */
    background: #f8fbff;
    border-color: #007bff;
}

/* 6. 优化图标样式：给图标增加漂亮的圆形渐变背景 */
.card-icon {
    font-size: 2.5rem;
    margin-bottom: 20px;
    width: 80px;
    height: 80px;
    margin-left: auto;
    margin-right: auto;
    border-radius: 50%;
    background: linear-gradient(135deg, #e3f2fd, #bbdefb); /* 浅蓝渐变圆底 */
    color: #007bff;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background 0.3s, color 0.3s;
}

/* 鼠标移入卡片时，图标背景变蓝，图标变白 */
.dashboard-card:hover .card-icon {
    background: linear-gradient(135deg, #007bff, #00c6ff);
    color: #ffffff;
}

.card-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: #333;
    letter-spacing: 1px;
}