/**
 * Dify风格的引用CSS样式 - 优化美观版本
 */

/* 引用容器样式 - 现代卡片设计 */
.dify-references-container {
    margin-top: 15px;
    margin-bottom: 20px;
    padding: 16px;
    background: linear-gradient(135deg, #f8f9ff 0%, #f0f4f8 100%);
    border-radius: 12px;
    border: 1px solid #e1e8ed;
    box-shadow: 0 2px 8px rgba(26, 115, 232, 0.08);
    position: relative;
    overflow: hidden;
}

/* 装饰性渐变条 */
.dify-references-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #1a73e8, #4285f4, #34a853);
}

/* 引用标题样式 - 美化设计 */
.dify-references-title {
    font-weight: 600;
    margin-bottom: 12px;
    padding: 8px 0;
    font-size: 16px;
    color: #1a73e8;
    line-height: 3.6;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: color 0.2s ease;
    user-select: none;
}

.dify-references-title:hover {
    color: #1557b0;
}

.dify-references-title .layui-icon {
    margin-left: 8px;
    font-size: 14px;
    transition: transform 0.2s ease;
}

/* 引用列表样式 */
.dify-references-list {
    line-height: 1.3;
}

/* 引用项目样式 - 现代卡片设计 */
.dify-reference-item {
    background: #ffffff;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 6px;
    border: 1px solid #e8f0fe;
    border-left: 4px solid #1a73e8;
    min-height: 44px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.dify-reference-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, transparent 0%, rgba(26, 115, 232, 0.02) 100%);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.dify-reference-item:hover {
    background: #ffffff;
    border-color: #d1e3ff;
    box-shadow: 0 4px 12px rgba(26, 115, 232, 0.12);
    transform: translateY(-1px);
}

.dify-reference-item:hover::before {
    opacity: 1;
}

.dify-reference-item.highlight {
    background: #f0f7ff;
    border-color: #4285f4;
    box-shadow: 0 4px 16px rgba(26, 115, 232, 0.2);
    transform: translateY(-2px);
}

/* 引用项头部 - 优化布局 */
.dify-reference-header {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 32px;
    position: relative;
    z-index: 1;
}

/* 引用编号样式 - 美化设计 */
.dify-reference-number {
    color: #2d3748;
    font-weight: 600;
    font-size: 12px;
    margin-right: 12px;
    flex-shrink: 0;
    padding: 4px 8px;
    border-radius: 12px;
    min-width: 28px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 引用标题样式 - 优化排版 */
.dify-reference-title {
    font-weight: 500;
    color: #2d3748;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    font-size: 14px;
    line-height: 1.4;
}

/* 引用内容样式 */
.dify-reference-content {
    font-size: 13px;
    line-height: 1.4;
    color: #64748b;
}

/* 引用文本样式 */
.dify-reference-text {
    margin-bottom: 8px;
    white-space: pre-line;
    max-height: 200px;
    overflow-y: auto;
    color: #374151;
    line-height: 1.5;
    padding-right: 8px;
}

/* 引用来源样式 */
.dify-reference-source {
    font-size: 11px;
    color: #9ca3af;
    padding-top: 8px;
    border-top: 1px solid #f3f4f6;
    line-height: 1.3;
    display: flex;
    align-items: center;
    font-style: italic;
}

.dify-reference-source::before {
    content: "📄";
    margin-right: 6px;
    font-size: 12px;
}

/* 自定义弹出层样式 - 现代卡片设计 */
.dify-reference-tip .layui-layer-content {
    padding: 0 !important;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    border: none;
    border-radius: 16px;
    max-width: 650px !important;
    min-width: 450px !important;
    overflow: hidden;
    background: #ffffff;
}

/* 弹出层头部区域 - 渐变设计 */
.reference-popup-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px 24px;
    position: relative;
    color: white;
}

.reference-popup-header::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 0;
    right: 0;
    height: 8px;
    background: linear-gradient(180deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.1) 100%);
}

/* 弹出层标题样式 */
.reference-popup-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: white;
    padding-right: 40px;
    line-height: 1.3;
    word-wrap: break-word;
}

/* 弹出层主体内容区域 */
.reference-popup-body {
    padding: 24px;
    background: #ffffff;
}

/* 弹出层内容文本 */
.reference-popup-text {
    margin-bottom: 20px;
    color: #374151;
    font-size: 15px;
    line-height: 1.6;
    white-space: pre-line;
    word-wrap: break-word;
    max-height: 320px;
    overflow-y: auto;
    padding-right: 8px;
}

/* 弹出层来源信息 */
.reference-popup-source {
    font-size: 13px;
    color: #6b7280;
    padding: 16px;
    background: #f9fafb;
    border-radius: 8px;
    border-left: 4px solid #1a73e8;
    display: flex;
    align-items: center;
    gap: 8px;
    font-style: italic;
}

.reference-popup-source::before {
    content: "📚";
    font-size: 16px;
    flex-shrink: 0;
}

/* 关闭按钮样式 - 现代设计 */
.reference-popup-close {
    position: absolute;
    right: 20px;
    top: 20px;
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-size: 20px;
    color: rgba(255, 255, 255, 0.8);
    text-align: center;
    line-height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    transition: all 0.2s ease;
}

.reference-popup-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    transform: scale(1.1);
}

/* 引用文本滚动条美化 */
.dify-reference-text::-webkit-scrollbar,
.reference-popup-text::-webkit-scrollbar {
    width: 6px;
}

.dify-reference-text::-webkit-scrollbar-track,
.reference-popup-text::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.dify-reference-text::-webkit-scrollbar-thumb,
.reference-popup-text::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.dify-reference-text::-webkit-scrollbar-thumb:hover,
.reference-popup-text::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* 弹出层动画优化 */
.dify-reference-tip {
    animation: modalSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalSlideIn {
    0% {
        opacity: 0;
        transform: scale(0.8) translateY(-40px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* 移动设备适配 */
@media (max-width: 768px) {
    .dify-references-container {
        margin: 12px 0;
        padding: 12px;
        border-radius: 8px;
    }

    .dify-reference-item {
        padding: 10px 12px;
        min-height: 40px;
    }

    .dify-references-title {
        font-size: 15px;
    }

    .dify-reference-title {
        font-size: 13px;
    }

    .reference-popup-header {
        padding: 16px 20px;
    }

    .reference-popup-body {
        padding: 20px;
    }
}

/* 暗黑模式支持 */
@media (prefers-color-scheme: dark) {
    .dify-references-container {
        background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
        border-color: #374151;
    }

    .dify-reference-item {
        background: #1f2937;
        border-color: #374151;
        color: #e5e7eb;
    }

    .dify-reference-item:hover {
        background: #374151;
        border-color: #4b5563;
    }

    .dify-reference-title {
        color: #e5e7eb;
    }

    .dify-references-title {
        color: #60a5fa;
    }

    .reference-popup-content {
        background: #1f2937;
    }

    .reference-popup-body {
        background: #1f2937;
    }

    .reference-popup-text {
        color: #e5e7eb;
    }

    .reference-popup-source {
        background: #111827;
        color: #9ca3af;
    }
}
