/* ========================================
   蓝牙设备遥控器 - 全局样式
   ======================================== */

/* Reset & Base */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    user-select: none;
    -webkit-user-select: none;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    background: #0a0a0a;
}

/* ========================================
   App Container - 模拟手机屏幕
   ======================================== */
#app {
    position: relative;
    width: 100%;
    max-width: 430px;
    height: 100vh;
    max-height: 932px;
    overflow: hidden;
    background: linear-gradient(
        180deg,
        #1a0a2e 0%,
        #2d1245 25%,
        #4a1942 45%,
        #6b2456 60%,
        #8b2f6e 75%,
        #a83d6b 85%,
        #c2556e 100%
    );
}

/* ========================================
   页面通用
   ======================================== */
.page {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.page.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(30px);
}

.page.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
}

/* ========================================
   页面1：设备连接页
   ======================================== */
.connect-page {
    align-items: center;
    padding: 0 30px;
}

.connect-page .page-title {
    margin-top: 40px;
    font-size: 20px;
    font-weight: 600;
    color: #ffffff;
    letter-spacing: 2px;
    text-align: center;
}

/* 右上角语言切换 */
.lang-globe {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 100;
}

.globe-icon {
    width: 28px;
    height: 28px;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    transition: color 0.25s ease, transform 0.2s ease;
}

.globe-icon:hover {
    color: #ffffff;
    transform: scale(1.1);
}

.globe-icon:active {
    transform: scale(0.95);
}

.lang-dropdown {
    display: none;
    position: absolute;
    top: 36px;
    right: 0;
    background: rgba(30, 15, 50, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 6px 0;
    min-width: 140px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    animation: dropdownFadeIn 0.2s ease;
}

.lang-dropdown.show {
    display: block;
}

@keyframes dropdownFadeIn {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

.lang-option {
    display: block;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s ease;
}

.lang-option:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.lang-option.active {
    color: #ffffff;
    background: rgba(180, 140, 255, 0.15);
}

.connect-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-top: -40px;
}

/* 蓝牙图标 */
.bluetooth-icon {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 30px;
}

.bluetooth-icon svg {
    width: 50px;
    height: 50px;
    fill: rgba(255, 255, 255, 0.8);
}

.connect-content h2 {
    font-size: 24px;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 10px;
    letter-spacing: 2px;
}

.connect-content .subtitle {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.55);
    margin-bottom: 35px;
    letter-spacing: 1px;
}

/* 设备ID输入框 */
.device-input-wrapper {
    width: 100%;
    margin-bottom: 20px;
}

.device-input {
    width: 100%;
    height: 60px;
    border: none;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    font-size: 24px;
    font-weight: 500;
    text-align: center;
    letter-spacing: 6px;
    outline: none;
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

.device-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
    font-size: 16px;
    letter-spacing: 2px;
}

.device-input:focus {
    background: rgba(255, 255, 255, 0.18);
    box-shadow: 0 0 0 2px rgba(232, 67, 147, 0.4);
}

/* 连接按钮 */
.connect-btn {
    width: 100%;
    height: 58px;
    border: none;
    border-radius: 16px;
    background: linear-gradient(135deg, #e84393 0%, #fd79a8 100%);
    color: #ffffff;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: 4px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
    box-shadow: 0 4px 20px rgba(232, 67, 147, 0.4);
}

.connect-btn:active {
    transform: scale(0.97);
    box-shadow: 0 2px 10px rgba(232, 67, 147, 0.3);
}

.connect-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 连接成功提示 */
.connect-success {
    width: 100%;
    height: 50px;
    margin-top: 16px;
    border: 2px solid #fd79a8;
    border-radius: 16px;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fd79a8;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 2px;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.connect-success.show {
    opacity: 1;
    transform: translateY(0);
}

/* ========================================
   页面2：遥控主界面
   ======================================== */
.control-page {
    padding: 0;
}

/* 顶部导航栏 */
.control-header {
    padding: 16px 20px 8px;
    flex-shrink: 0;
}

.control-header .nav-row {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
}

.back-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: #ffffff;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s;
    flex-shrink: 0;
}

.back-btn:active {
    opacity: 0.6;
}

.header-title {
    flex: 1;
    text-align: center;
    font-size: 17px;
    font-weight: 600;
    color: #ffffff;
    letter-spacing: 2px;
    margin-right: 36px;
}

.connection-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    letter-spacing: 0.5px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #00e676;
    box-shadow: 0 0 6px rgba(0, 230, 118, 0.6);
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { box-shadow: 0 0 6px rgba(0, 230, 118, 0.6); }
    50% { box-shadow: 0 0 12px rgba(0, 230, 118, 0.9); }
}

/* 强度显示区 */
.intensity-section {
    text-align: center;
    padding: 10px 0 5px;
    flex-shrink: 0;
}

.intensity-value {
    font-size: 80px;
    font-weight: 200;
    color: #ffffff;
    line-height: 1;
    letter-spacing: -2px;
}

.intensity-value .unit {
    font-size: 28px;
    font-weight: 300;
    color: rgba(255, 255, 255, 0.6);
    margin-left: 2px;
    vertical-align: super;
}

.intensity-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.45);
    letter-spacing: 6px;
    margin-top: 4px;
    text-transform: uppercase;
}

/* 波形可视化区域 */
.waveform-section {
    flex: 1;
    min-height: 0;
    position: relative;
    padding: 0 10px;
}

#waveform-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* 模式切换 */
.mode-section {
    padding: 12px 30px;
    display: flex;
    gap: 12px;
    flex-shrink: 0;
}

.mode-btn {
    flex: 1;
    height: 44px;
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    border-radius: 22px;
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 2px;
    cursor: pointer;
    transition: all 0.25s ease;
}

.mode-btn.active {
    background: #ffffff;
    border-color: #ffffff;
    color: #4a1942;
    font-weight: 600;
    box-shadow: 0 2px 12px rgba(255, 255, 255, 0.2);
}

.mode-btn:active {
    transform: scale(0.95);
}

/* 滑块区域 */
.sliders-section {
    padding: 8px 30px 6px;
    flex-shrink: 0;
}

.slider-row {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.slider-label {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    letter-spacing: 2px;
    min-width: 58px;
    flex-shrink: 0;
}

.slider-wrapper {
    flex: 1;
    margin: 0 14px;
    position: relative;
}

.slider-value {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
    min-width: 52px;
    text-align: right;
    flex-shrink: 0;
    letter-spacing: 0.5px;
}

/* 自定义滑块样式 */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.15);
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: transform 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:active {
    transform: scale(1.15);
}

input[type="range"]::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    border: none;
}

/* 底部控制栏 */
.bottom-controls {
    padding: 10px 30px 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
    flex-shrink: 0;
}

.intensity-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: transparent;
    color: #ffffff;
    font-size: 28px;
    font-weight: 300;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    line-height: 1;
}

.intensity-btn:active {
    transform: scale(0.92);
    background: rgba(255, 255, 255, 0.1);
}

.play-pause-btn {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #e84393 0%, #fd79a8 100%);
    color: #ffffff;
    font-size: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 24px rgba(232, 67, 147, 0.5);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.play-pause-btn:active {
    transform: scale(0.93);
    box-shadow: 0 2px 12px rgba(232, 67, 147, 0.4);
}

/* 播放/暂停图标 */
.play-icon, .pause-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.pause-icon {
    gap: 5px;
}

.pause-icon span {
    display: block;
    width: 5px;
    height: 22px;
    background: #ffffff;
    border-radius: 2px;
}

.play-icon {
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 12px 0 12px 20px;
    border-color: transparent transparent transparent #ffffff;
    margin-left: 3px;
}

/* 会话信息 */
.session-info {
    text-align: center;
    padding: 6px 0 20px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 2px;
    flex-shrink: 0;
}

/* ========================================
   动画
   ======================================== */
@keyframes fade-in-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-in {
    animation: fade-in-up 0.5s ease forwards;
}

/* ========================================
   响应式 - 小屏幕适配
   ======================================== */
@media (max-height: 700px) {
    .intensity-value {
        font-size: 60px;
    }

    .mode-section {
        padding: 8px 30px;
    }

    .sliders-section {
        padding: 4px 30px;
    }

    .bottom-controls {
        padding: 6px 30px 4px;
    }

    .session-info {
        padding: 4px 0 12px;
    }

    .play-pause-btn {
        width: 62px;
        height: 62px;
    }

    .intensity-btn {
        width: 48px;
        height: 48px;
        font-size: 24px;
    }

    .bluetooth-icon {
        width: 100px;
        height: 100px;
    }
}

@media (max-height: 600px) {
    .intensity-value {
        font-size: 48px;
    }

    .intensity-section {
        padding: 4px 0 2px;
    }

    .control-header {
        padding: 10px 20px 4px;
    }
}

/* ========================================
   语言切换 - 地球图标 & 下拉菜单
   ======================================== */

/* 连接页的地球图标 */
.connect-page .lang-globe-wrap {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 100;
    cursor: pointer;
}

.connect-page .lang-globe-icon {
    width: 28px;
    height: 28px;
    color: rgba(255,255,255,0.7);
    transition: color 0.2s;
}

.connect-page .lang-globe-icon:hover {
    color: #fff;
}

/* 遥控页的地球图标 */
.nav-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-row .lang-globe-wrap {
    position: relative;
    cursor: pointer;
    margin-left: auto;
}

.nav-row .lang-globe-icon {
    width: 22px;
    height: 22px;
    color: rgba(255,255,255,0.7);
    transition: color 0.2s;
}

.nav-row .lang-globe-icon:hover {
    color: #fff;
}

/* 下拉菜单通用样式 */
.lang-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: rgba(30, 15, 50, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 12px;
    padding: 6px 0;
    min-width: 150px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s ease;
    z-index: 200;
}

.lang-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.lang-option {
    display: block;
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s;
}

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

.lang-option.active {
    color: #ff8ec4;
    font-weight: 600;
}
