/* 基础样式 */
:root {
    --green-alert: #4CAF50;
    --yellow-alert: #FFC107;
    --red-alert: #F44336;
    --primary-color: #2196F3;
    --secondary-color: #607D8B;
    --warning-color: #F44336;
     /* 系统警报颜色 */
    --sys-green: #2E7D32;
    --sys-yellow: #F9A825;
    --sys-red: #C62828;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    border-top: 60px;
    background-color: #f5f7fa;
    color: #333;
    transition: all 0.3s ease;
}

/* 警报状态 */
body.alert-green {
    background-color: rgba(76, 175, 80, 0.1);
}

body.alert-yellow {
    background-color: rgba(255, 193, 7, 0.1);
}

body.alert-red {
    background-color: rgba(244, 67, 54, 0.1);
}

/* 头部样式 */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

h1 {
    margin: 0;
    font-size: 1.5rem;
    color: #2c3e50;
}

/* 控制面板样式 */
.control-panel {
    background-color: white;
    padding: 0; /* 初始无内边距 */
    margin: 0 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    max-height: 0;
    overflow: hidden;
    transition: all 0.3s ease;
}

.control-panel.open {
    max-height: 1000px;
    padding: 20px;
    margin-bottom: 20px;
}

.panel-section {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.panel-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.panel-section h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: var(--secondary-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 按钮样式 */
button {
    padding: 8px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s ease;
}

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

button.secondary {
    background-color: var(--secondary-color);
    color: white;
}

button.warning {
    background-color: var(--warning-color);
    color: white;
}

button:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* 控制元素样式 */
.url-control {
    display: flex;
    gap: 10px;
}

#apiUrl {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

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

.refresh-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

#refreshInterval {
    width: 60px;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.auto-refresh-status {
    color: #666;
    font-style: italic;
    font-size: 14px;
}

/* 警报规则样式 */
.alert-rules {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.alert-rule {
    display: none;
    gap: 10px;
    align-items: center;
    padding: 10px;
    background-color: #f9f9f9;
    border-radius: 4px;
    border-left: 4px solid #ddd;
}

.alert-rule.show {
    display: flex;
}
.alert-rule.green {
    border-left-color: var(--green-alert);
}

.alert-rule.yellow {
    border-left-color: var(--yellow-alert);
}

.alert-rule.red {
    border-left-color: var(--red-alert);
}

.sensor-select, .alert-level {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    min-width: 120px;
}

.threshold, .custom-message {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.threshold {
    width: 80px;
}

.custom-message {
    flex: 1;
}

.remove-rule {
    padding: 8px;
    min-width: auto;
}

/* 数据容器 */
.data-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    border-top: 20px solid #f5f7fa;
    padding: 0 20px 20px;
}

.sensor-card {
    background-color: white;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    position: relative;
}

.sensor-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background-color: #ddd;
    border-radius: 8px 0 0 8px;
}

.sensor-card.alert-green::before {
    background-color: var(--green-alert);
}

.sensor-card.alert-yellow::before {
    background-color: var(--yellow-alert);
}

.sensor-card.alert-red::before {
    background-color: var(--red-alert);
}

.sensor-header {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 10px;
}

.sensor-name {
    font-weight: bold;
    color: #333;
    font-size: 1.1rem;
}

.sensor-time {
    color: #666;
    font-size: 0.8rem;
}

.sensor-value {
    display: flex;
    justify-content: space-between;
    margin: 8px 0;
}

.value-item {
    flex: 1;
    text-align: center;
}

.value-label {
    font-weight: bold;
    color: #555;
    font-size: 0.9rem;
}

.value-data {
    font-size: 1.2rem;
    color: #2c3e50;
    font-weight: bold;
}

.status {
    margin-top: 10px;
    font-style: italic;
    color: #666;
    font-size: 0.8rem;
}

/* 加载指示器 */
.loading {
    text-align: center;
    padding: 20px;
    display: none;
}

.loading i {
    margin-right: 10px;
}

/* 警报覆盖层基础样式 */
.alert-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.alert-overlay.hidden {
    display: none;
}

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

/* 警报内容框样式 */
.alert-content {
    background-color: white;
    padding: 2.5rem;
    border-radius: 8px;
    width: 600px;  /* 固定宽度 */
    min-height: 200px;  /* 最小高度 */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}


/* 不同警报级别的边框颜色 */
.alert-content.alert-green {
    border-left: 6px solid var(--green-alert);
}

.alert-content.alert-yellow {
    border-left: 6px solid var(--yellow-alert);
}

.alert-content.alert-red {
    border-left: 6px solid var(--red-alert);
}

/* 系统警报样式 - 无边框，仅文字颜色 */
.alert-content.sys-green h2,
.alert-content.sys-green #alertMessage {
    color: var(--sys-green);
}
.alert-content.sys-yellow h2,
.alert-content.sys-yellow #alertMessage {
    color: var(--sys-yellow);
}
.alert-content.sys-red h2,
.alert-content.sys-red #alertMessage {
    color: var(--sys-red);
}
/* 标题样式 */
#alertTitle {
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
}

/* 消息内容样式 */
#alertMessage {
    font-size: 1.2rem;
    line-height: 1.6;
    flex-grow: 1;
}

/* 确认按钮样式 */
#acknowledgeAlert {
    align-self: flex-end;
    padding: 0.8rem 1.5rem;
    background-color: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
}

#acknowledgeAlert:hover {
    background-color: #e0e0e0;
}

/* 显示/隐藏控制 */
.alert-overlay.hidden {
    display: none;
}
.alert-overlay.show {
    display: flex;
}

/* 外部警报指示器样式 */
.external-alert-indicator {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-weight: bold;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    z-index: 999;
}

.external-alert-indicator.green {
    background-color: var(--green-alert);
}
.external-alert-indicator.yellow {
    background-color: var(--yellow-alert);
}
.external-alert-indicator.red {
    background-color: var(--red-alert);
}
/* 进度条 */
.alert-progress {
    height: 3px;
    background: rgba(255,255,255,0.3);
    width: 100%;
    position: absolute;
    bottom: 0;
    left: 0;
    animation: progress 10s linear forwards;
}

@keyframes progress {
    from { width: 100% }
    to { width: 0% }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .alert-rule {
        flex-wrap: wrap;
    }
    
    .alert-rule > * {
        flex: 1 1 100%;
    }
    
    .data-container {
        grid-template-columns: 1fr;
    }
}