/**
 * AI工具模态框统一样式
 * 包括AI查询、风险检测、起名助手、AI消痕、AI审稿等
 */

/* 确保模态框头部有相对定位 */
.modal-header {
    position: relative;
}

/* 模态框关闭按钮统一样式 */
.modal-header .close-btn {
    position: absolute;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg-hover);
    color: var(--text-secondary);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    opacity: 1;
}

.modal-header .close-btn:hover {
    background: rgba(255, 59, 48, 0.1);
    color: #ff3b30;
    transform: translateY(-50%) scale(1.05);
}

.modal-header .close-btn:active {
    transform: translateY(-50%) scale(0.95);
}

.modal-header .close-btn i {
    font-size: 16px;
}

/* 模型选择和提示词选择按钮统一样式 */
.btn-model-select,
.btn-prompt-select {
    width: 100%;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(139, 92, 246, 0.1) 100%);
    border: 1px solid var(--border-purple);
    border-radius: 10px;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.btn-model-select:hover,
.btn-prompt-select:hover {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2) 0%, rgba(139, 92, 246, 0.2) 100%);
    border-color: rgba(139, 92, 246, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.btn-model-select:active,
.btn-prompt-select:active {
    transform: translateY(0);
}

.btn-model-select i,
.btn-prompt-select i {
    color: #a78bfa;
    font-size: 16px;
    flex-shrink: 0;
}

.btn-model-select span,
.btn-prompt-select span {
    flex: 1;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 主操作按钮样式 */
.modal-body .btn-primary {
    width: 100%;
    padding: 14px 24px;
    margin-top: 20px;
    background: var(--primary-color);
    border: none;
    border-radius: var(--radius-lg);
    color: #ffffff !important;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-purple);
}

.modal-body .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.modal-body .btn-primary:active {
    transform: translateY(0);
}

.modal-body .btn-primary:disabled {
    background: var(--bg-tertiary);
    color: rgba(255, 255, 255, 0.4) !important;
    cursor: not-allowed;
    box-shadow: none;
}

.modal-body .btn-primary i {
    font-size: 14px;
}

/* 表单组样式 */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
}

.form-group label i {
    color: #a78bfa;
    font-size: 14px;
}

/* 面板描述样式 */
.panel-description {
    padding: 12px 16px;
    background: rgba(139, 92, 246, 0.1);
    border-left: 3px solid #a78bfa;
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.panel-description i {
    color: #a78bfa;
    margin-top: 2px;
    flex-shrink: 0;
}

/* 自定义对话框样式 */
.custom-dialog-modal {
    max-width: 480px !important;
    min-width: 400px;
}

.custom-dialog-modal .modal-header h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.custom-dialog-modal .modal-header h3 i {
    color: #a78bfa;
}

.custom-dialog-modal .modal-body {
    padding: 24px;
}

.dialog-message {
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-primary);
    margin: 0;
}

.dialog-input {
    width: 100%;
    padding: 12px 16px;
    margin-top: 12px;
    background: var(--bg-hover);
    border: 1px solid var(--border-purple);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.3s ease;
    outline: none;
}

.dialog-input:focus {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(139, 92, 246, 0.5);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.dialog-input::placeholder {
    color: var(--text-tertiary);
}

/* 模态框底部 */
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.modal-footer .btn-secondary {
    padding: 10px 24px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.modal-footer .btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--border-purple);
    transform: translateY(-1px);
}

.modal-footer .btn-secondary:active {
transform: translateY(0);
}

.modal-footer .btn-primary {
padding: 10px 24px;
background: var(--primary-color);
border: none;
border-radius: 10px;
color: #ffffff !important;
font-size: 14px;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
box-shadow: var(--shadow-purple);
}

.modal-footer .btn-primary:hover {
transform: translateY(-2px);
box-shadow: var(--shadow-purple-lg);
}

.modal-footer .btn-primary:active {
transform: translateY(0);
}

/* 自定义模态框样式（历史记录和智能排序）*/
.custom-modal {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.7);
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
display: flex;
align-items: center;
justify-content: center;
z-index: 10000;
padding: 20px;
}

.custom-modal-content {
background: var(--bg-card);
border-radius: 16px;
box-shadow: var(--shadow-xl);
border: 1px solid var(--border-color);
max-height: 80vh;
overflow: hidden;
display: flex;
flex-direction: column;
}

.custom-modal-header {
padding: 20px 24px;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
display: flex;
align-items: center;
justify-content: space-between;
position: relative;
}

.custom-modal-header h3 {
display: flex;
align-items: center;
gap: 10px;
font-size: 18px;
font-weight: 600;
color: #e4e4e7;
margin: 0;
}

.custom-modal-header h3 i {
color: #a78bfa;
}

.custom-modal-close {
position: absolute;
top: 50%;
right: 20px;
transform: translateY(-50%);
width: 36px;
height: 36px;
border: none;
background: rgba(255, 255, 255, 0.05);
color: rgba(255, 255, 255, 0.7);
border-radius: 8px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
font-size: 18px;
transition: all 0.3s ease;
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
}

.custom-modal-close:hover {
background: rgba(255, 59, 48, 0.1);
color: #ff3b30;
transform: translateY(-50%) scale(1.05);
}

.custom-modal-close:active {
transform: translateY(-50%) scale(0.95);
}

.custom-modal-close i {
font-size: 16px;
}

.custom-modal-body {
padding: 24px;
overflow-y: auto;
flex: 1;
}

/* 自定义模态框底部 */
.custom-modal-footer {
padding: 16px 24px;
border-top: 1px solid rgba(255, 255, 255, 0.1);
display: flex;
gap: 12px;
justify-content: flex-end;
}

.custom-modal-footer .btn-secondary {
padding: 10px 24px;
background: var(--bg-tertiary);
border: 1px solid var(--border-color);
border-radius: 10px;
color: var(--text-primary);
cursor: pointer;
font-size: 14px;
font-weight: 500;
transition: all 0.3s ease;
}

.custom-modal-footer .btn-secondary:hover {
background: var(--bg-hover);
border-color: var(--border-purple);
transform: translateY(-1px);
}

.custom-modal-footer .btn-secondary:active {
transform: translateY(0);
}

.custom-modal-footer .btn-primary {
padding: 10px 24px;
background: var(--primary-color);
border: none;
border-radius: 10px;
color: #ffffff !important;
font-size: 14px;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
box-shadow: var(--shadow-purple);
display: flex;
align-items: center;
gap: 8px;
}

.custom-modal-footer .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-purple-lg);
}

.custom-modal-footer .btn-primary:active {
    transform: translateY(0);
}

.custom-modal-footer .btn-primary i {
    font-size: 13px;
}

/* 引用模态框工具栏 */
.mention-reference-toolbar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    align-items: center;
}

.mention-search-input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-size: 14px;
}

.mention-search-input:focus {
    outline: none;
    border-color: rgba(139, 92, 246, 0.6);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.1);
}

.mention-toolbar-btns {
    display: flex;
    gap: 0.5rem;
}

.mention-footer-info {
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
}

.mention-footer-info strong {
    color: #a78bfa;
}

.mention-footer-btns {
    display: flex;
    gap: 12px;
}

.mention-footer-btns button {
    padding: 10px 24px !important;
    min-width: auto !important;
    width: auto !important;
    height: auto !important;
    aspect-ratio: unset !important;
}

/* 树状引用列表 */
.mention-reference-tree {
    max-height: 450px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 8px;
}

/* 文件夹节点 */
.mention-tree-folder {
    margin-bottom: 4px;
}

.mention-tree-folder-header {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: rgba(139, 92, 246, 0.1);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    gap: 8px;
}

.mention-tree-folder-header:hover {
    background: rgba(139, 92, 246, 0.2);
}

.mention-tree-folder-header.selected {
    background: rgba(139, 92, 246, 0.3);
    box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.5);
}

.mention-tree-toggle {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.6);
    transition: transform 0.2s ease;
}

.mention-tree-toggle.collapsed {
    transform: rotate(-90deg);
}

.mention-tree-folder-icon {
    color: #fbbf24;
    font-size: 14px;
}

.mention-tree-folder-name {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
}

.mention-tree-folder-count {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 8px;
    border-radius: 10px;
}

.mention-tree-folder-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #a78bfa;
}

/* 文件夹内容（可折叠） */
.mention-tree-folder-content {
    margin-left: 28px;
    padding-left: 12px;
    border-left: 1px solid rgba(139, 92, 246, 0.2);
    margin-top: 4px;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.mention-tree-folder-content.collapsed {
    display: none !important;
}

/* 文件节点 */
.mention-tree-file {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    margin: 2px 0;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    gap: 10px;
}

.mention-tree-file:hover {
    background: rgba(139, 92, 246, 0.15);
}

.mention-tree-file.selected {
    background: rgba(139, 92, 246, 0.25);
    box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.4);
}

.mention-tree-file-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #a78bfa;
}

.mention-tree-file-icon {
    color: #60a5fa;
    font-size: 13px;
    width: 18px;
    text-align: center;
}

.mention-tree-file-icon.chapter { color: #34d399; }
.mention-tree-file-icon.character { color: #f472b6; }
.mention-tree-file-icon.inspiration { color: #fbbf24; }

.mention-tree-file-name {
    flex: 1;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.85);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mention-tree-file-meta {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
}

/* 空状态 */
.mention-tree-empty {
    text-align: center;
    padding: 40px 20px;
    color: rgba(255, 255, 255, 0.5);
}

.mention-tree-empty i {
    font-size: 40px;
    margin-bottom: 12px;
    opacity: 0.3;
}

.mention-tree-empty p {
    margin: 0;
    font-size: 14px;
}

/* 旧版引用列表样式（保留兼容） */
.mention-reference-list {
    max-height: 400px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.mention-item {
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mention-item:hover {
    background: rgba(139, 92, 246, 0.1);
    border-color: rgba(139, 92, 246, 0.4);
    transform: translateY(-2px);
}

.mention-item.selected {
    background: rgba(139, 92, 246, 0.2);
    border-color: rgba(139, 92, 246, 0.6);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.2);
}

.mention-item-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mention-item-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #a78bfa;
}

.mention-item-title {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mention-item-type {
    font-size: 11px;
    padding: 2px 8px;
    background: rgba(139, 92, 246, 0.2);
    border-radius: 4px;
    color: #a78bfa;
}

.mention-item-preview {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* 历史记录样式 */
.history-records-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-record-item {
    padding: 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.history-record-item:hover {
    background: var(--bg-hover);
    border-color: var(--border-purple);
    transform: translateX(4px);
}

.history-record-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.history-record-header i {
    color: var(--primary-color);
}

.history-record-type {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 14px;
}

.history-record-time {
    color: var(--text-secondary);
    font-size: 13px;
}

/* 通用按钮样式 */
.btn-icon-sm {
    width: 32px;
    height: 32px;
    padding: 0;
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-icon-sm:hover {
    background: var(--bg-active);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-icon-sm i {
    font-size: 14px;
}

/* 书名生成器样式 */
.title-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.title-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.title-item:hover {
    background: var(--bg-hover);
    border-color: var(--primary-color);
}

.title-text {
    flex: 1;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
}

.title-actions {
    display: flex;
    gap: 8px;
}


/* 响应式设计 */
@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    .modal-header .close-btn {
        top: 16px;
        right: 16px;
        width: 32px;
        height: 32px;
    }

    .btn-model-select,
    .btn-prompt-select {
        padding: 10px 14px;
        font-size: 13px;
    }

    .modal-body .btn-primary {
        padding: 12px 20px;
        font-size: 14px;
    }
    
    .modal-footer {
        padding: 12px 16px;
    }
    
    .custom-dialog-modal {
        max-width: 90vw !important;
        min-width: 300px;
        margin: 0 16px;
    }
    
    .modal-footer .btn-secondary,
    .modal-footer .btn-primary {
        padding: 10px 20px;
        font-size: 13px;
    }
    
    .custom-modal-content {
        max-width: 90vw !important;
        margin: 0 16px;
    }
    
    .custom-modal-header {
        padding: 16px 20px;
    }
    
    .custom-modal-close {
        width: 32px;
        height: 32px;
        right: 16px;
    }
    
    .custom-modal-body {
        padding: 16px;
    }
    
    .custom-modal-footer {
        padding: 12px 16px;
    }
    
    .custom-modal-footer .btn-secondary,
    .custom-modal-footer .btn-primary {
        padding: 10px 20px;
        font-size: 13px;
    }
    
    .mention-reference-list {
        grid-template-columns: 1fr;
        max-height: 300px;
    }
    
    .mention-item {
        padding: 10px;
    }
}
