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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1800px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.15);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 40px);
}

/* 头部样式 */
.app-header {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    padding: 30px 40px;
    text-align: center;
}
.header-content h1 {
    font-size: 2.8em;
    margin-bottom: 10px;
    background: linear-gradient(45deg, #3498db, #9b59b6, #e74c3c);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
}

.header-subtitle {
    font-size: 1.3em;
    opacity: 0.9;
    margin-bottom: 20px;
    color: #bdc3c7;
}

.connection-status {
    display: inline-block;
    padding: 12px 24px;
    background: rgba(255,255,255,0.1);
    border-radius: 25px;
    font-weight: 600;
    font-size: 1.1em;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255,255,255,0.2);
}

.status-connected { background: rgba(39, 174, 96, 0.2); color: #27ae60; border-color: #27ae60; }
.status-disconnected { background: rgba(231, 76, 60, 0.2); color: #e74c3c; border-color: #e74c3c; }
.status-error { background: rgba(243, 156, 18, 0.2); color: #f39c12; border-color: #f39c12; }

/* 主布局 */
.app-main {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 0;
    flex: 1;
    min-height: 800px;
}

/* 侧边栏样式 */
.sidebar {
    background: #f8f9fa;
    padding: 30px 25px;
    border-right: 1px solid #e9ecef;
    overflow-y: auto;
    max-height: calc(100vh - 200px);
}

.control-section {
    margin-bottom: 35px;
}

.control-section h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 1.3em;
    border-bottom: 3px solid #3498db;
    padding-bottom: 10px;
    font-weight: 600;
}

.btn-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn {
    padding: 14px 20px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(52, 152, 219, 0.4);
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
    transform: translateY(-1px);
}

.btn-success {
    background: linear-gradient(135deg, #27ae60, #229954);
    color: white;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(39, 174, 96, 0.4);
}

.btn-warning {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: white;
}

.btn-warning:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(243, 156, 18, 0.4);
}

.btn-info {
    background: linear-gradient(135deg, #17a2b8, #138496);
    color: white;
}

.btn-info:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(23, 162, 184, 0.4);
}

/* 设备列表 */
.device-list {
    max-height: 300px;
    overflow-y: auto;
    margin: 15px 0;
}

.device-item {
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 20px;
    margin: 12px 0;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.device-item:hover {
    border-color: #3498db;
    transform: translateX(5px);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.2);
}

.device-item.active {
    border-color: #27ae60;
    background: linear-gradient(135deg, #d5f4e6, #e8f6f3);
}

.device-name {
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 8px;
    font-size: 1.1em;
}

.device-id {
    font-size: 0.9em;
    color: #7f8c8d;
    margin-bottom: 12px;
    word-break: break-all;
}

.btn-connect {
    width: 100%;
    padding: 10px;
    font-size: 12px;
}

/* 主内容区域 */
.main-content {
    padding: 30px 40px;
    overflow-y: auto;
    max-height: calc(100vh - 200px);
}

.panel {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.08);
}

.panel h2 {
    color: #2c3e50;
    margin-bottom: 25px;
    font-size: 1.5em;
    border-bottom: 2px solid #3498db;
    padding-bottom: 12px;
    font-weight: 600;
}

/* 键盘可视化 */
.keyboard-visualization {
    margin: 20px 0;
}

.keyboard-container {
    background: #2c3e50;
    border-radius: 12px;
    padding: 25px;
    box-shadow: inset 0 4px 15px rgba(0,0,0,0.3);
}

.keyboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    color: white;
}

.keyboard-header h3 {
    margin: 0;
    font-size: 1.2em;
}

.keyboard-info {
    font-size: 0.9em;
    opacity: 0.8;
}

.keyboard-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 25px;
}

.keyboard-row {
    display: flex;
    gap: 3px;
    justify-content: center;
}

.keyboard-key {
    width: 45px;
    height: 45px;
    border: 2px solid #34495e;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #34495e;
    color: #ecf0f1;
    position: relative;
    overflow: hidden;
}

.keyboard-key:hover {
    border-color: #3498db;
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(52, 152, 219, 0.6);
}

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

.keyboard-key:hover::after {
    left: 100%;
}

.keyboard-key.highlighted {
    border-color: #f39c12;
    box-shadow: 0 0 20px rgba(243, 156, 18, 0.8);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.keyboard-legend {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-top: 15px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #bdc3c7;
    font-size: 12px;
}

.color-box {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid rgba(255,255,255,0.3);
}

/* 颜色控制 */
.color-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
    margin-top: 20px;
}

.color-control-section {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
}

.color-control-section h4 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 1.1em;
}

.color-picker-group {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 12px 0;
}

.color-picker-group label {
    min-width: 80px;
    font-weight: 600;
    color: #34495e;
}

input[type="color"] {
    width: 60px;
    height: 40px;
    border: 2px solid #bdc3c7;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

input[type="color"]:hover {
    border-color: #3498db;
    transform: scale(1.05);
}

.slider-group {
    margin: 15px 0;
}

.slider-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #34495e;
}

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

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

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3498db;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.quick-colors {
    margin-top: 20px;
}

.quick-colors label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: #34495e;
}

.color-buttons {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 5px;
}

.color-btn {
    width: 30px;
    height: 30px;
    border: 2px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.color-btn:hover {
    transform: scale(1.1);
    border-color: #3498db;
}

/* 预设控制 */
.preset-controls-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.preset-section, .zone-section {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
}

.preset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    margin-top: 15px;
}

.preset-btn {
    padding: 12px 8px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.3s ease;
    text-align: center;
}

.preset-btn.rainbow {
    background: linear-gradient(45deg, #ff0000, #ff9900, #ffff00, #00ff00, #00ffff, #0000ff, #9900ff);
    color: white;
}

.preset-btn.wave {
    background: linear-gradient(45deg, #0066ff, #00ccff, #0066ff);
    color: white;
}

.preset-btn.breathing {
    background: linear-gradient(45deg, #666666, #999999, #666666);
    color: white;
}

.preset-btn.static {
    background: linear-gradient(45deg, #333333, #666666);
    color: white;
}

.preset-btn.gradient {
    background: linear-gradient(45deg, #ff3366, #0066ff);
    color: white;
}

.preset-btn.pulse {
    background: linear-gradient(45deg, #ff0000, #ff6666, #ff0000);
    color: white;
}

.preset-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

/* 区域控制 */
.zone-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
    margin-top: 15px;
}

.zone-btn {
    padding: 12px 8px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.3s ease;
    text-align: center;
}

.zone-btn.wasd {
    background: linear-gradient(45deg, #27ae60, #2ecc71);
    color: white;
}

.zone-btn.numbers {
    background: linear-gradient(45deg, #e74c3c, #e67e22);
    color: white;
}

.zone-btn.arrows {
    background: linear-gradient(45deg, #3498db, #2980b9);
    color: white;
}

.zone-btn.function {
    background: linear-gradient(45deg, #9b59b6, #8e44ad);
    color: white;
}

.zone-btn.all {
    background: linear-gradient(45deg, #2c3e50, #34495e);
    color: white;
}

.zone-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.zone-custom {
    margin-top: 15px;
    padding: 15px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.zone-custom input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 10px;
}

/* 信息面板 */
.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.device-info-section, .debug-section {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
    height: 300px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.device-info-section h3, .debug-section h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 1.1em;
    border-bottom: 2px solid #3498db;
    padding-bottom: 8px;
}

.device-info-content {
    flex: 1;
    overflow-y: auto;
    background: white;
    border-radius: 8px;
    padding: 15px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.4;
}

.debug-console {
    flex: 1;
    overflow-y: auto;
    background: #1a1a1a;
    border-radius: 8px;
    padding: 15px;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    line-height: 1.3;
    color: #00ff00;
}

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

.log-entry.error {
    color: #ff6b6b;
    background: rgba(255, 0, 0, 0.1);
    padding: 5px;
    border-radius: 3px;
}

.log-time {
    color: #666;
    margin-right: 10px;
}

.log-message {
    color: #00ff00;
}

.log-data {
    color: #66ccff;
    margin-left: 10px;
}

/* 底部样式 */
.app-footer {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    padding: 20px 40px;
    text-align: center;
}

.footer-content p {
    margin: 5px 0;
    color: #bdc3c7;
}

.footer-links {
    margin-top: 15px;
    display: flex;
    justify-content: center;
    gap: 20px;
}

.btn-link {
    background: rgba(255,255,255,0.1);
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 12px;
    text-decoration: none;
}

.btn-link:hover {
    background: rgba(255,255,255,0.2);
    transform: translateY(-1px);
}

/* 快捷键提示 */
.shortcut-hint {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(44, 62, 80, 0.95);
    color: white;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.1);
    z-index: 1000;
    max-width: 200px;
}

.shortcut-title {
    font-weight: bold;
    margin-bottom: 10px;
    color: #3498db;
    font-size: 14px;
}

.shortcut-list {
    font-size: 12px;
    line-height: 1.4;
}

.shortcut-item {
    margin: 3px 0;
    color: #bdc3c7;
}

/* Toast通知 */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 10px;
    color: white;
    z-index: 10000;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
    max-width: 400px;
    backdrop-filter: blur(10px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-success {
    background: rgba(39, 174, 96, 0.9);
    border-left: 4px solid #27ae60;
}

.toast-error {
    background: rgba(231, 76, 60, 0.9);
    border-left: 4px solid #e74c3c;
}

.toast-warning {
    background: rgba(243, 156, 18, 0.9);
    border-left: 4px solid #f39c12;
    color: #2c3e50;
}

.toast-info {
    background: rgba(52, 152, 219, 0.9);
    border-left: 4px solid #3498db;
}

.toast-icon {
    font-size: 18px;
    margin-right: 10px;
}

.toast-message {
    flex: 1;
    font-weight: 500;
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .app-main {
        grid-template-columns: 280px 1fr;
    }
    
    .preset-controls-grid {
        grid-template-columns: 1fr;
    }
    
    .info-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .container {
        border-radius: 0;
        min-height: 100vh;
    }
    
    .app-main {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        border-right: none;
        border-bottom: 1px solid #e9ecef;
    }
    
    .keyboard-row {
        flex-wrap: wrap;
        justify-content: flex-start;
    }
    
    .keyboard-key {
        width: 40px;
        height: 40px;
        font-size: 10px;
    }
    
    .shortcut-hint {
        display: none;
    }
}

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

.panel {
    animation: fadeIn 0.5s ease;
}

.keyboard-key {
    animation: fadeIn 0.3s ease;
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 高亮效果 */
.highlight {
    animation: highlight 1s ease;
}

@keyframes highlight {
    0% { background-color: #3498db; }
    100% { background-color: transparent; }
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 工具提示 */
.tooltip {
    position: relative;
    cursor: help;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #2c3e50;
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 1000;
}

.tooltip:hover::after {
    opacity: 1;
}

/* 状态指示器 */
.status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
}

.status-online {
    background: #27ae60;
    box-shadow: 0 0 8px #27ae60;
}

.status-offline {
    background: #e74c3c;
}

.status-connecting {
    background: #f39c12;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}