/* ==================== 全局样式 ==================== */
* {
    box-sizing: border-box;
}

body {
    font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
    margin: 0;
    padding: 0px;
    background-image: url('bg.png');
}

/* ==================== 容器布局 ==================== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    border-radius: 10px;
    padding: 0px;
}

/* 两栏布局 */
.two-column-layout {
    display: flex;
    gap: 20px;
    align-items: stretch;
    margin-top: 10px;
    margin-bottom: 10px;
}

.two-column-layout>.section {
    flex: 1;
    margin-top: 0;
    margin-bottom: 0;
    min-width: 0;
}

/* ==================== 通用区块样式 ==================== */
.section {
    margin-top: 10px;
    margin-bottom: 10px;
    padding: 10px;
    border-radius: 15px;
    background-color: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.section h2 {
    margin: 0;
    color: #000;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.02em;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ==================== 通用按钮样式 ==================== */
button {
    padding: 8px 15px;
    border: none;
    border-radius: 5px;
    background-color: #007aff;
    color: white;
    cursor: pointer;
    transition: background-color 0.2s;
}

button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

/* 切换按钮和连接按钮 */
.toggle-button,
.connect-button {
    margin-left: auto;
    padding: 4px 12px;
    font-size: 14px;
    border-radius: 20px;
    cursor: pointer;
    height: 28px;
    line-height: 20px;
}

.toggle-button {
    border: 1px solid #007aff;
    background-color: #fff;
    color: #007aff;
}

.connect-button {
    box-shadow: 0px 0px 10px 2px rgba(0, 122, 255, 0.28);
}

/* ==================== 设备配置面板 ==================== */
.config-panel {
    display: block;
    transition: all 0.3s ease;
}

/* MCP工具面板默认隐藏 */
#mcpToolsPanel {
    display: none;
}

#mcpToolsPanel.expanded {
    display: block;
}

.control-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

/* 配置行 */
.config-row {
    display: flex;
    gap: 10px;
    width: 100%;
}

/* 配置项 */
.config-item {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    margin-bottom: 8px;
    width: 100%;
}

.config-item label {
    white-space: nowrap;
    min-width: 70px;
    text-align: left;
    color: #666;
    font-size: 12px;
}

.config-item input {
    flex: 1;
    width: 0;
    flex-grow: 1;
    padding: 6px;
    font-size: 12px;
    border: 1px solid #b1c9f8;
    border-radius: 5px;
}

.config-item input:disabled {
    background-color: #fff;
    border-color: #fff;
    cursor: default;
}

/* ==================== 连接信息面板 ==================== */
.connection-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    margin-top: 10px;
}

.connection-controls input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 5px;
    box-sizing: border-box;
}

.connection-controls button {
    white-space: nowrap;
    padding: 8px 15px;
}

#serverUrl,
#otaUrl {
    flex-grow: 1;
    padding: 8px;
    border-radius: 5px;
}

#otaUrl {
    border: 1px solid #b1c9f8;
}

#serverUrl {
    border: 1px solid #fafafa;
    background-color: #fafafa;
}

/* 连接状态 */
.connection-status {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-left: 0px;
    padding: 0 15px;
    height: 28px;
    line-height: 28px;
}

.connection-status span {
    font-size: 13px;
}

.connection-status .status {
    background-color: #fef2f2;
    color: #b91c1c;
    font-size: 12px;
    padding: 0px 8px;
    border-radius: 20px;
    transition: all 0.3s ease;
}

/* 已连接状态 */
.connection-status .status.connected {
    background-color: #ecfdf3;
    color: #15803d;
}

/* 会话状态 - 离线中 */
.connection-status .status.offline {
    background-color: #fef2f2;
    color: #b91c1c;
}

/* 会话状态 - 聆听中 */
.connection-status .status.listening {
    background-color: #ecfdf3;
    color: #15803d;
}

/* 会话状态 - 说话中 */
.connection-status .status.speaking {
    background-color: #fff7ed;
    color: #c2410c;
    animation: pulse-speaking 1.5s infinite;
}

@keyframes pulse-speaking {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

/* LLM状态emoji样式 */
span.connection-status.llm-emoji {
    display: block !important;
    text-align: center !important;
    width: 100% !important;
    margin: 0 auto !important;
}

.llm-emoji .status {
    font-size: 14px !important;
    padding: 8px 20px !important;
}

.emoji-large {
    font-size: 2em !important;
    vertical-align: middle;
    display: inline-block;
    line-height: 1;
}

/* ==================== 标签页样式 ==================== */
.tabs {
    display: flex;
    margin-bottom: 20px;
    border-bottom: 1px solid #e0e0e0;
    align-items: center;
}

.tab {
    padding: 10px 20px;
    cursor: pointer;
    border: none;
    background: none;
    font-size: 14px;
    color: #666;
    position: relative;
    transition: all 0.3s ease;
}

.tab:hover {
    color: #007aff;
}

.tab.active {
    color: #007aff;
    font-weight: bold;
}

.tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 1px;
    background-color: #007aff;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ==================== 文本消息输入 ==================== */
.message-input {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

#messageInput {
    flex-grow: 1;
    padding: 8px 20px 8px 20px;
    border: 1px solid #b1c9f8;
    border-radius: 10px;
}

#messageInput:disabled {
    border: 1px solid #fafafa;
    background-color: #fafafa;
}

#sendTextButton,
#recordButton {
    border-radius: 20px;
}

/* ==================== 语音消息控制 ==================== */
.audio-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
}

.audio-visualizer {
    height: 60px;
    width: 100%;
    margin-top: 10px;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background-color: #fafafa;
}

.record-button {
    background-color: #db4437;
}

.record-button:hover {
    background-color: #c53929;
}

.record-button.recording {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        background-color: #db4437;
    }

    50% {
        background-color: #ff6659;
    }

    100% {
        background-color: #db4437;
    }
}

/* ==================== 会话记录和日志 ==================== */
.flex-container {
    display: flex;
    margin-top: 10px;
    background-color: #f9fafb;
}

/* 会话记录容器 */
.conversation {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-right: none;
    border-radius: 5px 0px 0px 5px;
    padding: 10px;
    flex: 1;
}

/* 消息气泡 */
.message {
    margin-bottom: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    width: fit-content;
    max-width: 80%;
}

.user {
    background-color: #fff;
    margin-left: auto;
    margin-right: 10px;
    text-align: right;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.server {
    background-color: #95ec69;
    margin-right: auto;
    margin-left: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* 日志容器 */
#logContainer {
    margin-top: 0;
    padding: 10px;
    border-radius: 0px 5px 5px 0px;
    font-family: monospace;
    height: 300px;
    overflow-y: auto;
    flex: 1;
    border: 1px solid #ddd;
}

.log-entry {
    margin: 5px 0;
    font-size: 12px;
}

.log-info {
    color: #333;
}

.log-error {
    color: #db4437;
}

.log-success {
    color: #0f9d58;
}

/* ==================== MCP 工具管理 ==================== */
.mcp-tools-container {
    display: grid;
    gap: 12px;
    margin-top: 10px;
}

.mcp-tool-card {
    background-color: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    transition: all 0.2s;
}

.mcp-tool-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.mcp-tool-card.disabled {
    opacity: 0.6;
    pointer-events: none;
}

.mcp-tool-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.mcp-tool-name {
    font-size: 15px;
    font-weight: 600;
    color: #333;
    flex: 1;
}

.mcp-tool-actions {
    display: flex;
    gap: 6px;
}

.mcp-tool-description {
    color: #666;
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 8px;
}

.mcp-tool-info {
    background-color: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 8px;
    font-size: 12px;
}

.mcp-tool-info-row {
    display: flex;
    gap: 15px;
    margin-bottom: 4px;
}

.mcp-tool-info-label {
    color: #999;
    min-width: 60px;
}

.mcp-tool-info-value {
    color: #333;
    font-family: 'Courier New', monospace;
}

/* MCP 属性项 */
.mcp-property-item {
    background-color: white;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    padding: 12px;
    margin-bottom: 10px;
}

.mcp-property-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.mcp-property-name {
    font-weight: 600;
    color: #333;
}

.mcp-property-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 8px;
}

.mcp-property-row-full {
    margin-bottom: 8px;
}

.mcp-small-label {
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    color: #666;
}

.mcp-small-input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
}

.mcp-checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #666;
    cursor: pointer;
}

.mcp-error {
    background-color: #ffebee;
    color: #c62828;
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 15px;
    font-size: 14px;
}

.mcp-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    margin-left: 8px;
}

.mcp-badge-required {
    background-color: #ffebee;
    color: #c62828;
}

.mcp-badge-optional {
    background-color: #e3f2fd;
    color: #1976d2;
}

/* ==================== 脚本加载状态 ==================== */
.script-status {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 5px;
}

.script-loaded {
    background-color: #0f9d58;
}

.script-loading {
    background-color: #f4b400;
}

.script-error {
    background-color: #db4437;
}

.script-list {
    margin: 10px 0;
    padding: 10px;
    background-color: #f9f9f9;
    border-radius: 5px;
    font-family: monospace;
    font-size: 11px;
}

#scriptStatus.success {
    background-color: #e6f4ea;
    color: #0f9d58;
    border-left: 4px solid #0f9d58;
}

#scriptStatus.error {
    background-color: #fce8e6;
    color: #db4437;
    border-left: 4px solid #db4437;
}

#scriptStatus.warning {
    background-color: #fef7e0;
    color: #f4b400;
    border-left: 4px solid #f4b400;
}

/* ==================== File协议警告 ==================== */
#fileProtocolWarning {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    color: white;
    padding: 20px;
    box-sizing: border-box;
}

#fileProtocolWarning h2 {
    color: #ff4d4d;
    margin-bottom: 20px;
}

#fileProtocolWarning pre {
    background-color: green;
    font-size: 18px;
    padding: 15px;
    border-radius: 5px;
    font-family: monospace;
    overflow-x: auto;
    margin: 15px 0;
}

#fileProtocolWarning button {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 10px 20px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    margin: 10px 2px;
    cursor: pointer;
    border-radius: 4px;
}

#fileProtocolWarning button:hover {
    background-color: #45a049;
}

/* ==================== 响应式布局 ==================== */

/* 大屏幕 (宽度 > 1200px) */
@media (min-width: 1201px) {
    .container {
        max-width: 80%;
    }
}

/* 中等屏幕 (宽度 <= 1200px) */
@media (max-width: 1200px) {
    .container {
        max-width: 95%;
        padding: 10px;
    }
}

/* 平板设备 (宽度 <= 1060px) */
@media (max-width: 1060px) {

    /* 两栏布局改为单栏 */
    .two-column-layout {
        flex-direction: column;
        gap: 0;
    }

    .two-column-layout>.section {
        width: 100%;
        margin-top: 10px;
        margin-bottom: 10px;
    }

    /* 连接状态标签调整 */
    .connection-status {
        flex-wrap: wrap;
        gap: 8px;
        margin-left: 0px;
        padding: 0 8px;
    }

    /* 会话记录和日志容器改为上下布局 */
    .flex-container {
        flex-direction: column;
    }

    .conversation,
    #logContainer {
        border-radius: 5px;
        border: 1px solid #ddd;
        max-height: 200px;
    }

    .conversation {
        margin-bottom: 10px;
    }

    /* MCP 属性行改为单列 */
    .mcp-property-row {
        grid-template-columns: 1fr;
    }
}

/* 移动设备 (宽度 <= 768px) */
@media (max-width: 768px) {
    body {
        padding: 0;
    }

    .container {
        max-width: 100%;
        padding: 5px;
    }

    /* 调整区块内边距 */
    .section {
        padding: 8px;
        margin-top: 8px;
        margin-bottom: 8px;
        border-radius: 10px;
    }

    /* 调整标题字体 */
    .section h2 {
        font-size: 13px;
        flex-wrap: wrap;
        gap: 5px;
    }

    /* 配置行改为单列 */
    .config-row {
        flex-direction: column;
    }

    /* 按钮调整 */
    .toggle-button,
    .connect-button {
        padding: 3px 10px;
        font-size: 12px;
        height: 24px;
        line-height: 18px;
    }

    button {
        padding: 6px 12px;
        font-size: 13px;
    }

    /* 输入框 */
    #serverUrl,
    #otaUrl,
    #messageInput {
        font-size: 14px;
        padding: 6px;
    }

    /* 配置项标签 */
    .config-item label {
        min-width: 60px;
        font-size: 12px;
    }

    .config-item input {
        font-size: 13px;
        padding: 5px;
    }

    /* 标签页 */
    .tab {
        padding: 8px 12px;
        font-size: 14px;
    }

    /* 消息气泡 */
    .message {
        max-width: 90%;
        font-size: 14px;
        padding: 6px 10px;
    }

    /* 日志容器 */
    #logContainer {
        font-size: 11px;
        padding: 8px;
    }

    .log-entry {
        font-size: 11px;
    }

    /* 连接状态 */
    .connection-status {
        margin-left: 0;
        padding: 5px 0;
        height: auto;
        line-height: normal;
    }

    .connection-status .status {
        font-size: 11px;
        padding: 0px 6px;
    }

    /* 音频可视化 */
    .audio-visualizer {
        height: 50px;
    }

    /* MCP 工具卡片 */
    .mcp-tool-card {
        padding: 10px;
    }

    .mcp-tool-name {
        font-size: 13px;
    }

    .mcp-tool-description {
        font-size: 12px;
    }

    .mcp-tool-info {
        font-size: 11px;
        padding: 6px;
    }

    .mcp-tool-info-row {
        flex-direction: column;
        gap: 2px;
    }

    .mcp-tool-info-label {
        min-width: auto;
    }

    /* 消息输入框 */
    .message-input {
        gap: 5px;
    }

    /* 会话记录高度调整 */
    .conversation,
    #logContainer {
        max-height: 180px;
    }
}

/* 小型移动设备 (宽度 <= 480px) */
@media (max-width: 480px) {
    .container {
        padding: 3px;
    }

    .section {
        padding: 6px;
        margin-top: 5px;
        margin-bottom: 5px;
    }

    .section h2 {
        font-size: 12px;
    }

    /* 更紧凑的按钮 */
    .toggle-button,
    .connect-button {
        padding: 2px 8px;
        font-size: 11px;
        height: 22px;
        line-height: 16px;
    }

    button {
        padding: 5px 10px;
        font-size: 12px;
    }

    .config-item label {
        min-width: 50px;
        font-size: 11px;
    }

    .config-item input {
        font-size: 12px;
    }

    /* 标签页 */
    .tab {
        padding: 6px 10px;
        font-size: 13px;
    }

    /* 消息气泡 */
    .message {
        max-width: 95%;
        font-size: 13px;
    }

    /* 会话记录 */
    .conversation,
    #logContainer {
        max-height: 150px;
        padding: 8px;
    }

    /* 连接状态文字更小 */
    .connection-status .status {
        font-size: 10px;
    }

    /* MCP 工具 */
    .mcp-tool-name {
        font-size: 12px;
    }

    .mcp-tool-description {
        font-size: 11px;
    }
}