/* 基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Arial', sans-serif;
}

body {
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

/* 头部样式 */
header {
    background-color: #2c3e50;
    color: white;
    padding: 1rem;
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.header-right {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.logout-btn {
    background-color: #e74c3c;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
}

.logout-btn:hover {
    background-color: #c0392b;
}

nav {
    background-color: #34495e;
    padding: 0.5rem;
}

.home-link {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
}

.home-link:hover {
    background-color: #2c3e50;
}

/* 主内容区 */
main {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
}

section {
    background-color: white;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

h2 {
    margin-bottom: 1rem;
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
    padding-bottom: 0.5rem;
}

h3 {
    margin: 1rem 0;
    color: #34495e;
}

/* 表单样式 */
.form-group {
    margin-bottom: 1rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
}

input, textarea, select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

button {
    cursor: pointer;
}

/* 平台连接设置样式 */
.platform-section {
    text-align: center;
    padding: 2rem;
}

.platform-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    margin: 2rem 0;
    flex-wrap: wrap;
}

.platform-select {
    min-width: 200px;
}

.connection-status {
    font-weight: bold;
    min-width: 150px;
}

.status-connected {
    color: #2ecc71; /* 绿色表示已连接 */
}

.status-disconnected {
    color: #e74c3c; /* 红色表示已断开 */
}

.platform-info {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 1rem;
    color: #666;
    flex-wrap: wrap;
}

#connect-btn {
    padding: 0.75rem 2rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    transition: all 0.3s ease;
    cursor: pointer;
}

.disconnected {
    background-color: #e74c3c;
    color: white;
}

.connected {
    background-color: #2ecc71;
    color: white;
}

/* MQTT发布区域样式 */
.mqtt-publish {
    margin-top: 2rem;
    padding: 1.5rem;
    background-color: #f8f9fa;
    border-radius: 8px;
    display: inline-block;
    width: 100%;
    max-width: 600px;
}

.mqtt-publish .form-group {
    margin-bottom: 1rem;
}

.publish-btn {
    background-color: #2ecc71;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
}

.publish-btn:hover {
    background-color: #27ae60;
}

/* 功能导航样式 */
.feature-nav {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.feature-card {
    background-color: #ecf0f1;
    padding: 1.5rem;
    border-radius: 8px;
    text-align: center;
}

.feature-btn {
    display: inline-block;
    margin-top: 1rem;
    background-color: #3498db;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    text-decoration: none;
}

.feature-btn:hover {
    background-color: #2980b9;
}

/* 按钮基础样式 */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
}

.btn-primary {
    background-color: #3498db;
    color: white;
}

.btn-primary:hover {
    background-color: #2980b9;
}

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

.btn-danger:hover {
    background-color: #c0392b;
}

/* 卡片基础样式 */
.card {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.card-header {
    background-color: #f8f9fa;
    padding: 1rem;
    border-bottom: 1px solid #eee;
}

.card-body {
    padding: 1.5rem;
}

/* 容器样式 */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.mt-3 {
    margin-top: 1rem;
}

.mt-4 {
    margin-top: 1.5rem;
}

.mt-5 {
    margin-top: 2rem;
}

.mb-4 {
    margin-bottom: 1.5rem;
}

/* 警告框样式 */
.alert {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-danger {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* 登录页面 */
.login-section {
    max-width: 500px;
    margin: 2rem auto;
}

.login-btn {
    width: 100%;
    background-color: #3498db;
    color: white;
    border: none;
    padding: 0.75rem;
    border-radius: 4px;
    font-size: 1rem;
}

.login-btn:hover {
    background-color: #2980b9;
}

.error-message {
    background-color: #e74c3c;
    color: white;
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.success-message {
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.success-green {
    color: #2ecc71; /* 绿色 */
}

.success-red {
    color: #e74c3c; /* 红色 */
}

/* 表格样式 */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.data-table th,
.data-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.data-table th {
    background-color: #f8f9fa;
    font-weight: bold;
}

.actions {
    display: flex;
    gap: 0.5rem;
}

/* 按钮样式 */
.upload-btn, .save-btn, .config-btn,.detail-btn, .back-btn, .save-all-config,
.save-config, .edit-btn, .download-btn, .delete-btn, .batch-btn {
    padding: 0.5rem 1rem;
    border-radius: 4px;
    border: none;
    font-size: 0.9rem;
    text-decoration: none;
    display: inline-block;
}

.upload-btn, .save-btn {
    background-color: #2ecc71;
    color: white;
}

.upload-btn:hover, .save-btn:hover {
    background-color: #27ae60;
}

.edit-btn {
    background-color: #3498db;
    color: white;
}

.edit-btn:hover {
    background-color: #2980b9;
}

.download-btn {
    background-color: #f39c12;
    color: white;
}

.download-btn:hover {
    background-color: #d35400;
}

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

.delete-btn:hover {
    background-color: #c0392b;
}

.batch-actions {
    margin-bottom: 1rem;
    display: flex;
    gap: 1rem;
}

.batch-btn {
    background-color: #9b59b6;
    color: white;
}

.batch-btn:hover {
    background-color: #8e44ad;
}

.config-btn {
    background-color: #1abc9c;
    color: white;
    margin-right: 5px;
}

.config-btn:hover {
    background-color: #16a085;
}

.detail-btn {
    background-color: #3498db;
    color: white;
}

.detail-btn:hover {
    background-color: #2980b9;
}

/* 设备详情页面样式 */
.device-detail {
    max-width: 800px;
    margin: 0 auto;
}

.device-info-card {
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.info-row {
    display: flex;
    margin-bottom: 1rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 0.5rem;
}

.info-label {
    font-weight: bold;
    width: 150px;
    color: #7f8c8d;
}

.info-value {
    flex: 1;
    color: #333;
}

.back-btn-container {
    text-align: center;
    margin-top: 2rem;
}

.back-btn {
    background-color: #34495e;
    color: white;
}

.back-btn:hover {
    background-color: #2c3e50;
}

/* 设备配置页面 */
.radio-group {
    display: flex;
    flex-wrap: nowrap;
    gap: 1.5rem;
    margin-bottom: 1rem;
    overflow-x: auto;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0;
    white-space: nowrap;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.info-item {
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 4px;
}

.label {
    font-weight: bold;
    display: block;
    color: #7f8c8d;
}

.config-section {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eee;
}

.config-form {
    margin-top: 1rem;
}

.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 0.5rem;
}

.radio-group label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.save-config {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    margin-top: 1rem;
}

.save-config:hover {
    background-color: #2980b9;
}

/* 固件表格容器样式 */
.firmware-table-container {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 1rem;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* 模态框样式 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: white;
    margin: 15% auto;
    padding: 2rem;
    border-radius: 8px;
    width: 80%;
    max-width: 500px;
    position: relative;
}

.close-btn {
    position: absolute;
    right: 1rem;
    top: 1rem;
    font-size: 1.5rem;
    cursor: pointer;
}

/* 页脚样式 */
footer {
    text-align: center;
    padding: 1rem;
    margin-top: 2rem;
    color: #7f8c8d;
    border-top: 1px solid #eee;
}

/* 日志容器样式 */
.log-container {
    min-height: 100px; /* 设置最小高度 */
    max-height: 80vh; /* 设置最大高度为视口高度的80% */
    overflow-y: auto; /* 内容超过最大高度时显示垂直滚动条 */
    transition: max-height 0.3s ease; /* 添加过渡效果 */
}

/* 响应式调整 */
@media (max-width: 768px) {
    .platform-controls {
        flex-direction: column;
        gap: 1rem;
    }

    .platform-select, .connection-status {
        width: 100%;
    }

    .platform-info {
        flex-direction: column;
        align-items: center;
    }

    .actions {
        flex-direction: column;
    }

    .batch-actions {
        flex-wrap: wrap;
    }
}