/* 自定义样式 */
body {
    background-color: #f8f9fa;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.card {
    border: none;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    border-radius: 0.375rem;
}

.card-header {
    background-color: #fff;
    border-bottom: 1px solid #dee2e6;
    font-weight: 500;
}

/* 聊天界面样式 */
.chat-messages {
    height: 400px;
    overflow-y: auto;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.message {
    display: flex;
    margin-bottom: 15px;
    animation: fadeIn 0.3s ease-in;
}

.message.user {
    justify-content: flex-end;
}

.message.assistant {
    justify-content: flex-start;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    margin: 0 8px;
}

.message.user .message-avatar {
    background-color: #007bff;
    color: white;
    order: 2;
}

.message.assistant .message-avatar {
    background-color: #28a745;
    color: white;
    order: 1;
}

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.4;
    word-wrap: break-word;
}

.message.user .message-content {
    background-color: #007bff;
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
    background-color: white;
    color: #333;
    border: 1px solid #dee2e6;
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 0.75rem;
    color: #6c757d;
    margin-top: 4px;
    text-align: center;
}

/* 流式输出动画 */
.streaming-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background-color: #007bff;
    animation: blink 1s infinite;
    margin-left: 2px;
}

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

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

/* 输入状态指示器 */
.typing-indicator {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background-color: white;
    border: 1px solid #dee2e6;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    color: #6c757d;
    font-style: italic;
}

.typing-dots {
    display: flex;
    margin-left: 8px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #6c757d;
    margin: 0 2px;
    animation: typingDot 1.4s infinite;
}

.typing-dot:nth-child(1) { animation-delay: 0.0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-10px); opacity: 1; }
}

/* 聊天输入框 */
.chat-input-container {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.chat-input-container .form-control {
    flex: 1;
    border-radius: 20px;
    padding: 8px 16px;
}

.chat-input-container .btn {
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

/* 八字表格样式 */
.bazi-table {
    font-size: 0.9rem;
    margin-bottom: 0;
}

.bazi-table th,
.bazi-table td {
    vertical-align: middle;
    padding: 0.5rem;
}

.bazi-table th:first-child,
.bazi-table td:first-child {
    background-color: #f8f9fa;
    width: 80px;
}

.bazi-table .bg-warning {
    background-color: #fff3cd !important;
    font-weight: 600;
}

/* 八字表格样式 */
.bazi-table {
    font-size: 0.9rem;
    margin-bottom: 0;
}

.bazi-table th,
.bazi-table td {
    vertical-align: middle;
    padding: 0.5rem;
}

.bazi-table th:first-child,
.bazi-table td:first-child {
    background-color: #f8f9fa;
    width: 80px;
}

.bazi-table .bg-warning {
    background-color: #fff3cd !important;
    font-weight: 600;
}

/* 大运流年表格样式 */
.dayun-table {
    font-size: 0.75rem;
    white-space: nowrap;
    width: 100%;
    table-layout: fixed;
}

.dayun-table th,
.dayun-table td {
    vertical-align: middle;
    padding: 0.4rem 0.2rem;
    text-align: center;
}

/* 前两列使用最小宽度和更小内边距 */
.dayun-table th:nth-child(-n+2),
.dayun-table td:nth-child(-n+2) {
    padding: 0.4rem 0.1rem;
}

.dayun-table th:first-child,
.dayun-table td:first-child {
    width: 1%;
    background-color: #f8f9fa;
}

.dayun-table th:nth-child(2),
.dayun-table td:nth-child(2) {
    width: 1%;
}

/* 流年列等宽设置 - 98%平均分给10列 */
.dayun-table th:nth-child(n+3),
.dayun-table td:nth-child(n+3) {
    width: 9.8%;
}

/* 大运步数信息样式 */
.dayun-step-info {
    line-height: 1.2;
}

.dayun-step-info > div {
    margin-bottom: 1px;
}

/* 大运干支信息样式 */
.dayun-ganzhi-info {
    line-height: 1.1;
}

.dayun-ganzhi-info > div {
    margin-bottom: 2px;
}

/* 流年信息样式 */
.liunian-info {
    line-height: 1;
    padding: 1px;
}

.liunian-info > div {
    margin-bottom: 0.5px;
    white-space: nowrap;
}

.liunian-info .fw-bold {
    font-size: 0.8rem;
    margin-bottom: 1px;
}

.liunian-info .small {
    font-size: 0.62rem;
}

.dayun-table .small {
    font-size: 0.7rem;
    line-height: 1.1;
}

.dayun-table .small div {
    margin-bottom: 1px;
}

.table-responsive {
    border-radius: 0.375rem;
}

/* 表格容器 */
.bazi-table-container,
.dayun-table-container {
    background: white;
    border-radius: 0.375rem;
    padding: 1rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    border: 1px solid #dee2e6;
}

.bazi-table-container h6,
.dayun-table-container h6 {
    color: #495057;
    margin-bottom: 1rem;
    font-weight: 600;
}

/* 五行分数 */
.wuxing-scores {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 0.5rem;
    margin: 1rem 0;
}

.wuxing-item {
    text-align: center;
    padding: 0.5rem;
    border-radius: 0.25rem;
    color: white;
    font-weight: 500;
}

.wuxing-jin { background-color: #ffc107; }
.wuxing-mu { background-color: #28a745; }
.wuxing-shui { background-color: #007bff; }
.wuxing-huo { background-color: #dc3545; }
.wuxing-tu { background-color: #6c757d; }

/* 聊天区域 */
.chat-messages {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 1rem;
    background-color: #fff;
}

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

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

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

.message.user .message-avatar {
    background-color: #007bff;
}

.message.assistant .message-avatar {
    background-color: #28a745;
}

.message-content {
    max-width: 85%;  /* 增加到85% */
    min-width: 150px;  /* 增加最小宽度到150px */
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    word-wrap: break-word;
    word-break: keep-all;
    white-space: pre-wrap;
    line-height: 1.4;
    display: inline-block;
}

.message.user .message-content {
    background-color: #007bff;
    color: white;
    border-bottom-right-radius: 0.25rem;
}

.message.assistant .message-content {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-bottom-left-radius: 0.25rem;
}

.message-time {
    font-size: 0.75rem;
    color: #6c757d;
    margin-top: 0.25rem;
}

/* 打字效果 */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem;
    color: #6c757d;
    font-style: italic;
}

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

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #6c757d;
    animation: typing 1.4s infinite;
}

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

@keyframes typing {
    0%, 60%, 100% { opacity: 0.3; }
    30% { opacity: 1; }
}

/* 分析卡片 */
.analysis-section {
    margin: 1rem 0;
}

.analysis-card {
    background: white;
    border-left: 4px solid #007bff;
    padding: 1rem;
    margin-bottom: 0.5rem;
    border-radius: 0 0.375rem 0.375rem 0;
}

.analysis-card h6 {
    color: #007bff;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.analysis-card ul {
    margin: 0;
    padding-left: 1.25rem;
}

.analysis-card li {
    margin-bottom: 0.25rem;
    line-height: 1.5;
}

/* 大运流年 */
.dayun-container {
    display: flex;
    overflow-x: auto;
    gap: 0.5rem;
    padding: 0.5rem 0;
}

.dayun-item {
    min-width: 120px;
    text-align: center;
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    padding: 0.75rem;
    border-radius: 0.375rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.dayun-item h6 {
    margin: 0 0 0.5rem 0;
    font-size: 0.875rem;
    color: #8b4513;
}

.dayun-item .gan-zhi {
    font-size: 1rem;
    font-weight: bold;
    color: #d2691e;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .bazi-pillars {
        justify-content: center;
    }
    
    .bazi-pillar {
        min-width: 70px;
        padding: 0.75rem;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .dayun-container {
        justify-content: flex-start;
    }
    
    .container-fluid {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    
    .dayun-table {
        font-size: 0.6rem;
        table-layout: fixed;
    }
    
    .dayun-table th,
    .dayun-table td {
        padding: 0.2rem 0.05rem;
    }
    
    /* 移动端前两列使用更小内边距 */
    .dayun-table th:nth-child(-n+2),
    .dayun-table td:nth-child(-n+2) {
        padding: 0.2rem 0.03rem;
    }
    
    .dayun-table th:first-child,
    .dayun-table td:first-child {
        width: 2%;
    }
    
    .dayun-table th:nth-child(2),
    .dayun-table td:nth-child(2) {
        width: 2%;
    }
    
    /* 移动端流年列等宽 - 96%平均分给10列 */
    .dayun-table th:nth-child(n+3),
    .dayun-table td:nth-child(n+3) {
        width: 9.6%;
    }
    
    .dayun-table .small {
        font-size: 0.55rem;
    }
    
    .liunian-info .fw-bold {
        font-size: 0.6rem;
    }
    
    .liunian-info .small {
        font-size: 0.48rem;
    }
    
    .liunian-info {
        padding: 0.5px;
    }
    
    .liunian-info > div {
        margin-bottom: 0.3px;
    }
}

/* 全宽表格容器 */
.container-fluid {
    max-width: none;
    padding-left: 1rem;
    padding-right: 1rem;
}

/* 表格响应式优化 */
.table-responsive {
    margin: 0 -15px;
}

/* 大运表格优化 */
.dayun-table-container .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (min-width: 1400px) {
    .dayun-table {
        font-size: 0.8rem;
    }
    
    .dayun-table th,
    .dayun-table td {
        padding: 0.5rem 0.3rem;
    }
    
    .liunian-info .fw-bold {
        font-size: 0.85rem;
    }
    
    .liunian-info .small {
        font-size: 0.7rem;
    }
    
    .dayun-table .small {
        font-size: 0.75rem;
    }
}

/* 加载动画 */
.loading-spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* 工具提示 */
.tooltip-inner {
    max-width: 250px;
    text-align: left;
}

/* 积分显示 */
.credits-low {
    background-color: #dc3545 !important;
}

/* 聊天会话列表 */
.chat-session-item {
    padding: 0.75rem;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-session-item:hover {
    background-color: #f8f9fa;
    border-color: #007bff;
}

.chat-session-item.active {
    background-color: #e3f2fd;
    border-color: #007bff;
}

/* 历史记录面板 */
.history-list {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    padding-bottom: 1rem; /* 确保底部有足够的空间 */
}

.history-item {
    padding: 0.75rem;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    margin-bottom: 0.5rem;
    transition: all 0.2s;
    background: white;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
}

.history-item-content {
    flex: 1;
    cursor: pointer;
    min-width: 0; /* 允许内容收缩 */
}

.history-item-actions {
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.2s;
}

.history-item:hover .history-item-actions {
    opacity: 1;
}

.delete-history-btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.delete-history-btn:hover {
    background-color: #dc3545;
    border-color: #dc3545;
    color: white;
}

.history-item:last-child {
    margin-bottom: 0; /* 最后一个项目去掉下边距 */
}

.history-item:hover {
    background-color: #f8f9fa;
    border-color: #007bff;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.history-item.active {
    background-color: #e3f2fd;
    border-color: #007bff;
}

.history-item-title {
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.25rem;
}

.history-item-date {
    font-size: 0.75rem;
    color: #6c757d;
}

.history-item-preview {
    font-size: 0.8rem;
    color: #868e96;
    margin-top: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 滚动条样式 */
.chat-messages::-webkit-scrollbar,
.dayun-container::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.chat-messages::-webkit-scrollbar-track,
.dayun-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb,
.dayun-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover,
.dayun-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 聊天消息移动端适配 */
@media (max-width: 768px) {
    .message-content {
        max-width: 90%;  /* 移动端增加到90% */
        min-width: 120px;  /* 移动端最小宽度120px */
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }
    
    .message-avatar {
        width: 28px;
        height: 28px;
        font-size: 0.85rem;
    }
    
    .chat-messages {
        padding: 0.75rem;
        max-height: 350px;
    }
    
    .message {
        gap: 0.5rem;
        margin-bottom: 0.75rem;
    }
}