/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 页面内容 */
#page-content {
    flex: 1;
    padding: 20px;
    padding-bottom: 80px; /* 为底部导航栏留出空间 */
}

.page {
    display: none;
    overflow-y: auto;
    max-height: calc(100vh - 80px);
}

.page.active {
    display: block;
}

/* 标题 */
h1 {
    text-align: center;
    margin-bottom: 20px;
    color: #333;
    font-size: 24px;
}

/* 按钮样式 */
.primary-button {
    background-color: #4CAF50;
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    margin: 10px 0;
    transition: background-color 0.3s;
}

.primary-button:hover {
    background-color: #45a049;
}

.secondary-button {
    background-color: #f0f0f0;
    color: #333;
    padding: 8px 16px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
}

.secondary-button:hover {
    background-color: #e0e0e0;
}

/* 表单组 */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
}

.form-group input[type="file"],
.form-group input[type="text"],
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    background-color: white;
}

/* 滑块容器 */
.slider-container {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
}

.slider-container label {
    flex: 0 0 120px;
    font-weight: 600;
    color: #555;
}

.slider-container input[type="range"] {
    flex: 1;
    margin: 0 10px;
}

.slider-container span {
    flex: 0 0 40px;
    text-align: right;
    font-weight: 600;
}

/* 按钮组 */
.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.button-group button {
    flex: 1;
    min-width: 100px;
}

/* 结果区域 */
.result {
    margin-top: 20px;
    padding: 15px;
    background-color: #f9f9f9;
    border-radius: 8px;
    border: 1px solid #ddd;
}

/* 信息文本 */
.info {
    color: #666;
    font-size: 14px;
    margin-top: 8px;
}

/* 底部导航栏 */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: white;
    display: flex;
    justify-content: space-around;
    padding: 10px 0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #999;
    font-size: 12px;
    padding: 5px;
    transition: color 0.3s;
}

.nav-item.active {
    color: #4CAF50;
}

.nav-item i {
    font-size: 24px;
    margin-bottom: 4px;
}

/* 蓝牙页面 */
.bluetooth-container {
    background-color: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.status {
    text-align: center;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 8px;
    font-weight: 600;
}

.status:not(.connected) {
    background-color: #ffebee;
    color: #c62828;
}

.status.connected {
    background-color: #e8f5e8;
    color: #2e7d32;
}

.device-list {
    margin: 20px 0;
}

.device-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background-color: #f5f5f5;
    border-radius: 8px;
    margin-bottom: 10px;
}

.device-item button {
    background-color: #2196F3;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
}

/* 占位页面 */
.placeholder-content {
    text-align: center;
    padding: 60px 20px;
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.placeholder-content .icon {
    font-size: 64px;
    color: #999;
    margin-bottom: 20px;
}

.placeholder-content h2 {
    color: #666;
    margin-bottom: 10px;
}

.placeholder-content p {
    color: #999;
    font-size: 14px;
}

/* 画布样式 */
#canvas {
    border: 1px solid #ddd;
    border-radius: 8px;
    margin: 15px auto;
    display: block;
    max-width: 100%;
    height: auto;
}

/* 标签页样式 */
.tabs {
    display: flex;
    margin-bottom: 20px;
    border-bottom: 1px solid #ddd;
}

.tab {
    flex: 1;
    padding: 12px;
    text-align: center;
    cursor: pointer;
    background-color: #f5f5f5;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    font-weight: 600;
    color: #666;
    transition: all 0.3s;
}

.tab.active {
    background-color: white;
    color: #4CAF50;
    border-bottom: 3px solid #4CAF50;
}

.tab-content {
    display: none;
    padding: 15px;
    background-color: white;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.tab-content.active {
    display: block;
}

/* 响应式设计 */
@media (max-width: 768px) {
    #page-content {
        padding: 15px;
    }

    h1 {
        font-size: 20px;
    }

    .button-group {
        flex-direction: column;
    }

    .button-group button {
        width: 100%;
    }

    .slider-container label {
        flex: 0 0 100px;
        font-size: 14px;
    }
}

/* 动画效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.page.active {
    animation: fadeIn 0.3s ease-out;
}

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

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

/* 错误提示 */
.error {
    color: #c62828;
    margin-top: 10px;
    font-size: 14px;
}

/* 成功提示 */
.success {
    color: #2e7d32;
    margin-top: 10px;
    font-size: 14px;
}

/* 传输进度样式 */
.transfer-container {
    margin: 15px 0;
    padding: 15px;
    background-color: #f5f5f5;
    border-radius: 8px;
    border: 1px solid #ddd;
}

.transfer-status {
    text-align: center;
    font-size: 14px;
    color: #333;
    margin-bottom: 10px;
    font-weight: 600;
}

.progress-bar {
    width: 100%;
    height: 20px;
    background-color: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
}

.progress-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #45a049);
    transition: width 0.3s ease;
}

.transfer-progress {
    text-align: center;
    font-size: 14px;
    color: #666;
    margin-top: 8px;
    font-weight: 600;
}

/* OTA升级页面样式 */
.ota-container {
    background-color: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.ota-info {
    text-align: center;
    color: #666;
    margin-bottom: 20px;
    font-size: 14px;
}

.ota-file-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.ota-file-size {
    color: #666;
    font-size: 14px;
}

.ota-tips {
    margin-top: 20px;
    padding: 15px;
    background-color: #fff3e0;
    border-radius: 8px;
    border: 1px solid #ffcc80;
}

.ota-tips h3 {
    color: #e65100;
    font-size: 16px;
    margin-bottom: 10px;
}

.ota-tips ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ota-tips li {
    color: #666;
    font-size: 14px;
    padding: 5px 0;
    padding-left: 20px;
    position: relative;
}

.ota-tips li:before {
    content: "•";
    color: #ff9800;
    position: absolute;
    left: 0;
    font-weight: bold;
}

/* 设置页面样式 */
.settings-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.settings-section {
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 20px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    font-weight: 600;
    color: #333;
}

.section-header i {
    color: #4CAF50;
    font-size: 22px;
}

.section-content {
    padding: 20px;
}

.setting-item {
    margin-bottom: 15px;
}

.setting-item:last-child {
    margin-bottom: 0;
}

.setting-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.setting-label {
    font-weight: 600;
    color: #555;
    font-size: 15px;
}

.setting-value {
    color: #4CAF50;
    font-weight: 600;
    font-size: 15px;
}

.battery-bar {
    width: 100%;
    height: 12px;
    background-color: #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
}

.battery-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #66BB6A);
    border-radius: 6px;
    transition: width 0.3s ease;
}

.button-row {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.button-row .secondary-button {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 12px;
}

.button-row .secondary-button i {
    font-size: 18px;
}

.secondary-button.warning {
    background-color: #fff3e0;
    color: #e65100;
    border: 1px solid #ffcc80;
}

.secondary-button.warning:hover {
    background-color: #ffe0b2;
}

.secondary-button.danger {
    background-color: #ffebee;
    color: #c62828;
    border: 1px solid #ffcdd2;
}

.secondary-button.danger:hover {
    background-color: #ffcdd2;
}

.file-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.file-list-header span {
    font-weight: 600;
    color: #555;
}

.icon-button {
    background: none;
    border: none;
    padding: 5px;
    cursor: pointer;
    color: #666;
    border-radius: 50%;
    transition: all 0.3s;
}

.icon-button:hover {
    background-color: #f0f0f0;
    color: #4CAF50;
}

.icon-button i {
    font-size: 22px;
}

.file-list {
    max-height: 150px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 10px;
}

.file-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background-color 0.2s;
}

.file-item:last-child {
    border-bottom: none;
}

.file-item:hover {
    background-color: #f5f5f5;
}

.file-item.selected {
    background-color: #e8f5e8;
}

.file-item.displaying {
    background-color: #e3f2fd;
    border-left: 3px solid #2196F3;
}

.file-item input[type="checkbox"] {
    margin-right: 10px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.file-item .file-id {
    min-width: 30px;
    font-weight: 600;
    color: #2196F3;
    margin-right: 10px;
}

.file-item .file-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
    color: #333;
}

.file-item .file-size {
    font-size: 12px;
    color: #999;
    margin-left: 10px;
}

.empty-state {
    text-align: center;
    padding: 30px 20px;
    color: #999;
    font-size: 14px;
}

.mode-selector {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.mode-button {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 15px 10px;
    background-color: #f5f5f5;
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    color: #666;
    font-weight: 600;
    font-size: 14px;
}

.mode-button i {
    font-size: 28px;
}

.mode-button:hover {
    background-color: #e8e8e8;
}

.mode-button.active {
    background-color: #e8f5e8;
    border-color: #4CAF50;
    color: #2e7d32;
}

.switch-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}

.switch-item:last-child {
    border-bottom: none;
}

.switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider-toggle {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 28px;
}

.slider-toggle:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.switch input:checked + .slider-toggle {
    background-color: #4CAF50;
}

.switch input:checked + .slider-toggle:before {
    transform: translateX(24px);
}

.slider-container {
    margin-top: 5px;
}

.slider-container input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e0e0e0;
    outline: none;
    -webkit-appearance: none;
}

.slider-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #4CAF50;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.slider-ticks {
    display: flex;
    justify-content: space-between;
    margin-top: 5px;
    font-size: 12px;
    color: #999;
}

.wake-slider-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.wake-slider-wrapper .slider-container {
    flex: 1;
    margin: 0;
}

.wake-min,
.wake-max {
    font-size: 12px;
    color: #999;
    white-space: nowrap;
}

.debug-log {
    background-color: #1e1e1e;
    color: #d4d4d4;
    padding: 10px;
    font-family: monospace;
    font-size: 11px;
    max-height: 150px;
    overflow-y: auto;
    margin-bottom: 15px;
    border-radius: 8px;
    display: none;
}

.debug-log.show {
    display: block;
}

.debug-log .log-entry {
    margin: 2px 0;
    padding: 2px 0;
    border-bottom: 1px solid #333;
}

.debug-log .log-entry.error {
    color: #f48771;
}

.debug-log .log-entry.success {
    color: #89d185;
}

.debug-log .log-entry.info {
    color: #75beff;
}

.setting-hint {
    display: block;
    font-size: 12px;
    color: #999;
    font-weight: normal;
    margin-top: 2px;
}

.setting-hint-icon {
    position: relative;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
}

.setting-hint-icon i {
    font-size: 18px;
    color: #ff9800;
}

.hint-tooltip {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #333;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 100;
    margin-bottom: 5px;
}

.hint-tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #333;
}

.setting-hint-icon:hover .hint-tooltip {
    display: block;
}