/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    height: 100%;
    color: #333;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    box-sizing: border-box;
}

html {
    margin: 0;
    padding: 0;
    height: 100%;
    box-sizing: border-box;
}

/* Header Styles */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-icon {
    color: #6366f1;
    font-size: 1.5rem;
}

.header-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #1f2937;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    transition: background-color 0.3s;
}

.header-right:hover {
    background-color: rgba(99, 102, 241, 0.1);
}

.clear-icon {
    color: #6b7280;
    font-size: 1rem;
}

.clear-text {
    color: #6b7280;
    font-size: 0.9rem;
}

/* Main Content Layout */
.main-content {
    display: flex;
    gap: 1.5rem;
    padding: 1.5rem 2rem;
    max-width: 1400px;
    margin: 0 auto;
    min-height: calc(100vh - 120px);
}

/* Sidebar Styles */
.sidebar {
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    flex-shrink: 0;
}

.card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 1rem;
}

.question-list {
    list-style: none;
}

.question-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.3s;
    margin-bottom: 0.5rem;
}

.question-item:hover {
    background: rgba(99, 102, 241, 0.1);
    transform: translateX(4px);
}

.question-icon {
    color: #6366f1;
    font-size: 0.9rem;
    width: 16px;
}

.question-item span {
    font-size: 0.9rem;
    color: #4b5563;
}

.advisor-description {
    font-size: 0.9rem;
    line-height: 1.6;
    color: #6b7280;
}

/* Policy Notice Card Styles */
.policy-notice-card .card-title {
    color: #1f2937;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.notice-icon {
    color: #6366f1;
    font-size: 1rem;
}

.policy-notice-text {
    font-size: 0.9rem;
    line-height: 1.6;
    color: #6b7280;
}

/* Chat Window Styles */
.chat-window {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 1rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    overflow: hidden;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.5rem;
    border-bottom: 1px solid rgba(229, 231, 235, 0.8);
}

.chat-icon {
    color: #6366f1;
    font-size: 1.2rem;
}

.chat-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1f2937;
}

.chat-messages {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 400px;
    max-height: 500px;
}

.message {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.user-message {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.advisor-message .message-avatar {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
}

.user-message .message-avatar {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

.message-bubble {
    max-width: 70%;
    padding: 1rem 1.25rem;
    border-radius: 1.25rem;
    font-size: 0.95rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.advisor-message .message-bubble {
    background: linear-gradient(135deg, #f3f4f6, #e5e7eb);
    color: #374151;
    border-bottom-left-radius: 0.5rem;
}

.user-message .message-bubble {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border-bottom-right-radius: 0.5rem;
}

.chat-input-container {
    padding: 1.5rem;
    border-top: 1px solid rgba(229, 231, 235, 0.8);
    display: flex;
    gap: 1rem;
    align-items: center;
}

.chat-input {
    flex: 1;
    padding: 1rem 1.25rem;
    border: 2px solid #e5e7eb;
    border-radius: 2rem;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.3s;
    background: #f9fafb;
}

.chat-input:focus {
    border-color: #6366f1;
    background: white;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.send-button {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.3s;
}

.send-button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.chat-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: #f3f4f6;
}

.input-hint {
    text-align: center;
    font-size: 0.8rem;
    color: #9ca3af;
    margin-top: 0.5rem;
}

/* Footer */
.footer {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem 2rem;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
}

/* Loading Animation */
.loading {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.loading-dots {
    display: flex;
    gap: 0.25rem;
}

.loading-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #6b7280;
    animation: loading 1.4s infinite ease-in-out both;
}

.loading-dot:nth-child(1) { animation-delay: -0.32s; }
.loading-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes loading {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
        padding: 1rem;
        gap: 1rem;
    }
    
    .sidebar {
        width: 100%;
    }
    
    .header {
        padding: 1rem;
    }
    
    .chat-messages {
        max-height: 300px;
    }
    
    .message-bubble {
        max-width: 85%;
    }
    
    .footer {
        text-align: center;
        padding: 1rem;
    }
}

/* Markdown Styles */
.message-bubble h1,
.message-bubble h2,
.message-bubble h3,
.message-bubble h4,
.message-bubble h5,
.message-bubble h6 {
    margin: 0.5em 0 0.3em 0;
    font-weight: 600;
    line-height: 1.3;
}

.message-bubble h1 { font-size: 1.3em; }
.message-bubble h2 { font-size: 1.2em; }
.message-bubble h3 { font-size: 1.1em; }
.message-bubble h4 { font-size: 1.05em; }
.message-bubble h5 { font-size: 1em; }
.message-bubble h6 { font-size: 0.95em; }

.message-bubble p {
    margin: 0.5em 0;
    line-height: 1.5;
}

.message-bubble ul,
.message-bubble ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.message-bubble li {
    margin: 0.2em 0;
    line-height: 1.4;
}

.message-bubble blockquote {
    margin: 0.5em 0;
    padding: 0.5em 1em;
    border-left: 3px solid #6366f1;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 0 4px 4px 0;
    font-style: italic;
}

.message-bubble code {
    background: rgba(0, 0, 0, 0.1);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.message-bubble pre {
    background: rgba(0, 0, 0, 0.1);
    padding: 0.8em;
    border-radius: 6px;
    overflow-x: auto;
    margin: 0.5em 0;
}

.message-bubble pre code {
    background: none;
    padding: 0;
    border-radius: 0;
}

.message-bubble strong {
    font-weight: 600;
}

.message-bubble em {
    font-style: italic;
}

.message-bubble a {
    color: #6366f1;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-bottom-color 0.3s;
}

.message-bubble a:hover {
    border-bottom-color: #6366f1;
}

.message-bubble table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.5em 0;
}

.message-bubble th,
.message-bubble td {
    border: 1px solid rgba(0, 0, 0, 0.2);
    padding: 0.5em;
    text-align: left;
}

.message-bubble th {
    background: rgba(99, 102, 241, 0.1);
    font-weight: 600;
}

.message-bubble hr {
    border: none;
    border-top: 1px solid rgba(0, 0, 0, 0.2);
    margin: 1em 0;
}

/* 用户消息中的Markdown样式（较淡） */
.user-message .message-bubble h1,
.user-message .message-bubble h2,
.user-message .message-bubble h3,
.user-message .message-bubble h4,
.user-message .message-bubble h5,
.user-message .message-bubble h6 {
    color: rgba(255, 255, 255, 0.9);
}

.user-message .message-bubble blockquote {
    border-left-color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.1);
}

.user-message .message-bubble code {
    background: rgba(255, 255, 255, 0.2);
}

.user-message .message-bubble pre {
    background: rgba(255, 255, 255, 0.2);
}

.user-message .message-bubble a {
    color: rgba(255, 255, 255, 0.9);
}

.user-message .message-bubble a:hover {
    border-bottom-color: rgba(255, 255, 255, 0.9);
}

.user-message .message-bubble th {
    background: rgba(255, 255, 255, 0.1);
}

.user-message .message-bubble th,
.user-message .message-bubble td {
    border-color: rgba(255, 255, 255, 0.3);
}

.user-message .message-bubble hr {
    border-top-color: rgba(255, 255, 255, 0.3);
}

/* Streaming Message Styles */
.streaming-message .message-bubble {
    position: relative;
}

.streaming-cursor {
    color: #6366f1;
    font-weight: bold;
    animation: blink 1s infinite;
    margin-left: 2px;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.streaming-content {
    display: inline;
}

/* Scrollbar Styles */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Utility Classes */
.hidden {
    display: none !important;
}
