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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #000;
    color: #fff;
    overflow-x: hidden;
}

/* 隐藏类 */
.hidden {
    display: none !important;
}

/* 顶部导航栏 */
.header {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    padding: 10px 0;
    border-bottom: 2px solid #4a00e0;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
}

.logo {
    font-size: 24px;
    font-weight: bold;
    background: linear-gradient(135deg, #ff6b6b, #4ecdc4, #45b7d1, #96ceb4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav {
    display: flex;
    gap: 20px;
}

.nav-item {
    color: #fff;
    text-decoration: none;
    font-size: 14px;
    padding: 8px 12px;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* 主内容区域 */
.main {
    min-height: calc(100vh - 60px);
    background: radial-gradient(circle at center, #0f0f23 0%, #000 100%);
}

/* 欢迎页面 */
.welcome-section {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 60px);
    background: radial-gradient(circle at center, #0f0f23 0%, #000 100%);
    position: relative;
    overflow: hidden;
}

.welcome-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('../images/star-field.svg') repeat;
    animation: starField 200s linear infinite;
    opacity: 0.3;
}

@keyframes starField {
    0% { transform: translateY(0); }
    100% { transform: translateY(-100%); }
}

.welcome-content {
    text-align: center;
    z-index: 1;
    max-width: 800px;
    padding: 20px;
}

.welcome-title {
    font-size: 8rem;
    font-weight: bold;
    background: linear-gradient(135deg, #ff6b6b, #4ecdc4, #45b7d1, #96ceb4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 20px;
    text-shadow: 0 0 30px rgba(255, 107, 107, 0.5);
    animation: titleGlow 3s ease-in-out infinite alternate;
}

@keyframes titleGlow {
    0% { text-shadow: 0 0 30px rgba(255, 107, 107, 0.5); }
    100% { text-shadow: 0 0 50px rgba(78, 205, 196, 0.8); }
}

.welcome-subtitle {
    font-size: 1.5rem;
    color: #ccc;
    margin-bottom: 30px;
}

.welcome-tips {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 40px;
    backdrop-filter: blur(10px);
}

.welcome-tips p {
    font-size: 14px;
    color: #aaa;
    line-height: 1.6;
}

.connect-btn {
    padding: 15px 40px;
    font-size: 1.2rem;
    font-weight: bold;
    color: #fff;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
    position: relative;
    overflow: hidden;
}

.connect-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: all 0.5s ease;
}

.connect-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 40px rgba(102, 126, 234, 0.6);
}

.connect-btn:hover::before {
    left: 100%;
}

.connect-btn:active {
    transform: translateY(0);
}

/* 设备管理页面 */
.device-section {
    display: flex;
    min-height: calc(100vh - 60px);
}

/* 左侧侧边栏 */
.sidebar {
    width: 280px;
    background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
    border-right: 2px solid #4a00e0;
    padding: 20px 0;
}

.device-info {
    padding: 0 20px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.device-name {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 5px;
}

.device-type {
    font-size: 12px;
    color: #aaa;
    margin-bottom: 10px;
}

.device-sn {
    font-size: 11px;
    color: #888;
    margin-bottom: 15px;
    word-break: break-all;
}

.device-switch {
    margin-top: 10px;
}

.device-select {
    width: 100%;
    padding: 8px;
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    font-size: 14px;
}

.config-switch {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.config-title {
    font-size: 14px;
    color: #aaa;
    margin-bottom: 10px;
}

.config-item {
    padding: 8px 12px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.config-item.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.sidebar-nav {
    padding: 20px 0;
}

.nav-section {
    margin-bottom: 20px;
}

.nav-section-title {
    font-size: 12px;
    color: #aaa;
    padding: 0 20px 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sidebar-nav .nav-item {
    display: block;
    padding: 12px 20px;
    margin: 0;
    border-radius: 0;
}

.sidebar-nav .nav-item.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

/* 右侧主内容 */
.content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

/* 键盘布局 */
.keyboard-layout {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.keyboard-image {
    flex: 1;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.keyboard-image::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('../images/keyboard-bg.png') no-repeat center center;
    background-size: contain;
    opacity: 0.1;
    z-index: 0;
}

#keyboard-container {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 20px;
    max-width: 1000px;
    margin: 0 auto;
}

/* 默认样式（60配列） */
#keyboard-container.layout-60 {
    max-width: 950px;
    margin: 0 auto;
}

#keyboard-container.layout-60 .keyboard-row {
    display: flex;
    gap: 3px;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    width: fit-content;
}

#keyboard-container.layout-60 .key {
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    padding: 10px;
    text-align: center;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 60px;
    height: 45px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
}

/* 60配列按键宽度类 */
#keyboard-container.layout-60 .key.wide {
    width: 120px;
}

#keyboard-container.layout-60 .key.double-wide {
    width: 180px;
}

#keyboard-container.layout-60 .key.triple-wide {
    width: 240px;
}

#keyboard-container.layout-60 .key.space {
    flex: 1;
    min-width: 300px;
}

/* 60配列特殊处理 */
#keyboard-container.layout-60 .keyboard-row:nth-child(1) .key:first-child {
    width: 60px; /* ESC按键缩小10px */
}

#keyboard-container.layout-60 .keyboard-row:nth-child(1) .key:last-child {
    width: 120px;
}

#keyboard-container.layout-60 .keyboard-row:nth-child(2) .key:first-child {
    width: 90px;
}

#keyboard-container.layout-60 .keyboard-row:nth-child(2) .key:last-child {
    width: 85px; /* |按键缩小50px */
}

#keyboard-container.layout-60 .keyboard-row:nth-child(3) .key:first-child {
    width: 105px;
}

#keyboard-container.layout-60 .keyboard-row:nth-child(3) .key:last-child {
    width: 135px;
}

#keyboard-container.layout-60 .keyboard-row:nth-child(4) .key:first-child {
    width: 120px;
}

#keyboard-container.layout-60 .keyboard-row:nth-child(4) .key:last-child {
    width: 180px;
}

#keyboard-container.layout-60 .keyboard-row:nth-child(5) .key {
    width: 90px;
}

/* FN1按键缩小0.3（60px） */
#keyboard-container.layout-60 .keyboard-row:nth-child(5) .key:last-child {
    width: 60px;
}

/* 80配列样式 */
#keyboard-container.layout-80 {
    max-width: 900px;
    margin: 0 auto;
}

#keyboard-container.layout-80 .keyboard-row {
    display: flex;
    gap: 3px;
    align-items: center;
    justify-content: center;
    width: fit-content;
    margin: 0 auto;
}

#keyboard-container.layout-80 .key {
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    padding: 10px;
    text-align: center;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 50px;
    height: 40px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
}

/* 80配列按键宽度类 */
#keyboard-container.layout-80 .key.wide {
    width: 80px;
}

#keyboard-container.layout-80 .key.double-wide {
    width: 120px;
}

#keyboard-container.layout-80 .key.triple-wide {
    width: 160px;
}

#keyboard-container.layout-80 .key.space {
    flex: 1;
    min-width: 200px;
}

/* 80配列特殊处理 */
#keyboard-container.layout-80 .keyboard-row:nth-child(1) .key:first-child {
    width: 60px;
}

#keyboard-container.layout-80 .keyboard-row:nth-child(1) .key:last-child {
    width: 80px;
}

#keyboard-container.layout-80 .keyboard-row:nth-child(2) .key:first-child {
    width: 60px;
}

#keyboard-container.layout-80 .keyboard-row:nth-child(2) .key:last-child {
    width: 80px;
}

#keyboard-container.layout-80 .keyboard-row:nth-child(3) .key:first-child {
    width: 70px;
}

#keyboard-container.layout-80 .keyboard-row:nth-child(3) .key:last-child {
    width: 90px;
}

#keyboard-container.layout-80 .keyboard-row:nth-child(4) .key:first-child {
    width: 80px;
}

#keyboard-container.layout-80 .keyboard-row:nth-child(4) .key:last-child {
    width: 120px;
}

#keyboard-container.layout-80 .keyboard-row:nth-child(5) .key:first-child {
    width: 100px;
}

#keyboard-container.layout-80 .keyboard-row:nth-child(5) .key:last-child {
    width: 80px;
}

#keyboard-container.layout-80 .keyboard-row:nth-child(6) .key {
    width: 60px;
}

.key-trigger {
    font-size: 8px;
    color: #667eea;
    margin-top: 2px;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(102, 126, 234, 0.5);
}

.key:hover {
    background-color: rgba(102, 126, 234, 0.3);
    border-color: #667eea;
    box-shadow: 0 0 15px rgba(102, 126, 234, 0.5);
}

.key.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.7);
}

.key.active .key-trigger {
    color: #fff;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.8);
}

.key:hover {
    background-color: rgba(102, 126, 234, 0.3);
    border-color: #667eea;
    box-shadow: 0 0 15px rgba(102, 126, 234, 0.5);
}

.key.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.7);
}

.key.wide {
    min-width: 80px;
}

.key.space {
    min-width: 200px;
}

.keyboard-options {
    width: 120px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.option-item {
    padding: 12px;
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    text-align: center;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.option-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.option-item.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-color: #667eea;
}

/* 配置内容 */
.config-content {
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.tab-content {
    display: none;
}

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

/* 标签页头部 */
.tab-header {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.tab-btn {
    padding: 10px 20px;
    background-color: rgba(255, 255, 255, 0.05);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
}

.tab-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.tab-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

/* 标签页面板 */
.tab-panel {
    display: none;
}

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

/* 设置项 */
.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.setting-label {
    font-size: 14px;
    color: #ccc;
    flex: 1;
}

.setting-control {
    flex: 2;
    display: flex;
    align-items: center;
    gap: 15px;
    justify-content: flex-end;
}

/* 切换开关 */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

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

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
    border-radius: 34px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: all 0.3s ease;
    border-radius: 50%;
}

input:checked + .toggle-slider {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

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

/* 滑块控件 */
input[type="range"] {
    -webkit-appearance: none;
    width: 200px;
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.5);
    transition: all 0.3s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.8);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.5);
    transition: all 0.3s ease;
}

input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.8);
}

.range-value {
    min-width: 60px;
    text-align: center;
    font-size: 14px;
    color: #ccc;
    background-color: rgba(255, 255, 255, 0.1);
    padding: 5px 10px;
    border-radius: 4px;
}

/* 轴体选项 */
.axis-options {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.axis-btn {
    padding: 10px 20px;
    background-color: rgba(255, 255, 255, 0.05);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
}

.axis-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.axis-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.axis-info {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.axis-image {
    text-align: center;
}

.axis-image img {
    max-width: 150px;
    height: auto;
    margin-bottom: 10px;
    filter: drop-shadow(0 0 10px rgba(102, 126, 234, 0.5));
}

.axis-type {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 5px;
}

.axis-spec {
    font-size: 14px;
    color: #aaa;
}

/* 校准提示 */
.calibration-tips {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 15px;
    margin: 20px 0;
    text-align: center;
    font-size: 14px;
    color: #ccc;
    backdrop-filter: blur(10px);
}

/* 校准图表 */
.calibration-chart {
    display: flex;
    gap: 20px;
    margin-top: 20px;
    padding: 20px;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.chart-axis {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-end;
    padding-right: 10px;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    min-height: 300px;
}

.chart-label {
    font-size: 12px;
    color: #aaa;
    margin-bottom: 10px;
    transform: rotate(-90deg);
    transform-origin: center;
    white-space: nowrap;
}

.chart-mark {
    font-size: 11px;
    color: #888;
    margin: 5px 0;
    min-width: 30px;
    text-align: right;
}

.chart-area {
    flex: 1;
    min-height: 300px;
    background: linear-gradient(to top, rgba(102, 126, 234, 0.1) 0%, transparent 100%);
    border-radius: 8px;
    position: relative;
    overflow: hidden;
}

.chart-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        to bottom,
        transparent,
        transparent 20px,
        rgba(255, 255, 255, 0.05) 20px,
        rgba(255, 255, 255, 0.05) 21px
    );
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .keyboard-layout {
        flex-direction: column;
    }
    
    .keyboard-options {
        width: 100%;
        flex-direction: row;
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 10px;
    }
    
    .nav {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .device-section {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 2px solid #4a00e0;
    }
    
    .welcome-title {
        font-size: 4rem;
    }
    
    .welcome-subtitle {
        font-size: 1.2rem;
    }
    
    .tab-header {
        flex-wrap: wrap;
    }
    
    .setting-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .setting-control {
        width: 100%;
        justify-content: flex-start;
    }
}