* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body {
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8f0 100%);
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* 左侧侧边栏 */
.sidebar {
    width: 80px;
    background-color: #e8edf5;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 0;
    border-radius: 0 16px 16px 0;
}

.logo {
    margin-bottom: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.menu-item {
    width: 45px;
    height: 45px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #7f7f7f;
    margin-bottom: 15px !important;
}

.menu-item:hover {
    background-color: #FFFFFF;
    color: #165dff;
}

.menu-item.active {
    background-color: #165dff;
    color: #ffffff;
}
.menu-item.active .icon {
    filter: brightness(0) invert(1); /* 将黑色图标转为白色 */
}

/* SVG图标自动变色 */
.menu-item .icon {
    width: 35px;
    height: 35px;
    margin-bottom: 2px;
    fill: currentColor;
}

/* 侧边栏底部菜单 */
.sidebar-bottom {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
/* 底部菜单项作为气泡定位父级 */
.sidebar-bottom .menu-item {
    position: relative;
}

/* 气泡主体 */
.sidebar-bottom .menu-item::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 14px);
    top: 50%;
    transform: translateY(-50%);
    padding: 10px 20px;
    background: #707070;
    color: #ffffff;
    font-size: 15px;
    border-radius: 10px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 999;
    line-height: 1.2;
}

/* 左侧三角箭头 */
.sidebar-bottom .menu-item::before {
     content: '';
    position: absolute;
    left: calc(100% - 4px); /* 箭头变大后往左移，保证和气泡对齐 */
    top: 50%;
    transform: translateY(-50%);
    border: 10px solid transparent; /* 数值越大箭头越大 */
    border-right-color: #707070;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 999;
}

/* 悬停显示气泡 */
.sidebar-bottom .menu-item:hover::after,
.sidebar-bottom .menu-item:hover::before {
    opacity: 1;
    visibility: visible;
}

/* 确保侧边栏不裁剪气泡 */
.sidebar {
    overflow: visible;
}
.sidebar-bottom .menu-item .icon {
    width: 20px;
    height: 20px;
    margin-bottom: 2px;
    fill: currentColor;
}
/* 功能互换下拉弹窗样式 */
.axis-swap-pop {
    position: fixed;
    z-index: 1000;
    width: 330px;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 2px 14px rgba(0,0,0,0.07);
    padding: 8px 0;
    display: none; /* 默认隐藏 */
      transform: translateY(-50%); /* 垂直居中对齐按钮 */
}
.axis-swap-pop .swap-option {
    padding: 15px 26px;
    font-size: 16px;
    color: #333;
    cursor: pointer;
    position: relative;
    transition: background 0.2s ease;
}
.axis-swap-pop .swap-option:hover {
    background-color: #f5f5f5;
}
/* 选中项浅灰背景 */
.axis-swap-pop .swap-option.active {
    background-color: #f1f1f1;
}
/* 选中右侧对勾 */
.axis-swap-pop .swap-option.active::after {
    content: "✓";
    position: absolute;
    right: 26px;
    top: 50%;
    transform: translateY(-50%);
    color: #333;
    font-weight: 500;
}
/* 底部菜单选中态、tooltip隐藏通用样式（三个按钮共用） */
.sidebar-bottom .menu-item.active {
    background: #1677ff;
    border-radius: 8px;
}
.sidebar-bottom .menu-item.active .icon {
    filter: brightness(0) invert(1);
}
.sidebar-bottom .menu-item.active::before,
.sidebar-bottom .menu-item.active::after {
    visibility: hidden !important;
    opacity: 0 !important;
}

/* 恢复默认全局遮罩弹窗样式 */
.confirm-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.15);
    display: none; /* 默认隐藏 */
    z-index: 2000; /* 层级高于右侧下拉菜单 */
    justify-content: center;
    align-items: center;
}
.confirm-modal .modal-content {
   background: #ffffff;
    padding: 24px;
    border-radius: 16px;
    /* 原来的 min-width 控制最小宽度，换成固定宽度更精准 */
    width: 300px; /* 固定宽度，数值可自行调整 */
    box-sizing: border-box; /* 保证内边距不撑宽总宽度 */
}
.confirm-modal .modal-title {
    margin: 0 0 16px;
    font-size: 18px;
    font-weight: 500;
}
.confirm-modal .modal-desc {
    margin: 0 0 24px;
    color: #555;
    font-size: 16px;
}
.confirm-modal .modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}
.confirm-modal .modal-btn {
    padding: 9px 26px;
    border-radius: 8px;
    border: none;
    font-size: 16px;
    cursor: pointer;
}
.confirm-modal .confirm-btn {
    background-color: #1677ff;
    color: #fff;
}
.confirm-modal .cancel-btn {
    background-color: #f3f3f3;
    color: #333;
}

/* 主区域 */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow-y: auto; /* 关键：让主区域可以滚动 */
}

/* ✅ 核心：内容区保持flex布局，子元素垂直排列 */
.content {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
}

/* ✅ 面板基础样式：默认隐藏 */
.content .panel {
    display: none !important;
    width: 100%;
    min-height: 100%;
}

/* ✅ 激活的面板：占满全部高度 */
.content .panel.active {
    display: flex !important;
    flex-direction: column;
}

/* ✅ 首页特殊处理：内容居中，响应式缩放 */
#home.active {
    align-items: center;
    justify-content: center;
}

/* ✅ 功能面板特殊处理：内容流式布局，最大宽度限制 */
#joystick.active,
#buttons.active,
#motion.active,
#vibration.active,
#trigger.active,
#light.active,
#params.active,
#calibration.active,
#touchpad.active,
#settings.active,
#about.active {
    display: block !important; /* 关键：功能面板使用block布局，子元素从上到下 */
    max-width: 1300px; /* 限制最大宽度，防止太宽 */
    margin: 0 auto; /* 水平居中 */
}

/* 首页连接卡片（完全响应式） */
.connect-card {
    display: flex;
    width: 80vw; /* 使用视口宽度百分比 */
    max-width: 900px; /* 最大宽度 */
    min-width: 600px; /* 最小宽度 */
    height: 400px;
    background-color: #ffffff;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.connect-card-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.connect-card-title {
    font-size: 24px;
    font-weight: 600;
    color: #333333;
    margin-bottom: 16px;
}

.connect-card-subtitle {
    font-size: 16px;
    color: #666666;
    margin-bottom: 32px;
    text-align: center;
}

.connect-btn {
    width: 180px;
    height: 48px;
    background-color: #165dff;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.connect-btn:hover {
    background-color: #4080ff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(22, 93, 255, 0.3);
}

.connect-card-right {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f5f7fa;
    padding: 40px;
}

.gamepad-preview {
    width: 100%;
    max-width: 300px;
    height: auto;
}

/* 弹窗遮罩 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

/* 弹窗内容 */
.modal-content {
    width: 80vw;
    max-width: 800px;
    min-width: 500px;
    background-color: #ffffff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    padding: 48px;
    text-align: center;
}

/* 弹窗标题 */
.modal-title {
    font-size: 24px;
    font-weight: 600;
    color: #333333;
    margin-bottom: 16px;
}

/* 弹窗副标题 */
.modal-subtitle {
    font-size: 16px;
    color: #666666;
    margin-bottom: 32px;
    line-height: 1.5;
}

/* 引导图 */
.modal-guide-img {
    width: 100%;
    max-width: 500px;
    height: auto;
    margin-bottom: 40px;
    border-radius: 8px;
}

/* 弹窗按钮容器 */
.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 16px;
}

/* 弹窗按钮通用样式 */
.modal-btn {
    width: 180px;
    height: 48px;
    border: none;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

/* 主按钮（允许连接） */
.modal-btn-primary {
    background-color: #165dff;
    color: #ffffff;
}

.modal-btn-primary:hover {
    background-color: #4080ff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(22, 93, 255, 0.3);
}

/* 次按钮（取消连接） */
.modal-btn-secondary {
    background-color: #ffffff;
    color: #666666;
    border: 1px solid #e5e7eb;
}

.modal-btn-secondary:hover {
    background-color: #f9fafb;
}
/* ====== 侧边栏禁用状态（手柄未连接）====== */
.sidebar.disabled {
    opacity: 0.4;
    pointer-events: none;
    transition: opacity 0.3s ease, pointer-events 0s;
}

.sidebar.disabled .menu-item {
    cursor: not-allowed !important;
}

.sidebar.disabled .menu-item.active {
    background-color: transparent !important;
    color: #7f7f7f !important;
}

.sidebar.disabled .menu-item.active .icon {
    filter: none !important; /* 恢复原始图标颜色 */
}
/* ========== 深色主题全局样式（增强版）========== */

/* ===== 基础背景与文字 ===== */
body.dark-theme {
    background-color: #0d1117;
    color: #c9d1d9;
}

/* ===== 主区域（关键修复）===== */
body.dark-theme .main {
    background-color: #0d1117;
}

/* ===== 侧边栏 ===== */
body.dark-theme .sidebar {
    background-color: #161b22;
    border-right-color: #30363d;
}

body.dark-theme .menu-item {
    color: #8b949e;
}

body.dark-theme .menu-item:hover {
    background-color: #21262d;
    color: #58a6ff;
}

body.dark-theme .menu-item.active {
    background-color: #1f6feb;
    color: #ffffff;
}

/* ===== 通用卡片 ===== */
body.dark-theme .card,
body.dark-theme .cal-card,
body.dark-theme .connect-card,
body.dark-theme .info-card,
body.dark-theme .gamepad-status-container {
    background-color: #161b22;
    color: #c9d1d9;
    border-color: #30363d;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

/* ===== 卡片文字 ===== */
body.dark-theme .card-title,
body.dark-theme .card-desc,
body.dark-theme .rate-group-title,
body.dark-theme .info-card-label,
body.dark-theme .info-card-value {
    color: #e6edf3;
}

body.dark-theme .info-card-desc {
    color: #8b949e;
}

body.dark-theme .card-desc {
    color: #8b949e;
}

/* ===== 信息卡片分割线 ===== */
body.dark-theme .info-card-header {
    border-bottom-color: #30363d;
}

/* ===== 设备名称徽章 ===== */
body.dark-theme .device-name-badge {
    background-color: #21262d;
    color: #8b949e;
}

/* ===== 连接卡片分区 ===== */
body.dark-theme .connect-card-right {
    background-color: #0d1117;
}

body.dark-theme .connect-card-title {
    color: #e6edf3;
}

body.dark-theme .connect-card-subtitle {
    color: #8b949e;
}

/* ===== 按钮系统 ===== */
body.dark-theme .rate-btn {
    background-color: #21262d;
    color: #c9d1d9;
    border-color: #30363d;
}

body.dark-theme .rate-btn:hover {
    background-color: #30363d;
    border-color: #484f58;
}

/* 连接按钮保持蓝色强调 */
body.dark-theme .connect-btn:hover {
    box-shadow: 0 4px 12px rgba(31, 111, 235, 0.4);
}

/* ===== 输入框 ===== */
body.dark-theme .step-input,
body.dark-theme .slider-input input {
    background-color: #0d1117;
    border-color: #30363d;
    color: #e6edf3;
}

body.dark-theme .step-input:focus,
body.dark-theme .slider-input input:focus {
    border-color: #1f6feb;
    box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.15);
}

/* ===== 下拉选择框 ===== */
body.dark-theme .select {
    background-color: #0d1117;
    border-color: #30363d;
    color: #e6edf3;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238b949e' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

body.dark-theme .select:focus {
    border-color: #1f6feb;
    box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.15);
}

/* ===== 弹窗系统 ===== */
body.dark-theme .modal {
    background-color: rgba(13, 17, 23, 0.85);
}

body.dark-theme .modal-content,
body.dark-theme .confirm-modal .modal-content {
    background-color: #161b22;
    color: #c9d1d9;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

body.dark-theme .modal-title,
body.dark-theme .confirm-modal .modal-title {
    color: #e6edf3;
}

body.dark-theme .modal-subtitle,
body.dark-theme .confirm-modal .modal-desc {
    color: #8b949e;
}

/* 次级按钮 */
body.dark-theme .modal-btn-secondary,
body.dark-theme .confirm-modal .cancel-btn {
    background-color: #21262d;
    color: #c9d1d9;
    border-color: #30363d;
}

body.dark-theme .modal-btn-secondary:hover,
body.dark-theme .confirm-modal .cancel-btn:hover {
    background-color: #30363d;
}

/* 确认按钮保持蓝色 */
body.dark-theme .confirm-btn:hover {
    box-shadow: 0 4px 12px rgba(31, 111, 235, 0.4);
}

/* ===== 功能互换下拉弹窗 ===== */
body.dark-theme .axis-swap-pop {
    background: #161b22;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

body.dark-theme .axis-swap-pop .swap-option {
    color: #c9d1d9;
}

body.dark-theme .axis-swap-pop .swap-option:hover {
    background-color: #21262d;
}

body.dark-theme .axis-swap-pop .swap-option.active {
    background-color: #21262d;
}

body.dark-theme .axis-swap-pop .swap-option.active::after {
    color: #58a6ff;
}

/* ===== Tooltip气泡 ===== */
body.dark-theme .sidebar-bottom .menu-item::after {
    background: #21262d;
    color: #c9d1d9;
}

body.dark-theme .sidebar-bottom .menu-item::before {
    border-right-color: #21262d;
}

/* ===== 滑块组件 ===== */
body.dark-theme .slider {
    background: #30363d;
}

body.dark-theme .slider::-webkit-slider-thumb {
    background: #1f6feb;
    box-shadow: 0 0 4px rgba(31, 111, 235, 0.4);
}

body.dark-theme .slider-value {
    background: #30363d;
    color: #e6edf3;
}

/* ===== 滚动条美化 ===== */
body.dark-theme .main::-webkit-scrollbar {
    width: 10px;
}

body.dark-theme .main::-webkit-scrollbar-track {
    background: #0d1117;
}

body.dark-theme .main::-webkit-scrollbar-thumb {
    background: #30363d;
    border-radius: 5px;
}

body.dark-theme .main::-webkit-scrollbar-thumb:hover {
    background: #484f58;
}
