/* ==========================================================================
   渐朗雷达 · 数据管理系统 —— 自定义样式
   基于 Bootstrap 5，只覆盖必要部分，保持轻量
   ========================================================================== */

:root {
    --jl-primary: #1668dc;
    --jl-sidebar-bg: #1f2733;
    --jl-sidebar-hover: #2b3648;
    --jl-sidebar-active: #1668dc;
    --jl-border: #e5e8ee;
    --jl-bg: #f4f6f9;
    --jl-text-muted: #6b7280;
    --jl-sidebar-w: 220px;
}

html, body {
    height: 100%;
}

body {
    background-color: var(--jl-bg);
    font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    color: #1f2733;
}

/* ── 整体骨架 ───────────────────────────────── */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: var(--jl-sidebar-w);
    flex: 0 0 var(--jl-sidebar-w);
    background: var(--jl-sidebar-bg);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.app-main {
    flex: 1 1 auto;
    min-width: 0; /* 关键：不加这行，宽表格会把 flex 容器撑破导致横向滚动失效 */
    display: flex;
    flex-direction: column;
}

.app-content {
    flex: 1 1 auto;
    padding: 20px 24px;
}

.app-footer {
    padding: 12px 24px;
    color: var(--jl-text-muted);
    font-size: 12px;
    border-top: 1px solid var(--jl-border);
    background: #fff;
}

/* ── 侧边栏 ───────────────────────────────── */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--jl-primary);
    color: #fff;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    letter-spacing: .5px;
    flex-shrink: 0;
}

.brand-title {
    color: #fff;
    font-weight: 600;
    line-height: 1.2;
}

.brand-sub {
    font-size: 12px;
    color: #94a3b8;
    line-height: 1.3;
}

.sidebar-nav {
    padding: 12px 8px;
    flex: 1 1 auto;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 6px;
    color: #cbd5e1;
    text-decoration: none;
    margin-bottom: 4px;
    transition: background-color .15s, color .15s;
}

.sidebar-nav .nav-link:hover {
    background: var(--jl-sidebar-hover);
    color: #fff;
}

.sidebar-nav .nav-link.active {
    background: var(--jl-sidebar-active);
    color: #fff;
    font-weight: 500;
}

.nav-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(255, 255, 255, .08);
}

.sidebar-footer .text-muted {
    color: #64748b !important;
}

/* ── 顶栏 ───────────────────────────────── */
.app-topbar {
    display: flex;
    align-items: center;
    padding: 0 24px;
    height: 56px;
    background: #fff;
    border-bottom: 1px solid var(--jl-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-title {
    font-size: 16px;
    font-weight: 600;
}

.topbar-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-name {
    font-weight: 500;
}

/* ── 卡片 ───────────────────────────────── */
.card {
    border: 1px solid var(--jl-border);
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}

.card-header {
    background: #fff;
    border-bottom: 1px solid var(--jl-border);
    font-weight: 600;
    padding: 12px 16px;
}

/* ── 查询条件面板 ───────────────────────────────── */
.filter-card .form-label {
    font-size: 13px;
    color: var(--jl-text-muted);
    margin-bottom: 4px;
}

.filter-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding-top: 12px;
    border-top: 1px dashed var(--jl-border);
}

.quick-range-label {
    font-size: 13px;
    color: var(--jl-text-muted);
}

/* ── 数据表格 ───────────────────────────────── */
.data-table {
    font-size: 13px;
    margin-bottom: 0;
}

.data-table thead th {
    background: #fafbfc;
    border-bottom: 2px solid var(--jl-border);
    font-weight: 600;
    white-space: nowrap;
    padding: 10px 12px;
    color: #374151;
}

.data-table tbody td {
    padding: 8px 12px;
    vertical-align: middle;
}

.num-cell {
    font-variant-numeric: tabular-nums; /* 数字等宽，列对齐更整齐 */
}

.sn-code {
    font-family: inherit;
    color: #495057;
    background: #f1f5f9;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 13px;
}

.status-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    background: #f1f5f9;
    color: #475569;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
}

.data-table .badge {
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
}

.empty-cell {
    text-align: center;
    padding: 48px 16px !important;
    color: var(--jl-text-muted);
}

/* 排序表头 */
.sort-link {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.sort-link:hover {
    color: var(--jl-primary);
}

.sort-link.active {
    color: var(--jl-primary);
}

.sort-arrow {
    font-size: 11px;
    opacity: .55;
}

.sort-link.active .sort-arrow {
    opacity: 1;
}

/* ── 概览统计卡 ───────────────────────────────── */
.stat-card {
    background: #fff;
    border: 1px solid var(--jl-border);
    border-radius: 8px;
    padding: 18px 20px;
    height: 100%;
    border-left: 3px solid var(--jl-primary);
}

.stat-card.stat-warning {
    border-left-color: #f59e0b;
}

.stat-card.stat-muted {
    border-left-color: #94a3b8;
}

.stat-label {
    font-size: 13px;
    color: var(--jl-text-muted);
}

.stat-value {
    font-size: 28px;
    font-weight: 600;
    line-height: 1.3;
    font-variant-numeric: tabular-nums;
}

.stat-hint {
    font-size: 12px;
    color: #9aa3af;
}

.info-list dt {
    font-weight: 500;
    color: var(--jl-text-muted);
    padding: 6px 0;
}

.info-list dd {
    padding: 6px 0;
    margin-bottom: 0;
}

/* ── 登录页 ───────────────────────────────── */
.login-page {
    background: linear-gradient(135deg, #1f2733 0%, #2c3e50 100%);
    min-height: 100vh;
}

.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: #fff;
    border-radius: 12px;
    padding: 36px 34px 28px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .22);
}

.login-header {
    text-align: center;
    margin-bottom: 26px;
}

.login-logo {
    width: 54px;
    height: 54px;
    margin: 0 auto 12px;
    border-radius: 12px;
    background: var(--jl-primary);
    color: #fff;
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 4px;
}

.login-subtitle {
    font-size: 13px;
    color: var(--jl-text-muted);
    margin-bottom: 0;
}

.login-footer {
    text-align: center;
    font-size: 12px;
    color: #9aa3af;
    margin-top: 22px;
}

/* ── 响应式：窄屏收起侧边栏文字 ───────────────────────────────── */
@media (max-width: 992px) {
    :root {
        --jl-sidebar-w: 60px;
    }

    .brand-text,
    .sidebar-nav .nav-link span,
    .sidebar-footer {
        display: none;
    }

    .sidebar-brand {
        justify-content: center;
        padding: 18px 8px;
    }

    .sidebar-nav .nav-link {
        justify-content: center;
    }

    .app-content {
        padding: 16px 12px;
    }

    .app-topbar {
        padding: 0 12px;
    }
}

/* ── 手机端 (< 576px)：进一步压缩 ───────────────────── */
@media (max-width: 576px) {
    :root {
        --jl-sidebar-w: 0px;
    }

    .app-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        z-index: 1100;
        width: 200px;
        flex: 0 0 200px;
        transform: translateX(-100%);
        transition: transform .25s;
    }

    .app-shell.sidebar-open .app-sidebar {
        transform: translateX(0);
    }

    .app-shell.sidebar-open::after {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, .4);
        z-index: 1050;
    }

    .brand-text,
    .sidebar-nav .nav-link span,
    .sidebar-footer {
        display: revert;
    }

    .sidebar-brand,
    .sidebar-nav .nav-link {
        justify-content: flex-start;
    }

    .filter-card .col-md-3,
    .filter-card .col-md-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .table-responsive .data-table th,
    .table-responsive .data-table td {
        padding: 6px 8px;
        font-size: 12px;
    }

    .topbar-user .user-name {
        display: none;
    }

    .topbar-toggle {
        display: inline-flex !important;
    }
}

.topbar-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--jl-border);
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    margin-right: 8px;
    padding: 0;
    color: #1f2733;
}
.topbar-toggle:hover {
    background: #f8f9fa;
}

/* ── 统计卡片 ── */
.stat-card {
    border: 1px solid var(--border, #e9ecef);
}
.stat-card .card-header {
    font-weight: 600;
    background: #f8f9fa;
    border-bottom: 1px solid var(--border, #e9ecef);
}
.stat-table th {
    font-weight: 500;
    color: #868e96;
    background: #fbfbfc;
}
.stat-table td, .stat-table th {
    padding: 0.35rem 0.75rem;
}

/* ── BLE 入口卡 ── */
.ble-entry {
    border: 1px solid var(--border, #e9ecef);
    transition: box-shadow .15s, transform .15s;
}
.ble-entry:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,.08);
    transform: translateY(-2px);
}
.ble-entry-icon {
    font-size: 28px;
    margin-bottom: 8px;
}

/* ── 波形图容器 ── */
canvas#waveCanvas,
.card-body canvas {
    width: 100%;
    display: block;
}

/* 列表里 SNO 等代码样式（继承自上方 .sn-code，这里保持空定义避免重复覆盖） */

/* 数字右对齐单元格 */
.num-cell {
    font-variant-numeric: tabular-nums;
}

/* 宽表格横向滚动时不压缩列 */
.table-responsive .data-table {
    min-width: max-content;
    white-space: nowrap;
}
.table-responsive .data-table th,
.table-responsive .data-table td {
    white-space: nowrap;
}

/* 登录页底部版本/备案 */
.login-page-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 10px;
    text-align: center;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
}
.login-page-footer a {
    color: rgba(255, 255, 255, 0.7);
}
.login-page-footer a:hover {
    color: #fff;
}

/* 波形图悬停 tooltip */
.ble-wave-tooltip {
    position: absolute;
    z-index: 1000;
    background: #1f2733;
    color: #fff;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    line-height: 1.5;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
    min-width: 100px;
}
.ble-wave-tooltip b {
    color: #ffc107;
}

/* 图表 hover tooltip（饼图/折线图共用） */
.chart-tooltip {
    position: absolute;
    z-index: 1000;
    background: #1f2733;
    color: #fff;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    line-height: 1.5;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
    white-space: nowrap;
}
.chart-tooltip b {
    color: #ffc107;
}
