:root {
    --primary-color: #3498db;
    --secondary-color: #2c3e50;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
    --light-color: #ecf0f1;
    --dark-color: #34495e;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8f9fa;
}

.min-vh-100 {
    min-height: 100vh;
}

.card {
    border: none;
    border-radius: 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease-in-out;
}

.card:hover {
    transform: translateY(-2px);
}

.navbar-brand {
    font-weight: 700;
}

.btn {
    border-radius: 8px;
    font-weight: 500;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), #2980b9);
    border: none;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #2980b9, var(--primary-color));
    transform: translateY(-1px);
}

.table th {
    border-top: none;
    font-weight: 600;
    color: var(--dark-color);
}

.status-badge {
    padding: 0.35em 0.65em;
    border-radius: 50px;
    font-size: 0.75em;
    font-weight: 600;
}

.status-online {
    background-color: rgba(39, 174, 96, 0.1);
    color: var(--success-color);
}

.status-offline {
    background-color: rgba(149, 165, 166, 0.1);
    color: #95a5a6;
}

.status-warning {
    background-color: rgba(243, 156, 18, 0.1);
    color: var(--warning-color);
}

.temperature-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.temp-normal { color: var(--success-color); }
.temp-warning { color: var(--warning-color); }
.temp-danger { color: var(--danger-color); }

.battery-level {
    font-weight: 600;
}

.battery-high { color: var(--success-color); }
.battery-medium { color: var(--warning-color); }
.battery-low { color: var(--danger-color); }

.wifi-strength {
    font-weight: 600;
}

.wifi-excellent { color: var(--success-color); }
.wifi-good { color: var(--warning-color); }
.wifi-weak { color: var(--danger-color); }

/* 响应式设计 */
@media (max-width: 768px) {
    .card-body {
        padding: 1rem;
    }
    
    .table-responsive {
        font-size: 0.875rem;
    }
    
    .temperature-value {
        font-size: 1.25rem;
    }
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 自定义滚动条 */
::-webkit-scrollbar {
    width: 6px;
}

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

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

::-webkit-scrollbar-thumb:hover {
    background: #2980b9;
}


/* 移动端导航栏优化 */
@media (max-width: 991.98px) {
    .navbar-collapse {
        margin-top: 0.5rem;
    }
    
    .navbar-nav .dropdown-menu {
        position: static;
        float: none;
        margin-top: 0;
    }
}

/* 超小屏幕优化 */
@media (max-width: 575.98px) {
    .container-fluid {
        padding: 0.5rem;
    }
    
    .card-body {
        padding: 0.75rem;
    }
    
    /* 实时数据卡片在超小屏幕上调整 */
    .card .row.g-1 > [class*="col-"] {
        padding-left: 2px;
        padding-right: 2px;
    }
    
    /* 表格在小屏幕上更紧凑 */
    .table-responsive {
        font-size: 0.8rem;
    }
    
    /* 图表在小屏幕上调整高度 */
    #temperatureChart,
    #batteryChart {
        height: 100px !important;
    }
    
    /* 时间段按钮在小屏幕上更紧凑 */
    .btn-group-sm > .btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
}

/* 中等屏幕优化 */
@media (max-width: 768px) {
    /* 左侧信息栏和右侧内容在中等屏幕上堆叠 */
    .col-md-4, .col-md-8 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* 确保下拉菜单在移动端正常显示 */
.dropdown-menu {
    z-index: 1021; /* 确保在导航栏上方 */
}

/* 导航栏在移动端展开时的背景色 */
@media (max-width: 991.98px) {
    .navbar-collapse {
        background-color: #0d6efd; /* 主色调 */
        padding: 1rem;
        border-radius: 0.375rem;
        margin-top: 0.5rem;
    }
}

/* 温度颜色样式 - 修正为正常字体大小 */
.temp-normal {
    color: #28a745;
}

.temp-warning {
    color: #ffc107;
}

.temp-danger {
    color: #dc3545;
}

/* 电量颜色样式 */
.battery-high {
    color: #28a745;
}

.battery-medium {
    color: #ffc107;
}

.battery-low {
    color: #dc3545;
}

/* 图表容器样式修复 */
.card-body {
    position: relative;
    overflow: hidden;
}

/* 确保Canvas在移动端正确显示 */
canvas {
    display: block;
    max-width: 100%;
    height: auto;
}

/* 移动端触摸优化 */
@media (max-width: 768px) {
    .card-body {
        -webkit-overflow-scrolling: touch;
    }
    
    /* 防止移动端触摸时选择文本 */
    canvas {
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }
}

/* 导出按钮加载状态 */
.btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

/* 设备状态卡片优化样式 */
.device-status-card .card-body {
    padding: 1rem;
}

/* 实时数据小卡片样式优化 */
.realtime-data-item {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 0.75rem;
    text-align: center;
    transition: all 0.2s;
    height: 100%;
}

.realtime-data-item:hover {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    transform: translateY(-1px);
}

.realtime-data-item .fs-5 {
    margin-bottom: 0.5rem;
}

/* 状态徽章样式 */
.status-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-online {
    background-color: #d1e7dd;
    color: #0f5132;
}

.status-offline {
    background-color: #f8d7da;
    color: #721c24;
}

/* 温度颜色样式 */
.temp-normal {
    color: #28a745;
    font-weight: 500;
}

.temp-warning {
    color: #ffc107;
    font-weight: 500;
}

.temp-danger {
    color: #dc3545;
    font-weight: 500;
}

/* 电量颜色样式 */
.battery-high {
    color: #28a745;
    font-weight: 500;
}

.battery-medium {
    color: #ffc107;
    font-weight: 500;
}

.battery-low {
    color: #dc3545;
    font-weight: 500;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .realtime-data-item {
        padding: 0.5rem;
    }
    
    .device-status-card .card-body {
        padding: 0.75rem;
    }
}


/* PWA 相关样式 */
.status-badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-online {
    background-color: #d1fae5;
    color: #065f46;
}

.status-offline {
    background-color: #fee2e2;
    color: #991b1b;
}

/* 移动端优化 */
@media (max-width: 768px) {
    .container-fluid {
        padding-left: 8px;
        padding-right: 8px;
    }
    
    .card-body {
        padding: 8px;
    }
    
    /* 导航栏中的添加到桌面按钮 */
    #addToHomeScreenBtn {
        border: none;
        background: none;
        text-decoration: none;
    }
}

/* 温度颜色 */
.temp-danger { color: #dc3545; }
.temp-warning { color: #fd7e14; }
.temp-normal { color: #198754; }

/* 电量颜色 */
.battery-high { color: #198754; }
.battery-medium { color: #fd7e14; }
.battery-low { color: #dc3545; }



/* 防止水平滚动和内容晃动 */
html, body {
    max-width: 100% !important;
    overflow-x: hidden !important;
}

body {
    width: 100% !important;
    position: relative !important;
}

/* 确保所有容器不超出视口 */
.container, .container-fluid, .row, .col, [class*="col-"] {
    max-width: 100% !important;
    overflow-x: hidden !important;
}

/* 特别针对可能引起水平滚动的元素 */
.card, .navbar, .modal-content {
    max-width: 100% !important;
}

/* 防止flex容器导致水平滚动 */
.row {
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* 确保列不会溢出 */
[class*="col-"] {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
}