* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f8f9fa;
    color: #333;
    padding: 16px;
    line-height: 1.5;
}

header {
    text-align: center;
    margin-bottom: 20px;
    padding-top: 10px;
    position: relative;
}

h1 {
    font-size: 24px;
    font-weight: 600;
    color: #1a73e8;
}

.hidden {
    display: none;
}


.settings-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    background: #1a73e8;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: opacity 0.2s;
}

.settings-btn:hover {
    opacity: 0.85;
}

/* === 模态框通用样式 === */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: white;
    margin: 15% auto;
    padding: 20px;
    border-radius: 12px;
    max-width: 90%;
    width: 400px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    position: relative;
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 20px;
    color: #aaa;
    cursor: pointer;
}

.close-btn:hover {
    color: #333;
}

.form-group {
    margin-bottom: 16px;
}

.form-label {
    font-size: 14px;
    color: #5f6368;
    margin-bottom: 6px;
    display: block;
}

.form-input,
.form-select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
}

.submit-btn {
    background: #1a73e8;
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: opacity 0.2s;
    width: 100%;
}

.submit-btn:hover {
    opacity: 0.85;
}

.logout-btn {
    background: #535557;
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: opacity 0.2s;
    width: 100%;
}

.logout-btn:hover {
    opacity: 0.85;
}

/* === 设备网格 === */
.device-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
}

/* 普通设备卡片 */
.device-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    padding: 12px;
    margin: 8px;
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 120px;
}


/* 复杂设备全宽 */
.device-card.full-width {
    grid-column: span 2;
}

/* 设备头部信息 */
.device-header {
    display: flex;
    flex-direction: column;
}

.device-name {
    font-size: 16px;
    font-weight: 600;
    color: #202124;
    margin: 0;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 6px;
    cursor:pointer;
}

.device-type {
    font-size: 12px;
    color: #757575;
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-block;
    /* 确保标签紧凑 */
    align-self: flex-start;
    /* 标签靠左对齐 */
    max-width: fit-content;
    /* 宽度适应内容 */
}

/* 状态显示区域 */
.device-status {
    font-size: 14px;
    color: #757575;
    padding: 8px;
    border-radius: 8px;

}

/* 按钮容器 - 放置在底部 */
.device-actions {
    display: flex;
    gap: 8px;
    margin-top: auto;
    /* 将按钮推到容器底部 */
    width: 100%;
    justify-content: flex-start;

}

.status-value {
    font-weight: 600;
    color: #1a73e8;
    margin-right: 8px;
}


/* 闪烁动画 - 用于离线状态 */
@keyframes blink {

    0%,
    50% {
        opacity: 1;
    }

    51%,
    100% {
        opacity: 0.3;
    }
}

/* 离线状态的红点 - 闪烁 */
.offline {
    color: #808080;
    /* 红色 */
    opacity: 1;
}

/* 在线状态的红点 - 不闪烁，可以改为绿色或其他颜色 */
.online {
    color: #202124;
}


/* 确保初始状态 */
.online-status {
    display: inline-block;
    font-size: 12px;
}

/* === Toggle 开关 === */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .3s;
    border-radius: 13px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: #34a853;
}

input:checked+.slider:before {
    transform: translateX(24px);
}

.control-area {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toggle-label {
    font-size: 14px;
    color: #5f6368;
}

/* === 风扇多按钮 === */
.control-area {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-top: 8px;
}

.control-area .btn {
    padding: 10px 4px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    background: #e8f0fe;
    color: #1a73e8;
    cursor: pointer;
}

.control-area .btn.active {
    background: #1a73e8;
    color: white;
}

/* === 开机模块多按钮 === */
.pc-switch-control .control-area {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 8px;
}

.btn {
    padding: 10px 4px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1;
    background: #e8f0fe;
    color: #1a73e8;
}

.btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* 在线状态指示器 */
.online-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4caf50;
    margin-right: 8px;
}

/* === 传感器（只读）=== */
.sensor-card .control-area {
    display: none;
}

.sensor-values {
    display: flex;
    justify-content: space-around;
    margin-top: 8px;
}

.sensor-item {
    text-align: center;
}

.sensor-value {
    font-size: 18px;
    font-weight: 700;
    color: #1a73e8;
}

.sensor-label {
    font-size: 11px;
    color: #5f6368;
}


.refresh {
    position: fixed;
    top: -60px;
    left: 0;
    right: 0;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f3f4;
    color: #5f6368;
    font-size: 14px;
    transition: top 0.3s ease;
    z-index: 999;
    border-bottom: 1px solid #e0e0e0;
}

.alert-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.alert-box {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-width: 350px;
    width: 80%;
    text-align: center;
}

.alert-message {
    margin: 10px 0;
    color: #333;
}

.close-alert {
    margin-top: 15px;
    padding: 8px 16px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.device-card.dragging {
    opacity: 0.5;
    z-index: 1000;
}

.confirm-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.confirm-box {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-width: 350px;
    width: 80%;
    text-align: center;
}

.confirm-message {
    margin: 10px 0 20px 0;
    color: #333;
    font-size: 16px;
}

.confirm-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.confirm-cancel,
.confirm-ok {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.confirm-cancel {
    background-color: #6c757d;
    color: white;
}

.confirm-ok {
    background-color: #dc3545;
    color: white;
}

.confirm-cancel:hover,
.confirm-ok:hover {
    opacity: 0.8;
}

.nav-btn {
    font-size: 24px;
    color: #1a73e8;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    background: none;
    border: none;
    outline: none;
    cursor: pointer;
    padding: 0;
    margin: 0;
}

.mqtt-connecting {
    /*闪烁*/
    animation: blink 1s infinite;
    opacity: 1;
    font-size: 15px;
    color: #1a73e8;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
}

#deviceInfoModal table {
    width: 90%;

}
#deviceInfoModal th {
    width: 35%;
    text-align: right;
    padding: 0px 5px;
}
#deviceInfoModal td {
    width: 65%;
    padding: 0px 5px;
}