/**
 * 键盘测试V2版样式表 - 精确模仿图片样式
 */

/* 容器样式 */
.keyboard-test-v2-container {
    font-family: 'Arial', sans-serif;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background-color: #f8f8f8;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

/* 头部样式 */
.keyboard-test-v2-header {
    margin-bottom: 20px;
}

.keyboard-test-v2-header h2 {
    font-size: 24px;
    color: #333;
    margin-bottom: 15px;
    text-align: center;
}

/* 控制区域样式 */
.keyboard-test-v2-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    padding: 15px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.keyboard-layout-selector,
.keyboard-theme-selector,
.sound-toggle-container {
    display: flex;
    align-items: center;
    margin: 0 10px;
}

.keyboard-layout-select-v2,
.keyboard-theme-select {
    padding: 8px 12px;
    border-radius: 5px;
    border: 1px solid #ddd;
    background: #f9f9f9;
    font-size: 14px;
    margin-left: 5px;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
}

.keyboard-layout-select-v2:hover,
.keyboard-theme-select:hover {
    border-color: #aaa;
}

.keyboard-test-v2-btn {
    padding: 8px 16px;
    background: #4a90e2;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
    outline: none;
}

.keyboard-test-v2-btn:hover {
    background: #3a7bc8;
}

/* 开关样式 */
.sound-toggle-container {
    display: flex;
    align-items: center;
}

.sound-toggle {
    position: relative;
    width: 50px;
    height: 24px;
    margin-left: 5px;
}

.sound-toggle-checkbox {
    display: none;
}

.sound-toggle-label {
    position: absolute;
    top: 0;
    left: 0;
    width: 50px;
    height: 24px;
    background: #ccc;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.sound-toggle-label:after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.sound-toggle-checkbox:checked + .sound-toggle-label {
    background: #4a90e2;
}

.sound-toggle-checkbox:checked + .sound-toggle-label:after {
    transform: translateX(26px);
}

/* 统计信息区域 */
.keyboard-test-v2-stats {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 15px;
    margin: 20px 0;
}

.stat-box {
    padding: 10px 20px;
    background: #fff;
    border-radius: 8px;
    text-align: center;
    min-width: 120px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.stat-box:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
}

.stat-value {
    font-size: 22px;
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 13px;
    color: #666;
}

/* 进度条样式 */
.keyboard-test-v2-progress {
    margin: 20px 0;
}

.progress-bar {
    height: 10px;
    background: #e0e0e0;
    border-radius: 5px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(to right, #4a90e2, #63b3ed);
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    text-align: center;
    margin-top: 5px;
    font-size: 14px;
    color: #666;
}

/* 键盘主体样式 - 精确匹配图片 */
.keyboard-test-v2-main {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
    overflow: hidden; /* 防止溢出 */
    max-width: 100%; /* 确保不会超出容器 */
}

/* 键盘包装器 - 整合主键盘和数字键盘 */
.keyboard-wrapper {
    display: flex;
    background: #222;
    border-radius: 12px;
    padding: 18px 30px 0 30px; /* 增加左右边距，去除底部间距 */
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.6), 0 0 2px rgba(255, 105, 97, 0.5);
    border: 1px solid #333;
    align-items: flex-end;
    position: relative;
    max-width: 100%; /* 确保不超过容器宽度 */
    width: fit-content; /* 适应内容宽度 */
    margin: 0 auto; /* 居中显示 */
}

/* 添加轻微红色边框光效 */
.keyboard-wrapper::after {
    content: '';
    position: absolute;
    top: -1px;
    left: -1px;
    right: -1px;
    bottom: -1px;
    border-radius: 13px;
    box-shadow: 0 0 8px rgba(255, 85, 85, 0.3);
    pointer-events: none;
    z-index: -1;
}

/* 主键盘布局 */
.keyboard-layout-v2 {
    display: none;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 0;
    padding-bottom: 0;
}

.keyboard-layout-v2.active {
    display: flex;
}

/* 小键盘布局 */
.numpad-layout-v2 {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-left: 12px;
    flex-shrink: 0;
    width: auto;
    margin-bottom: 0;
    padding-bottom: 0;
}

/* 键盘行样式 */
.keyboard-row-v2, .numpad-row-v2 {
    display: flex;
    gap: 5px;
    margin-bottom: 0; /* 移除底部间距 */
    flex-wrap: nowrap;
    white-space: nowrap;
    margin-left: 10px;
}

/* 键盘键样式 - 精确匹配图片 */
.key-v2 {
    position: relative;
    width: 45px; /* 再次减少宽度 */
    height: 45px; /* 再次减少高度 */
    background: #333;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.3);
    transition: all 0.1s ease;
    color: #fff;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
    margin-bottom: 5px; /* 统一底部间距 */
    margin-top: 0;
}

.key-v2:active, .key-v2.pressed {
    transform: translateY(2px);
    box-shadow: 0 2px 3px rgba(0, 0, 0, 0.3);
    filter: brightness(0.9);
}

/* 键盘测试指示器 - 使用右上角绿色圆点代替背景高亮 */
.key-v2.tested::after {
    content: '';
    position: absolute;
    top: 5px;
    right: 5px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #4caf50; /* 绿色圆点 */
    box-shadow: 0 0 4px rgba(76, 175, 80, 0.6);
}

/* 特殊键样式 - 精确匹配图片颜色 */
.key-esc, .key-enter, .numpad-enter {
    background: #f55;
    color: white;
}

/* 功能键的蓝灰色，精确匹配图片 */
.key-tab, 
.key-capslock,
.key-lshift, 
.key-rshift,
.key-lctrl, 
.key-rctrl, 
.key-lalt, 
.key-ralt, 
.key-win, 
.key-menu,
.key-f5, .key-f6, .key-f7, .key-f8,
.key-prtscr, .key-scrolllock, .key-pause,
.key-insert, .key-home, .key-pgup,
.key-delete, .key-end, .key-pgdn,
.key-up, .key-down, .key-left, .key-right, .key-numpad-add,
.key-backspace {
    background: #5a7ca6;
}

/* 特殊键尺寸，精确匹配图片 */
.key-tab, .key-capslock {
    width: 75px;
    text-align: left;
    padding-left: 15px;
    justify-content: center;
}

.key-lshift, .key-rshift {
    width: 105px;
    text-align: left;
    padding-left: 15px;
    justify-content: center;
}

.key-backspace {
    width: 95px;
    text-align: center;
}

.key-enter {
    width: 99px;
    text-align: center;
}

.key-space {
    width: 275px; /* 减少宽度 */
    background: #333;
}

.key-lctrl, .key-rctrl {
    width: 95px;
}

.key-lalt, .key-ralt, .key-win {
    width: 50px;
}

.key-f {
    width: 45px;
    height: 45px;
    font-size: 12px;
}

/* F1-F4和F9-F12使用深灰色，匹配图片 */
.key-f1, .key-f2, .key-f3, .key-f4,
.key-f9, .key-f10, .key-f11, .key-f12 {
    background: #333;
}

.key-group {
    display: flex;
    gap: 5px;
}

.key-spacer-v2 {
    width: 15px;
}

/* 修饰键的文本样式 */
.key-main-char, .key-secondary-char {
    width: 100%;
    text-align: center;
    line-height: 1;
}

.key-main-char {
    font-size: 11px;
    color: #bbb;
    position: absolute;
    top: 6px;
    left: 0;
}

.key-secondary-char {
    font-size: 15px;
    font-weight: bold;
    margin-top: 3px;
}

/* 箭头键布局 - 位置调整 */
.arrow-keys-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-left: 17px; /* 再次增加左边距，向右移动一格 */
    position: relative;
    top: -55px; /* 向上移动整个箭头键组 */
}

.arrow-keys-top {
    margin-bottom: 5px;
}

.arrow-keys-bottom {
    display: flex;
    gap: 5px;
}

/* 小键盘按键样式 */
/* .numpad-add {

    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    background: #333;
    margin-right: 0;
} */

/* 加号按键的特定样式 */
.numpad-add {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #333;
    color: white;
    border: 1px solid #555;

    /* --- 定位和尺寸修改 --- */
    position: absolute;
    right: 20px;
    bottom: 160px;
    height: 95px;
    
    /* 需要手动设置宽度，因为它不再参与 flex 布局的宽度计算 */
    /* 这个宽度应该和其他按键的宽度相匹配 */

}

.numpad-enter {
    height: 95px; /* 调整高度以匹配2行+间距 */
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    margin-right: 0;
}

.numpad-0 {
    width: 95px;
}

/* 小键盘特殊键样式 */
.key-numlock, .key-numpad-divide, .key-numpad-multiply, .key-numpad-subtract {
    background: #333;
}

/* 键盘Plus按键 */
.key-numpad-add {
    background: #333;
}

/* 数字键盘底部行调整 - 上移一行 */
.numpad-bottom-row {
    /* position: relative; */
    top: -50px; /* 向上移动一整行 */
}

/* 移除底部空行 */
.keyboard-layout-v2,
.numpad-layout-v2 {
    margin-bottom: 0;
    padding-bottom: 0;
}

/* 数字键盘789+行下移 */
.numpad-top-row {
    position: relative;
    /* top: 25px; 
    margin-bottom: 25px;  */
}

/* 数字键盘调整 */
.numpad-layout-v2 {
    width: 198px; /* 精确设置宽度 */
}

.numpad-spacer {
    width: 45px; /* 与按键同宽 */
    height: 45px; /* 与按键同高 */
    visibility: hidden; /* 隐藏但保留空间 */
}

.numpad-row-v2 {
    width: 100%;
    justify-content: flex-start;
}

/* 信息区域 */
.keyboard-test-v2-info {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 30px;
}

.test-info-section {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.test-info-section h3 {
    font-size: 18px;
    color: #333;
    margin-bottom: 10px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.test-info-section p {
    font-size: 14px;
    color: #555;
    line-height: 1.6;
    margin-bottom: 10px;
}

/* 按键记录样式 */
.key-data-log {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.key-data-log h3 {
    font-size: 18px;
    color: #333;
    margin-bottom: 10px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.key-log-container {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 15px;
    border: 1px solid #eee;
    border-radius: 5px;
}

.key-log-header {
    display: flex;
    background: #f5f5f5;
    padding: 10px;
    font-weight: bold;
    border-bottom: 1px solid #ddd;
}

.key-log-col {
    flex: 1;
    padding: 0 5px;
}

.key-log-content {
    background: #fff;
}

.key-log-row {
    display: flex;
    padding: 8px 10px;
    border-bottom: 1px solid #eee;
    font-size: 13px;
}

.key-log-row:nth-child(even) {
    background: #f9f9f9;
}

/* 使用说明样式 */
.keyboard-test-v2-guide {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    margin-top: 20px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.guide-content {
    font-size: 14px;
    color: #555;
    line-height: 1.6;
}

/* RGB主题 */
@keyframes rgb-border {
    0% { border-color: #ff0000; }
    16.666% { border-color: #ff8000; }
    33.333% { border-color: #ffff00; }
    50% { border-color: #00ff00; }
    66.666% { border-color: #0080ff; }
    83.333% { border-color: #8000ff; }
    100% { border-color: #ff0000; }
}

@keyframes rgb-glow {
    0% { box-shadow: 0 0 8px #ff0000; }
    16.666% { box-shadow: 0 0 8px #ff8000; }
    33.333% { box-shadow: 0 0 8px #ffff00; }
    50% { box-shadow: 0 0 8px #00ff00; }
    66.666% { box-shadow: 0 0 8px #0080ff; }
    83.333% { box-shadow: 0 0 8px #8000ff; }
    100% { box-shadow: 0 0 8px #ff0000; }
}

.keyboard-test-v2-container[data-theme="rgb"] .keyboard-wrapper {
    background: #111;
    border: 2px solid transparent;
    animation: rgb-border 5s infinite linear;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.7);
}

.keyboard-test-v2-container[data-theme="rgb"] .key-v2 {
    border: 1px solid transparent;
    animation: rgb-border 5s infinite linear;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    box-shadow: 0 4px 0 #000, 0 5px 10px rgba(0, 0, 0, 0.6);
}

.keyboard-test-v2-container[data-theme="rgb"] .key-v2.pressed {
    animation: rgb-glow 2s infinite linear;
    box-shadow: 0 0 0 #000, 0 1px 5px rgba(0, 0, 0, 0.6);
    transform: translateY(4px);
}

.keyboard-test-v2-container[data-theme="rgb"] .key-v2.tested {
    animation: rgb-glow 5s infinite linear;
    background: rgba(0, 0, 0, 0.9);
}

/* 复古主题 */
.keyboard-test-v2-container[data-theme="retro"] {
    background-color: #f0e6d2;
    box-shadow: 0 5px 15px rgba(139, 69, 19, 0.3);
}

.keyboard-test-v2-container[data-theme="retro"] .keyboard-wrapper {
    background: #d2c59d;
}

.keyboard-test-v2-container[data-theme="retro"] .key-v2 {
    background: #f5f0e1;
    color: #5f4b32;
    border-radius: 2px;
    box-shadow: 0 3px 0 #b89f74, 0 4px 5px rgba(139, 69, 19, 0.2);
    font-family: 'Courier New', monospace;
}

.keyboard-test-v2-container[data-theme="retro"] .key-v2:active,
.keyboard-test-v2-container[data-theme="retro"] .key-v2.pressed {
    box-shadow: 0 0 0 #b89f74, 0 1px 2px rgba(139, 69, 19, 0.2);
}

.keyboard-test-v2-container[data-theme="retro"] .key-v2.tested {
    background: #d6a86c;
    color: #3a2c1a;
}

/* 响应式调整 */
@media (max-width: 1200px) {
    .keyboard-wrapper {
        flex-direction: column;
        align-items: center;
        padding: 15px;
    }
    
    .numpad-layout-v2 {
        margin-left: 0;
        margin-top: 15px;
    }
    
    .key-v2 {
        width: 40px;
        height: 40px;
        font-size: 12px;
    }
    
    .key-tab, .key-capslock, .key-lshift, .key-rshift {
        width: 65px;
    }
    
    .key-backspace, .key-enter {
        width: 80px;
    }
    
    .key-space {
        width: 220px;
    }
    
    .arrow-keys-wrapper {
        top: 0;
    }
    
    .numpad-bottom-row {
        top: 0;
    }
}

@media (max-width: 768px) {
    .keyboard-test-v2-controls {
        flex-direction: column;
        gap: 10px;
    }
    
    .keyboard-layout-selector, .keyboard-theme-selector, .sound-toggle-container {
        width: 100%;
        justify-content: space-between;
        margin: 0;
    }
    
    .keyboard-row-v2 {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .key-v2 {
        width: 35px;
        height: 35px;
        font-size: 10px;
    }
}

/* 针对TKL和紧凑型布局的调整 */
.keyboard-layout-v2.tkl-layout + .numpad-layout-v2,
.keyboard-layout-v2.compact-layout + .numpad-layout-v2 {
    display: none;
}

.keyboard-layout-v2.compact-layout .function-row,
.keyboard-layout-v2.compact-layout .edit-keys,
.keyboard-layout-v2.compact-layout .arrow-keys {
    display: none;
}

/* 加载动画 */
@keyframes key-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.key-v2.key-highlight {
    animation: key-pulse 0.5s ease;
}