/* ========================================
   京东集团智能安防管理系统 - 界面规范CSS
   依据: 京东IBMS界面规范
   色系: 红(#E1251B) + 白(#FFFFFF) + 灰(#F4F6FA/#F9F9F9)
   ======================================== */

/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    font-family: "PingFang SC", "Microsoft YaHei", "京东朗正", "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    color: #333;
    background: #F4F6FA;
    overflow: hidden;
}

a { text-decoration: none; color: inherit; }
ul, ol { list-style: none; }
input, button, select, textarea { font-family: inherit; font-size: inherit; outline: none; border: none; }

/* ===== 水印 ===== */
.watermark {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    z-index: 9999;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
}
.watermark span {
    display: inline-block;
    width: 200px;
    text-align: center;
    color: rgba(0,0,0,0.06);
    font-size: 16px;
    transform: rotate(-30deg);
    padding: 80px 40px;
    white-space: nowrap;
    user-select: none;
}

/* ===== 顶部一级导航 ===== */
.top-nav {
    height: 56px;
    background: #E1251B;
    display: flex;
    align-items: center;
    padding: 0 24px;
    box-shadow: 0 2px 8px rgba(225,37,27,0.3);
    position: relative;
    z-index: 100;
}

.top-nav .logo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-right: 48px;
}

.top-nav .logo-icon {
    width: 36px; height: 36px;
    background: #fff;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    color: #E1251B;
}

.top-nav .logo-text {
    color: #fff;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 1px;
}

.top-nav .nav-menu {
    display: flex;
    gap: 4px;
    flex: 1;
}

.top-nav .nav-menu > li {
    position: relative;
}

.top-nav .nav-menu > li > a {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 20px;
    height: 56px;
    color: rgba(255,255,255,0.85);
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 3px solid transparent;
}

.top-nav .nav-menu > li > a:hover {
    color: #fff;
    background: rgba(0,0,0,0.1);
}

.top-nav .nav-menu > li.active > a {
    color: #fff;
    font-weight: 600;
    border-bottom-color: #fff;
}

.top-nav .nav-menu > li > a .icon {
    font-size: 18px;
}

/* 顶部导航下拉 */
.top-nav .nav-dropdown {
    position: absolute;
    top: 56px;
    left: 0;
    min-width: 180px;
    background: #fff;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    padding: 8px 0;
    display: none;
    z-index: 200;
}

.top-nav .nav-menu > li:hover .nav-dropdown {
    display: block;
}

.top-nav .nav-dropdown a {
    display: block;
    padding: 10px 20px;
    color: #333;
    font-size: 14px;
    transition: all 0.15s;
}

.top-nav .nav-dropdown a:hover {
    background: #FFF5F5;
    color: #E1251B;
}

/* 顶部右侧 */
.top-nav .top-right {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-left: auto;
}

.top-nav .top-right .search-box {
    display: flex;
    align-items: center;
    background: rgba(255,255,255,0.15);
    border-radius: 20px;
    padding: 0 16px;
    height: 34px;
    width: 200px;
    transition: width 0.3s;
}

.top-nav .top-right .search-box:focus-within {
    background: rgba(255,255,255,0.25);
    width: 260px;
}

.top-nav .top-right .search-box input {
    background: transparent;
    color: #fff;
    flex: 1;
    height: 100%;
}

.top-nav .top-right .search-box input::placeholder {
    color: rgba(255,255,255,0.6);
}

.top-nav .top-right .search-box .icon {
    color: rgba(255,255,255,0.6);
    font-size: 16px;
}

.top-nav .top-right .icon-btn {
    width: 34px; height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    cursor: pointer;
    transition: background 0.2s;
    position: relative;
}

.top-nav .top-right .icon-btn:hover {
    background: rgba(255,255,255,0.15);
}

.top-nav .top-right .icon-btn .badge {
    position: absolute;
    top: 2px; right: 2px;
    width: 8px; height: 8px;
    background: #FFD700;
    border-radius: 50%;
    border: 1px solid #E1251B;
}

.top-nav .top-right .user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 0 8px;
    height: 34px;
    border-radius: 17px;
    transition: background 0.2s;
}

.top-nav .top-right .user-info:hover {
    background: rgba(255,255,255,0.15);
}

.top-nav .top-right .user-info .avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: #fff;
    color: #E1251B;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
}

.top-nav .top-right .user-info .name {
    color: #fff;
    font-size: 13px;
}

/* ===== 布局容器 ===== */
.layout {
    display: flex;
    height: calc(100vh - 56px);
}

/* ===== 左侧二级+三级导航 ===== */
.sidebar {
    width: 220px;
    background: #FFFFFF;
    height: calc(100vh - 56px);
    overflow-y: auto;
    border-right: 1px solid #E8E8E8;
    flex-shrink: 0;
    transition: width 0.3s;
}

.sidebar.collapsed {
    width: 64px;
}

.sidebar .sidebar-header {
    padding: 16px 20px;
    font-size: 13px;
    color: #999;
    font-weight: 500;
    border-bottom: 1px solid #F0F0F0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar .sidebar-header .toggle-btn {
    cursor: pointer;
    font-size: 16px;
    color: #999;
    transition: color 0.2s;
}

.sidebar .sidebar-header .toggle-btn:hover {
    color: #E1251B;
}

/* 二级导航 */
.sidebar .nav-second > li {
    position: relative;
}

.sidebar .nav-second > li > a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    color: #333;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar .nav-second > li > a:hover {
    background: #FFF5F5;
    color: #E1251B;
}

.sidebar .nav-second > li > a.active {
    background: #FFF5F5;
    color: #E1251B;
    border-left-color: #E1251B;
    font-weight: 600;
}

.sidebar .nav-second > li > a .icon {
    font-size: 18px;
    width: 20px;
    text-align: center;
}

.sidebar .nav-second > li > a .arrow {
    margin-left: auto;
    font-size: 12px;
    transition: transform 0.2s;
}

.sidebar .nav-second > li.expanded > a .arrow {
    transform: rotate(90deg);
}

/* 三级导航 */
.sidebar .nav-third {
    background: #F9F9F9;
    overflow: hidden;
    display: none;
}

.sidebar .nav-second > li.expanded .nav-third {
    display: block;
}

.sidebar .nav-third > li > a {
    display: block;
    padding: 10px 20px 10px 50px;
    color: #666;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.sidebar .nav-third > li > a:hover {
    background: #F0F0F0;
    color: #E1251B;
}

.sidebar .nav-third > li > a.active {
    color: #E1251B;
    font-weight: 600;
}

/* ===== 主内容区 ===== */
.main-content {
    flex: 1;
    height: calc(100vh - 56px);
    overflow-y: auto;
    padding: 20px;
}

.main-content .page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.main-content .page-header .title {
    font-size: 22px;
    font-weight: 600;
    color: #1a1a1a;
}

.main-content .page-header .breadcrumb {
    font-size: 13px;
    color: #999;
    margin-top: 4px;
}

.main-content .page-header .actions {
    display: flex;
    gap: 10px;
}

/* ===== 卡片 ===== */
.card {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    margin-bottom: 20px;
}

.card .card-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card .card-title .more {
    font-size: 13px;
    color: #E1251B;
    cursor: pointer;
    font-weight: 400;
}

/* ===== 统计卡片 ===== */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

.stat-card {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.stat-card .stat-icon {
    width: 56px; height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    flex-shrink: 0;
}

.stat-card .stat-info .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1.2;
}

.stat-card .stat-info .stat-label {
    font-size: 13px;
    color: #999;
    margin-top: 4px;
}

.stat-card .stat-info .stat-trend {
    font-size: 12px;
    margin-top: 4px;
}

.stat-card .stat-info .stat-trend.up { color: #52C41A; }
.stat-card .stat-info .stat-trend.down { color: #FF4D4F; }

/* 颜色变体 */
.bg-red { background: #FFF1F0; color: #E1251B; }
.bg-blue { background: #E6F7FF; color: #1890FF; }
.bg-green { background: #F6FFED; color: #52C41A; }
.bg-orange { background: #FFF7E6; color: #FA8C16; }
.bg-purple { background: #F9F0FF; color: #722ED1; }
.bg-cyan { background: #E6FFFB; color: #13C2C2; }

/* ===== 表格 ===== */
.table-wrapper {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    overflow: hidden;
}

.table-toolbar {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #F0F0F0;
    flex-wrap: wrap;
    gap: 12px;
}

.table-toolbar .filters {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.table-toolbar .filters .filter-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.table-toolbar .filters label {
    font-size: 13px;
    color: #666;
    white-space: nowrap;
}

.table-toolbar .filters select,
.table-toolbar .filters input {
    height: 32px;
    border: 1px solid #D9D9D9;
    border-radius: 4px;
    padding: 0 10px;
    font-size: 13px;
    background: #fff;
    transition: border-color 0.2s;
}

.table-toolbar .filters select:focus,
.table-toolbar .filters input:focus {
    border-color: #E1251B;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead th {
    background: #FAFAFA;
    padding: 12px 16px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: #666;
    border-bottom: 1px solid #E8E8E8;
    white-space: nowrap;
}

.data-table tbody td {
    padding: 12px 16px;
    font-size: 13px;
    color: #333;
    border-bottom: 1px solid #F0F0F0;
}

.data-table tbody tr:hover {
    background: #FFF9F9;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* ===== 状态标签 ===== */
.tag {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.5;
}

.tag-red { background: #FFF1F0; color: #CF1322; border: 1px solid #FFA39E; }
.tag-blue { background: #E6F7FF; color: #096DD9; border: 1px solid #91D5FF; }
.tag-green { background: #F6FFED; color: #389E0D; border: 1px solid #B7EB8F; }
.tag-orange { background: #FFF7E6; color: #D46B08; border: 1px solid #FFD591; }
.tag-gray { background: #FAFAFA; color: #666; border: 1px solid #D9D9D9; }
.tag-purple { background: #F9F0FF; color: #531DAB; border: 1px solid #D3ADF7; }

/* ===== 按钮 ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 16px;
    height: 32px;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid #D9D9D9;
    background: #fff;
    color: #333;
    white-space: nowrap;
}

.btn:hover {
    border-color: #E1251B;
    color: #E1251B;
}

.btn-primary {
    background: #E1251B;
    color: #fff;
    border-color: #E1251B;
}

.btn-primary:hover {
    background: #D11E15;
    border-color: #D11E15;
    color: #fff;
}

.btn-sm {
    height: 26px;
    padding: 0 10px;
    font-size: 12px;
}

.btn-link {
    border: none;
    background: transparent;
    color: #E1251B;
    padding: 0 4px;
    height: auto;
    font-size: 13px;
}

.btn-link:hover {
    color: #D11E15;
}

/* ===== 分页 ===== */
.pagination {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    border-top: 1px solid #F0F0F0;
}

.pagination .page-info {
    font-size: 13px;
    color: #666;
    margin-right: 12px;
}

.pagination .page-btn {
    min-width: 32px;
    height: 32px;
    border: 1px solid #D9D9D9;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.pagination .page-btn:hover {
    border-color: #E1251B;
    color: #E1251B;
}

.pagination .page-btn.active {
    background: #E1251B;
    color: #fff;
    border-color: #E1251B;
}

.pagination .page-btn:disabled {
    cursor: not-allowed;
    color: #ccc;
}

/* ===== 图表容器 ===== */
.chart-container {
    width: 100%;
    height: 300px;
    position: relative;
}

/* ===== Flex布局工具 ===== */
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-12 { gap: 12px; }
.gap-20 { gap: 20px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }

/* ===== Grid ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }

/* ===== 进度条 ===== */
.progress-bar {
    width: 100%;
    height: 8px;
    background: #F0F0F0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar .progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s;
}

/* ===== 告警列表 ===== */
.alarm-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid #F0F0F0;
    transition: background 0.2s;
}

.alarm-item:hover {
    background: #FAFAFA;
}

.alarm-item .alarm-level {
    width: 4px;
    height: 40px;
    border-radius: 2px;
    flex-shrink: 0;
}

.alarm-item .alarm-level.high { background: #FF4D4F; }
.alarm-item .alarm-level.medium { background: #FA8C16; }
.alarm-item .alarm-level.low { background: #1890FF; }

.alarm-item .alarm-content {
    flex: 1;
}

.alarm-item .alarm-content .alarm-title {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin-bottom: 4px;
}

.alarm-item .alarm-content .alarm-desc {
    font-size: 12px;
    color: #999;
}

.alarm-item .alarm-time {
    font-size: 12px;
    color: #999;
    white-space: nowrap;
}

/* ===== 视频监控网格 ===== */
.video-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.video-item {
    aspect-ratio: 16/9;
    background: #1a1a1a;
    border-radius: 6px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s;
}

.video-item:hover {
    transform: scale(1.02);
}

.video-item .video-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 12px;
    background: linear-gradient(135deg, #1a1a1a 0%, #2a2a2a 100%);
}

.video-item .video-label {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 6px 10px;
    background: linear-gradient(transparent, rgba(0,0,0,0.8));
    color: #fff;
    font-size: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.video-item .video-label .recording-dot {
    width: 8px; height: 8px;
    background: #FF4D4F;
    border-radius: 50%;
    animation: blink 1.5s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ===== 模态框 ===== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: #fff;
    border-radius: 8px;
    width: 600px;
    max-width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.modal-header {
    padding: 16px 24px;
    border-bottom: 1px solid #F0F0F0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header .modal-title {
    font-size: 16px;
    font-weight: 600;
}

.modal-header .close-btn {
    cursor: pointer;
    font-size: 20px;
    color: #999;
    transition: color 0.2s;
}

.modal-header .close-btn:hover {
    color: #333;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 12px 24px;
    border-top: 1px solid #F0F0F0;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ===== 表单 ===== */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    color: #333;
    margin-bottom: 6px;
    font-weight: 500;
}

.form-group label .required {
    color: #FF4D4F;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    height: 34px;
    border: 1px solid #D9D9D9;
    border-radius: 4px;
    padding: 0 12px;
    font-size: 13px;
    transition: border-color 0.2s;
}

.form-group textarea {
    height: auto;
    padding: 8px 12px;
    min-height: 80px;
    resize: vertical;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #E1251B;
    box-shadow: 0 0 0 2px rgba(225,37,27,0.1);
}

/* ===== 滚动条 ===== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #C0C0C0;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* ===== 空状态 ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-state .icon {
    font-size: 48px;
    margin-bottom: 12px;
}

/* ===== 时间线 ===== */
.timeline {
    padding-left: 20px;
    border-left: 2px solid #E8E8E8;
}

.timeline-item {
    position: relative;
    padding-bottom: 20px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -26px;
    top: 4px;
    width: 10px; height: 10px;
    border-radius: 50%;
    background: #E1251B;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px #E1251B;
}

.timeline-item .timeline-time {
    font-size: 12px;
    color: #999;
    margin-bottom: 4px;
}

.timeline-item .timeline-content {
    font-size: 13px;
    color: #333;
}

/* ===== 响应式 ===== */
@media (max-width: 1200px) {
    .stat-cards { grid-template-columns: repeat(2, 1fr); }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .video-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .stat-cards { grid-template-columns: 1fr; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .video-grid { grid-template-columns: 1fr; }
    .sidebar { display: none; }
}
