/* YHW 字体引入 */
@font-face {
    font-family: 'YHW';
    src: url('/fonts/yhw.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: radial-gradient(circle at top left, #1e1548, #140b2e);
    color: #f0e6d2;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

/* 霓虹灯文字装饰 */
.neon-decoration {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

.neon-letter {
    position: absolute;
    font-family: 'YHW', sans-serif !important;
    opacity: 0;
    text-shadow: 0 0 10px currentColor, 0 0 20px currentColor, 0 0 30px currentColor;
    animation: neon-flicker 4s ease-in-out forwards;
}

@keyframes neon-flicker {
    0% {
        opacity: 0;
    }
    5% {
        opacity: 0.8;
    }
    10% {
        opacity: 0.4;
    }
    15% {
        opacity: 0.9;
    }
    20% {
        opacity: 0.5;
    }
    25% {
        opacity: 1;
    }
    30% {
        opacity: 0.6;
    }
    35% {
        opacity: 0.9;
    }
    40% {
        opacity: 0.4;
    }
    45% {
        opacity: 0.8;
    }
    50% {
        opacity: 1;
    }
    55% {
        opacity: 0.7;
    }
    60% {
        opacity: 0.9;
    }
    65% {
        opacity: 0.6;
    }
    70% {
        opacity: 1;
    }
    80% {
        opacity: 0.8;
    }
    90% {
        opacity: 0.3;
    }
    100% {
        opacity: 0;
    }
}

/* 主容器 */
.main-container {
    background: rgba(30, 21, 72, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(194, 139, 55, 0.3);
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    width: 90%;
    max-width: 1200px;
    height: 90vh;
    max-height: 900px;
    z-index: 10;
    position: relative;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    overflow: visible;
}

/* 导航栏 */
.nav-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 25px;
    border-bottom: 1px solid rgba(194, 139, 55, 0.3);
    position: relative;
    z-index: 50;
    overflow: visible;
}

.logo {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.logo-text {
    font-size: 1.8rem;
    font-weight: bold;
    background: linear-gradient(45deg, #c28b37, #f0e6d2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.subtitle {
    font-family: 'YHW', sans-serif;
    font-size: 0.9rem;
    color: #c28b37;
    margin-top: -5px;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 20px;
    position: relative;
    z-index: 60;
}

.nav-links a {
    color: #f0e6d2;
    text-decoration: none;
    padding: 8px 15px;
    border-radius: 20px;
    transition: all 0.3s ease;
    font-size: 0.95rem;
}

.nav-links a:hover, .nav-links a.active {
    color: #c28b37;
    background: rgba(194, 139, 55, 0.1);
}

/* 用户头像和下拉菜单 */
.user-avatar {
    position: relative;
    margin-left: 10px;
    z-index: 150;
}

.avatar-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(45deg, #c28b37, #8b6324);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #140b2e;
    font-size: 1.2rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    position: relative;
    z-index: 151;
}

/* 下拉菜单样式 */
.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: rgba(30, 21, 72, 0.98);
    border: 2px solid rgba(194, 139, 55, 0.5);
    border-radius: 12px;
    padding: 12px 0;
    width: 180px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
    z-index: 9999;
    display: none;
    transform: translateY(-10px);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    backdrop-filter: blur(15px);
}

.dropdown-menu.active {
    display: block;
    transform: translateY(0);
    opacity: 1;
}

.dropdown-item {
    display: block;
    padding: 12px 20px;
    color: #f0e6d2;
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-size: 0.95rem;
    font-family: inherit;
}

.dropdown-item:hover {
    background: rgba(194, 139, 55, 0.2);
    color: #c28b37;
}

/* 退出登录特殊样式 */
.dropdown-item.logout-item {
    border-top: 1px solid rgba(194, 139, 55, 0.2);
    margin-top: 5px;
    color: #ff6b6b;
}

.dropdown-item.logout-item:hover {
    background: rgba(255, 107, 107, 0.1);
    color: #ff6b6b;
}

/* 下拉菜单图标样式 */
.dropdown-item i {
    margin-right: 8px;
    width: 16px;
    text-align: center;
}

/* 炼药台主体 */
.lab-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow: hidden;
}

/* 对话历史区域 */
.conversation-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-radius: 12px;
    background: rgba(30, 21, 72, 0.5);
    border: 1px solid rgba(194, 139, 55, 0.2);
    overflow: hidden;
    margin-bottom: 20px;
}

.conversation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid rgba(194, 139, 55, 0.2);
}

.conversation-header h2 {
    font-size: 1.3rem;
    color: #c28b37;
    font-weight: normal;
    display: flex;
    align-items: center;
    gap: 10px;
}

.reset-btn {
    background: rgba(194, 139, 55, 0.15);
    color: #c28b37;
    border: 1px solid rgba(194, 139, 55, 0.3);
    padding: 8px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.reset-btn:hover {
    background: rgba(194, 139, 55, 0.25);
}

.conversation-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    scrollbar-width: thin;
    scrollbar-color: rgba(194, 139, 55, 0.5) rgba(30, 21, 72, 0.5);
}

.conversation-scroll::-webkit-scrollbar {
    width: 8px;
}

.conversation-scroll::-webkit-scrollbar-track {
    background: rgba(30, 21, 72, 0.5);
}

.conversation-scroll::-webkit-scrollbar-thumb {
    background: rgba(194, 139, 55, 0.3);
    border-radius: 4px;
}

.conversation-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(194, 139, 55, 0.5);
}

/* 消息样式 */
.message {
    display: flex;
    margin-bottom: 25px;
    animation: message-fade-in 0.5s ease forwards;
}

@keyframes message-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 15px;
    flex-shrink: 0;
    overflow: hidden;
}

.avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-message .message-avatar {
    background: linear-gradient(45deg, #39728f, #81c3dd);
    color: #0b141e;
}

.ai-message .message-avatar {
    background: linear-gradient(45deg, #c28b37, #8b6324);
    color: #140b2e;
}

.message-content {
    flex: 1;
    max-width: calc(100% - 55px);
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.message-name {
    font-weight: bold;
    font-size: 0.95rem;
}

.user-message .message-name {
    color: #81c3dd;
}

.ai-message .message-name {
    color: #c28b37;
}

.message-time {
    font-size: 0.8rem;
    color: rgba(240, 230, 210, 0.5);
}

.message-text {
    background: rgba(0, 0, 0, 0.2);
    padding: 15px;
    border-radius: 0 12px 12px 12px;
    line-height: 1.5;
    color: #f0e6d2;
}

.user-message .message-text {
    border-left: 3px solid #39728f;
}

.ai-message .message-text {
    border-left: 3px solid #c28b37;
}

.message-text p {
    margin-bottom: 10px;
}

.message-text p:last-child {
    margin-bottom: 0;
}

/* 思维链消息的特殊样式 */
.ai-message.reasoning .message-avatar {
    background: linear-gradient(45deg, #8b6324, #5e421a);
}

.ai-message.reasoning .message-name {
    color: #a67530;
}

.ai-message.reasoning .message-text {
    background: rgba(45, 34, 15, 0.4);
    border-left: 3px dashed #8b6324;
    font-style: italic;
}

/* Markdown样式 */
.message-text code {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 4px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    color: #dda365;
}

.message-text pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 10px;
    border-radius: 5px;
    border-left: 3px solid #c28b37;
    overflow-x: auto;
    margin: 10px 0;
}

.message-text pre code {
    background: transparent;
    padding: 0;
    color: #f0e6d2;
    display: block;
    line-height: 1.5;
}

.message-text blockquote {
    border-left: 3px solid #c28b37;
    margin: 10px 0;
    padding-left: 15px;
    color: #c28b37;
    font-style: italic;
}

.message-text ul, .message-text ol {
    margin-left: 20px;
    margin-bottom: 10px;
}

.message-text table {
    border-collapse: collapse;
    width: 100%;
    margin: 10px 0;
}

.message-text th, .message-text td {
    border: 1px solid rgba(194, 139, 55, 0.3);
    padding: 8px;
    text-align: left;
}

.message-text th {
    background: rgba(194, 139, 55, 0.2);
}

.message-text h1, .message-text h2, .message-text h3, 
.message-text h4, .message-text h5, .message-text h6 {
    color: #c28b37;
    margin-top: 15px;
    margin-bottom: 10px;
}

/* 用户信息样式 */
.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-right: 15px;
}

.user-level, .user-exp {
    background: rgba(194, 139, 55, 0.2);
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.85rem;
    color: #c28b37;
}

/* 输入区域 */
.input-container {
    display: flex;
    gap: 15px;
    margin-top: auto;
}

.input-wrapper {
    flex: 1;
    position: relative;
    border-radius: 12px;
    background: rgba(30, 21, 72, 0.7);
    border: 1px solid rgba(194, 139, 55, 0.3);
    overflow: hidden;
}

textarea {
    width: 100%;
    border: none;
    background: transparent;
    padding: 15px 20px;
    color: #f0e6d2;
    font-size: 1rem;
    resize: none;
    outline: none;
    font-family: inherit;
    max-height: 150px;
    min-height: 56px;
}

textarea::placeholder {
    color: rgba(240, 230, 210, 0.5);
}

.submit-btn {
    padding: 0 25px;
    border-radius: 12px;
    background: linear-gradient(45deg, #c28b37, #8b6324);
    color: #140b2e;
    border: none;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
    min-width: 150px;
    justify-content: center;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(194, 139, 55, 0.3);
}

.submit-btn:active {
    transform: translateY(0);
}

/* 底部样式 */
.lab-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 25px;
    border-top: 1px solid rgba(194, 139, 55, 0.3);
    font-size: 0.85rem;
}

.footer-info {
    color: rgba(240, 230, 210, 0.7);
}

.sga-text {
    font-family: 'YHW', sans-serif;
    color: #c28b37;
}

/* 加载指示器 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(20, 11, 46, 0.8);
    backdrop-filter: blur(5px);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.loading-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.cauldron {
    position: relative;
    width: 120px;
    height: 120px;
    margin-bottom: 20px;
}

.cauldron-body {
    position: absolute;
    width: 100px;
    height: 80px;
    background: #1e1548;
    border: 3px solid #c28b37;
    border-radius: 50% 50% 10% 10% / 80% 80% 20% 20%;
    top: 0;
    left: 10px;
    overflow: hidden;
}

.cauldron-handle {
    position: absolute;
    width: 20px;
    height: 60px;
    border: 3px solid #c28b37;
    border-bottom: none;
    border-radius: 50% 50% 0 0;
    top: 20px;
}

.cauldron-handle.left {
    left: -10px;
    border-right: none;
}

.cauldron-handle.right {
    right: -10px;
    border-left: none;
}

.cauldron-base {
    position: absolute;
    width: 80px;
    height: 15px;
    background: #c28b37;
    border-radius: 50%;
    bottom: 10px;
    left: 20px;
}

.liquid {
    position: absolute;
    width: 100%;
    height: 50px;
    background: linear-gradient(90deg, #8b6324, #c28b37);
    bottom: 0;
    animation: liquid-bubble 3s ease-in-out infinite;
}

@keyframes liquid-bubble {
    0%, 100% {
        height: 45px;
    }
    50% {
        height: 55px;
    }
}

.bubble {
    position: absolute;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    bottom: 10px;
    animation: bubble-rise 2s ease-in-out infinite;
}

.bubble-1 {
    width: 10px;
    height: 10px;
    left: 20px;
    animation-delay: 0.2s;
}

.bubble-2 {
    width: 15px;
    height: 15px;
    left: 40px;
    animation-delay: 0.5s;
}

.bubble-3 {
    width: 8px;
    height: 8px;
    left: 65px;
    animation-delay: 0.7s;
}

.bubble-4 {
    width: 12px;
    height: 12px;
    left: 80px;
    animation-delay: 0.1s;
}

.bubble-5 {
    width: 6px;
    height: 6px;
    left: 50px;
    animation-delay: 0.9s;
}

@keyframes bubble-rise {
    0% {
        transform: translateY(0) scale(1);
        opacity: 0.7;
    }
    100% {
        transform: translateY(-60px) scale(1.5);
        opacity: 0;
    }
}

.loading-text {
    color: #c28b37;
    font-size: 1.2rem;
    text-align: center;
    margin-top: 20px;
    animation: loading-text-pulse 1.5s ease-in-out infinite;
}

@keyframes loading-text-pulse {
    0%, 100% {
        opacity: 0.7;
    }
    50% {
        opacity: 1;
    }
}

/* 弹窗样式 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(20, 11, 46, 0.85);
    backdrop-filter: blur(5px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal-container {
    background: rgba(30, 21, 72, 0.95);
    border: 1px solid rgba(194, 139, 55, 0.5);
    border-radius: 15px;
    padding: 25px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    transform: translateY(-20px);
    opacity: 0;
    transition: transform 0.5s ease, opacity 0.5s ease;
}

.modal-overlay.active .modal-container {
    transform: translateY(0);
    opacity: 1;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(194, 139, 55, 0.3);
    padding-bottom: 15px;
}

.modal-title {
    font-size: 1.5rem;
    color: #c28b37;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-close {
    background: none;
    border: none;
    color: rgba(240, 230, 210, 0.6);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.3s ease;
}

.modal-close:hover {
    color: #f0e6d2;
}

.modal-body {
    margin-bottom: 20px;
    line-height: 1.6;
}

.modal-body p {
    margin-bottom: 15px;
    color: #f0e6d2;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
}

.modal-btn {
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.modal-btn-cancel {
    background: rgba(194, 139, 55, 0.2);
    color: #c28b37;
    border: 1px solid rgba(194, 139, 55, 0.3);
}

.modal-btn-cancel:hover {
    background: rgba(194, 139, 55, 0.3);
}

.modal-btn-confirm {
    background: linear-gradient(45deg, #c28b37, #8b6324);
    color: #140b2e;
    font-weight: bold;
}

.modal-btn-confirm:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(194, 139, 55, 0.3);
}

/* 登录提示弹窗 */
.login-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-modal {
    background: rgba(30, 21, 72, 0.95);
    border: 2px solid #c28b37;
    border-radius: 15px;
    padding: 30px;
    width: 90%;
    max-width: 450px;
    text-align: center;
    box-shadow: 0 0 30px rgba(194, 139, 55, 0.5);
    animation: glow 2s infinite alternate;
}

@keyframes glow {
    from {
        box-shadow: 0 0 20px rgba(194, 139, 55, 0.5);
    }
    to {
        box-shadow: 0 0 30px rgba(194, 139, 55, 0.8);
    }
}

.login-modal h2 {
    color: #c28b37;
    font-size: 1.8rem;
    margin-bottom: 20px;
}

.login-modal p {
    color: #f0e6d2;
    margin-bottom: 30px;
    line-height: 1.6;
}

.login-btn {
    background: linear-gradient(45deg, #c28b37, #8b6324);
    color: #140b2e;
    border: none;
    padding: 12px 25px;
    border-radius: 30px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.login-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

/* 水波纹效果 */
.input-ripple {
    position: absolute;
    background: rgba(194, 139, 55, 0.2);
    border-radius: 50%;
    transform: scale(0);
    animation: ripple 0.6s linear;
    pointer-events: none;
}

@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* 禁用状态样式 */
.disabled {
    opacity: 0.6;
    cursor: not-allowed !important;
    pointer-events: none;
}

/* 响应式设计 */
@media (max-width: 992px) {
    .main-container {
        width: 95%;
        height: 95vh;
    }
}

@media (max-width: 768px) {
    .nav-links a:not(.user-avatar) {
        display: none;
    }
    
    /* 小屏幕下拉菜单修复 */
    .nav-bar {
        position: relative;
        z-index: 1000;
    }
    
    .user-avatar {
        position: relative;
        z-index: 1001;
    }
    
    .dropdown-menu {
        position: absolute;
        top: calc(100% + 5px);
        right: 0;
        left: auto;
        width: 160px;
        z-index: 10000;
        border: 2px solid rgba(194, 139, 55, 0.8);
        background: rgba(20, 11, 46, 0.98);
        backdrop-filter: blur(20px);
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
        transform-origin: top right;
        max-height: 80vh;
        overflow-y: auto;
    }
    
    .dropdown-item {
        padding: 10px 15px;
        font-size: 0.9rem;
        border-bottom: 1px solid rgba(194, 139, 55, 0.1);
        white-space: nowrap;
    }
    
    .dropdown-item:last-child {
        border-bottom: none;
    }
    
    .dropdown-item i {
        width: 14px;
        margin-right: 6px;
    }
    
    .dropdown-item.logout-item {
        border-top: 2px solid rgba(194, 139, 55, 0.3);
        margin-top: 5px;
        padding-top: 12px;
    }
    
    .input-container {
        flex-direction: column;
        gap: 10px;
    }
    
    .submit-btn {
        width: 100%;
    }
    
    .message {
        margin-bottom: 15px;
    }
    
    .message-avatar {
        width: 32px;
        height: 32px;
        margin-right: 10px;
    }
    
    .message-text {
        padding: 12px;
    }
    
    .lab-footer {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .nav-bar {
        padding: 10px 15px;
    }
    
    .logo-text {
        font-size: 1.5rem;
    }
    
    .lab-container {
        padding: 10px;
    }
    
    .conversation-header {
        padding: 10px 15px;
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .conversation-header h2 {
        font-size: 1.1rem;
    }
    
    .user-info {
        flex-wrap: wrap;
        gap: 8px;
        margin-right: 0;
    }
    
    .user-level, .user-exp {
        font-size: 0.75rem;
        padding: 3px 8px;
    }
    
    .reset-btn {
        padding: 6px 12px;
        font-size: 0.75rem;
    }
    
    .conversation-scroll {
        padding: 10px;
    }
    
    /* 超小屏幕下拉菜单进一步优化 */
    .dropdown-menu {
        width: 140px;
        right: 0;
        top: calc(100% + 3px);
        padding: 6px 0;
    }
    
    .dropdown-item {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
    
    .dropdown-item i {
        width: 12px;
        margin-right: 4px;
        font-size: 0.75rem;
    }
    
    .modal-container {
        padding: 15px;
        width: 95%;
    }
    
    .modal-title {
        font-size: 1.3rem;
    }
}