@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Lora:wght@700&family=Noto+Sans+SC:wght@300;400;500;600;700&display=swap');

:root {
    /* 现代化配色方案 */
    --bg-color: linear-gradient(135deg, #e7edf0 0%, #b6ccd8 100%);
    --sidebar-bg-color: rgba(255, 255, 255, 0.95);
    --chat-input-bg: rgba(255, 255, 255, 0.9);
    --active-nav-bg: linear-gradient(135deg, #e7edf0 0%, #b6ccd8 100%);
    --text-color: #2d3748;
    --text-color-light: #718096;
    --text-color-dark: #4a5568;
    --accent-color: linear-gradient(135deg, #e7edf0 0%, #b6ccd8 100%);
    --border-color: rgba(226, 232, 240, 0.8);
    --assistant-message-bg: rgba(255, 255, 255, 0.8);
    --user-message-bg: linear-gradient(135deg, #e7edf0 0%, #b6ccd8 100%);
    --shadow-light: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 10px 25px rgba(0, 0, 0, 0.15);
    --shadow-heavy: 0 20px 40px rgba(0, 0, 0, 0.2);
    --border-radius: 16px;
    --border-radius-small: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Noto Sans SC', sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    display: flex;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-color);
    z-index: -1;
}

.container {
    display: flex;
    width: 100%;
    height: 100%;
    backdrop-filter: blur(10px);
}

/* --- Sidebar --- */
.sidebar {
    width: 280px;
    background: var(--sidebar-bg-color);
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-medium);
    position: relative;
    z-index: 10;
}

.sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--sidebar-bg-color);
    z-index: -1;
}

.logo {
    margin-bottom: 50px;
    padding: 0 20px;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
}

.logo img {
    max-width: 220px;
    max-height: 100px;
    width: auto;
    height: auto;
    object-fit: contain;
    aspect-ratio: auto;
    display: block;
    margin: 0 auto;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1));
    transition: transform 0.3s ease;
}

.logo img:hover {
    transform: scale(1.2);
}

.sidebar nav ul {
    list-style: none;
}

.sidebar nav li {
    margin-bottom: 8px;
    width: 100%;
}

.sidebar nav ul {
    list-style: none;
    width: 100%;
}

.sidebar nav a {
    color: var(--text-color);
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    display: block;
    padding: 12px 18px;
    border-radius: var(--border-radius-small);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
}

.sidebar nav a::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: var(--active-nav-bg);
    transition: left 0.3s ease;
    z-index: -1;
}

.sidebar nav a i {
    margin-right: 15px;
    width: 20px;
    text-align: center;
    font-size: 16px;
    display: inline-block;
    vertical-align: middle;
}

.sidebar nav li.active a,
.sidebar nav a:hover {
    color: white;
    transform: translateX(3px);
    box-shadow: var(--shadow-light);
}

.sidebar nav li.active a::before,
.sidebar nav a:hover::before {
    left: 0;
}

.profile {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 0;
}

.profile img {
    max-width: 65px;
    max-height: 65px;
    width: 65px;
    height: 65px;
    object-fit: contain;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.8);
    box-shadow: var(--shadow-light);
    transition: all 0.3s ease;
    display: block;
    margin: 0 auto;
    background: #fff;
}

.profile img:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-medium);
}

/* --- Chat Area --- */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(5px);
}

.chat-history {
    flex: 1;
    padding: 80px 40px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: 600px;
}

.message {
    max-width: 75%;
    margin-bottom: 20px;
    display: flex;
    animation: messageSlideIn 0.3s ease-out;
}

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

.message p {
    background: var(--assistant-message-bg);
    padding: 18px 24px;
    border-radius: var(--border-radius);
    line-height: 1.6;
    white-space: pre-wrap;
    color: var(--text-color);
    box-shadow: var(--shadow-light);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    position: relative;
}

.message p::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--assistant-message-bg);
    border-radius: var(--border-radius);
    z-index: -1;
}

.message.user {
    align-self: flex-end;
}

.message.user p {
    background: var(--user-message-bg);
    color: var(--text-color);
    box-shadow: var(--shadow-medium);
    border: none;
}

.message.assistant {
    align-self: flex-start;
}

.message.typing-indicator p {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: typing 1.5s infinite;
}

@keyframes typing {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.chat-input-area {
    padding: 60px 40px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-color);
    position: relative;
}

.chat-input-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    z-index: -1;
}

.input-wrapper {
    max-width: 800px;
    margin: 0 auto;
    position: relative;
    background: var(--chat-input-bg);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    box-shadow: var(--shadow-medium);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    padding-left: 44px;
}

.input-wrapper:focus-within {
    box-shadow: var(--shadow-heavy);
    transform: translateY(-2px);
    border-color: rgba(102, 126, 234, 0.5);
}

#chat-input {
    flex: 1;
    height: auto;
    max-height: 300px;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-color);
    font-size: 16px;
    font-weight: 400;
    padding: 40px 80px 40px 24px;
    resize: none;
    overflow-y: auto;
    font-family: 'Inter', 'Noto Sans SC', sans-serif;
    line-height: 1.5;
}

#chat-input::placeholder {
    color: var(--text-color-light);
    font-weight: 400;
}

#send-btn {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 12px;
    width: 50px;
    height: 50px;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-light);
}

#send-btn:hover {
    transform: translateY(-50%) scale(1.05);
    box-shadow: var(--shadow-medium);
}

#send-btn:active {
    transform: translateY(-50%) scale(0.95);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 20px;
}

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

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #acd4f3 0%, #4b58a2 100%);
    border-radius: 3px;
    transition: all 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #acd4f3 0%, #4b58a2 100%);
    transform: scaleX(1.2);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: fixed;
        top: 0;
        left: -100%;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease;
    }
    
    .sidebar.active {
        left: 0;
    }
    
    .chat-area {
        margin-left: 0;
    }
    
    .chat-history {
        padding: 40px 20px;
        min-height: 400px;
    }
    
    .chat-input-area {
        padding: 40px 20px;
    }
    
    .message {
        max-width: 90%;
    }
}

/* 深色模式支持 */
:root {
    /* 浅色模式变量 */
    --bg-color: linear-gradient(135deg, #e7edf0 0%, #b6ccd8 100%);
    --sidebar-bg-color: rgba(255, 255, 255, 0.95);
    --chat-input-bg: rgba(255, 255, 255, 0.9);
    --active-nav-bg: linear-gradient(135deg, #e7edf0 0%, #b6ccd8 100%);
    --text-color: #2d3748;
    --text-color-light: #718096;
    --text-color-dark: #4a5568;
    --accent-color: linear-gradient(135deg, #e7edf0 0%, #b6ccd8 100%);
    --border-color: rgba(226, 232, 240, 0.8);
    --assistant-message-bg: rgba(255, 255, 255, 0.8);
    --user-message-bg: linear-gradient(135deg, #e7edf0 0%, #b6ccd8 100%);
    --shadow-light: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 10px 25px rgba(0, 0, 0, 0.15);
    --shadow-heavy: 0 20px 40px rgba(0, 0, 0, 0.2);
    --border-radius: 16px;
    --border-radius-small: 12px;
}

/* 深色模式变量 */
[data-theme="dark"] {
    --bg-color: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
    --sidebar-bg-color: rgba(26, 32, 44, 0.95);
    --chat-input-bg: rgba(26, 32, 44, 0.9);
    --active-nav-bg: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
    --text-color: #e2e8f0;
    --text-color-light: #a0aec0;
    --text-color-dark: #cbd5e0;
    --accent-color: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
    --border-color: rgba(74, 85, 104, 0.8);
    --assistant-message-bg: rgba(45, 55, 72, 0.8);
    --user-message-bg: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
    --shadow-light: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-medium: 0 10px 25px rgba(0, 0, 0, 0.4);
    --shadow-heavy: 0 20px 40px rgba(0, 0, 0, 0.5);
}

/* 深色模式下的背景装饰调整 */
[data-theme="dark"] .floating-shape {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
}

/* 深色模式下的滚动条 */
[data-theme="dark"] ::-webkit-scrollbar-track {
    background: rgba(45, 55, 72, 0.1);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
}

/* 深色模式下的工作空间卡片 */
[data-theme="dark"] .workspace-card {
    background: var(--sidebar-bg-color);
    border-color: var(--border-color);
}

[data-theme="dark"] .workspace-card:hover {
    border-color: rgba(102, 126, 234, 0.5);
}

/* 深色模式下的输入框 */
[data-theme="dark"] .input-wrapper {
    background: var(--chat-input-bg);
    border-color: var(--border-color);
}

[data-theme="dark"] .input-wrapper:focus-within {
    border-color: rgba(102, 126, 234, 0.5);
}

/* 深色模式下的消息 */
[data-theme="dark"] .message p {
    background: var(--assistant-message-bg);
    border-color: rgba(74, 85, 104, 0.3);
}

[data-theme="dark"] .message.user p {
    background: var(--user-message-bg);
}

/* 深色模式下的聊天区域 */
[data-theme="dark"] .chat-area {
    background: rgba(26, 32, 44, 0.1);
}

[data-theme="dark"] .chat-input-area {
    background: rgba(26, 32, 44, 0.1);
}

[data-theme="dark"] .chat-input-area::before {
    background: rgba(26, 32, 44, 0.1);
}

/* 深色模式下的工作空间内容 */
[data-theme="dark"] .workspaces-content {
    background: rgba(26, 32, 44, 0.1);
}

/* 背景装饰元素 */
.bg-decoration {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
    overflow: hidden;
}

.floating-shape {
    position: absolute;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    animation: float 20s infinite ease-in-out;
}

.shape-1 {
    width: 200px;
    height: 200px;
    top: 10%;
    left: 10%;
    animation-delay: 0s;
}

.shape-2 {
    width: 150px;
    height: 150px;
    top: 60%;
    right: 15%;
    animation-delay: -7s;
}

.shape-3 {
    width: 100px;
    height: 100px;
    bottom: 20%;
    left: 20%;
    animation-delay: -14s;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px) rotate(0deg);
        opacity: 0.3;
    }
    25% {
        transform: translateY(-20px) rotate(90deg);
        opacity: 0.6;
    }
    50% {
        transform: translateY(-40px) rotate(180deg);
        opacity: 0.4;
    }
    75% {
        transform: translateY(-20px) rotate(270deg);
        opacity: 0.7;
    }
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

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

/* 消息时间戳 */
.message-time {
    font-size: 12px;
    color: var(--text-color-light);
    margin-top: 5px;
    opacity: 0.7;
}

/* 消息状态指示器 */
.message-status {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-left: 8px;
}

.message-status.sent {
    background-color: #48bb78;
}

.message-status.delivered {
    background-color: #4299e1;
}

.message-status.read {
    background-color: #667eea;
}

.clear-session-btn {
    position: absolute;
    left: 12px;
    bottom: 12px;
    z-index: 2;
    background: transparent !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    width: 28px;
}

.clear-session-btn:focus, .clear-session-btn:active, .clear-session-btn:hover {
    background: transparent !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

.clear-session-btn img {
    width: 28px;
    height: 28px;
    display: block;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.clear-session-btn:hover img {
    opacity: 1;
}

/* 深色模式切换按钮 */
.theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    background: var(--sidebar-bg-color);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-light);
    z-index: 100;
    backdrop-filter: blur(10px);
}

.theme-toggle:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-medium);
}

.theme-toggle i {
    font-size: 20px;
    color: var(--text-color);
    transition: all 0.3s ease;
}

.theme-toggle:hover i {
    color: var(--text-color-dark);
}

/* 深色模式下的切换按钮 */
[data-theme="dark"] .theme-toggle {
    background: var(--sidebar-bg-color);
    border-color: var(--border-color);
}

[data-theme="dark"] .theme-toggle:hover {
    border-color: rgba(102, 126, 234, 0.5);
}

/* --- Workspaces Page Styles --- */
.workspaces-content {
    flex: 1;
    padding: 80px 40px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 40px;
}

.workspaces-header {
    text-align: center;
    margin-bottom: 40px;
}

.workspaces-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.workspaces-header p {
    font-size: 1.1rem;
    color: var(--text-color-light);
    font-weight: 400;
}

.workspaces-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
    max-width: 1200px;
    margin: 0 auto;
}

.workspace-card {
    background: var(--sidebar-bg-color);
    border-radius: var(--border-radius);
    padding: 40px 30px;
    text-align: center;
    box-shadow: var(--shadow-medium);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.workspace-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--sidebar-bg-color);
    border-radius: var(--border-radius);
    z-index: -1;
}

.workspace-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-heavy);
    border-color: rgba(102, 126, 234, 0.3);
}

.workspace-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 25px;
    background: var(--accent-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-light);
    transition: all 0.3s ease;
}

.workspace-card:hover .workspace-icon {
    transform: scale(1.1);
    box-shadow: var(--shadow-medium);
}

.workspace-icon i {
    font-size: 32px;
    color: white;
}

.workspace-card h3 {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 12px;
}

.workspace-card p {
    font-size: 0.95rem;
    color: var(--text-color-light);
    line-height: 1.5;
}

/* 响应式设计 - Workspaces */
@media (max-width: 768px) {
    .workspaces-content {
        padding: 40px 20px;
    }
    
    .workspaces-header h1 {
        font-size: 2rem;
    }
    
    .workspaces-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .workspace-card {
        padding: 30px 20px;
    }
    
    .workspace-icon {
        width: 60px;
        height: 60px;
    }
    
    .workspace-icon i {
        font-size: 24px;
    }
}

/* Webhook 管理样式 */
.webhook-section {
    margin-top: 20px;
    padding: 15px 0;
    border-top: 1px solid var(--border-color);
}

/* Webhook 下拉选择器样式 */
.webhook-selector {
    position: relative;
}

.current-webhook-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    border: 1px solid var(--border-color);
}

.current-webhook-display:hover {
    background: var(--active-nav-bg);
    transform: translateX(3px);
}

.current-webhook-display i {
    font-size: 12px;
    color: var(--text-color-light);
    transition: transform 0.3s ease;
}

.webhook-selector.open .current-webhook-display i {
    transform: rotate(180deg);
}

.webhook-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--sidebar-bg-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: var(--shadow-medium);
    backdrop-filter: blur(20px);
    z-index: 1000;
    max-height: 200px;
    overflow-y: auto;
    display: none;
    margin-top: 5px;
}

.webhook-selector.open .webhook-dropdown {
    display: block;
    animation: dropdownSlideIn 0.3s ease-out;
}

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

.webhook-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 1px solid var(--border-color);
}

.webhook-option:last-child {
    border-bottom: none;
}

.webhook-option:hover {
    background: var(--active-nav-bg);
}

.webhook-option.active {
    background: var(--accent-color);
    color: white;
}

.webhook-option-name {
    font-size: 13px;
    color: var(--text-color);
    font-weight: 500;
}

.webhook-option.active .webhook-option-name {
    color: white;
}

