/* ========== 环政智询管家 - 全局样式 ========== */
:root {
    --primary: #2e7d32;
    --primary-light: #4caf50;
    --primary-dark: #1b5e20;
    --sidebar-bg: #2d3e36;
    --sidebar-hover: #3d4f46;
    --sidebar-active: #2e7d32;
    --bg-main: #f5f7f6;
    --bg-card: #ffffff;
    --text-primary: #1a1a1a;
    --text-secondary: #5f6368;
    --text-muted: #9e9e9e;
    --border-color: #e0e0e0;
    --user-bubble: #e8f5e9;
    --user-bubble-border: #c8e6c9;
    --bot-bubble: #ffffff;
    --bot-bubble-border: #e0e0e0;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    display: flex;
}

/* ========== 左侧边栏 ========== */
.sidebar {
    width: 260px;
    min-width: 260px;
    background: var(--sidebar-bg);
    color: #fff;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: #fff;
}

.brand i { color: var(--primary-light); font-size: 1.3rem; }

.new-chat-btn {
    width: 100%;
    padding: 10px 16px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.new-chat-btn:hover { background: var(--primary-light); }

.role-section, .history-section {
    padding: 16px 12px;
}

.role-section h4, .history-section h4 {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.5);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
    padding-left: 8px;
}

.role-list { display: flex; flex-direction: column; gap: 4px; }

.role-item {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    color: rgba(255,255,255,0.85);
    transition: all 0.2s;
    border: 1px solid transparent;
}

.role-item:hover { background: var(--sidebar-hover); }

.role-item.active {
    background: rgba(46, 125, 50, 0.2);
    border-color: var(--primary);
    color: #fff;
}

.role-item i { width: 18px; text-align: center; color: rgba(255,255,255,0.6); }
.role-item.active i { color: var(--primary-light); }

.history-list { display: flex; flex-direction: column; gap: 4px; }

.history-item {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    color: rgba(255,255,255,0.7);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.2s;
}

.history-item:hover { background: var(--sidebar-hover); color: #fff; }

.history-empty {
    padding: 20px;
    text-align: center;
    color: rgba(255,255,255,0.4);
    font-size: 0.85rem;
}

/* ========== 主对话区 ========== */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* 欢迎头 */
.welcome-header {
    text-align: center;
    padding: 40px 20px 20px;
    animation: fadeInDown 0.5s ease;
}

.welcome-header h1 {
    font-size: 1.6rem;
    color: var(--primary-dark);
    margin-bottom: 8px;
}

.welcome-header .subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.welcome-header .desc {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* 消息列表 */
.messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 40px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: fadeInUp 0.3s ease;
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message.assistant {
    align-self: flex-start;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1rem;
}

.message.user .avatar {
    background: var(--primary);
    color: #fff;
}

.message.assistant .avatar {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--primary);
}

.bubble {
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    line-height: 1.6;
    font-size: 0.95rem;
    word-break: break-word;
}

.message.user .bubble {
    background: var(--user-bubble);
    border: 1px solid var(--user-bubble-border);
    border-bottom-right-radius: 4px;
}

.message.assistant .bubble {
    background: var(--bot-bubble);
    border: 1px solid var(--bot-bubble-border);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow);
}

/* 加载态 */
.message.loading .bubble {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 16px 20px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

/* ========== 推荐卡片 ========== */
.suggestion-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 0 40px 20px;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.suggestion-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: all 0.2s;
    box-shadow: var(--shadow);
}

.suggestion-card:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

.suggestion-card i {
    color: var(--primary);
    font-size: 1rem;
    flex-shrink: 0;
}

.suggestion-card span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ========== 输入区 ========== */
.input-area {
    padding: 16px 40px 20px;
    background: var(--bg-main);
}

.input-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 12px 16px;
    box-shadow: var(--shadow);
    transition: border-color 0.2s;
}

.input-box:focus-within {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(46,125,50,0.1);
}

.input-box textarea {
    width: 100%;
    border: none;
    outline: none;
    resize: none;
    font-size: 0.95rem;
    line-height: 1.5;
    min-height: 24px;
    max-height: 120px;
    font-family: inherit;
    color: var(--text-primary);
}

.input-box textarea::placeholder {
    color: var(--text-muted);
}

.input-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}

.quick-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.tag {
    padding: 4px 10px;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.tag:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.tag i { font-size: 0.75rem; }

.send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.send-btn:hover { background: var(--primary-light); }
.send-btn:disabled { background: var(--text-muted); cursor: not-allowed; }

.disclaimer {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 8px;
}

/* ========== 模块专用样式 ========== */

/* 检索结果卡片 */
.search-result-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-bottom: 10px;
    transition: all 0.2s;
}

.search-result-card:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow);
}

.search-result-card .title {
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: 6px;
    font-size: 0.95rem;
}

.search-result-card .meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    display: flex;
    gap: 12px;
}

.search-result-card .meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.search-result-card .url {
    font-size: 0.8rem;
    color: var(--primary);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.search-result-card .url:hover { text-decoration: underline; }

.search-stats {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

/* 政策卡片 */
.policy-card {
    background: var(--bg-card);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
}

.policy-card .title {
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.policy-card .summary {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    line-height: 1.5;
}

.policy-card .tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.policy-card .tag-badge {
    padding: 2px 8px;
    background: var(--bg-main);
    border-radius: 12px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.policy-card .url {
    font-size: 0.8rem;
    color: var(--primary);
    text-decoration: none;
}

/* 自查清单 */
.checklist-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
}

.checklist-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.checklist-header h3 {
    font-size: 1rem;
    color: var(--text-primary);
}

.checklist-progress {
    font-size: 0.85rem;
    color: var(--primary);
    font-weight: 600;
}

.checklist-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.checklist-item:last-child { border-bottom: none; }

.checklist-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    accent-color: var(--primary);
    cursor: pointer;
}

.checklist-item .content {
    flex: 1;
}

.checklist-item .content .title {
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.checklist-item .content .title.required::after {
    content: "*";
    color: #e53935;
    margin-left: 4px;
}

.checklist-item .content textarea {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    font-size: 0.85rem;
    resize: vertical;
    min-height: 40px;
    font-family: inherit;
}

.checklist-item .content textarea:focus {
    outline: none;
    border-color: var(--primary-light);
}

.checklist-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.btn {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover { background: var(--primary-light); }

.btn-secondary {
    background: var(--bg-main);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover { background: var(--border-color); }

/* 建议标签 */
.suggestion-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.suggestion-tag {
    padding: 4px 10px;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.suggestion-tag:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ========== 动画 ========== */
@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* ========== Toast ========== */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    color: #fff;
    z-index: 1000;
    font-size: 0.9rem;
    animation: fadeInDown 0.3s ease;
    box-shadow: var(--shadow-lg);
}

.toast-info { background: var(--primary); }
.toast-error { background: #e53935; }
.toast-success { background: var(--primary-light); }

/* ========== 加载遮罩 ========== */
.loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========== 滚动条 ========== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.25); }

/* ========== 响应式 ========== */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .messages { padding: 16px; }
    .input-area { padding: 12px 16px; }
    .suggestion-cards { grid-template-columns: 1fr; padding: 0 16px 16px; }
    .welcome-header h1 { font-size: 1.3rem; }
}


/* ========== 顶部导航栏 (用于继承 base.html 的页面) ========== */
.page-layout {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

.navbar {
    width: 100%;
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 56px;
    flex-shrink: 0;
    z-index: 100;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary);
}

.nav-brand i { color: var(--primary-light); font-size: 1.3rem; }

.nav-menu {
    display: flex;
    list-style: none;
    gap: 4px;
    align-items: center;
    height: 100%;
    margin: 0;
    padding: 0;
}

.nav-menu li {
    height: 100%;
    display: flex;
    align-items: center;
    position: relative;
}

.nav-menu a {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
    white-space: nowrap;
}

.nav-menu a:hover,
.nav-menu a.active {
    background: var(--bg-main);
    color: var(--primary);
}

.nav-menu a.active { font-weight: 600; }

.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.footer {
    width: 100%;
    padding: 12px 24px;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    background: #fff;
    flex-shrink: 0;
}

/* Dropdown menu for emission modules */
.dropdown { position: relative; }
.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 180px;
    z-index: 1000;
    padding: 8px 0;
    list-style: none;
    margin: 0;
}
.dropdown:hover .dropdown-menu, .dropdown.active .dropdown-menu { display: block; }
.dropdown-menu li { padding: 0; }
.dropdown-menu li a {
    display: block;
    padding: 8px 16px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    white-space: nowrap;
}
.dropdown-menu li a:hover { background: #f0f7ff; color: #1976d2; }
.dropdown-menu li a i { margin-right: 8px; width: 16px; text-align: center; }
