/* 基础样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #1e88e5;
    --primary-dark: #1565c0;
    --danger-color: #e53935;
    --danger-dark: #c62828;
    --success-color: #43a047;
    --warning-color: #fb8c00;
    --bg-color: #f5f5f5;
    --sidebar-bg: #1976d2;
    --sidebar-dark: #1565c0;
    --header-bg: #1976d2;
    --text-primary: #333;
    --text-secondary: #666;
    --text-light: #999;
    --border-color: #e0e0e0;
    --card-bg: #fff;
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--bg-color);
    overflow: hidden;
}

/* 应用容器 */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

/* 顶部导航栏 */
.top-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 50px;
    background: var(--header-bg);
    color: white;
    padding: 0 16px;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.menu-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.menu-toggle:hover {
    background: rgba(255,255,255,0.1);
}

.system-title {
    font-size: 16px;
    font-weight: 500;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 4px;
    transition: background 0.2s;
}

.user-info:hover {
    background: rgba(255,255,255,0.1);
}

.user-info i:first-child {
    font-size: 20px;
}

.username {
    font-size: 14px;
}

.window-controls {
    display: flex;
    gap: 8px;
}

.win-btn {
    background: none;
    border: none;
    color: white;
    font-size: 14px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 4px;
    transition: background 0.2s;
}

.win-btn:hover {
    background: rgba(255,255,255,0.2);
}

.win-btn.close:hover {
    background: var(--danger-color);
}

/* 主体内容区 */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* 左侧导航菜单 */
.sidebar {
    width: 200px;
    background: var(--sidebar-bg);
    flex-shrink: 0;
    transition: width 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar.collapsed {
    width: 60px;
}

.nav-menu ul {
    list-style: none;
}

.nav-item {
    position: relative;
}

.nav-item > a {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    transition: all 0.2s;
    gap: 12px;
}

.nav-item > a:hover {
    background: var(--sidebar-dark);
    color: white;
}

.nav-item.active > a {
    background: var(--sidebar-dark);
    color: white;
    border-left: 3px solid #fff;
}

.nav-item i {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.nav-text {
    flex: 1;
    white-space: nowrap;
}

.sidebar.collapsed .nav-text,
.sidebar.collapsed .submenu-arrow {
    display: none;
}

.submenu-arrow {
    font-size: 12px;
    transition: transform 0.2s;
}

.nav-item.active .submenu-arrow {
    transform: rotate(180deg);
}

/* 子菜单 */
.submenu {
    background: rgba(0,0,0,0.1);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.nav-item.active .submenu {
    max-height: 200px;
}

.submenu-item a {
    display: block;
    padding: 10px 16px 10px 52px;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    font-size: 13px;
    transition: all 0.2s;
}

.submenu-item a:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.submenu-item.active a {
    background: rgba(255,255,255,0.15);
    color: white;
}

.sidebar.collapsed .submenu {
    display: none;
}

/* 右侧内容区 */
.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-color);
}

/* 工具栏 */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: white;
    border-bottom: 1px solid var(--border-color);
    gap: 20px;
}

.toolbar-left {
    display: flex;
    gap: 12px;
}

.toolbar-center {
    flex: 1;
    max-width: 500px;
}

/* 按钮样式 */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

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

.btn-danger:hover {
    background: var(--danger-dark);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* 搜索框 */
.search-box {
    position: relative;
    width: 100%;
}

.search-box input {
    width: 100%;
    padding: 8px 40px 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.search-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    padding: 4px 8px;
}

.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    margin-top: 4px;
    box-shadow: var(--shadow-lg);
    z-index: 100;
    display: none;
}

.search-dropdown.show {
    display: block;
}

.search-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
}

.search-item:last-child {
    border-bottom: none;
}

.search-item:hover {
    background: #f5f5f5;
}

.search-label {
    color: var(--text-light);
    margin-right: 8px;
}

.search-value {
    color: var(--primary-color);
}

/* 筛选标签 */
.filter-tabs {
    display: flex;
    gap: 8px;
    padding: 12px 20px;
    background: white;
    border-bottom: 1px solid var(--border-color);
}

.filter-tab {
    padding: 6px 16px;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.filter-tab:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

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

/* 页面容器 */
.page-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.view-section {
    display: none;
}

.view-section.active {
    display: block;
}

/* 设备卡片网格 */
.device-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

/* 设备卡片 */
.device-card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 16px;
    box-shadow: var(--shadow);
    transition: box-shadow 0.2s;
}

.device-card:hover {
    box-shadow: var(--shadow-lg);
}

.device-header {
    margin-bottom: 12px;
}

.device-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    word-break: break-all;
}

.device-info {
    margin-bottom: 16px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 13px;
}

.info-item .label {
    color: var(--text-secondary);
}

.info-item .value {
    color: var(--text-primary);
    font-weight: 500;
}

.info-item .value.status-offline {
    color: var(--text-light);
}

.device-actions {
    display: flex;
    gap: 8px;
}

.device-actions .btn {
    flex: 1;
    justify-content: center;
    padding: 6px 12px;
    font-size: 13px;
}

/* 设备详情视图 */
.detail-container {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 24px;
    max-width: 1000px;
    margin: 0 auto;
}

.detail-title {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 24px;
}

.detail-card {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
}

.detail-card h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.info-row {
    display: flex;
    margin-bottom: 10px;
    font-size: 13px;
}

.info-row .label {
    color: var(--text-secondary);
    min-width: 80px;
}

.info-row .value {
    color: var(--text-primary);
    flex: 1;
}

.info-row .value.status-running {
    color: var(--success-color);
    font-weight: 500;
}

.info-row .value.status-stopped {
    color: var(--text-light);
}

.detail-actions {
    display: flex;
    justify-content: center;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

/* 设备列表视图 */
.list-container {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 24px;
}

.list-title {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 20px;
    text-align: center;
}

.table-wrapper {
    overflow-x: auto;
}

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

.device-table th,
.device-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.device-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.device-table tbody tr:hover {
    background: #f8f9fa;
}

.device-table td {
    color: var(--text-secondary);
}

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.status-badge.online {
    background: #e8f5e9;
    color: var(--success-color);
}

.status-badge.offline {
    background: #fafafa;
    color: var(--text-light);
}

/* 底部状态栏 */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 32px;
    background: #424242;
    color: rgba(255,255,255,0.8);
    padding: 0 16px;
    font-size: 12px;
    flex-shrink: 0;
}

/* Toast提示 */
.toast-container {
    position: fixed;
    top: 60px;
    right: 20px;
    z-index: 1000;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: white;
    border-radius: 4px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 10px;
    animation: slideIn 0.3s ease;
}

.toast.success {
    border-left: 4px solid var(--success-color);
}

.toast.error {
    border-left: 4px solid var(--danger-color);
}

.toast.info {
    border-left: 4px solid var(--primary-color);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .device-grid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    }
}

@media (max-width: 992px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 50px;
        bottom: 32px;
        z-index: 100;
        transform: translateX(-100%);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .device-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    }
    
    .detail-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .toolbar-center {
        max-width: none;
    }
    
    .filter-tabs {
        flex-wrap: wrap;
    }
    
    .device-grid {
        grid-template-columns: 1fr;
    }
    
    .device-table {
        font-size: 12px;
    }
    
    .device-table th,
    .device-table td {
        padding: 8px 10px;
    }
}

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

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

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

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

.modal-content {
    background: white;
    border-radius: 8px;
    padding: 24px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

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

.modal-title {
    font-size: 18px;
    font-weight: 500;
}

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-light);
}

.modal-close:hover {
    color: var(--text-primary);
}
