/* ============================================
   规范汉字馆页面样式
   复用现有渐变主题
   ============================================ */

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

body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    margin: 0;
    font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* ============================================
   顶部导航栏
   ============================================ */
.top-nav {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
    background: rgba(255, 255, 255, 0.95);
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.top-nav a {
    padding: 10px 30px;
    text-decoration: none;
    color: #667eea;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.top-nav a:hover,
.top-nav a.active {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
}

/* ============================================
   页面头部
   ============================================ */
header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 1.2em;
    opacity: 0.95;
}

/* ============================================
   搜索区域
   ============================================ */
.search-section {
    margin-bottom: 30px;
}

.search-box {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
}

.search-box input {
    flex: 1;
    padding: 15px 20px;
    font-size: 1.1em;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    transition: all 0.3s ease;
}

.search-box input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#btn-search {
    padding: 15px 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.1em;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

#btn-search:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(102, 126, 234, 0.4);
}

#btn-search:active {
    transform: translateY(0);
}

/* ============================================
   快捷选项
   ============================================ */
.quick-options {
    background: rgba(255, 255, 255, 0.95);
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.quick-options h3 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 1.3em;
}

.option-groups {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.option-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 15px;
}

.option-group label {
    font-weight: 600;
    color: #667eea;
    min-width: 60px;
}

.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.button-group button {
    padding: 10px 20px;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    font-size: 0.95em;
}

.button-group button:hover {
    background: #f0f0ff;
    transform: translateY(-2px);
}

.button-group button.selected {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* ============================================
   加载和错误状态
   ============================================ */
.loading {
    text-align: center;
    padding: 40px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

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

.loading p {
    color: #667eea;
    font-weight: 600;
}

.error-message {
    background: #fee;
    color: #c33;
    padding: 15px;
    border-radius: 10px;
    border-left: 4px solid #c33;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* ============================================
   AI 助手响应区
   ============================================ */
.ai-response {
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 15px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.ai-response h2 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 1.5em;
}

.message-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-height: 500px;
    overflow-y: auto;
    padding: 10px;
}

.message {
    padding: 15px 20px;
    border-radius: 12px;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

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

.user-message {
    align-self: flex-end;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-message {
    align-self: flex-start;
    background: #f0f0ff;
    color: #333;
    border-bottom-left-radius: 4px;
    border: 2px solid #e0e0ff;
}

.message-content {
    word-wrap: break-word;
    line-height: 1.6;
}

/* 打字机光标效果 */
.ai-message .message-content::after {
    content: '|';
    animation: blink 1s infinite;
}

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

/* 响应完成时移除光标 */
.ai-message.completed .message-content::after {
    content: '';
    animation: none;
}

/* ============================================
   单元选择提示
   ============================================ */
.unit-selection {
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.unit-selection h3 {
    color: #667eea;
    margin-bottom: 15px;
}

.unit-selection p {
    color: #666;
    margin-bottom: 20px;
    font-size: 1.1em;
}

#unit-buttons {
    justify-content: center;
}

#unit-buttons button {
    min-width: 100px;
}

/* ============================================
   查询结果
   ============================================ */
.results {
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 15px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.results h2 {
    color: #667eea;
    margin-bottom: 20px;
}

.query-summary {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.query-summary p {
    margin: 5px 0;
    color: #555;
}

.query-summary strong {
    color: #667eea;
}

.files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.file-card {
    background: white;
    padding: 25px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    border: 2px solid #e0e0e0;
}

.file-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 12px rgba(0, 0, 0, 0.15);
    border-color: #667eea;
}

.file-icon {
    font-size: 3em;
    margin-bottom: 15px;
}

.file-card h4 {
    margin: 10px 0;
    color: #333;
    font-size: 1.1em;
    word-break: break-all;
}

.unit-tag {
    color: #667eea;
    font-weight: 600;
    margin: 5px 0;
}

.btn-download {
    display: inline-block;
    margin-top: 15px;
    padding: 12px 30px;
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-download:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(79, 172, 254, 0.4);
}

/* ============================================
   使用说明
   ============================================ */
.instructions {
    background: rgba(255, 255, 255, 0.95);
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.instructions h3 {
    color: #667eea;
    margin-bottom: 20px;
}

.instruction-content h4 {
    color: #555;
    margin: 15px 0 10px;
    font-size: 1.1em;
}

.instruction-content ul {
    list-style-position: inside;
    line-height: 1.8;
    color: #666;
}

.instruction-content li {
    margin: 8px 0;
}

.instruction-content strong {
    color: #667eea;
}

/* ============================================
   页脚
   ============================================ */
footer {
    text-align: center;
    margin-top: 40px;
    padding: 20px;
    color: white;
    opacity: 0.9;
}

/* ============================================
   响应式设计
   ============================================ */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.8em;
    }

    .subtitle {
        font-size: 1em;
    }

    .search-box {
        flex-direction: column;
    }

    #btn-search {
        width: 100%;
    }

    .option-group {
        flex-direction: column;
        align-items: flex-start;
    }

    .button-group {
        width: 100%;
    }

    .button-group button {
        flex: 1;
        min-width: 80px;
    }

    .files-grid {
        grid-template-columns: 1fr;
    }

    .top-nav {
        flex-direction: column;
    }

    .top-nav a {
        width: 100%;
        text-align: center;
    }
}
