/* Import Fonts */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Titillium+Web:wght@400;600;700&display=swap');

/* Root Variables (Consistent with other pages) */
:root {
    /* Use common navbar height variables or define page-specific if needed */
    --navbar-height: var(--cn-actual-height, 79px); /* Default to desktop common navbar height */
    --navbar-height-mobile: var(--cn-actual-height-mobile, 60px); /* Default to mobile common navbar height */

    --cs-font-ui: 'Titillium Web', sans-serif;
    --cs-font-body: 'Poppins', sans-serif;
    --bg-light: #fefaf5;
    --bg-white: #ffffff;
    --primary-yellow: #ffd77b;
    --secondary-yellow: #ffe4a1;
    --accent-orange: #ffdd99; /* Keep for consistency if used elsewhere */
    --text-dark: #333;
    --text-light-dark: #555; /* Renamed from --text-darker for clarity */
    --text-medium: #777;
    --shadow-soft: 0 6px 12px rgba(0, 0, 0, 0.08);
    --shadow-medium: 0 8px 16px rgba(0, 0, 0, 0.1);
    --border-light: #eee;
    --ai-blue: #4a90e2; 
    --user-blue: #dcf8c6; 
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--cs-font-body);
    background-color: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh; /* Ensure body takes at least full viewport height */
    padding-top: var(--navbar-height); /* Offset for the fixed common navbar */
}

/* Main Content Area */
.ai-container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
    flex-grow: 1; /* Makes main content take available space */
    width: 100%;
}

/* Hero Section */
.hero-section {
    position: relative;
    padding: 4rem 2rem;
    background: url('/AIAssistant/Background.png') no-repeat center center/cover;
    border-radius: 12px;
    text-align: center;
    color: var(--bg-white);
    overflow: hidden;
    margin-bottom: 2rem;
    height: 500px;
}


.hero-content {
    position: relative;
    z-index: 2;
}

.hero-content h2 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.4);
}

.hero-content p {
    font-size: 1.1rem;
    /* margin-bottom: 1.5rem; */ /* 原有，可以保持或调整 */
    margin-bottom: 1rem; /* 稍微减少一点，为按钮留出空间，或者在按钮上加 margin-top */
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.4);
}

/*  Hero Start Button  */
.hero-start-button {
    background-color: var(--primary-yellow); /* 使用变量中的黄色 */
    color: var(--text-dark);
    border: none;
    padding: 0.8rem 1.8rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 30px; /* 圆角 */
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    display: inline-flex; /* 使图标和文字在同一行且居中 */
    align-items: center;
    gap: 0.5rem; /* 图标和文字的间距 */
    margin-top: 9.5rem; /* 和上方段落的间距，根据实际效果调整 */
}

.hero-start-button:hover {
    background-color: var(--secondary-yellow);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

.hero-start-button i {
    font-size: 0.9em; /* 图标大小调整 */
}


/* Chat Container Layout */
.chat-container {
    display: grid;
    grid-template-columns: 1fr 2fr; /* Default 1:2 ratio for left panel to chat panel */
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* 新增：当左侧面板隐藏时，聊天容器的样式 */
.chat-container.left-panel-hidden {
    display: flex; /* 改为 flex 布局，方便单个子元素居中 */
    justify-content: center; /* 水平居中 .right-panel */
    align-items: flex-start; /* 垂直方向顶部对齐 */
}

.chat-container.left-panel-hidden .left-panel {
    display: none; /* 确保左侧面板确实不显示 */
}

/* Left Panel (Examples & Plans) */
.left-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Examples Container */
.examples-container {
    background-color: var(--bg-white);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-light);
}

.examples-title {
    font-family: var(--cs-font-ui);
    font-size: 1.2rem;
    font-weight: 600;
    color: #b36d42; /* JomKL orange */
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.example-prompt {
    background-color: #f8f8f8;
    border: 1px solid #e0e0e0;
    border-left: 4px solid var(--primary-yellow);
    border-radius: 6px;
    padding: 0.8rem 1rem;
    margin-bottom: 0.8rem;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.example-prompt:last-child {
    margin-bottom: 0;
}

.example-prompt:hover {
    background-color: #f0f8ff;
    border-left-color: var(--ai-blue);
    transform: translateY(-2px);
    box-shadow: var(--shadow-soft);
}

/* Plans Container */
.plans-container {
    background-color: var(--bg-white);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.plans-header h3 {
    font-family: var(--cs-font-ui);
    font-size: 1.2rem;
    color: #b36d42; /* JomKL orange */
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.plans-header p {
    color: var(--text-medium);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.loading {
    text-align: center;
    padding: 1rem;
    font-size: 1rem;
    color: var(--text-medium);
}

.loading i {
    margin-right: 0.5rem;
    color: var(--primary-yellow);
    animation: spin 1s infinite linear;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.plan-cards-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 0.5rem;
}



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

/* Plan Card Styling */
.plan-card {
    background: #fffdf8;
    border: 1px solid var(--border-light);
    border-left: 5px solid var(--primary-yellow);
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.plan-card:hover {
    box-shadow: var(--shadow-medium);
    transform: translateY(-3px);
}

.plan-card h4 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
}

.plan-details {
    font-size: 0.85rem;
    color: var(--text-medium);
    margin-bottom: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
}

.plan-details span {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: #f4f4f4;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.plan-details i {
    color: #b36d42;
}

.plan-actions {
    display: flex;
    justify-content: flex-end;
}

.plan-actions button {
    background: var(--ai-blue);
    color: white;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.plan-actions button:hover {
    background: #3a7bc8;
}

/* Right Panel (Chat Interface) */
.right-panel {
    background-color: var(--bg-white);
    border-radius: 12px;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    height: 650px; /* Fixed height for chat */
    overflow: hidden;
}

/* Chat Header */
.chat-header {
    background-color: var(--primary-yellow);
    color: var(--text-dark);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-light);
}

.chat-header h3 {
    font-family: var(--cs-font-ui);
    font-size: 1.2rem;
    margin: 0;
}

.chat-status {
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #4CAF50;
}

/* Chat Messages Area */
.chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1.5rem;
    background-color: #f9f9f9;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Messages Styling */
.message {
    max-width: 85%;
}

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

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

.message-content {
    padding: 0.8rem 1rem;
    border-radius: 12px;
    position: relative;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.bot-message .message-content {
    background-color: var(--bg-white);
    border: 1px solid #e0e0e0;
}

.user-message .message-content {
    background-color: var(--user-blue);
    border-top-right-radius: 0; /* Shape */
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-medium);
    margin-top: 0.3rem;
    display: block;
}

.bot-message .message-time {
    text-align: left;
    margin-left: 0.5rem;
}

.user-message .message-time {
    text-align: right;
    margin-right: 0.5rem;
}

/* Markdown Content Styling */
.markdown-content {
    line-height: 1.6;
    color: var(--text-dark);
}

.markdown-content h1 {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    font-weight: 700;
    font-size: 1.8rem;
    color: #b36d42;
}

.markdown-content h2 {
    margin-top: 1.2rem;
    margin-bottom: 0.8rem;
    font-weight: 700;
    font-size: 1.5rem;
    color: #b36d42;
    border-bottom: 2px solid var(--primary-yellow);
    padding-bottom: 0.3rem;
    display: inline-block;
}

.markdown-content h3 {
    margin-top: 1rem;
    margin-bottom: 0.6rem;
    font-weight: 600;
    font-size: 1.2rem;
    color: #b36d42;
}

.markdown-content ul, 
.markdown-content ol {
    margin-left: 1.5rem;
    margin-bottom: 1.2rem;
    padding-left: 0.5rem;
}

.markdown-content li {
    margin-bottom: 0.5rem;
    position: relative;
}

.markdown-content ul li::marker {
    color: var(--primary-yellow);
}

.markdown-content p {
    margin-bottom: 1rem;
}

.markdown-content strong,
.markdown-content b {
    font-weight: 700;
    color: #333;
}

.markdown-content a {
    color: var(--ai-blue);
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px dotted var(--ai-blue);
    transition: all 0.2s ease;
}

.markdown-content a:hover {
    text-decoration: none;
    background-color: rgba(74, 144, 226, 0.1);
}

.markdown-content img {
    max-width: 100%;
    border-radius: 6px;
    margin: 0.8rem 0;
    border: 1px solid #eee;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* Typing Indicator */
.typing-indicator {
    display: none;
    align-self: flex-start;
    margin-bottom: 1rem;
}

.typing-indicator .message-content {
    background-color: #f1f0f0;
    padding: 0.8rem 1rem;
    display: flex;
    align-items: center;
}

.typing-indicator .dot {
    width: 8px;
    height: 8px;
    background-color: #999;
    border-radius: 50%;
    margin-right: 4px;
    animation: bounce 1s infinite;
}

.typing-indicator .dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator .dot:nth-child(3) {
    animation-delay: 0.4s;
    margin-right: 0;
}

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

/* Chat Input Area */
.chat-input-area {
    display: flex;
    padding: 1rem;
    background-color: var(--bg-white);
    border-top: 1px solid var(--border-light);
    gap: 0.5rem;
}

#message-input {
    flex-grow: 1;
    padding: 0.8rem 1rem;
    border: 1px solid #ddd;
    border-radius: 30px;
    font-size: 1rem;
    font-family: var(--cs-font-body);
    outline: none;
    transition: border-color 0.2s;
}

#message-input:focus {
    border-color: var(--primary-yellow);
}

#send-button {
    background: var(--primary-yellow);
    color: var(--text-dark);
    border: none;
    border-radius: 30px;
    padding: 0 1.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

#send-button:hover {
    background: var(--secondary-yellow);
    transform: translateY(-2px);
    box-shadow: 0 3px 5px rgba(0,0,0,0.1);
}

#end-chat-button {
    background: #ff6b6b;
    color: white;
    border: none;
    border-radius: 30px;
    padding: 0 1.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

#end-chat-button:hover {
    background: #ff5252;
    transform: translateY(-2px);
    box-shadow: 0 3px 5px rgba(0,0,0,0.1);
}

/* System Messages */
.system-message {
    text-align: center;
    margin: 1rem 0;
    color: var(--text-medium);
}

.system-message span {
    background-color: #f0f0f0;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
}

.error-message {
    text-align: center;
    margin: 1rem 0;
    color: #c62828;
}

.error-message span {
    background-color: #ffebee;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
}

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

/* Responsive Adjustments */
@media (max-width: 992px) {
    .chat-container {
        grid-template-columns: 1fr; /* Stack in mobile */
        gap: 1rem;
    }
    
    .right-panel {
        height: 500px; /* Reduce height on mobile */
    }
    
    .hero-section {
        padding: 3rem 1rem;
    }
    
    .hero-content h2 {
        font-size: 2rem;
    }
    
    .hero-content p {
        font-size: 1rem;
    }
}

@media (max-width: 768px) {
    .chat-header h3 {
        font-size: 1.1rem;
    }
    
    .message {
        max-width: 90%;
    }
    
    #message-input {
        padding: 0.7rem 0.8rem;
        font-size: 0.95rem;
    }
    
    #send-button, #end-chat-button {
        padding: 0 1rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 576px) {
    .ai-container {
        margin: 1rem auto;
        padding: 0 0.5rem;
    }
    
    .hero-section {
        padding: 2rem 1rem;
        margin-bottom: 1rem;
    }
    
    .hero-content h2 {
        font-size: 1.6rem;
    }
    
    .examples-container, .plans-container, .right-panel {
        padding: 1rem;
    }
    
    .chat-messages {
        padding: 1rem;
    }
    
    .chat-input-area {
        padding: 0.8rem;
    }
    
    #end-chat-button {
        display: none; /* Hide end chat on very small screens */
    }
}

