/* 全局样式 - 农业绿色系 */
:root {
    --primary-green: #27ae60;
    --dark-green: #229954;
    --light-green: #a9dfbf;
    --bg-color: #f8f9fa;
    --card-bg: #ffffff;
    --text-dark: #2c3e50;
    --text-light: #7f8c8d;
    --border-color: #e0e0e0;
    --online-color: #2ecc71;
    --offline-color: #e74c3c;
    --warning-color: #f39c12;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.15);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-dark);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* 顶部导航 */
.header {
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--dark-green) 100%);
    color: white;
    padding: 20px 0;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.logo {
    font-size: 24px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo .icon {
    font-size: 32px;
}

.tabs {
    display: flex;
    gap: 10px;
}

.tab-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 10px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.tab-btn.active {
    background: white;
    color: var(--primary-green);
    border-color: white;
}

/* 主内容区 */
.main-content {
    padding: 30px 0;
    min-height: calc(100vh - 200px);
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== 实时监控页面 ===== */

/* 统计卡片 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--card-bg);
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: all 0.3s ease;
}

.stat-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.stat-icon {
    font-size: 48px;
}

.stat-info h3 {
    font-size: 14px;
    color: var(--text-light);
    margin-bottom: 5px;
}

.stat-value {
    font-size: 32px;
    font-weight: bold;
    color: var(--primary-green);
}

.stat-card.online .stat-value {
    color: var(--online-color);
}

.stat-card.offline .stat-value {
    color: var(--offline-color);
}

/* 传感器网格 */
.sensor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.sensor-card {
    background: var(--card-bg);
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
}

.sensor-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.sensor-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.sensor-icon {
    font-size: 32px;
}

.sensor-header h3 {
    font-size: 18px;
    color: var(--text-dark);
}

.sensor-value {
    font-size: 48px;
    font-weight: bold;
    color: var(--primary-green);
    margin-bottom: 10px;
}

.sensor-value .unit {
    font-size: 24px;
    color: var(--text-light);
    margin-left: 5px;
}

.sensor-range {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    font-size: 14px;
    color: var(--text-light);
}

.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge.normal {
    background: #d5f4e6;
    color: var(--online-color);
}

.chart-container {
    height: 150px;
    margin-top: 15px;
}

/* 设备列表 */
.device-section {
    margin-top: 40px;
}

.device-section h2 {
    font-size: 24px;
    margin-bottom: 20px;
    color: var(--text-dark);
}

.device-list {
    display: grid;
    gap: 15px;
}

.device-item {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
}

.device-item:hover {
    box-shadow: var(--shadow-hover);
    transform: translateX(5px);
}

.device-info {
    flex: 1;
}

.device-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.device-meta {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    font-size: 14px;
    color: var(--text-light);
}

.device-id {
    font-family: 'Courier New', monospace;
    background: var(--bg-color);
    padding: 2px 8px;
    border-radius: 4px;
}

.device-status {
    font-size: 16px;
    font-weight: 600;
    padding: 8px 20px;
    border-radius: 20px;
}

.device-status.online {
    color: var(--online-color);
    background: #d5f4e6;
}

.device-status.offline {
    color: var(--offline-color);
    background: #fadbd8;
}

/* ===== 设备检索页面 ===== */
.search-section {
    max-width: 900px;
    margin: 0 auto;
}

.search-section h2 {
    font-size: 32px;
    color: var(--text-dark);
    margin-bottom: 10px;
    text-align: center;
}

.search-description {
    text-align: center;
    color: var(--text-light);
    margin-bottom: 30px;
}

.search-box {
    position: relative;
    margin-bottom: 20px;
}

.search-box input {
    width: 100%;
    padding: 18px 60px 18px 24px;
    font-size: 18px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    outline: none;
    transition: all 0.3s ease;
    background: var(--card-bg);
}

.search-box input:focus {
    border-color: var(--primary-green);
    box-shadow: 0 0 0 4px rgba(39, 174, 96, 0.1);
}

.search-icon {
    position: absolute;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 24px;
    color: var(--text-light);
}

.search-stats {
    text-align: center;
    padding: 15px;
    background: var(--light-green);
    border-radius: 8px;
    margin-bottom: 20px;
    color: var(--dark-green);
    font-size: 16px;
}

.search-stats strong {
    color: var(--primary-green);
    font-weight: 700;
}

.search-results {
    display: grid;
    gap: 15px;
}

.search-result-item {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 12px;
    border-left: 4px solid var(--primary-green);
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
}

.search-result-item:hover {
    box-shadow: var(--shadow-hover);
    transform: translateX(5px);
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.result-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-dark);
}

.result-details {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    font-size: 14px;
    color: var(--text-light);
}

.result-id {
    font-family: 'Courier New', monospace;
    background: var(--bg-color);
    padding: 2px 8px;
    border-radius: 4px;
}

.no-results {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
    font-size: 18px;
}

mark {
    background: #fff59d;
    padding: 2px 4px;
    border-radius: 3px;
}

/* ===== 算法演示页面 ===== */
.demo-header {
    text-align: center;
    margin-bottom: 30px;
}

.demo-header h2 {
    font-size: 32px;
    color: var(--text-dark);
    margin-bottom: 10px;
}

.demo-header p {
    color: var(--text-light);
    font-size: 16px;
}

/* 算法选择标签（移到顶部） */
.algo-tabs {
    display: flex;
    gap: 10px;
    background: var(--card-bg);
    padding: 10px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.demo-layout {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr 1fr;
    gap: 20px;
    position: relative;
    left: 100px;
    width: calc(100% + 100px);
}

/* 左侧区域（可视化动画） */
.demo-left {
    display: flex;
    flex-direction: column;
}

/* 中间区域（搜索结果） */
.demo-middle {
    display: flex;
    flex-direction: column;
}

.algo-tab {
    flex: 1;
    padding: 12px 24px;
    background: transparent;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-dark);
    transition: all 0.3s ease;
}

.algo-tab:hover {
    background: var(--bg-color);
}

.algo-tab.active {
    background: var(--primary-green);
    color: white;
    border-color: var(--primary-green);
}

/* 控制面板 */
.control-panel {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 20px;
    position: sticky;
    top: 460px;
    z-index: 9;
}

.demo-search {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
}

.demo-search input {
    width: 100%;
    padding: 12px 16px;
    font-size: 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    outline: none;
    transition: all 0.3s ease;
}

.demo-search input:focus {
    border-color: var(--primary-green);
    box-shadow: 0 0 0 4px rgba(39, 174, 96, 0.1);
}

.demo-controls {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
}

.control-btn {
    padding: 12px 20px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: white;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.3s ease;
    text-align: center;
}

.control-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.control-btn.primary {
    background: var(--primary-green);
    color: white;
    border-color: var(--primary-green);
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.speed-control {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.speed-control label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
}

.speed-slider-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.speed-control input[type="range"] {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    outline: none;
    -webkit-appearance: none;
}

.speed-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-green);
    cursor: pointer;
    transition: all 0.3s ease;
}

.speed-control input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 8px rgba(39, 174, 96, 0.5);
}

.speed-control input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-green);
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
}

.speed-control input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 8px rgba(39, 174, 96, 0.5);
}

.speed-control span {
    min-width: 45px;
    font-weight: 600;
    color: var(--primary-green);
    text-align: right;
}

/* 可视化区域 */
.visualization-area {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 20px;
    min-height: 300px;
    height: 700px;
    overflow-y: auto;
    scroll-behavior: smooth;
    margin-left: -250px;
    padding-left: 40px;
    width: calc(100% + 250px);
}

.viz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
}

.viz-header h3 {
    font-size: 20px;
    color: var(--text-dark);
}

.viz-stats {
    display: flex;
    gap: 20px;
    font-size: 14px;
    color: var(--text-light);
}

.viz-stats strong {
    color: var(--primary-green);
    font-size: 18px;
}

.viz-content {
    min-height: 200px;
}

.viz-placeholder {
    text-align: center;
    color: var(--text-light);
    padding: 60px 20px;
    font-size: 16px;
}

.viz-step {
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid var(--primary-green);
    background: var(--bg-color);
}

.viz-step.match {
    border-left-color: var(--online-color);
    background: #d5f4e6;
}

.viz-step.skip {
    border-left-color: var(--text-light);
    background: #f5f5f5;
}

.viz-step.fail {
    border-left-color: var(--offline-color);
    background: #fadbd8;
}

.viz-step.success {
    border-left-color: var(--primary-green);
    background: #d5f4e6;
}

.viz-message {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 15px;
    color: var(--text-dark);
}

.viz-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
    padding: 15px;
    background: white;
    border-radius: 8px;
}

.viz-path,
.viz-match-count {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.path-text {
    font-family: 'Courier New', monospace;
    background: var(--light-green);
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 18px;
    font-weight: bold;
    color: var(--dark-green);
}

.count-badge {
    background: var(--primary-green);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: bold;
}

/* 前缀树可视化 - 树形结构 */
.trie-tree-container {
    margin-top: 20px;
}

.tree-legend {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
    padding: 10px;
    background: white;
    border-radius: 6px;
    font-size: 13px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.legend-dot.current {
    background: #f39c12;
    box-shadow: 0 0 8px rgba(243, 156, 18, 0.5);
}

.legend-dot.path {
    background: var(--online-color);
}

.legend-dot.normal {
    background: #95a5a6;
}

/* 树形结构容器 */
.trie-tree-vertical {
    background: white;
    padding: 20px;
    border-radius: 8px;
    overflow-x: auto;
}

.tree-root {
    list-style: none;
    padding: 0;
    margin: 0;
}

.tree-item {
    position: relative;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: flex-start;
    gap: 20px;
}

.tree-item.root-item {
    margin-bottom: 0;
}

.tree-children {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
}

/* 横向连接线 - 从父节点中心出发 */
.tree-item.has-children::after {
    content: '';
    position: absolute;
    left: 100%;
    top: 22px;
    width: 20px;
    height: 2px;
    background: #cbd5e0;
}

/* 子节点的垂直连接线 - 从第一个子节点中心到最后一个子节点中心 */
.tree-item.has-children > .tree-children::before {
    content: '';
    position: absolute;
    left: -20px;
    top: 22px;
    bottom: calc(100% - 22px);
    height: calc(100% - 44px);
    width: 2px;
    background: #cbd5e0;
}

/* root节点不显示竖线 */
.tree-item.root-item > .tree-children::before {
    display: none;
}

/* 每个子节点的横向连接线 - 对齐节点中心 */
.tree-children > .tree-item::before {
    content: '';
    position: absolute;
    left: -20px;
    top: 22px;
    width: 20px;
    height: 2px;
    background: #cbd5e0;
}

/* 树节点样式 */
.tree-node {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 8px;
    transition: all 0.3s ease;
    position: relative;
    border: 2px solid transparent;
    font-size: 16px;
    flex-shrink: 0;
    white-space: nowrap;
}

.tree-node.root-node {
    background: linear-gradient(135deg, var(--primary-green), var(--dark-green));
    color: white;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(39, 174, 96, 0.3);
    font-size: 18px;
}

.tree-node.normal-node {
    background: #f7fafc;
    color: var(--text-dark);
    border-color: #e2e8f0;
}

.tree-node.in-path-node {
    background: #d5f4e6;
    color: var(--dark-green);
    border-color: var(--online-color);
    box-shadow: 0 2px 6px rgba(46, 204, 113, 0.3);
    font-weight: 600;
}

.tree-node.current-node {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: white;
    border-color: #f39c12;
    box-shadow: 0 0 15px rgba(243, 156, 18, 0.5);
    font-weight: bold;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.tree-node.more-node {
    background: transparent;
    border: 2px dashed #cbd5e0;
    color: var(--text-light);
    font-style: italic;
    font-size: 14px;
}

.node-char {
    font-family: 'Courier New', monospace;
    font-size: inherit;
    font-weight: inherit;
}

.node-badge {
    background: var(--primary-green);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
    min-width: 24px;
    text-align: center;
}

.tree-node.current-node .node-badge {
    background: rgba(255, 255, 255, 0.3);
    color: white;
}

.tree-node.in-path-node .node-badge {
    background: var(--dark-green);
}

.node-end-marker {
    color: var(--online-color);
    font-size: 14px;
    font-weight: bold;
}

.tree-node.current-node .node-end-marker,
.tree-node.in-path-node .node-end-marker {
    color: inherit;
}

.tree-empty {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
    font-size: 16px;
}

.viz-device {
    background: white;
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
    display: grid;
    gap: 8px;
    font-size: 14px;
}

.viz-progress {
    margin-top: 15px;
}

.progress-bar {
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: var(--primary-green);
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 14px;
    color: var(--text-light);
    text-align: center;
}

/* 顺序查找设备列表 - 网格布局 */
.seq-device-list {
    margin-top: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    max-height: 550px;
    overflow-y: auto;
    padding: 5px;
}

.seq-device-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    background: white;
    border-radius: 6px;
    border: 2px solid var(--border-color);
    transition: all 0.3s ease;
    position: relative;
    min-height: auto;
    cursor: default;
}

.seq-device-item:hover:not(.checking) {
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.seq-device-item.checking {
    background: linear-gradient(135deg, #fff3cd, #ffeaa7);
    border-color: #f39c12;
    box-shadow: 0 4px 16px rgba(243, 156, 18, 0.4);
    transform: scale(1.05);
    z-index: 10;
}

.seq-device-item.checked {
    opacity: 0.65;
    filter: grayscale(20%);
}

.seq-device-item.checked.matched {
    background: linear-gradient(135deg, #d5f4e6, #a8e6cf);
    border-color: var(--online-color);
    opacity: 1;
    filter: grayscale(0%);
}

.seq-device-index {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--border-color);
    color: var(--text-light);
    border-radius: 4px;
    font-weight: bold;
    font-size: 11px;
}

.seq-device-item.checking .seq-device-index {
    background: #f39c12;
    color: white;
}

.seq-device-item.matched .seq-device-index {
    background: var(--online-color);
    color: white;
}

.seq-device-name {
    flex: 1;
    font-weight: 500;
    color: var(--text-dark);
    font-size: 12px;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.seq-device-item.checking .seq-device-name {
    font-weight: 600;
}

.seq-device-item.matched .seq-device-name {
    font-weight: 600;
}

.viz-info-text {
    color: var(--text-light);
    font-size: 14px;
    margin-bottom: 15px;
    padding: 10px 15px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid var(--primary-green);
}

/* 搜索结果 */
.demo-results {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 20px;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.demo-results h3 {
    font-size: 18px;
    margin-bottom: 15px;
    color: var(--text-dark);
}

.results-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    flex: 1;
    align-content: flex-start;
}

.result-item {
    padding: 12px;
    background: var(--bg-color);
    border-radius: 8px;
    border-left: 3px solid var(--primary-green);
    flex-shrink: 0;
}

.result-item .result-name {
    font-weight: 600;
    margin-bottom: 5px;
    font-size: 14px;
}

.result-item .result-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 11px;
    color: var(--text-light);
}

/* 右侧步骤面板 */
.demo-right {
    position: relative;
}

.steps-panel {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 20px;
    max-height: 350px;
    overflow-y: auto;
    scroll-behavior: smooth;
    position: sticky;
    top: 90px;
    z-index: 10;
}

.steps-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
}

.steps-header h3 {
    font-size: 18px;
    color: var(--text-dark);
}

.steps-count {
    font-size: 14px;
    color: var(--text-light);
}

.steps-count strong {
    color: var(--primary-green);
    font-size: 16px;
}

.steps-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.steps-placeholder {
    text-align: center;
    color: var(--text-light);
    padding: 40px 20px;
}

.step-item {
    display: flex;
    gap: 15px;
    padding: 15px;
    border-radius: 8px;
    background: var(--bg-color);
    border-left: 3px solid var(--border-color);
    transition: all 0.3s ease;
}

.step-item.current {
    background: #fff3cd;
    border-left-color: var(--warning-color);
    box-shadow: var(--shadow);
}

.step-item.past {
    opacity: 0.6;
}

.step-item.match {
    border-left-color: var(--online-color);
}

.step-item.skip {
    border-left-color: var(--text-light);
}

.step-item.fail {
    border-left-color: var(--offline-color);
}

.step-number {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    background: var(--primary-green);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
}

.step-content {
    flex: 1;
}

.step-message {
    font-size: 14px;
    color: var(--text-dark);
    line-height: 1.5;
}

/* 页脚 */
.footer {
    background: var(--text-dark);
    color: white;
    text-align: center;
    padding: 20px;
    margin-top: 50px;
}

/* ===== 设备管理页面 ===== */
.manage-header {
    text-align: center;
    margin-bottom: 30px;
}

.manage-header h2 {
    font-size: 32px;
    color: var(--text-dark);
    margin-bottom: 10px;
}

.manage-header p {
    color: var(--text-light);
    font-size: 16px;
}

.manage-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* 左侧：添加设备和列表 */
.manage-left {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.add-device-panel {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 20px;
}

.add-device-panel h3 {
    font-size: 18px;
    margin-bottom: 15px;
    color: var(--text-dark);
}

.add-device-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

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

.form-group label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
}

.form-group input {
    padding: 12px 16px;
    font-size: 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    outline: none;
    transition: all 0.3s ease;
}

.form-group input:focus {
    border-color: var(--primary-green);
    box-shadow: 0 0 0 4px rgba(39, 174, 96, 0.1);
}

.btn-primary,
.btn-secondary {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary-green);
    color: white;
}

.btn-primary:hover {
    background: var(--dark-green);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: #e74c3c;
    color: white;
}

.btn-secondary:hover {
    background: #c0392b;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.manage-devices-panel {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 20px;
    flex: 1;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
}

.panel-header h3 {
    font-size: 18px;
    color: var(--text-dark);
    margin: 0;
}

.device-count,
.node-count {
    font-size: 14px;
    color: var(--text-light);
}

.device-count strong,
.node-count strong {
    color: var(--primary-green);
    font-size: 18px;
}

.manage-device-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 400px;
    overflow-y: auto;
}

.manage-device-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-color);
    border-radius: 8px;
    border-left: 4px solid var(--primary-green);
    transition: all 0.3s ease;
}

.manage-device-item:hover {
    background: #e8f5e9;
    transform: translateX(5px);
}

.device-name-text {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-dark);
}

.device-index {
    font-size: 14px;
    color: var(--text-light);
    background: white;
    padding: 4px 12px;
    border-radius: 20px;
}

.btn-remove {
    padding: 6px 12px;
    background: transparent;
    border: 2px solid #e74c3c;
    color: #e74c3c;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

.btn-remove:hover {
    background: #e74c3c;
    color: white;
}

/* 右侧：树可视化 */
.manage-right {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.tree-visualization-panel {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 20px;
    flex: 1;
}

.manage-tree-content {
    background: var(--bg-color);
    border-radius: 8px;
    padding: 20px;
    min-height: 400px;
    max-height: 500px;
    overflow-y: auto;
    scroll-behavior: smooth;
}

.tree-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 400px;
    color: var(--text-light);
    text-align: center;
}

.placeholder-icon {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.tree-placeholder p {
    font-size: 16px;
    margin: 5px 0;
}

.placeholder-hint {
    font-size: 14px;
    opacity: 0.7;
}

.build-steps-panel {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 20px;
    max-height: 250px;
    overflow-y: auto;
}

.build-steps-panel h3 {
    font-size: 18px;
    margin-bottom: 15px;
    color: var(--text-dark);
}

.build-steps-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.build-step-item {
    padding: 12px;
    background: var(--bg-color);
    border-radius: 6px;
    border-left: 3px solid var(--primary-green);
    font-size: 14px;
    color: var(--text-dark);
    animation: slideIn 0.3s ease;
}

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

.build-step-new {
    background: #e8f5e9;
    font-weight: 600;
}

.empty-hint {
    text-align: center;
    color: var(--text-light);
    padding: 40px 20px;
    font-size: 14px;
}

/* 响应式设计 */
@media (max-width: 1400px) {
    .demo-layout {
        grid-template-columns: 1fr 0.8fr 1fr;
    }
}

@media (max-width: 1200px) {
    .demo-layout {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto;
    }
    
    .demo-middle {
        grid-column: 1 / -1;
    }
    
    .manage-layout {
        grid-template-columns: 1fr;
    }
    
    .steps-panel {
        position: static;
        max-height: 500px;
    }
    
    .control-panel {
        position: static;
    }
}

@media (max-width: 900px) {
    .demo-layout {
        grid-template-columns: 1fr;
    }
    
    .demo-middle {
        grid-column: auto;
    }
}

@media (max-width: 768px) {
    .header .container {
        flex-direction: column;
        text-align: center;
    }
    
    .tabs {
        width: 100%;
        justify-content: center;
    }
    
    .tab-btn {
        flex: 1;
        padding: 10px 15px;
        font-size: 14px;
    }
    
    .logo {
        font-size: 20px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .sensor-grid {
        grid-template-columns: 1fr;
    }
    
    .demo-controls {
        flex-direction: column;
    }
    
    .speed-control {
        margin-left: 0;
        width: 100%;
        justify-content: space-between;
    }
    
    .device-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }
    
    .sensor-value {
        font-size: 36px;
    }
    
    .demo-header h2,
    .search-section h2 {
        font-size: 24px;
    }
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-green);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--dark-green);
}
