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

body {
    font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
    margin: 0;
    padding: 0;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* ==================== 背景容器 ==================== */
.background-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-image: url('../images/1.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: background-image 0.5s ease-in-out;
    z-index: -2;
}

.background-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    z-index: -1;
}

/* ==================== 主容器 ==================== */
.container {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    /* 从底部开始排列 */
    padding: 20px;
    padding-bottom: 0;
    /* 移除底部padding，让模型可以延伸到页面底部 */
}

/* ==================== 模型加载区 ==================== */
.model-container {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 300px;
    height: 200px;
    transform: translate(-50%, -50%);
    user-select: none;
}

.model-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 999;
    transition: opacity 0.5s ease-out, visibility 0.5s ease-out;
    background-image: linear-gradient(transparent 50%, rgba(88, 101, 242, 0.05) 50%);
    background-size: 100% 4px;
    animation: scan 1.26s linear infinite;
}

.loading-char-float {
    font-size: 22px;
    letter-spacing: 3px;
    position: relative;
}

.loading-char-float .main-char {
    color: #f0f8ff;
    text-shadow: 0 0 5px #5865f2, 0 0 10px rgba(88, 101, 242, 0.8);
    display: inline-block;
}

.loading-char-float .main-char span {
    animation: char-float 1.26s ease-in-out infinite;
    display: inline-block;
}

.loading-char-float .shadow-char {
    position: absolute;
    top: 3px;
    left: 0;
    color: rgba(88, 101, 242, 0.3);
    pointer-events: none;
    animation: shadow-float 1.26s ease-in-out infinite;
}

.loading-char-float .main-char span:nth-child(1) { animation-delay: 0s; }
.loading-char-float .main-char span:nth-child(2) { animation-delay: 0.11s; }
.loading-char-float .main-char span:nth-child(3) { animation-delay: 0.22s; }
.loading-char-float .main-char span:nth-child(4) { animation-delay: 0.33s; }
.loading-char-float .main-char span:nth-child(5) { animation-delay: 0.44s; }
.loading-char-float .main-char span:nth-child(6) { animation-delay: 0.55s; }

@keyframes scan {
    0% { background-position: 0 0; }
    100% { background-position: 0 100px; }
}

@keyframes char-float {
    0%, 100% { transform: translateY(0); opacity: 1; text-shadow: 0 0 5px #5865f2, 0 0 10px rgba(88, 101, 242, 0.8); }
    50% { transform: translateY(-5px); opacity: 0.9; text-shadow: 0 0 10px #5865f2, 0 0 20px rgba(88, 101, 242, 0.8); }
}

@keyframes shadow-float {
    0%, 100% { transform: translateY(3px); opacity: 0.3; }
    50% { transform: translateY(8px); opacity: 0.15; }
}

/* ==================== Live2D显示区域 ==================== */
#live2d-stage {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: block;
    z-index: 100;
    pointer-events: auto;
}

.status-indicator {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 14px;
    font-weight: 500;
    z-index: 10;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.status-disconnected {
    background-color: #f44336;
}

.status-connecting {
    background-color: #ff9800;
}

.status-connected {
    background-color: #4caf50;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* ==================== 聊天消息流（弹幕样式） ==================== */
.chat-container {
    position: absolute;
    bottom: 150px;
    right: 20px;
    z-index: 100;
}

.chat-stream {
    width: 300px;
    max-height: 200px;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    margin-bottom: 10px;
}

.chat-ipt {
    width: 100%;
    display: none;
    justify-content: center;
    margin-top: 10px;
}

.chat-ipt input {
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-radius: 24px;
    background: rgba(35, 39, 42, 0.85);
    backdrop-filter: blur(10px);
    color: white;
    font-size: 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.chat-ipt input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.chat-ipt input:focus {
    outline: none;
    border-color: rgba(88, 101, 242, 0.6);
    box-shadow: 0 4px 16px rgba(88, 101, 242, 0.3);
    background: rgba(45, 49, 52, 0.9);
}

.chat-message {
    animation: slideInRight 0.3s ease-out;
    pointer-events: auto;
}

.chat-message.ai .message-bubble {
    background: transparent;
    color: white;
    align-self: flex-end;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.chat-message.user .message-bubble {
    background: rgba(88, 101, 242, 0.7);
    color: white;
    align-self: flex-start;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.chat-message.system .message-bubble {
    background: transparent;
    color: #b9bbbe;
    align-self: center;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.message-bubble {
    padding: 8px 12px;
    border-radius: 18px;
    font-size: 14px;
    max-width: 250px;
    word-wrap: break-word;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: fadeIn 0.3s ease-out;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

/* ==================== 底部控制栏 ==================== */
.control-bar {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 16px;
    background: rgba(35, 39, 42, 0.9);
    backdrop-filter: blur(20px);
    padding: 12px 24px;
    border-radius: 28px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    /* 确保控制栏在最上层 */
}

.control-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 50%;
    background: rgba(79, 84, 92, 0.8);
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.control-btn:hover {
    background: rgba(114, 137, 218, 0.8);
    transform: translateY(-2px);
}

.control-btn:active {
    transform: translateY(0);
}

.control-btn:disabled {
    background: rgba(79, 84, 92, 0.4);
    color: rgba(255, 255, 255, 0.4);
    cursor: not-allowed;
    transform: none;
}

.control-btn:disabled:hover {
    background: rgba(79, 84, 92, 0.4);
    transform: none;
}

.btn-icon {
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
}

.btn-text {
    font-size: 12px;
    font-weight: 500;
}

/* 拨号按钮特殊样式 */
.dial-btn.dial-active {
    background: rgba(237, 66, 69, 0.9);
}

.dial-btn.dial-active:hover {
    background: rgba(237, 66, 69, 1);
}

/* 录音按钮特殊样式 */
.control-btn.recording {
    background: rgba(237, 66, 69, 0.9);
    animation: pulse 1.5s infinite;
}

.control-btn.recording:hover {
    background: rgba(237, 66, 69, 1);
}

/* 录音按钮脉冲动画 */
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(237, 66, 69, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(237, 66, 69, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(237, 66, 69, 0);
    }
}

/* ==================== 弹窗样式 ==================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: #36393f;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.3s ease-out;
}

.settings-modal {
    max-width: 700px;
    max-height: 85vh;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #40444b;
    background: #2f3136;
}

.modal-header h2 {
    color: white;
    font-size: 20px;
    font-weight: 600;
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    color: #b9bbbe;
    font-size: 24px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.close-btn:hover {
    background: #40444b;
    color: white;
}

.modal-body {
    padding: 24px;
    max-height: calc(80vh - 80px);
    overflow-y: auto;
}

/* ==================== 输入组样式 ==================== */
.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    color: #b9bbbe;
    font-size: 14px;
    font-weight: 500;
}

.input-group input,
.input-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #40444b;
    border-radius: 6px;
    background: #40444b;
    color: white;
    font-size: 14px;
    transition: border-color 0.2s;
}

.input-group input:focus,
.input-group textarea:focus {
    outline: none;
    border-color: #5865f2;
}

.input-group textarea {
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
}

/* ==================== 按钮样式 ==================== */
.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* ==================== 文件协议警告样式 ==================== */
#fileProtocolWarning {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 95%;
    max-width: 800px;
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.95), rgba(56, 142, 60, 0.95));
    border: 3px solid #4caf50;
    border-radius: 16px;
    padding: 32px;
    z-index: 10000;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(15px);
    color: white;
    font-family: inherit;
    animation: fadeInUp 0.5s ease-out;
}

#fileProtocolWarning h2 {
    color: #e8f5e8;
    margin-bottom: 20px;
    font-size: 28px;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

#fileProtocolWarning p {
    margin-bottom: 16px;
    line-height: 1.6;
    font-size: 16px;
    color: #e8f5e8;
}

#fileProtocolWarning ol {
    margin: 16px 0;
    padding-left: 24px;
    font-size: 16px;
}

#fileProtocolWarning pre {
    background: rgba(255, 255, 255, 0.15);
    padding: 12px 16px;
    border-radius: 8px;
    margin: 12px 0;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    overflow-x: auto;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

#fileProtocolWarning strong {
    color: #c8e6c9;
    font-weight: 600;
}

/* 背景模糊遮罩 */
.file-protocol-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    z-index: 9999;
    animation: fadeIn 0.3s ease-out;
}

/* 动画效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translate(-50%, -40%);
    }

    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

/* ==================== 连接信息样式 ==================== */
.connection-info {
    margin-top: 20px;
    padding: 16px;
    background: rgba(88, 101, 242, 0.1);
    border: 1px solid rgba(88, 101, 242, 0.3);
    border-radius: 8px;
    text-align: center;
}

.connection-info p {
    color: #b9bbbe;
    font-size: 14px;
    line-height: 1.4;
    margin: 0;
}

.btn-primary {
    background: #5865f2;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s;
}

.btn-primary:hover {
    background: #4752c4;
}

.btn-secondary {
    background: #4f545c;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s;
}

.btn-secondary:hover {
    background: #5d6269;
}

/* ==================== 设置标签页样式 ==================== */
.settings-tabs {
    display: flex;
    border-bottom: 1px solid #40444b;
    margin-bottom: 20px;
}

.tab-btn {
    background: none;
    border: none;
    color: #b9bbbe;
    padding: 12px 24px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab-btn.active {
    color: white;
    border-bottom-color: #5865f2;
}

.tab-btn:hover:not(.active) {
    color: white;
    background: #40444b;
}

.tab-content {
    display: none;
}

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

/* ==================== 配置面板样式 ==================== */
.config-panel {
    background: #2f3136;
    border-radius: 8px;
    padding: 20px;
}

.config-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.config-item {
    flex: 1;
}

.config-item label {
    display: block;
    margin-bottom: 6px;
    color: #b9bbbe;
    font-size: 12px;
    font-weight: 500;
}

.config-item input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #40444b;
    border-radius: 4px;
    background: #40444b;
    color: white;
    font-size: 14px;
}

/* ==================== MCP工具样式 ==================== */
.mcp-tools-container {
    background: #2f3136;
    border-radius: 8px;
    padding: 0;
    overflow: hidden;
}

.mcp-tools-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #36393f;
    border-bottom: 1px solid #40444b;
}

.mcp-tools-header h3 {
    margin: 0;
    color: #ffffff;
    font-size: 16px;
    font-weight: 600;
}

.mcp-tools-panel {
    padding: 20px;
    transition: max-height 0.3s ease;
    overflow: hidden;
}

.mcp-tools-panel.expanded {
    max-height: 500px;
}

.mcp-tools-panel:not(.expanded) {
    max-height: 0;
    padding: 0 20px;
}

.mcp-tools-list {
    min-height: 200px;
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 16px;
}

/* MCP工具卡片样式 */
.mcp-tool-card {
    background: #36393f;
    border: 1px solid #40444b;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    transition: background-color 0.2s;
}

.mcp-tool-card:hover {
    background: #40444b;
}

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

.mcp-tool-name {
    font-weight: 600;
    color: white;
    font-size: 14px;
}

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

.mcp-edit-btn {
    padding: 4px 10px;
    border: none;
    border-radius: 4px;
    background-color: #2196f3;
    color: white;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.2s;
}

.mcp-edit-btn:hover {
    background-color: #1976d2;
}

.mcp-delete-btn {
    padding: 4px 10px;
    border: none;
    border-radius: 4px;
    background-color: #f44336;
    color: white;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.2s;
}

.mcp-delete-btn:hover {
    background-color: #d32f2f;
}

.mcp-tool-description {
    color: #b9bbbe;
    font-size: 13px;
    line-height: 1.4;
    margin-bottom: 12px;
}

.mcp-tool-info {
    background: #2f3136;
    border-radius: 4px;
    padding: 8px;
}

.mcp-tool-info-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.mcp-tool-info-label {
    color: #b9bbbe;
    font-size: 12px;
}

.mcp-tool-info-value {
    color: white;
    font-size: 12px;
    font-weight: 500;
}

.mcp-actions {
    text-align: center;
}

.properties-container {
    background: #2f3136;
    border: 1px solid #40444b;
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 12px;
}

.property-item {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    align-items: center;
}

.property-item input {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid #40444b;
    border-radius: 4px;
    background: #40444b;
    color: white;
    font-size: 12px;
}

.remove-property {
    background: #ed4245;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.remove-property:hover {
    background: #c03537;
}

/* ==================== 音频可视化器样式 ==================== */
.audio-visualizer {
    position: fixed;
    bottom: 100px;
    left: 20px;
    width: 200px;
    height: 60px;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 999;
}

/* ==================== 响应式设计 ==================== */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .live2d-section {
        height: 60vh;
        margin-bottom: 10px;
    }

    .live2d-canvas {
        max-width: 300px;
        max-height: 450px;
    }

    .control-bar {
        bottom: 10px;
        padding: 8px 16px;
        gap: 12px;
    }

    .control-btn {
        width: 50px;
        height: 50px;
    }

    .btn-icon {
        width: 20px;
        height: 20px;
    }

    .btn-text {
        font-size: 10px;
    }

    .chat-container {
        width: 230px;
        right: 10px;
        bottom: 105px;
    }

    .message-bubble {
        max-width: 200px;
        font-size: 12px;
    }

    .modal-content {
        width: 95%;
        margin: 10px;
    }

    .config-row {
        flex-direction: column;
        gap: 12px;
    }

    .audio-visualizer {
        width: 150px;
        height: 50px;
        left: 10px;
        bottom: 80px;
    }
}

@media (max-width: 480px) {
    .live2d-section {
        height: 50vh;
    }

    .live2d-canvas {
        max-width: 250px;
        max-height: 350px;
    }

    .control-bar {
        gap: 8px;
        padding: 6px 12px;
    }

    .control-btn {
        width: 45px;
        height: 45px;
    }

    .btn-text {
        display: none;
    }

    .chat-stream {
        width: 200px;
        max-height: 150px;
    }

    .audio-visualizer {
        width: 120px;
        height: 40px;
        left: 5px;
        bottom: 70px;
    }
}

/* 竖屏优化 */
@media (max-height: 700px) {
    .live2d-section {
        height: 55vh;
    }

    .live2d-canvas {
        max-height: 400px;
    }

    .chat-stream {
        bottom: 70px;
        max-height: 150px;
    }

    .audio-visualizer {
        bottom: 70px;
    }
}

/* 横屏优化 */
@media (min-width: 1024px) and (min-height: 600px) {
    .live2d-section {
        height: 75vh;
    }

    .live2d-canvas {
        max-width: 500px;
        max-height: 650px;
    }

    .chat-stream {
        width: 350px;
        max-height: 250px;
    }

    .audio-visualizer {
        width: 250px;
        height: 80px;
    }
}

/* 滚动条样式 */
.chat-stream::-webkit-scrollbar,
.modal-body::-webkit-scrollbar,
.mcp-tools-list::-webkit-scrollbar {
    width: 6px;
}

.chat-stream::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track,
.mcp-tools-list::-webkit-scrollbar-track {
    background: #2f3136;
    border-radius: 3px;
}

.chat-stream::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb,
.mcp-tools-list::-webkit-scrollbar-thumb {
    background: #40444b;
    border-radius: 3px;
}

.chat-stream::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover,
.mcp-tools-list::-webkit-scrollbar-thumb:hover {
    background: #4f545c;
}