:root {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --danger-color: #ef4444;
    --success-color: #22c55e;
    --warning-color: #f59e0b;
    
    --bg-color: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --border-color: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    
    --transition: all 0.2s ease;
    
    --sidebar-width: 260px;
    --panel-width: 320px;
    --header-height: 60px;
}

[data-theme="dark"] {
    --bg-color: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --border-color: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    transition: var(--transition);
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* 顶部导航 */
.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 1px;
}

.logo svg {
    flex-shrink: 0;
}

.logo span {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.project-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.project-name {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-secondary);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.project-actions {
    display: flex;
    gap: 4px;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 按钮样式 */
.btn {
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn:hover {
    background: var(--bg-tertiary);
}

.btn-primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 1rem;
}

.btn-icon:hover {
    background: var(--bg-tertiary);
}

.btn-danger {
    background: var(--danger-color);
    border-color: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

/* 主内容区 */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* 左侧边栏 */
.sidebar-left {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: var(--transition);
}

.sidebar-left.collapsed {
    width: 60px;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h3 {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.section-list {
    list-style: none;
    padding: 8px;
    overflow-y: auto;
    flex: 1;
}

.section-item {
    padding: 10px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: var(--transition);
    margin-bottom: 4px;
}

.section-item:hover {
    background: var(--bg-tertiary);
}

.section-item.active {
    background: var(--primary-color);
    color: white;
}

.section-item.dragging {
    opacity: 0.5;
}

.section-item.drag-over {
    border-top: 2px solid var(--primary-color);
}

.section-drag-handle {
    cursor: grab;
    padding: 4px;
    margin-right: 4px;
    color: var(--text-muted);
    font-size: 0.875rem;
    letter-spacing: 2px;
    user-select: none;
}

.section-drag-handle:hover {
    color: var(--text-primary);
}

.section-drag-handle:active {
    cursor: grabbing;
}

.section-item.active .section-drag-handle {
    color: rgba(255,255,255,0.7);
}

.section-item .section-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.section-item .section-count {
    font-size: 0.75rem;
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
}

.section-item.active .section-count {
    background: rgba(255,255,255,0.2);
}

.section-actions {
    display: none;
    gap: 4px;
}

.section-item:hover .section-actions {
    display: flex;
}

.section-item:hover .section-count {
    display: none;
}

.section-action-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.section-action-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* 中央编辑区 */
.editor-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-color);
}

.editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.editor-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
}

.editor-actions {
    display: flex;
    gap: 8px;
}

.prompt-list {
    flex: 1;
    padding: 16px 24px;
    overflow-y: auto;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
}

.empty-state.hidden {
    display: none;
}

.prompt-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 12px;
    transition: var(--transition);
    animation: slideIn 0.2s ease;
}

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

.prompt-card:hover {
    box-shadow: var(--shadow-md);
}

.prompt-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 8px;
}

.prompt-type {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
}

.prompt-type.positive {
    background: #dcfce7;
    color: #166534;
}

.prompt-type.negative {
    background: #fee2e2;
    color: #991b1b;
}

[data-theme="dark"] .prompt-type.positive {
    background: #166534;
    color: #dcfce7;
}

[data-theme="dark"] .prompt-type.negative {
    background: #991b1b;
    color: #fee2e2;
}

.prompt-actions {
    display: flex;
    gap: 4px;
}

.prompt-content {
    font-size: 0.9375rem;
    color: var(--text-primary);
    margin-bottom: 8px;
    line-height: 1.6;
}

.prompt-description {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-style: italic;
}

.prompt-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.prompt-weight {
    display: flex;
    align-items: center;
    gap: 4px;
}

.weight-slider {
    width: 80px;
    height: 4px;
    -webkit-appearance: none;
    background: var(--border-color);
    border-radius: 2px;
    outline: none;
}

.weight-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
}

/* 右侧面板 */
.sidebar-right {
    width: var(--panel-width);
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: var(--transition);
}

.sidebar-right.hidden {
    display: none;
}

.panel-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
}

.tab-btn {
    flex: 1;
    padding: 12px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 2px solid transparent;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-panel {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.tab-panel.active {
    display: flex;
}

.search-box {
    padding: 12px;
}

.search-box input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.875rem;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.library-categories {
    padding: 0 12px 12px;
}

.library-categories select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.875rem;
}

.library-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px;
}

.library-item {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}

.library-item:hover {
    border-color: var(--primary-color);
    background: var(--bg-tertiary);
}

.library-item.dragging {
    opacity: 0.5;
}

.library-item.drag-over {
    border-top: 2px solid var(--primary-color);
}

.library-drag-handle {
    cursor: grab;
    color: var(--text-muted);
    font-size: 1rem;
    padding: 4px;
    user-select: none;
}

.library-drag-handle:active {
    cursor: grabbing;
}

.library-item-content {
    flex: 1;
    min-width: 0;
}

.library-add-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-size: 1.2rem;
    display: none;
}

.library-add-btn:hover {
    background: var(--primary-color);
    color: white;
}

.library-delete-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-size: 1.2rem;
    display: none;
}

.library-item:hover .library-add-btn,
.library-item:hover .library-delete-btn {
    display: block;
}

.library-delete-btn:hover {
    background: var(--danger-color);
    color: white;
}

.library-item-title {
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 4px;
}

.library-item-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.library-item-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}

.tag {
    font-size: 0.625rem;
    padding: 2px 6px;
    background: var(--primary-color);
    color: white;
    border-radius: 10px;
}

.library-actions {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--border-color);
}

.library-actions .btn {
    flex: 1;
}

/* 预览面板 */
#previewPanel {
    padding: 16px;
}

.preview-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    line-height: 1.8;
    white-space: pre-wrap;
    word-break: break-word;
}

.preview-actions {
    padding-top: 12px;
}

.preview-actions .btn {
    width: 100%;
}

/* 模态框 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 560px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.2s ease;
}

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

.modal-content.modal-sm {
    max-width: 400px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    font-size: 1.5rem;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
}

.modal-footer .btn-danger {
    margin-right: auto;
}

/* 表单样式 */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-secondary);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.9375rem;
    transition: var(--transition);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group {
    flex: 1;
}

/* 导出选项 */
.export-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.export-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.export-option:hover {
    border-color: var(--primary-color);
    background: var(--bg-tertiary);
}

.export-icon {
    font-size: 1.5rem;
}

/* 项目列表 */
.project-list {
    margin-top: 16px;
    max-height: 300px;
    overflow-y: auto;
}

.project-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.project-item:hover {
    border-color: var(--primary-color);
}

.project-item.active {
    border-color: var(--primary-color);
    background: var(--bg-tertiary);
}

/* 智能推荐面板 */
.recommend-panel {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--shadow-lg);
    max-width: 600px;
    width: 90%;
    display: none;
    z-index: 100;
}

.recommend-panel.active {
    display: block;
    animation: slideUp 0.2s ease;
}

.recommend-panel h4 {
    font-size: 0.875rem;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

.recommend-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.recommend-item {
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: var(--transition);
}

.recommend-item:hover {
    background: var(--primary-color);
    color: white;
}

/* 拖拽排序 */
.dragging {
    opacity: 0.5;
}

.drag-over {
    border-top: 2px solid var(--primary-color);
}

/* 复选框样式 */
.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-wrapper input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .sidebar-right {
        width: 280px;
    }
}

@media (max-width: 768px) {
    .sidebar-left {
        position: fixed;
        left: -260px;
        top: var(--header-height);
        bottom: 0;
        z-index: 100;
        box-shadow: var(--shadow-lg);
    }
    
    .sidebar-left.open {
        left: 0;
    }
    
    .sidebar-right {
        position: fixed;
        right: -320px;
        top: var(--header-height);
        bottom: 0;
        z-index: 100;
        box-shadow: var(--shadow-lg);
    }
    
    .sidebar-right.open {
        right: 0;
    }
    
    .editor-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
    
    .nav-left {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* 工具提示 */
[title] {
    position: relative;
}

/* 选择文本样式 */
::selection {
    background: var(--primary-color);
    color: white;
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 通知提示 */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast.success {
    border-color: var(--success-color);
}

.toast.error {
    border-color: var(--danger-color);
}
