/* 导入字体 */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

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

/* 全局动画变量 */
:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --glass-bg: rgba(255, 255, 255, 0.9);
    --glass-border: rgba(255, 255, 255, 0.2);
    --shadow-light: 0 8px 32px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 12px 40px rgba(102, 126, 234, 0.15);
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-attachment: fixed;
    color: #1a202c;
    line-height: 1.6;
}

/* 新增：左侧菜单栏布局 */
.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 280px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    flex-direction: column;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.sidebar-header {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
    display: flex;
    justify-content: flex-start;
    min-height: 64px;
    align-items: center;
}

.sidebar-title {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    letter-spacing: -0.5px;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    margin: 4px 12px;
    color: #64748b;
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    background: none;
    width: calc(100% - 24px);
    text-align: left;
    cursor: pointer;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
}

.nav-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.8);
    color: #334155;
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.nav-item:hover::before {
    opacity: 1;
}

.nav-item.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.nav-item.active::before {
    opacity: 0;
}

.nav-item .icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.nav-item .text {
    font-size: 14px;
    font-weight: 500;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid #e5e7eb;
}

/* 移动端侧边栏底部适配 - 应用到所有页面 */
@media (max-width: 768px) {
    .sidebar-footer,
    .app-layout .sidebar-footer,
    .sidebar .sidebar-footer {
        padding-bottom: calc(20px + env(safe-area-inset-bottom, 20px)) !important;
        margin-bottom: env(safe-area-inset-bottom, 0px);
        /* 确保在有导航栏的设备上也有足够的间距 */
        min-height: 80px;
        box-sizing: border-box;
    }
    
    /* 针对可能有虚拟导航栏的Android设备 */
    @supports not (padding: max(0px)) {
        .sidebar-footer,
        .app-layout .sidebar-footer,
        .sidebar .sidebar-footer {
            padding-bottom: 60px !important; /* 为没有安全区域支持的设备提供固定间距 */
        }
    }
    
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: visible;
    background: #ffffff;
    border-radius: 0;
    margin-left: 0;
    padding: 20px;
    box-shadow: none;
    border-left: 1px solid #e8eaed;
}

.top-bar {
    height: 60px;
    background: transparent;
    border-bottom: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    border-radius: 0;
    overflow: visible;
    position: relative;
    z-index: 100;
}

.top-bar .left-section {
    display: flex;
    align-items: center;
    gap: 15px;
}

.top-bar .right-section {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* 顶部栏认证按钮样式 */
.topbar-auth-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.topbar-login-btn {
    background: #667eea;
    color: white;
}

.topbar-login-btn:hover {
    background: #5a6fd8;
    transform: translateY(-1px);
}

.topbar-register-btn {
    background: #10b981;
    color: white;
}

.topbar-register-btn:hover {
    background: #059669;
    transform: translateY(-1px);
}

.mobile-menu-btn {
    display: none;
    width: 38px; /* 与mobile-menu-float保持一致 */
    height: 26px; /* 与其他按钮高度保持一致 */
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 6px; /* 与其他按钮圆角保持一致 */
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px; /* 调整字体大小 */
    color: #6b7280;
    box-sizing: border-box;
}

/* 移动端显示浮动菜单按钮 */
.mobile-menu-float {
    position: fixed;
    top: calc(12px + env(safe-area-inset-top, 12px)); /* 与移动端模型选择器对齐 */
    left: 20px;
    width: 38px; /* 调整宽度以匹配按钮高度 */
    height: 26px; /* 与登录按钮高度对齐 */
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(229, 231, 235, 0.3);
    border-radius: 6px; /* 与其他按钮保持一致的圆角 */
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px; /* 调整字体大小 */
    color: #667eea;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    z-index: 1001;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.mobile-menu-float:hover {
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 8px 30px rgba(102, 126, 234, 0.2);
    transform: translateY(-2px);
}

/* 当侧边栏打开时隐藏汉堡菜单按钮 */
.mobile-menu-float.hidden {
    opacity: 0;
    visibility: hidden;
    transform: translateX(-20px);
}

/* 移除多余的容器样式，直接使用main-content布局 */

/* 隐藏原来的顶部菜单 */
.upMenu {
    display: none !important;
}

#welcome p {
    font-size: 1.2rem;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.otherUrl {
    display: flex;
    gap: 20px;
    align-items: center;
}

.otherUrl a {
    text-decoration: none;
    color: #667eea;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 8px;
    transition: all 0.3s ease;
    background: rgba(102, 126, 234, 0.1);
}

.otherUrl a:hover {
    background: rgba(102, 126, 234, 0.2);
    transform: translateY(-2px);
}

.login-section {
    position: relative;
}

/* 历史记录区域 - ChatGPT风格简洁设计 */
#history {
    flex: 1;
    background: transparent;
    padding: 16px 0;
    overflow-y: auto;
    border: none;
    margin: 0 0 16px 0;
    border-radius: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
    min-height: 0;
}

#history::-webkit-scrollbar {
    width: 4px;
}

#history::-webkit-scrollbar-track {
    background: transparent;
}

#history::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
}

#history::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* 输入区域 - 优化布局 */
.input-section {
    flex-shrink: 0;
    background: transparent;
    border-top: none;
}

#prompt {
    width: 100%;
    padding: 16px 20px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    font-size: 16px;
    font-family: inherit;
    resize: none;
    transition: all 0.2s ease;
    background: #ffffff;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    color: #1a202c;
    line-height: 1.5;
}

#prompt:focus {
    outline: none;
    border-color: #4285f4;
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(66, 133, 244, 0.15);
}

#prompt::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

/* 控制器样式 - 简化设计 */
.controls {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
}

.select-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.select-group label {
    font-weight: 500;
    color: #333;
    white-space: nowrap;
}

/* 统一精致按钮样式 */
.btn, button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.3);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    position: relative;
    overflow: hidden;
    letter-spacing: 0.5px;
}

.btn::before, button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.btn:hover, button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(102, 126, 234, 0.4);
}

.btn:hover::before, button:hover::before {
    left: 100%;
}

.btn:active, button:active {
    transform: translateY(0);
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.3);
}

.btn:disabled, button:disabled {
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
    color: #94a3b8;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* 按钮变体 */
.btn-secondary {
    background: rgba(255, 255, 255, 0.9);
    color: #475569;
    border: 1px solid rgba(148, 163, 184, 0.3);
    box-shadow: 0 4px 20px rgba(148, 163, 184, 0.2);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 1);
    border-color: rgba(102, 126, 234, 0.3);
    color: #334155;
    box-shadow: 0 8px 30px rgba(148, 163, 184, 0.3);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    box-shadow: 0 8px 30px rgba(239, 68, 68, 0.4);
}

.btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
    box-shadow: 0 8px 30px rgba(16, 185, 129, 0.4);
}

/* 选择框样式 */
select {
    padding: 12px 16px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    margin: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 150px;
    color: #334155;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}

select:focus {
    outline: none;
    border-color: rgba(102, 126, 234, 0.5);
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 8px 30px rgba(102, 126, 234, 0.15);
    transform: translateY(-1px);
}

/* 聊天消息样式 */
.user-input, .chatgpt-output {
    margin-bottom: 20px;
    padding: 20px;
    border-radius: 20px;
    color: #1a202c;
    position: relative;
    animation: messageSlide 0.5s ease-out;
}

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

.user-input {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin-left: 15%;
    box-shadow: 0 8px 30px rgba(102, 126, 234, 0.3);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.user-input::before {
    content: '';
    position: absolute;
    top: 15px;
    right: -10px;
    width: 0;
    height: 0;
    border: 10px solid transparent;
    border-left-color: #764ba2;
}

.chatgpt-output {
    margin-right: 15%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.chatgpt-output::before {
    content: '';
    position: absolute;
    top: 15px;
    left: -10px;
    width: 0;
    height: 0;
    border: 10px solid transparent;
    border-right-color: rgba(255, 255, 255, 0.9);
}

.chatgpt-processing {
    background: rgba(148, 163, 184, 0.1);
    color: #64748b;
    font-style: italic;
    border: 1px solid rgba(148, 163, 184, 0.2);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .app-layout {
        flex-direction: column;
        height: 100vh;
    }
    
    .main-content {
        padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 20px)) 12px;
        border-radius: 0;
        margin-left: 0;
        width: 100%;
        flex: 1;
        min-height: 0;
        border-left: none;
        background: #ffffff;
    }
    
    .top-bar {
        border-radius: 0;
        position: static;
        top: 0;
        z-index: 200;
        display: flex;
        height: 50px;
        padding: 0 15px;
    }
    
    #history {
        padding: 12px 0;
    }
    
    #prompt {
        padding: 14px 16px;
        font-size: 16px;
    }
    
    .upMenu {
        padding: 15px 20px;
        flex-wrap: wrap;
        gap: 10px;
    }
    
    #welcome p {
        font-size: 1rem;
    }
    
    .otherUrl {
        gap: 10px;
    }
    
    .otherUrl a {
        padding: 6px 12px;
        font-size: 14px;
    }
    
    .input-section {
        padding: 15px 20px;
        padding-bottom: calc(25px + env(safe-area-inset-bottom, 30px));
        margin-bottom: env(safe-area-inset-bottom, 10px);
    }
    
    #prompt {
        padding: 12px;
        font-size: 16px;
    }
    
    .controls {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        flex-wrap: wrap;
    }
    
    .select-group {
        flex-direction: row;
        align-items: center;
        gap: 8px;
        flex: 1;
        min-width: 0;
    }
    
    .select-group label {
        text-align: left;
        white-space: nowrap;
        font-size: 13px;
    }
    
    select {
        min-width: auto;
        width: 100%;
        flex: 1;
        min-width: 100px;
    }
    
    button {
        padding: 12px 24px;
        font-size: 14px;
        min-height: 48px;
        white-space: nowrap;
        flex-shrink: 0;
    }
    
    .user-input, .chatgpt-output {
        margin-left: 10%;
        margin-right: 10%;
        padding: 12px;
    }
}

@media (max-width: 480px) {
    .app-layout {
        height: 100vh;
        height: calc(var(--vh, 1vh) * 100);
    }
    
    .main-content {
        padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 20px)) 8px;
    }
    
    .top-bar {
        padding: 0 12px;
        height: 45px;
        min-height: 45px;
        display: flex;
    }
    
    .topbar-auth-btn {
        padding: 6px 12px;
        font-size: 13px;
    }
    
    .top-bar .left-section span {
        display: none;
    }
    
    .controls {
        flex-direction: column;
        gap: 12px;
    }
    
    .select-group {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }
    
    button {
        width: 100%;
        padding: 14px 20px;
        font-size: 16px;
    }
    
    #history {
        padding: 8px 0;
    }
    
    .user-input, .chatgpt-output {
        margin-left: 2%;
        margin-right: 2%;
        padding: 16px;
        font-size: 15px;
        line-height: 1.6;
    }
    
    .otherUrl {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .otherUrl a {
        font-size: 13px;
        padding: 8px 12px;
    }
    
    /* 小屏幕设备侧边栏底部额外适配 */
    .sidebar-footer,
    .app-layout .sidebar-footer,
    .sidebar .sidebar-footer {
        padding-bottom: calc(30px + env(safe-area-inset-bottom, 30px)) !important;
        min-height: 90px !important;
    }
}

/* 平板设备优化 */
@media (min-width: 769px) and (max-width: 1024px) {
    .chat-container {
        width: 98%;
        max-width: 900px;
    }
    
    .upMenu {
        padding: 20px 25px;
    }
    
    .input-section {
        padding: 20px 25px;
        padding-bottom: calc(30px + env(safe-area-inset-bottom, 35px));
        margin-bottom: env(safe-area-inset-bottom, 15px);
    }
}

/* 用户弹窗样式 */
#popup {
    position: fixed;
    bottom: 80px;
    left: 20px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    padding: 20px;
    min-width: 200px;
    z-index: 10000;
    display: none;
}

/* 响应式设计 - 移动端 */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        height: calc(var(--vh, 1vh) * 100);
        z-index: 1000;
        transform: translateX(-100%);
        box-sizing: border-box;
        /* 确保整个侧边栏有足够的底部空间 */
        padding-bottom: calc(env(safe-area-inset-bottom, 10px) + 10px);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .mobile-menu-float {
        display: flex;
    }
    
    /* 小屏幕设备特殊处理 */
    @media (max-width: 480px) {
        .mobile-menu-float {
            top: calc(10px + env(safe-area-inset-top, 10px)); /* 与小屏幕模型选择器对齐 */
            left: 15px;
            width: 36px; /* 调整小屏幕宽度 */
            height: 26px; /* 与其他按钮高度保持一致 */
            font-size: 14px; /* 调整小屏幕字体大小 */
        }
    }
    
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }
    
    .sidebar-overlay.show {
        opacity: 1;
        visibility: visible;
    }
    
    #popup {
        left: 10px;
        bottom: calc(80px + env(safe-area-inset-bottom, 20px));
        min-width: 180px;
    }
    
    /* iOS设备用户弹窗特殊处理 */
    @supports (-webkit-touch-callout: none) {
        #popup {
            bottom: calc(90px + env(safe-area-inset-bottom, 25px)) !important;
        }
    }
    
    /* 横屏模式下的特殊处理 */
    @media screen and (max-width: 768px) and (orientation: landscape) {
        #popup {
            bottom: calc(60px + env(safe-area-inset-bottom, 15px));
            max-height: 40vh;
            overflow-y: auto;
        }
    }
}

