/**
 * AI Components Styling
 * 统一的AI功能组件样式
 */

:root {
    --ai-primary: #1890ff;
    --ai-success: #52c41a;
    --ai-warning: #faad14;
    --ai-error: #ff4d4f;
    --ai-text-primary: #262626;
    --ai-text-secondary: #8c8c8c;
    --ai-border: #d9d9d9;
    --ai-bg-light: #fafafa;
    --ai-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --ai-shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.12);
    --ai-radius: 8px;
    --ai-transition: all 0.3s ease;
}

/* ========== 骨架屏 ========== */
.skeleton-text {
    padding: 12px 0;
}

.skeleton-line {
    height: 16px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 4px;
    margin-bottom: 12px;
}

.skeleton-card {
    padding: 20px;
    background: white;
    border-radius: var(--ai-radius);
    box-shadow: var(--ai-shadow);
}

.skeleton-header {
    height: 24px;
    width: 150px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 4px;
    margin-bottom: 16px;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ========== 加载状态 ========== */
.ai-loading {
    text-align: center;
    padding: 40px 20px;
}

.ai-spinner {
    display: inline-block;
    position: relative;
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
}

.spinner-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 4px solid transparent;
    border-top-color: var(--ai-primary);
    border-radius: 50%;
    animation: spinner-rotate 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

.spinner-ring:nth-child(1) {
    animation-delay: -0.45s;
}

.spinner-ring:nth-child(2) {
    animation-delay: -0.3s;
}

.spinner-ring:nth-child(3) {
    animation-delay: -0.15s;
}

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

.ai-loading-text {
    font-size: 16px;
    color: var(--ai-text-primary);
    font-weight: 500;
    margin-bottom: 8px;
}

.ai-loading-tip {
    font-size: 12px;
    color: var(--ai-text-secondary);
}

/* 进度条 */
.ai-progress {
    padding: 20px;
}

.ai-progress-text {
    font-size: 14px;
    color: var(--ai-text-primary);
    margin-bottom: 12px;
}

.ai-progress-bar {
    height: 8px;
    background: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.ai-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--ai-primary), #40a9ff);
    transition: width 0.3s ease;
    border-radius: 4px;
}

.ai-progress-percent {
    font-size: 12px;
    color: var(--ai-text-secondary);
    text-align: right;
}

/* ========== 错误提示 ========== */
.ai-error-card {
    text-align: center;
    padding: 40px 20px;
    background: white;
    border-radius: var(--ai-radius);
    border: 1px solid #ffccc7;
    background-color: #fff2f0;
}

.ai-error-icon {
    margin-bottom: 16px;
}

.ai-error-message {
    font-size: 14px;
    color: var(--ai-error);
    margin-bottom: 20px;
}

.ai-error-retry {
    padding: 8px 24px;
    background: var(--ai-error);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: var(--ai-transition);
}

.ai-error-retry:hover {
    background: #ff7875;
}

/* 空状态 */
.ai-empty-state {
    text-align: center;
    padding: 60px 20px;
}

.ai-empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.ai-empty-message {
    font-size: 14px;
    color: var(--ai-text-secondary);
    margin-bottom: 20px;
}

.ai-empty-action {
    padding: 8px 24px;
    background: var(--ai-primary);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: var(--ai-transition);
}

.ai-empty-action:hover {
    background: #40a9ff;
}

/* ========== 摘要卡片 ========== */
.ai-summary-card {
    background: white;
    border-radius: var(--ai-radius);
    padding: 20px;
    box-shadow: var(--ai-shadow);
    margin-bottom: 16px;
    transition: var(--ai-transition);
}

.ai-summary-card:hover {
    box-shadow: var(--ai-shadow-hover);
}

.summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.summary-badge {
    display: inline-block;
    padding: 4px 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 12px;
    border-radius: 12px;
    font-weight: 500;
}

.summary-type {
    font-size: 12px;
    color: var(--ai-text-secondary);
    padding: 4px 8px;
    background: var(--ai-bg-light);
    border-radius: 4px;
}

.summary-content {
    font-size: 14px;
    line-height: 1.8;
    color: var(--ai-text-primary);
    margin-bottom: 16px;
    text-align: justify;
}

.summary-key-events {
    margin-bottom: 12px;
    padding: 12px;
    background: #f6ffed;
    border-left: 3px solid var(--ai-success);
    border-radius: 4px;
}

.summary-key-events ul {
    margin: 8px 0 0 0;
    padding-left: 20px;
}

.summary-key-events li {
    font-size: 13px;
    line-height: 1.6;
    color: var(--ai-text-primary);
}

.summary-characters {
    margin-bottom: 12px;
}

.character-tag {
    display: inline-block;
    padding: 4px 12px;
    background: #e6f7ff;
    color: var(--ai-primary);
    border-radius: 12px;
    font-size: 12px;
    margin: 4px 8px 4px 0;
}

.summary-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 12px;
    border-top: 1px solid var(--ai-border);
    font-size: 12px;
    color: var(--ai-text-secondary);
}

/* 全书摘要 */
.ai-book-summary {
    background: white;
    border-radius: var(--ai-radius);
    padding: 24px;
    box-shadow: var(--ai-shadow);
    margin-bottom: 20px;
}

.book-summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--ai-primary);
}

.book-summary-header h3 {
    margin: 0;
    font-size: 20px;
    color: var(--ai-text-primary);
}

.summary-type-badge {
    padding: 6px 16px;
    background: var(--ai-primary);
    color: white;
    border-radius: 16px;
    font-size: 12px;
}

.book-summary-content {
    font-size: 15px;
    line-height: 2;
    color: var(--ai-text-primary);
    margin-bottom: 20px;
    text-align: justify;
}

.book-summary-section {
    margin-bottom: 20px;
}

.book-summary-section h4 {
    font-size: 16px;
    margin-bottom: 12px;
    color: var(--ai-text-primary);
}

.character-list, .theme-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.character-chip {
    padding: 6px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 16px;
    font-size: 13px;
}

.theme-tag {
    padding: 6px 16px;
    background: #fff7e6;
    color: var(--ai-warning);
    border: 1px solid #ffd591;
    border-radius: 16px;
    font-size: 13px;
}

.book-summary-conclusion {
    padding: 16px;
    background: var(--ai-bg-light);
    border-left: 4px solid var(--ai-primary);
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.8;
    font-style: italic;
    color: var(--ai-text-secondary);
}

/* ========== 人物分析卡片 ========== */
.ai-character-analysis {
    background: white;
    border-radius: var(--ai-radius);
    padding: 24px;
    box-shadow: var(--ai-shadow);
    margin-bottom: 20px;
}

.analysis-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--ai-primary);
}

.analysis-header h3 {
    margin: 0;
    font-size: 22px;
    color: var(--ai-text-primary);
}

.role-badge {
    padding: 6px 16px;
    background: var(--ai-primary);
    color: white;
    border-radius: 16px;
    font-size: 13px;
}

.analysis-section {
    margin-bottom: 24px;
}

.analysis-section h4 {
    font-size: 16px;
    margin-bottom: 12px;
    color: var(--ai-text-primary);
    display: flex;
    align-items: center;
}

.analysis-section h4::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 16px;
    background: var(--ai-primary);
    margin-right: 8px;
    border-radius: 2px;
}

.analysis-section p {
    font-size: 14px;
    line-height: 1.8;
    color: var(--ai-text-primary);
    text-align: justify;
}

.trait-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.trait-tag {
    padding: 8px 16px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

.relationship-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.relationship-item {
    padding: 12px;
    background: var(--ai-bg-light);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.rel-character {
    font-weight: 500;
    color: var(--ai-text-primary);
    min-width: 80px;
}

.rel-type {
    padding: 4px 12px;
    background: var(--ai-primary);
    color: white;
    border-radius: 12px;
    font-size: 12px;
}

.rel-desc {
    flex: 1;
    font-size: 13px;
    color: var(--ai-text-secondary);
}

.quotes-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.character-quote {
    margin: 0;
    padding: 16px 20px;
    background: #f6ffed;
    border-left: 4px solid var(--ai-success);
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.8;
    color: var(--ai-text-primary);
    font-style: italic;
}

/* ========== 情节分析卡片 ========== */
.ai-plot-analysis {
    background: white;
    border-radius: var(--ai-radius);
    padding: 24px;
    box-shadow: var(--ai-shadow);
    margin-bottom: 20px;
}

.plot-header h3 {
    margin: 0 0 24px 0;
    font-size: 22px;
    color: var(--ai-text-primary);
    padding-bottom: 16px;
    border-bottom: 2px solid var(--ai-primary);
}

.plot-section {
    margin-bottom: 24px;
}

.plot-section h4 {
    font-size: 16px;
    margin-bottom: 16px;
    color: var(--ai-text-primary);
}

.acts-timeline {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.act-item {
    padding: 16px;
    background: linear-gradient(135deg, #667eea22 0%, #764ba222 100%);
    border-left: 4px solid var(--ai-primary);
    border-radius: 8px;
}

.act-number {
    font-size: 18px;
    font-weight: 600;
    color: var(--ai-primary);
    margin-bottom: 4px;
}

.act-chapters {
    font-size: 12px;
    color: var(--ai-text-secondary);
    margin-bottom: 8px;
}

.act-desc {
    font-size: 14px;
    color: var(--ai-text-primary);
}

.key-events-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.event-item {
    padding: 12px 16px;
    border-radius: 8px;
    border-left: 4px solid #d9d9d9;
}

.event-item.event-high {
    background: #fff1f0;
    border-left-color: var(--ai-error);
}

.event-item.event-medium {
    background: #fff7e6;
    border-left-color: var(--ai-warning);
}

.event-item.event-low {
    background: #f6ffed;
    border-left-color: var(--ai-success);
}

.event-chapter {
    font-weight: 500;
    color: var(--ai-primary);
    margin-right: 12px;
}

.event-type {
    display: inline-block;
    padding: 2px 8px;
    background: var(--ai-primary);
    color: white;
    border-radius: 8px;
    font-size: 11px;
    margin-right: 12px;
}

.event-desc {
    margin: 8px 0 0 0;
    font-size: 14px;
    color: var(--ai-text-primary);
}

.conflict-item {
    padding: 12px;
    background: var(--ai-bg-light);
    border-radius: 8px;
    margin-bottom: 12px;
}

.conflict-type {
    font-weight: 500;
    color: var(--ai-text-primary);
    margin-bottom: 8px;
}

.conflict-parties {
    font-size: 13px;
    color: var(--ai-primary);
    margin-bottom: 8px;
}

.conflict-resolution {
    font-size: 13px;
    color: var(--ai-text-secondary);
}

.climax-box {
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px;
}

.climax-chapter {
    display: inline-block;
    padding: 4px 12px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    font-size: 12px;
    margin-bottom: 12px;
}

.climax-box p {
    margin: 0;
    font-size: 15px;
    line-height: 1.8;
}

/* ========== 主题分析卡片 ========== */
.ai-theme-analysis {
    background: white;
    border-radius: var(--ai-radius);
    padding: 24px;
    box-shadow: var(--ai-shadow);
    margin-bottom: 20px;
}

.theme-header h3 {
    margin: 0 0 24px 0;
    font-size: 22px;
    color: var(--ai-text-primary);
    padding-bottom: 16px;
    border-bottom: 2px solid var(--ai-primary);
}

.theme-section {
    margin-bottom: 24px;
}

.theme-section h4 {
    font-size: 16px;
    margin-bottom: 16px;
    color: var(--ai-text-primary);
}

.theme-item {
    padding: 16px;
    background: var(--ai-bg-light);
    border-radius: 8px;
    margin-bottom: 12px;
}

.theme-item h5 {
    margin: 0 0 8px 0;
    font-size: 15px;
    color: var(--ai-primary);
}

.theme-item p {
    margin: 0 0 8px 0;
    font-size: 14px;
    line-height: 1.8;
    color: var(--ai-text-primary);
}

.evidence-chapters {
    font-size: 12px;
    color: var(--ai-text-secondary);
}

.writing-style {
    padding: 16px;
    background: var(--ai-bg-light);
    border-radius: 8px;
}

.writing-style > div {
    margin-bottom: 8px;
    font-size: 14px;
    line-height: 1.6;
}

.writing-style strong {
    color: var(--ai-text-primary);
    margin-right: 8px;
}

.symbol-item {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    background: #fff7e6;
    border-radius: 20px;
    margin: 4px 8px 4px 0;
}

.symbol-name {
    font-weight: 500;
    color: var(--ai-warning);
    margin-right: 8px;
}

.symbol-meaning {
    font-size: 12px;
    color: var(--ai-text-secondary);
}

.ideas-list {
    margin: 0;
    padding-left: 20px;
}

.ideas-list li {
    font-size: 14px;
    line-height: 1.8;
    color: var(--ai-text-primary);
    margin-bottom: 8px;
}

/* ========== 推荐卡片 ========== */
.ai-recommend-card {
    display: flex;
    background: white;
    border-radius: var(--ai-radius);
    box-shadow: var(--ai-shadow);
    overflow: hidden;
    cursor: pointer;
    transition: var(--ai-transition);
    margin-bottom: 16px;
}

.ai-recommend-card:hover {
    box-shadow: var(--ai-shadow-hover);
    transform: translateY(-2px);
}

.recommend-cover {
    position: relative;
    width: 100px;
    flex-shrink: 0;
}

.recommend-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.recommend-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 4px 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 10px;
    border-radius: 8px;
}

.recommend-info {
    flex: 1;
    padding: 12px;
    display: flex;
    flex-direction: column;
}

.recommend-title {
    margin: 0 0 4px 0;
    font-size: 16px;
    color: var(--ai-text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.recommend-author {
    margin: 0 0 8px 0;
    font-size: 12px;
    color: var(--ai-text-secondary);
}

.recommend-reason {
    margin: 0 0 8px 0;
    font-size: 13px;
    line-height: 1.6;
    color: var(--ai-text-primary);
    flex: 1;
}

.recommend-meta {
    display: flex;
    gap: 8px;
    font-size: 11px;
}

.recommend-category, .recommend-status {
    padding: 2px 8px;
    background: var(--ai-bg-light);
    border-radius: 8px;
    color: var(--ai-text-secondary);
}

/* ========== 可展开文本 ========== */
.expandable-text {
    position: relative;
}

.text-expand-btn {
    display: inline-block;
    margin-top: 8px;
    padding: 4px 16px;
    background: transparent;
    color: var(--ai-primary);
    border: 1px solid var(--ai-primary);
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: var(--ai-transition);
}

.text-expand-btn:hover {
    background: var(--ai-primary);
    color: white;
}

/* ========== 响应式适配 ========== */
@media (max-width: 768px) {
    .ai-summary-card,
    .ai-book-summary,
    .ai-character-analysis,
    .ai-plot-analysis,
    .ai-theme-analysis {
        padding: 16px;
    }

    .summary-header,
    .book-summary-header,
    .analysis-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .character-list,
    .theme-list,
    .trait-tags {
        gap: 6px;
    }

    .relationship-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .acts-timeline {
        gap: 12px;
    }

    .ai-recommend-card {
        flex-direction: column;
    }

    .recommend-cover {
        width: 100%;
        height: 200px;
    }
}

/* ========== 打印样式 ========== */
@media print {
    .ai-loading,
    .ai-error-card,
    .text-expand-btn {
        display: none;
    }

    .ai-summary-card,
    .ai-book-summary,
    .ai-character-analysis,
    .ai-plot-analysis,
    .ai-theme-analysis {
        box-shadow: none;
        border: 1px solid #ddd;
        page-break-inside: avoid;
    }
}
