/* ==================== 科科角色主题样式 ==================== */
:root {
    /* 核心配色 - 取自重庆科技馆 */
    --keke-blue: #4A90E2;    /* 玻璃幕墙水蓝色 */
    --keke-grey: #7E8C9C;    /* 山岩灰 */
    --keke-red: #C03532;     /* 重庆红 */
    --keke-silver: #E0E0E0;  /* 科技银 */
    
    /* 场景配色 */
    --bg-deep: #0B1026;      /* 深空底色 */
    --bg-panel: rgba(16, 24, 48, 0.7);
    --holo-light: rgba(74, 144, 226, 0.15);
    
    /* 交互色 */
    --accent-glow: 0 0 20px rgba(74, 144, 226, 0.6);
    --text-primary: #FFFFFF;
    --text-secondary: rgba(255, 255, 255, 0.8);
    
    /* 动画 */
    --anim-float: float 3s ease-in-out infinite;
    --anim-pulse: pulse 2s ease-in-out infinite;
}

/* ==================== 滚动条样式 ==================== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: rgba(74, 144, 226, 0.3);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(74, 144, 226, 0.5);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg-deep);
    background-image: 
        radial-gradient(circle at 50% 0%, #1a237e 0%, transparent 60%),
        linear-gradient(0deg, transparent 24%, rgba(74, 144, 226, .05) 25%, rgba(74, 144, 226, .05) 26%, transparent 27%, transparent 74%, rgba(74, 144, 226, .05) 75%, rgba(74, 144, 226, .05) 76%, transparent 77%, transparent),
        linear-gradient(90deg, transparent 24%, rgba(74, 144, 226, .05) 25%, rgba(74, 144, 226, .05) 26%, transparent 27%, transparent 74%, rgba(74, 144, 226, .05) 75%, rgba(74, 144, 226, .05) 76%, transparent 77%, transparent);
    background-size: 100% 100%, 50px 50px, 50px 50px;
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

/* ==================== 布局容器 ==================== */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    max-width: 768px; /* 移动端优先 */
    margin: 0 auto;
    background: radial-gradient(circle at center bottom, #1c2645 0%, var(--bg-deep) 70%);
}

/* ==================== 顶部导航栏 ==================== */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(180deg, rgba(11, 16, 38, 0.9) 0%, rgba(11, 16, 38, 0) 100%);
    z-index: 10;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-indicator {
    position: relative;
    width: 12px;
    height: 12px;
}

.status-core {
    width: 8px;
    height: 8px;
    background: var(--keke-grey);
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: all 0.3s ease;
}

.status-pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 1px solid var(--keke-grey);
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.3s ease;
}

.status-indicator.connected .status-core {
    background: #00E676;
    box-shadow: 0 0 10px #00E676;
}

.status-indicator.connected .status-pulse {
    border-color: #00E676;
    animation: ping 2s cubic-bezier(0, 0, 0.2, 1) infinite;
    opacity: 1;
}

@keyframes ping {
    75%, 100% { transform: scale(2); opacity: 0; }
}

.status-text {
    font-size: 12px;
    color: var(--keke-silver);
    font-family: monospace;
}

.logo-container {
    text-align: center;
}

.logo-text {
    display: block;
    font-weight: 800;
    font-size: 18px;
    letter-spacing: 2px;
    background: linear-gradient(135deg, #fff, var(--keke-blue));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-sub {
    font-size: 10px;
    color: var(--keke-blue);
    display: block;
    letter-spacing: 1px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-connect-btn {
    background: linear-gradient(135deg, var(--keke-blue), #1E3A5F);
    border: none;
    color: white;
    font-weight: 500;
    animation: keke-btn-pulse 2s ease-in-out infinite;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

@keyframes keke-btn-pulse {
    0%, 100% { box-shadow: 0 0 8px rgba(74, 144, 226, 0.4); }
    50% { box-shadow: 0 0 20px rgba(74, 144, 226, 0.7); }
}

.header-connect-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 25px rgba(74, 144, 226, 0.8);
}

.header-connect-btn.connected {
    background: rgba(192, 53, 50, 0.2);
    border: 1px solid var(--keke-red);
    color: var(--keke-red);
    animation: none;
}

.header-connect-btn.connected:hover {
    background: rgba(192, 53, 50, 0.3);
    box-shadow: 0 0 10px rgba(192, 53, 50, 0.3);
}

.header-clear-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: all 0.2s ease;
}

.header-clear-btn:hover {
    background: rgba(192, 53, 50, 0.3);
    border-color: rgba(192, 53, 50, 0.5);
}

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

.settings-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(4px);
}

/* ==================== 主内容区 ==================== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* ==================== 科科角色展示 ==================== */
.keke-stage {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    min-height: 300px;
}

.keke-container {
    position: relative;
    width: 200px;
    height: 200px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 科科 Avatar 绘制 */
.keke-avatar {
    position: relative;
    width: 180px; /* 稍微调大一点以适应图片 */
    height: 180px;
    animation: var(--anim-float);
    z-index: 5;
    display: flex;
    justify-content: center;
    align-items: center;
}

.keke-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    z-index: 2;
    transition: transform 0.3s ease;
}

/* 说话时的简单动画 */
.keke-avatar.speaking .keke-image {
    animation: speakingPulse 0.5s ease-in-out infinite alternate;
}

@keyframes speakingPulse {
    from { transform: scale(1); }
    to { transform: scale(1.05); }
}

.keke-aura {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 220px;
    height: 220px;
    background: radial-gradient(circle, rgba(74, 144, 226, 0.2) 0%, transparent 70%);
    border-radius: 50%;
    filter: blur(10px);
    z-index: -1;
}

/* 状态气泡 */
.keke-status-bubble {
    position: absolute;
    top: -40px;
    right: -40px;
    background: rgba(255, 255, 255, 0.95);
    padding: 8px 12px;
    border-radius: 12px 12px 12px 0;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 6px;
    transform: scale(0.9);
    opacity: 0;
    transition: all 0.3s;
    pointer-events: none;
    max-width: 160px;
}

.keke-status-bubble.show {
    opacity: 1;
    transform: scale(1);
    top: -50px;
}

.status-emoji {
    font-size: 20px;
}

.status-text {
    font-size: 12px;
    color: #333;
    font-weight: 600;
}

/* 粒子特效 */
.keke-particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.particle {
    position: absolute;
    background: var(--keke-blue);
    border-radius: 50%;
    opacity: 0.6;
    animation: particleFloat 4s linear infinite;
}

@keyframes particleFloat {
    0% { transform: translateY(0) scale(1); opacity: 0; }
    50% { opacity: 0.8; }
    100% { transform: translateY(-100px) scale(0); opacity: 0; }
}

/* ==================== 全息对话区 ==================== */
.holo-chat-section {
    height: 55%;
    padding: 0 16px;
    mask-image: linear-gradient(to bottom, transparent, black 10%, black 90%, transparent);
    -webkit-mask-image: linear-gradient(to bottom, transparent, black 10%, black 90%, transparent);
}

.chat-container {
    height: 100%;
    overflow-y: auto;
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.holo-card {
    background: rgba(74, 144, 226, 0.1);
    border: 1px solid rgba(74, 144, 226, 0.3);
    border-radius: 12px;
    padding: 16px;
    color: #fff;
    backdrop-filter: blur(5px);
    box-shadow: 0 0 15px rgba(74, 144, 226, 0.1);
}

.holo-card h3 {
    color: var(--keke-blue);
    font-size: 16px;
    margin-bottom: 8px;
}

.holo-card p {
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 8px;
}

.holo-card .highlight-btn {
    display: inline-block;
    background: linear-gradient(135deg, var(--keke-blue), #1E3A5F);
    color: white;
    padding: 2px 10px;
    border-radius: 12px;
    font-weight: 500;
    animation: keke-btn-pulse 2s ease-in-out infinite;
}

.message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    animation: messageIn 0.3s ease;
    position: relative;
}

@keyframes messageIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--keke-blue), #2196F3);
    color: white;
    border-bottom-right-radius: 2px;
}

.message.assistant {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    border-bottom-left-radius: 2px;
}

.message.assistant::before {
    content: '';
    position: absolute;
    left: -6px;
    bottom: 0;
    width: 6px;
    height: 10px;
    background: inherit;
    clip-path: polygon(100% 0, 0 100%, 100% 100%);
}

/* ==================== 底部控制台 ==================== */
.control-deck {
    background: rgba(11, 16, 38, 0.95);
    border-top: 1px solid rgba(74, 144, 226, 0.2);
    padding: 16px 20px calc(30px + env(safe-area-inset-bottom, 0px));
    padding-bottom: calc(30px + env(safe-area-inset-bottom, 0px));
    position: sticky;
    bottom: 0;
    z-index: 50;
}

@supports not (padding-bottom: env(safe-area-inset-bottom)) {
    .control-deck {
        padding-bottom: 35px;
    }
}

.control-panel {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 600px;
    margin: 0 auto;
}

.input-module {
    flex: 1;
    display: flex;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    padding: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s;
}

.input-module:focus-within {
    border-color: var(--keke-blue);
    background: rgba(255, 255, 255, 0.12);
}

.input-module input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 8px 12px;
    color: #fff;
    font-size: 14px;
    outline: none;
}

.action-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.send-btn {
    background: var(--keke-blue);
    color: white;
}

.send-btn:disabled {
    background: var(--keke-grey);
    opacity: 0.5;
}

/* 语音激活器 */
.voice-activator {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: transparent;
    border: none;
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
}

.activator-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 2px solid var(--keke-blue);
    border-radius: 50%;
    opacity: 0.5;
    transition: all 0.3s;
}

.activator-core {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--keke-blue), #1976D2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 10px rgba(74, 144, 226, 0.3);
    transition: all 0.3s;
    overflow: hidden;
}

.voice-activator:active .activator-core {
    transform: scale(0.95);
}

.voice-activator.recording .activator-ring {
    border-color: var(--keke-red);
    animation: pulse-ring 1.5s infinite;
}

.voice-activator.recording .activator-core {
    background: var(--keke-red);
}

@keyframes pulse-ring {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(1.5); opacity: 0; }
}

.audio-waves {
    position: absolute;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 20px;
}

.voice-activator.recording .mic-icon { display: none; }
.voice-activator.recording .audio-waves { display: flex; }

.audio-waves span {
    width: 3px;
    background: #fff;
    border-radius: 2px;
    animation: wave 1s ease-in-out infinite;
}

.audio-waves span:nth-child(1) { height: 40%; animation-delay: 0s; }
.audio-waves span:nth-child(2) { height: 70%; animation-delay: 0.1s; }
.audio-waves span:nth-child(3) { height: 100%; animation-delay: 0.2s; }
.audio-waves span:nth-child(4) { height: 60%; animation-delay: 0.3s; }

.recording-hint {
    display: none;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    font-size: 12px;
    color: var(--text-secondary);
}

.recording-hint.show {
    display: flex;
}

.recording-timer {
    color: var(--keke-red);
    font-family: monospace;
    font-weight: bold;
}

/* ==================== 设置面板 ==================== */
.system-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    visibility: hidden;
    opacity: 0;
    transition: all 0.3s;
}

.system-panel.open {
    visibility: visible;
    opacity: 1;
}

.panel-backdrop {
    position: absolute;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(5px);
}

.panel-content {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: #151b33;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.system-panel.open .panel-content {
    transform: translateY(0);
}

.panel-header {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.panel-header h2 {
    font-size: 16px;
    color: var(--text-primary);
}

.close-panel-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
}

.panel-body {
    padding: 20px;
    overflow-y: auto;
}

.setting-group {
    margin-bottom: 16px;
}

.setting-group label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.setting-group input {
    width: 100%;
    background: rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 10px;
    color: #fff;
    font-size: 14px;
}

.readonly-input {
    background: rgba(255,255,255,0.05) !important;
    color: rgba(255,255,255,0.4) !important;
}

.status-display {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--keke-grey);
    border-radius: 50%;
}

.status-dot.connected {
    background: #00E676;
}

.panel-actions {
    margin-top: 24px;
}

.connect-main-btn {
    width: 100%;
    background: var(--keke-blue);
    color: white;
    border: none;
    padding: 14px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(74, 144, 226, 0.3);
}

.connect-main-btn.connected {
    background: var(--keke-red);
    box-shadow: 0 4px 15px rgba(192, 53, 50, 0.3);
}

/* ==================== 浮动动画 ==================== */
@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0px); }
}

/* ==================== 加载遮罩 ==================== */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0B1026;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(74, 144, 226, 0.3);
    border-top-color: var(--keke-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay p {
    color: var(--keke-blue);
    font-size: 12px;
    letter-spacing: 1px;
}
