/* ==================== 祁煜 · 潮汐之神 主题样式 ==================== */
:root {
    /* 核心配色 - 利莫里亚海洋与火焰 */
    --qiyu-ocean: #1E3A5F;       /* 深海蓝 */
    --qiyu-tide: #4A90C2;        /* 潮汐蓝 */
    --qiyu-gold: #C9A962;        /* 海神金饰 */
    --qiyu-flame: #E85A4F;       /* 火属性Evol */
    --qiyu-pearl: #F5F0E8;       /* 珍珠白 */
    
    /* 场景配色 */
    --bg-deep: #0A1628;          /* 深渊底色 */
    --bg-panel: rgba(10, 22, 40, 0.85);
    --glass-light: rgba(74, 144, 194, 0.15);
    
    /* 交互色 */
    --accent-glow: 0 0 20px rgba(74, 144, 194, 0.5);
    --gold-glow: 0 0 15px rgba(201, 169, 98, 0.4);
    --text-primary: #FFFFFF;
    --text-secondary: rgba(255, 255, 255, 0.85);
    --text-muted: rgba(255, 255, 255, 0.6);
    
    /* 动画 */
    --anim-tide: tide 4s ease-in-out infinite;
    --anim-shimmer: shimmer 3s ease-in-out infinite;
}

/* ==================== 背景图层 ==================== */
.bg-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('qiyu.jpg');
    background-size: cover;
    background-position: center top;
    background-repeat: no-repeat;
    z-index: -2;
}

.bg-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        180deg, 
        rgba(10, 22, 40, 0.1) 0%,
        rgba(10, 22, 40, 0.05) 30%,
        rgba(10, 22, 40, 0.3) 70%,
        rgba(10, 22, 40, 0.75) 100%
    );
    z-index: -1;
}

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

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

::-webkit-scrollbar-thumb {
    background: rgba(74, 144, 194, 0.4);
    border-radius: 2px;
}

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

* {
    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);
    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;
}

/* ==================== 加载状态 ==================== */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-deep);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.5s, visibility 0.5s;
}

.loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(74, 144, 194, 0.2);
    border-top-color: var(--qiyu-tide);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-overlay p {
    margin-top: 20px;
    color: var(--text-secondary);
    font-size: 14px;
    letter-spacing: 2px;
}

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

/* ==================== 顶部导航栏 ==================== */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(180deg, rgba(10, 22, 40, 0.9) 0%, rgba(10, 22, 40, 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(--text-muted);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.status-pulse {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: transparent;
}

.status-indicator.connected .status-core {
    background: var(--qiyu-tide);
    box-shadow: 0 0 8px var(--qiyu-tide);
}

.status-indicator.connected .status-pulse {
    animation: pulse-ring 1.5s ease-out infinite;
    border: 2px solid var(--qiyu-tide);
}

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

.header-left .status-text {
    font-size: 12px;
    color: var(--text-muted);
}

.status-indicator.connected + .status-text {
    color: var(--qiyu-tide);
}

.header-center {
    text-align: center;
}

.logo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.logo-text {
    font-size: 20px;
    font-weight: 600;
    color: var(--qiyu-gold);
    letter-spacing: 4px;
    text-shadow: 0 0 20px rgba(201, 169, 98, 0.5);
}

.logo-sub {
    font-size: 10px;
    color: var(--qiyu-gold);
    letter-spacing: 2px;
    margin-top: 2px;
    opacity: 0.8;
}

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

.header-connect-btn {
    background: linear-gradient(135deg, var(--qiyu-tide), var(--qiyu-ocean));
    border: none;
    padding: 8px 18px;
    border-radius: 20px;
    color: white;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    animation: btn-pulse 2s ease-in-out infinite;
}

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

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

.header-connect-btn.connected {
    background: rgba(232, 90, 79, 0.2);
    border: 1px solid var(--qiyu-flame);
    color: var(--qiyu-flame);
    animation: none;
}

.header-connect-btn.connected:hover {
    background: rgba(232, 90, 79, 0.3);
    box-shadow: 0 0 15px rgba(232, 90, 79, 0.3);
}

.header-clear-btn,
.settings-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    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(232, 90, 79, 0.3);
    border-color: rgba(232, 90, 79, 0.5);
}

.settings-btn:hover {
    background: rgba(74, 144, 194, 0.3);
    border-color: rgba(74, 144, 194, 0.5);
}

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

/* ==================== 对话区域 ==================== */
.chat-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0 16px;
    overflow: hidden;
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* 欢迎卡片 */
.welcome-message {
    display: flex;
    justify-content: center;
    padding-top: 45vh;
    padding-bottom: 20px;
}

.welcome-card {
    background: rgba(10, 22, 40, 0.7);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(74, 144, 194, 0.2);
    border-radius: 16px;
    padding: 30px 24px;
    max-width: 320px;
    text-align: center;
}

.welcome-icon {
    font-size: 40px;
    margin-bottom: 16px;
    animation: tide 3s ease-in-out infinite;
}

@keyframes tide {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.welcome-card h3 {
    font-size: 18px;
    color: var(--qiyu-pearl);
    font-weight: 500;
    letter-spacing: 2px;
    margin-bottom: 16px;
}

.welcome-quote {
    font-size: 15px;
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: 12px;
}

.welcome-hint {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 20px;
}

.welcome-divider {
    width: 60px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--qiyu-gold), transparent);
    margin: 0 auto 16px;
}

.welcome-tip {
    font-size: 12px;
    color: var(--text-secondary);
}

.welcome-tip .highlight-btn {
    display: inline-block;
    background: linear-gradient(135deg, var(--qiyu-tide), var(--qiyu-ocean));
    color: white;
    padding: 2px 10px;
    border-radius: 12px;
    font-weight: 500;
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 5px rgba(74, 144, 194, 0.5); }
    50% { box-shadow: 0 0 15px rgba(74, 144, 194, 0.8); }
}

/* 消息样式 */
.message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.6;
    animation: fadeInUp 0.3s ease;
}

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

.message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, rgba(74, 144, 194, 0.4), rgba(74, 144, 194, 0.2));
    border: 1px solid rgba(74, 144, 194, 0.3);
    color: var(--text-primary);
    border-bottom-right-radius: 4px;
}

.message.assistant {
    align-self: flex-start;
    background: rgba(10, 22, 40, 0.8);
    border: 1px solid rgba(201, 169, 98, 0.2);
    color: var(--text-secondary);
    border-bottom-left-radius: 4px;
    backdrop-filter: blur(8px);
}

/* 状态气泡 */
.status-bubble {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(10, 22, 40, 0.85);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(201, 169, 98, 0.3);
    border-radius: 30px;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.status-bubble.show {
    opacity: 1;
    visibility: visible;
}

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

.status-label {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ==================== 底部控制台 ==================== */
.control-deck {
    padding: 16px 20px calc(24px + env(safe-area-inset-bottom, 0px));
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(0deg, rgba(10, 22, 40, 0.95) 0%, rgba(10, 22, 40, 0.8) 50%, transparent 100%);
    position: sticky;
    bottom: 0;
    z-index: 50;
}

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

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

.input-module {
    flex: 1;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 25px;
    padding: 4px 6px 4px 18px;
    backdrop-filter: blur(8px);
}

.input-module input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
}

.input-module input::placeholder {
    color: var(--text-muted);
}

.input-module input:disabled {
    opacity: 0.5;
}

.send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--qiyu-tide), var(--qiyu-ocean));
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: var(--accent-glow);
}

.send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* 语音按钮 */
.voice-activator {
    position: relative;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.activator-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid rgba(74, 144, 194, 0.4);
    transition: all 0.3s ease;
}

.voice-activator:not(:disabled):hover .activator-ring {
    border-color: var(--qiyu-tide);
    box-shadow: var(--accent-glow);
}

.voice-activator.recording .activator-ring {
    border-color: var(--qiyu-flame);
    animation: recording-pulse 1s ease-in-out infinite;
}

@keyframes recording-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.7; }
}

.activator-core {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--qiyu-ocean), var(--qiyu-tide));
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.2s ease;
}

.voice-activator.recording .activator-core {
    background: linear-gradient(135deg, var(--qiyu-flame), #FF8A80);
}

.mic-icon {
    color: white;
    transition: opacity 0.2s;
}

.voice-activator.recording .mic-icon {
    opacity: 0;
}

.audio-waves {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    opacity: 0;
}

.voice-activator.recording .audio-waves {
    opacity: 1;
}

.audio-waves span {
    width: 3px;
    height: 12px;
    background: white;
    border-radius: 2px;
    animation: wave 0.8s ease-in-out infinite;
}

.audio-waves span:nth-child(2) { animation-delay: 0.1s; }
.audio-waves span:nth-child(3) { animation-delay: 0.2s; }
.audio-waves span:nth-child(4) { animation-delay: 0.3s; }

@keyframes wave {
    0%, 100% { height: 8px; }
    50% { height: 20px; }
}

.voice-activator:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* 录音提示 */
.recording-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.recording-hint.show {
    opacity: 1;
    visibility: visible;
}

.hint-icon {
    font-size: 14px;
}

.hint-text {
    font-size: 12px;
    color: var(--text-muted);
}

.recording-timer {
    font-size: 12px;
    color: var(--qiyu-flame);
    font-family: monospace;
}

/* ==================== 系统设置面板 ==================== */
.system-panel {
    position: fixed;
    inset: 0;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

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

.panel-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.panel-content {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 320px;
    max-width: 90%;
    background: var(--bg-panel);
    border-left: 1px solid rgba(74, 144, 194, 0.2);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

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

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

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

.close-panel-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

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

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

.setting-group input {
    width: 100%;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}

.setting-group input:focus {
    border-color: var(--qiyu-tide);
}

.setting-group input.readonly-input {
    opacity: 0.6;
}

.status-display {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

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

.status-dot.connected {
    background: var(--qiyu-tide);
    box-shadow: 0 0 8px var(--qiyu-tide);
}

#panelConnectionText {
    font-size: 13px;
    color: var(--text-secondary);
}

.panel-actions {
    padding-top: 10px;
}

.connect-main-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--qiyu-tide), var(--qiyu-ocean));
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.connect-main-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--accent-glow);
}

.connect-main-btn.connected {
    background: linear-gradient(135deg, var(--qiyu-flame), #FF8A80);
}

/* ==================== 响应式适配 ==================== */
@media (max-width: 480px) {
    .header-connect-btn .btn-text {
        display: none;
    }
    
    .header-connect-btn {
        width: 36px;
        height: 36px;
        padding: 0;
        border-radius: 50%;
    }
    
    .header-connect-btn::before {
        content: "⚡";
    }
    
    .welcome-card {
        margin: 0 10px;
    }
}

/* ==================== 动画效果 ==================== */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
