/**
 * 提示词管理页面样式
 * 
 * 支持黑白主题切换
 */

/* 基础变量 - 深色主题（默认） */
:root {
    --primary: #7c3aed;
    --primary-light: #8b5cf6;
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #252540;
    --bg-card: #1f2937;
    --bg-input: #2a2a45;
    --bg-hover: #303050;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-primary: #6366f1;
    --accent-secondary: #818cf8;
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;
    --border-color: #374151;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

/* 浅色主题 */
[data-theme="light"] {
    --primary: #7c3aed;
    --primary-light: #8b5cf6;
    --bg-primary: #f8fafc;
    --bg-secondary: #f1f5f9;
    --bg-tertiary: #e2e8f0;
    --bg-card: #ffffff;
    --bg-input: #e2e8f0;
    --bg-hover: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --accent-primary: #6366f1;
    --accent-secondary: #818cf8;
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* 基础重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: background 0.3s, color 0.3s;
}

/* 主题切换按钮 */
.theme-toggle {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 10px 14px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    border-color: var(--primary);
    color: var(--text-primary);
    background: var(--bg-hover);
}

/* 容器 */
.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 头部 - 紧凑模式 */
.header {
    display: none;
    /* 隐藏原头部，使用工具栏代替 */
}

/* icon-btn 样式（与其他页面一致） */
.icon-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    text-decoration: none;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

/* 工具栏 */
.toolbar {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    flex-shrink: 0;
}

.toolbar .logo {
    font-size: 1.1rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* 环境切换 */
.env-selector {
    display: flex;
    gap: 4px;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: 10px;
}

.env-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

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

.env-btn.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.env-btn.active[data-env="local"] .env-indicator {
    background: var(--accent-success);
}

.env-btn.active[data-env="prod"] .env-indicator {
    background: var(--accent-primary);
}

.env-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-secondary);
}

/* Tab 切换样式 */
.tab-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tab-header {
    display: flex;
    gap: 4px;
    padding: 0 0 12px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 16px;
}

.tab-btn {
    padding: 10px 24px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s;
}

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

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

.tab-content {
    display: none;
    flex: 1;
    overflow: hidden;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
}

/* 场景预览面板 */
.preview-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 16px;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.scene-selector {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.scene-selector select {
    min-width: 200px;
}

.scene-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-style: italic;
}

.prompts-used {
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.prompts-used label {
    color: var(--accent-success);
    font-weight: 500;
}

.prompt-tag {
    background: var(--accent-primary);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.85rem;
}

.preview-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 16px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.preview-box label {
    display: block;
    margin-bottom: 12px;
    font-weight: 600;
    color: var(--accent-secondary);
}

.preview-box pre {
    flex: 1;
    background: var(--bg-primary);
    border-radius: 6px;
    padding: 16px;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-primary);
    overflow-y: auto;
    margin: 0;
}

.filter-group,
.search-group,
.action-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-group label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.search-group {
    flex: 1;
}

.search-group input {
    width: 100%;
    max-width: 300px;
}

/* 表单控件 */
input[type="text"],
select,
textarea {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: all 0.2s;
}

input[type="text"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

input[type="text"]:disabled,
select:disabled,
textarea:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* 按钮 */
.btn {
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

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

.btn-secondary:hover:not(:disabled) {
    background: var(--border-color);
}

.btn-warning {
    background: var(--accent-warning);
    color: #1a1a2e;
}

.btn-warning:hover:not(:disabled) {
    background: #d97706;
}

/* 主内容区 */
.main-content {
    display: flex;
    gap: 20px;
    flex: 1;
    min-height: 0;
}

/* 左侧列表 */
.prompt-list {
    width: 360px;
    flex-shrink: 0;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.count-badge {
    background: var(--accent-primary);
    color: white;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
}

.list-container {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.prompt-item {
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 4px;
    border: 1px solid transparent;
}

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

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

.prompt-item .name {
    font-weight: 500;
    margin-bottom: 4px;
}

.prompt-item .meta {
    display: flex;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.prompt-item .category-tag {
    background: var(--bg-secondary);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
}

.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

/* 右侧编辑区 */
.prompt-editor {
    flex: 1;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.editor-header span {
    font-weight: 600;
}

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

.editor-form {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group.flex-grow {
    flex: 1;
    min-height: 200px;
}

.form-group label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group .hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
    opacity: 0.7;
}

.form-group textarea {
    flex: 1;
    resize: none;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
}

.info-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* 使用场景和组合说明（醒目样式，让员工易懂） */
.scenario-group,
.combo-group {
    background: var(--bg-tertiary);
    padding: 12px;
    border-radius: 8px;
    border-left: 4px solid var(--accent-primary);
}

.scenario-box,
.combo-box {
    color: var(--text-primary);
    font-size: 0.95rem;
    line-height: 1.6;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: 6px;
    margin-top: 8px;
}

.scenario-group label,
.combo-group label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent-secondary);
}

.combo-group {
    border-left-color: var(--accent-success);
}

.combo-group label {
    color: var(--accent-success);
}

/* Toast 提示 */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 14px 24px;
    border-radius: 8px;
    font-size: 0.9rem;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s;
    z-index: 1000;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.success {
    background: var(--accent-success);
    color: white;
}

.toast.error {
    background: var(--accent-danger);
    color: white;
}

.toast.warning {
    background: var(--accent-warning);
    color: #1a1a2e;
}

/* 滚动条 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

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

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

/* 响应式 */
@media (max-width: 1024px) {
    .main-content {
        flex-direction: column;
    }

    .prompt-list {
        width: 100%;
        max-height: 300px;
    }
}

/* ============ 抽屉组件样式 ============ */

/* 抽屉外层容器 */
.drawer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    visibility: hidden;
    pointer-events: none;
}

.drawer.open {
    visibility: visible;
    pointer-events: auto;
}

/* 半透明遮罩层 */
.drawer-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.drawer.open .drawer-overlay {
    opacity: 1;
}

/* 抽屉主体内容 */
.drawer-content {
    position: absolute;
    top: 0;
    right: 0;
    width: 500px;
    max-width: 90vw;
    height: 100%;
    background: var(--bg-card);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
}

.drawer.open .drawer-content {
    transform: translateX(0);
}

/* 抽屉头部 */
.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.drawer-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.drawer-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.drawer-close:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* 抽屉主体 */
.drawer-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* 抽屉底部 */
.drawer-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

/* 抽屉内的表单 */
.drawer-body .form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.drawer-body .form-group label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.drawer-body .form-group textarea {
    min-height: 300px;
    resize: vertical;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
}

/* 可点击的提示词标签 */
.prompt-tag.clickable {
    cursor: pointer;
    transition: all 0.2s;
}

.prompt-tag.clickable:hover {
    background: var(--accent-secondary);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}