:root {
    --bg-color: #f0f2f5;
    --text-color: #333;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.5);
    --accent-color: #00bcd4;
    --accent-gradient: linear-gradient(135deg, #00bcd4, #2196f3);
    --sidebar-bg: rgba(255, 255, 255, 0.5);
    --input-bg: rgba(255, 255, 255, 0.9);
    --warning-color: #ff9800;
    --success-color: #4caf50;
    --danger-color: #ff5252;
}

[data-theme="dark"] {
    --bg-color: #0d0d0d;
    --text-color: #e0e0e0;
    --glass-bg: rgba(30, 30, 30, 0.4);
    --glass-border: rgba(255, 255, 255, 0.08);
    --sidebar-bg: rgba(20, 20, 20, 0.4);
    --input-bg: rgba(40, 40, 40, 0.6);
}

* { box-sizing: border-box; margin: 0; padding: 0; transition: all 0.3s ease; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 20px;
}

/* 布局 */
.main-layout {
    display: flex;
    gap: 20px;
    width: 100%;
    max-width: 1200px;
}

/* 毛玻璃通用样式 */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
}

/* 侧边栏 */
.sidebar {
    width: 250px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    height: 80vh;
    position: sticky;
    top: 20px;
}

/* 侧边栏链接 */
.sidebar-links {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--glass-border);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin-bottom: 5px;
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.85em;
    opacity: 0.7;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.sidebar-link:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .sidebar-link:hover {
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-link i {
    font-size: 0.9em;
    width: 16px;
}

.log-content {
    margin-top: 15px;
    flex: 1;
    overflow-y: auto;
    font-size: 0.9em;
    color: var(--text-color);
    opacity: 0.8;
}

.log-item {
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--glass-border);
}

/* 房间关闭倒计时面板 */
.room-close-panel {
    margin-top: auto;
    padding: 12px;
    background: rgba(255, 152, 0, 0.1);
    border: 1px solid rgba(255, 152, 0, 0.3);
    border-radius: 10px;
    text-align: center;
    font-size: 0.85em;
}

.room-close-panel.hidden {
    display: none;
}

.close-timer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--warning-color);
    font-weight: bold;
    font-size: 1.1em;
    margin-bottom: 4px;
}

.close-timer i {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.close-hint {
    font-size: 0.75em;
    color: var(--text-color);
    opacity: 0.7;
    margin-bottom: 8px;
}

.btn-keep-alive {
    width: 100%;
    padding: 6px 10px;
    background: rgba(0, 188, 212, 0.2);
    border: 1px solid var(--accent-color);
    border-radius: 6px;
    color: var(--accent-color);
    font-size: 0.8em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: all 0.2s ease;
}

.btn-keep-alive:hover {
    background: var(--accent-color);
    color: white;
}

/* 主内容区 */
.content-area {
    flex: 1;
    padding: 40px;
    display: flex;
    flex-direction: column;
}

header { text-align: center; margin-bottom: 30px; }
.gradient-text {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 2.5em;
    font-weight: bold;
}
.subtitle { opacity: 0.6; margin-top: 5px; }

.divider {
    border: 0;
    height: 1px;
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(128, 128, 128, 0.2) 20%, 
        rgba(128, 128, 128, 0.2) 80%, 
        transparent 100%
    );
    margin: 30px 0;
}

/* 控制区块样式 - 毛玻璃悬浮效果 */
.control-section {
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 
        0 4px 20px rgba(0, 0, 0, 0.05),
        0 1px 3px rgba(0, 0, 0, 0.02),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

/* 暗黑模式下的控制区块 - 透明毛玻璃 */
[data-theme="dark"] .control-section {
    background: rgba(25, 25, 25, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 
        0 4px 20px rgba(0, 0, 0, 0.3),
        0 1px 3px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

/* 本地控制区块 */
.local-section .section-header h2 {
    color: #555;
}

.local-section .section-header h2 i {
    color: #777;
}

[data-theme="dark"] .local-section .section-header h2 {
    color: #aaa;
}

[data-theme="dark"] .local-section .section-header h2 i {
    color: #888;
}

/* 远程控制区块 */
.remote-section .section-header h2 {
    color: #2196f3;
}

.remote-section .section-header h2 i {
    color: #2196f3;
}

[data-theme="dark"] .remote-section .section-header h2 {
    color: #64b5f6;
}

[data-theme="dark"] .remote-section .section-header h2 i {
    color: #64b5f6;
}

/* 区块标题样式 */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .section-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.section-header h2 {
    font-size: 1.2em;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
}

.section-header h2 i {
    font-size: 1em;
}

/* 状态框样式 - 矩形 */
.status-box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.85em;
    font-weight: 500;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(10px);
}

[data-theme="dark"] .status-box {
    background: rgba(30, 30, 30, 0.5);
}

.status-box.disconnected {
    background: rgba(255, 82, 82, 0.1);
    color: var(--danger-color);
    border-color: rgba(255, 82, 82, 0.2);
}

.status-box.connected {
    background: rgba(76, 175, 80, 0.1);
    color: var(--success-color);
    border-color: rgba(76, 175, 80, 0.2);
}

.status-box i {
    font-size: 1em;
}

/* 弹性控制开关组 */
.elastic-toggle-group {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 15px;
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
}

[data-theme="dark"] .elastic-toggle-group {
    background: rgba(40, 40, 40, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.elastic-label {
    font-size: 0.9em;
    font-weight: 500;
    color: var(--text-color);
}

.elastic-hint {
    font-size: 0.75em;
    color: var(--text-color);
    opacity: 0.6;
    margin-left: auto;
}

/* 滑块开关样式 */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.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(150, 150, 150, 0.3);
    transition: 0.3s;
    border-radius: 24px;
    border: 1px solid var(--glass-border);
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--accent-gradient);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

/* 马达滑块区域 */
.motor-sliders {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

/* 滑块组 */
.slider-group {
    margin-bottom: 0;
}

.slider-label-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.slider-group label {
    font-weight: 500;
    font-size: 0.9em;
    color: var(--text-color);
}

.slider-value {
    font-size: 0.85em;
    color: var(--accent-color);
    font-weight: 600;
}

input[type=range] {
    width: 100%;
    accent-color: var(--accent-color);
    height: 6px;
    border-radius: 5px;
    background: rgba(150, 150, 150, 0.2);
    outline: none;
}

[data-theme="dark"] input[type=range] {
    background: rgba(100, 100, 100, 0.3);
}

/* 按钮组 */
.button-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 15px;
}

.btn-primary {
    padding: 12px;
    background: var(--accent-gradient);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.95em;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 188, 212, 0.3);
}

.btn-secondary {
    padding: 12px;
    background: rgba(150, 150, 150, 0.2);
    color: var(--text-color);
    border: 1px solid rgba(150, 150, 150, 0.3);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.95em;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: rgba(150, 150, 150, 0.3);
}

/* 提示文字 */
.hint-text {
    font-size: 0.8em;
    color: var(--text-color);
    opacity: 0.6;
    margin-top: 10px;
    line-height: 1.4;
}

.hint-warning {
    color: var(--warning-color);
    opacity: 0.9;
    background: rgba(255, 152, 0, 0.08);
    padding: 10px;
    border-radius: 6px;
    border-left: 3px solid var(--warning-color);
}

.hint-warning i {
    margin-right: 5px;
}

/* 房间功能区域 */
.room-functions {
    margin-bottom: 20px;
}

.btn-toggle-room {
    width: 100%;
    padding: 10px;
    background: rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9em;
    color: var(--text-color);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 15px;
    transition: all 0.3s ease;
}

[data-theme="dark"] .btn-toggle-room {
    background: rgba(40, 40, 40, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.btn-toggle-room:hover {
    background: rgba(255, 255, 255, 0.5);
}

[data-theme="dark"] .btn-toggle-room:hover {
    background: rgba(50, 50, 50, 0.4);
}

.btn-toggle-room i {
    transition: transform 0.3s ease;
}

.btn-toggle-room.collapsed i {
    transform: rotate(180deg);
}

.room-content {
    overflow: hidden;
    transition: all 0.3s ease;
    max-height: 1000px;
    opacity: 1;
}

.room-content.collapsed {
    max-height: 0;
    opacity: 0;
    margin: 0;
    padding: 0;
}

/* 远程区域 */
.remote-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.glass-inner {
    background: rgba(255,255,255,0.4);
    backdrop-filter: blur(10px);
    padding: 15px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.3);
}

[data-theme="dark"] .glass-inner {
    background: rgba(40, 40, 40, 0.3);
    border: 1px solid rgba(255,255,255,0.05);
}

.glass-inner input {
    width: 100%;
    padding: 10px;
    margin: 8px 0;
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    background: var(--input-bg);
    color: var(--text-color);
    font-size: 0.9em;
}

.btn-action {
    width: 100%;
    padding: 10px;
    background: var(--text-color);
    color: var(--bg-color);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    margin-top: 8px;
}

.tiny-hint {
    font-size: 0.75em;
    color: var(--text-color);
    opacity: 0.6;
    margin-top: 8px;
}

/* 公开房间开关 */
.toggle-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    margin: 8px 0;
    background: rgba(255,255,255,0.4);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 8px;
}

[data-theme="dark"] .toggle-group {
    background: rgba(40, 40, 40, 0.3);
    border: 1px solid rgba(255,255,255,0.05);
}

.toggle-label {
    font-size: 0.9em;
    font-weight: 500;
    color: var(--text-color);
}

/* 房间列表 */
.room-list-container {
    margin-bottom: 20px;
}

.room-list-container h3 {
    font-size: 1em;
    font-weight: 500;
    margin-bottom: 10px;
    color: var(--text-color);
}

.room-item {
    display: flex;
    justify-content: space-between;
    padding: 12px;
    background: rgba(255,255,255,0.3);
    backdrop-filter: blur(10px);
    margin-bottom: 5px;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

[data-theme="dark"] .room-item {
    background: rgba(40, 40, 40, 0.3);
}

.room-item:hover {
    background: rgba(255,255,255,0.5);
    border-color: var(--glass-border);
}

[data-theme="dark"] .room-item:hover {
    background: rgba(50, 50, 50, 0.4);
}

.room-lock {
    color: #ff9800;
    margin-left: 5px;
}

.empty-list {
    padding: 20px;
    text-align: center;
    color: var(--text-color);
    opacity: 0.5;
    font-size: 0.9em;
}

.hidden {
    display: none;
}

/* 远程控制器 */
.remote-controller {
    margin-top: 20px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
}

[data-theme="dark"] .remote-controller {
    background: rgba(30, 30, 30, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.remote-controller h3 {
    font-size: 1em;
    font-weight: 500;
    margin-bottom: 15px;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.remote-controller h3 i {
    color: var(--accent-color);
}

/* 页脚 */
footer {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--glass-border);
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.footer-copyright {
    font-size: 0.85em;
    color: var(--text-color);
    opacity: 0.6;
}

.footer-links {
    display: flex;
    gap: 15px;
}

.footer-links a {
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.85em;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.footer-links a:hover {
    opacity: 1;
    color: var(--accent-color);
}

/* 主题按钮 */
.theme-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2em;
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    border: none;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* Toast 弹窗 */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.toast {
    padding: 12px 20px;
    margin-bottom: 10px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: slideIn 0.3s ease;
}

.toast.success {
    background: var(--success-color);
}

.toast.error {
    background: var(--danger-color);
}

.toast.warning {
    background: var(--warning-color);
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* 响应式 - 手机端优化 */
@media (max-width: 768px) {
    body {
        padding: 0;
        margin: 0;
    }
    
    .main-layout {
        flex-direction: column;
        gap: 0;
        width: 100%;
        max-width: 100%;
    }
    
    /* 侧边栏在手机端隐藏或简化 */
    .sidebar {
        display: none;
    }
    
    /* 主内容区填满屏幕 */
    .content-area {
        width: 100%;
        max-width: 100%;
        padding: 15px;
        border-radius: 0;
        min-height: 100vh;
    }
    
    /* 标题缩小 */
    .gradient-text {
        font-size: 1.8em;
    }
    
    .subtitle {
        font-size: 0.9em;
    }
    
    /* 控制区块填满宽度 */
    .control-section {
        padding: 20px 15px;
        margin-bottom: 15px;
        border-radius: 12px;
    }
    
    /* 马达滑块垂直排列 */
    .motor-sliders {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    /* 按钮垂直排列 */
    .button-group {
        grid-template-columns: 1fr;
    }
    
    /* 弹性开关换行 */
    .elastic-toggle-group {
        flex-wrap: wrap;
        padding: 10px 12px;
    }
    
    .elastic-hint {
        width: 100%;
        margin-left: 0;
        margin-top: 8px;
        font-size: 0.7em;
    }
    
    /* 房间功能区域 */
    .remote-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    /* 页脚调整 */
    .footer-content {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }
    
    .footer-links {
        justify-content: center;
    }
    
    /* 主题按钮位置调整 */
    .theme-btn {
        bottom: 20px;
        right: 20px;
        width: 45px;
        height: 45px;
    }
    
    /* Toast位置调整 */
    #toast-container {
        left: 20px;
        right: 20px;
        top: 20px;
    }
    
    .toast {
        width: 100%;
    }
}
