/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', 'Segoe UI', Arial, sans-serif;
    background: #f5f7fa;
    min-height: 100vh;
}

/* 头部样式 */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left h1 {
    font-size: 24px;
    font-weight: 500;
    margin-bottom: 5px;
}

.header-left h1 i {
    margin-right: 10px;
}

.header-left .subtitle {
    font-size: 14px;
    opacity: 0.9;
}

.btn-refresh {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 10px 20px;
    border-radius: 6px;
    transition: all 0.3s;
}

.btn-refresh:hover {
    background: rgba(255,255,255,0.3);
    color: white;
}

/* 主容器 */
.main-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 30px;
}

/* 统计卡片网格 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 0;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    display: flex;
    overflow: hidden;
}

.stat-icon {
    width: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    color: white;
}

.stat-icon.bg-primary { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.stat-icon.bg-success { background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%); }
.stat-icon.bg-danger { background: linear-gradient(135deg, #eb3349 0%, #f45c43 100%); }
.stat-icon.bg-info { background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); }

.stat-content {
    flex: 1;
    padding: 25px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.stat-content h3 {
    color: #666;
    font-size: 14px;
    font-weight: 400;
    margin-bottom: 10px;
}

.stat-content .value {
    font-size: 36px;
    font-weight: 600;
    color: #333;
}

.stat-content .value.text-success { color: #52c41a; }
.stat-content .value.text-danger { color: #ff4d4f; }
.stat-content .value.text-info { color: #1890ff; }

/* 面板样式 */
.panel {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    margin-bottom: 30px;
    overflow: hidden;
}

.panel-header {
    padding: 20px 25px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fafafa;
}

.panel-header h2 {
    font-size: 18px;
    color: #333;
    font-weight: 500;
    margin: 0;
}

.panel-header h2 i {
    margin-right: 8px;
    color: #667eea;
}

.panel-body {
    padding: 25px;
}

.refresh-info {
    font-size: 14px;
    color: #999;
}

/* 按钮样式 */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
}

.btn-success:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, #eb3349 0%, #f45c43 100%);
    color: white;
}

.btn-danger:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    color: white;
}

.btn-secondary {
    background: #999;
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn i {
    margin-right: 5px;
}

/* 表格样式 */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
}

.table th {
    background: #fafafa;
    font-weight: 500;
    color: #666;
    font-size: 14px;
    white-space: nowrap;
}

.table td {
    color: #333;
    font-size: 14px;
}

.table tbody tr:hover {
    background: #f5f7fa;
}

.table-responsive {
    overflow-x: auto;
}

/* 状态标签 */
.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.status-online {
    background: #f6ffed;
    color: #52c41a;
}

.status-offline {
    background: #fff2f0;
    color: #ff4d4f;
}

.status-enabled {
    background: #e6f7ff;
    color: #1890ff;
}

.status-disabled {
    background: #f5f5f5;
    color: #999;
}

/* 表单样式 */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-size: 14px;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s;
    min-height: 45px;
    line-height: 1.5;
}

.form-control select {
    min-height: 45px;

    line-height: 1.5;
}

select.form-control {
    min-height: 45px;

    line-height: 1.5;
    height: auto;
}

select.form-control option {
    padding: 12px 15px;
    line-height: 1.8;
    min-height: 45px;
    white-space: normal;
    word-wrap: break-word;
    font-size: 14px;
}

#apiDeviceSelect,
#apiValueSelect {
    min-height: 45px;
    padding: 12px 15px;
    line-height: 1.8;
    font-size: 14px;
}

#apiDeviceSelect option,
#apiValueSelect option {
    padding: 12px 15px;
    line-height: 1.8;
    min-height: 45px;
    white-space: normal;
    word-wrap: break-word;
    font-size: 14px;
    height: auto;
}

.form-control:focus {
    outline: none;
    border-color: #667eea;
}

.text-danger {
    color: #ff4d4f;
}

/* 模态框样式 */
.modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid #f0f0f0;
}

.modal-title {
    font-size: 18px;
    color: #333;
    margin: 0;
}

.modal-body {
    padding: 25px;
}

.modal-footer {
    padding: 20px 25px;
    border-top: 1px solid #f0f0f0;
    text-align: right;
}

.modal-footer .btn {
    margin-left: 10px;
}

.close {
    font-size: 28px;
    font-weight: 300;
    color: #999;
}

.close:hover {
    color: #666;
}

/* 空状态 */
.text-center {
    text-align: center;
}

.text-muted {
    color: #999;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .panel-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }

    .container-fluid.main-container {
        padding: 15px;
    }

    .stat-card {
        flex-direction: column;
    }

    .stat-icon {
        width: 100%;
        padding: 15px;
    }
}

/* 加载动画 */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.loading::after {
    content: '';
    width: 30px;
    height: 30px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 操作按钮组 */
.action-btns {
    display: flex;
    gap: 8px;
}

/* 分隔线 */
hr {
    border: none;
    border-top: 1px solid #f0f0f0;
    margin: 20px 0;
}

/* 面包屑 */
.breadcrumb {
    background: transparent;
    padding: 0;
    margin-bottom: 20px;
}

.breadcrumb-item a {
    color: #667eea;
    text-decoration: none;
}

.breadcrumb-item a:hover {
    text-decoration: underline;
}

.breadcrumb-item.active {
    color: #999;
}

/* 面板头部按钮组 */
.header-btns {
    display: flex;
    gap: 10px;
}

/* 模板编辑样式 */
.template-toolbar {
    margin-bottom: 15px;
    padding: 10px;
    background: #f5f7fa;
    border-radius: 6px;
    display: flex;
    gap: 10px;
}

.template-toolbar .btn {
    padding: 8px 15px;
}

.template-container {
    overflow: auto;
    max-height: 400px;
    border: 1px solid #ffffff;
    border-radius: 6px;
    padding: 10px;
    background: #000000;
}

.template-table {
    border-collapse: collapse;
    border-style: solid;
    border-width: 1px;
    color: aliceblue;  /* 淡蓝色文字 */
    width: 100%;
    margin: 0px;
    padding: 0px;
    font-size: 18px;
    table-layout: fixed;
    background: #000000;
}

.template-table td {
    border: 1px solid aliceblue;  /* 淡蓝色边框 */
    height: 22px;
    padding: 4px;
    text-align: center;
    vertical-align: middle;
}

.template-table td:hover {
    background: #1a1a1a;
}

/* 预览表格样式 */
#previewTable {
    border-collapse: collapse;
    border-style: solid;
    border-width: 1px;
    color: aliceblue;
    width: 100%;
    font-size: 18px;
    table-layout: fixed;
    background: #000000;
}

#previewTable td {
    border: 1px solid aliceblue;
    padding: 8px;
    min-width: 80px;
    min-height: 40px;
    text-align: center;
}

.template-cell {
    width: 100%;
    min-height: 40px;
    padding: 8px;
    border: none;
    background: transparent;
    text-align: center;
    cursor: pointer;
    color: red;  /* 文字红色 */
    font-size: 12px;
}

.template-cell:focus {
    outline: 2px solid #667eea;
    outline-offset: -2px;
}

.template-cell .cell-label {
    display: block;
    font-size: 10px;
    color: aliceblue;  /* 标签使用淡蓝色 */
    margin-bottom: 2px;
}

.template-cell .cell-value {
    font-weight: 500;
}

.cell-type-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cell-type-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
}

.cell-type-item:hover {
    border-color: #667eea;
    background: #f0f7ff;
}

.cell-type-item i {
    font-size: 18px;
    color: #667eea;
    width: 24px;
}

.cell-type-item span {
    font-size: 14px;
    color: #333;
}

.delete-cell {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    line-height: 16px;
    text-align: center;
    font-size: 12px;
    color: #ff4d4f;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s;
    background: white;
    border-radius: 50%;
}

.template-table td:hover .delete-cell {
    opacity: 1;
}

.template-hint {
    font-size: 12px;
    color: #999;
    text-align: center;
    padding: 30px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logout-form {
    margin: 0;
}

.btn-logout {
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.55);
    background: transparent;
}

.btn-logout:hover,
.btn-logout:focus {
    color: #1f2933;
    background: #fff;
}

.login-page {
    min-height: 100vh;
    margin: 0;
    color: #1f2933;
    background: #f3f6f8;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-panel {
    width: 100%;
    max-width: 400px;
    padding: 36px;
    border: 1px solid #d8e0e5;
    border-top: 4px solid #147d64;
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 14px 36px rgba(31, 41, 51, 0.12);
}

.login-heading {
    margin-bottom: 28px;
    text-align: center;
}

.login-heading h1 {
    margin: 14px 0 6px;
    font-size: 25px;
    font-weight: 600;
}

.login-heading p {
    margin: 0;
    color: #65727c;
}

.login-icon {
    display: inline-grid;
    width: 48px;
    height: 48px;
    place-items: center;
    border-radius: 6px;
    color: #fff;
    background: #147d64;
    font-size: 21px;
}

.login-form label {
    font-weight: 600;
}

.login-input {
    position: relative;
}

.login-input > i {
    position: absolute;
    top: 50%;
    left: 13px;
    z-index: 1;
    color: #77848d;
    transform: translateY(-50%);
}

.login-input .form-control {
    height: 44px;
    padding-left: 39px;
}

.login-input .form-control:focus {
    border-color: #147d64;
    box-shadow: 0 0 0 0.2rem rgba(20, 125, 100, 0.15);
}

.login-submit {
    height: 44px;
    margin-top: 24px;
    border-color: #147d64;
    background: #147d64;
}

.login-submit:hover,
.login-submit:focus {
    border-color: #0f6651;
    background: #0f6651;
}

.login-error {
    margin-bottom: 18px;
    padding: 10px 12px;
    border-left: 3px solid #c0392b;
    color: #8f2d22;
    background: #fff2f0;
}

.login-error ul {
    margin: 0;
    padding-left: 18px;
}

@media (max-width: 575.98px) {
    .login-shell {
        padding: 16px;
    }

    .login-panel {
        padding: 28px 22px;
    }

    .header-right {
        flex-wrap: wrap;
        justify-content: flex-end;
    }
}
