/* =============================================
   提示词模板 - prompt_template.css
   ============================================= */

/* --- 通用隐藏类 --- */
.pt-hidden {
    display: none;
}

/* --- 工具栏 --- */
.pt-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.pt-search-wrap {
    flex: 1;
    min-width: 200px;
    position: relative;
    display: flex;
    align-items: center;
}

.pt-search-icon {
    position: absolute;
    left: 10px;
    font-size: 14px;
    pointer-events: none;
    opacity: 0.5;
}

.pt-search-input {
    width: 100%;
    padding: 0 36px 0 36px;
    height: 40px;
    line-height: 40px;
    border: 1.5px solid #d1d5db;
    border-radius: 10px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fff;
    box-sizing: border-box;
}

.pt-search-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.pt-search-clear {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: #9ca3af;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.2s;
}

.pt-search-clear:hover {
    color: #374151;
}

.pt-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0 18px;
    height: 40px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    cursor: pointer;
    transition: box-shadow 0.2s, transform 0.15s;
    white-space: nowrap;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.pt-add-btn:hover {
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
    transform: translateY(-1px);
}

/* --- 分类标签 --- */
.pt-tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e5e7eb;
}

.pt-tab {
    padding: 6px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    background: #f9fafb;
    color: #374151;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    outline: none;
}

.pt-tab:hover {
    border-color: #6366f1;
    color: #6366f1;
    background: #f0f0ff;
}

.pt-tab.active {
    background: #6366f1;
    border-color: #6366f1;
    color: #fff;
    font-weight: 600;
}

.pt-tab-custom.active {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    border-color: #f59e0b;
}

.pt-stats-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    font-size: 13px;
    color: #6b7280;
}

.pt-stats-hint {
    font-size: 12px;
    color: #9ca3af;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* 键盘快捷键徽标样式 */
.pt-stats-hint kbd {
    display: inline-flex;
    align-items: center;
    padding: 1px 5px;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 11px;
    font-family: monospace;
    color: #374151;
    box-shadow: 0 1px 0 #c8cdd5;
    line-height: 1.4;
}

/* --- 模板卡片网格 --- */
.pt-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.pt-card {
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 14px 16px;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
    background: #fff;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
}

.pt-card:hover {
    border-color: #818cf8;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.16);
    transform: translateY(-3px);
}

.pt-card.active {
    border-color: #6366f1;
    background: linear-gradient(145deg, #f0f0ff 0%, #faf5ff 100%);
    box-shadow: 0 6px 24px rgba(99, 102, 241, 0.22);
    transform: translateY(-2px);
}

.pt-card-custom {
    border-color: #fde68a;
}

.pt-card-custom.active,
.pt-card-custom:hover {
    border-color: #f59e0b;
    box-shadow: 0 4px 16px rgba(245, 158, 11, 0.15);
}

.pt-card-header {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 6px;
}

.pt-card-icon {
    font-size: 22px;
    line-height: 1;
    flex-shrink: 0;
}

.pt-card-info {
    flex: 1;
    min-width: 0;
}

.pt-card-name {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pt-card-desc {
    font-size: 12px;
    color: #6b7280;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.pt-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
}

.pt-card-vars {
    font-size: 11px;
    color: #8b5cf6;
    background: #f3f0ff;
    padding: 2px 7px;
    border-radius: 10px;
    font-weight: 500;
}

.pt-card-cat {
    font-size: 11px;
    color: #9ca3af;
    background: #f3f4f6;
    padding: 2px 7px;
    border-radius: 10px;
}

.pt-card-del,
.pt-card-edit {
    position: absolute;
    background: none;
    border: none;
    font-size: 13px;
    cursor: pointer;
    padding: 2px 5px;
    border-radius: 4px;
    line-height: 1;
    transition: color 0.2s, background 0.2s;
    display: none;
}

.pt-card-del {
    top: 8px;
    right: 8px;
    color: #d1d5db;
}

.pt-card-edit {
    top: 8px;
    right: 34px;
    color: #c4b5fd;
}

.pt-card-custom:hover .pt-card-del,
.pt-card-custom.active .pt-card-del,
.pt-card-custom:hover .pt-card-edit,
.pt-card-custom.active .pt-card-edit {
    display: block;
}

.pt-card-del:hover {
    color: #ef4444;
    background: #fee2e2;
}

.pt-card-edit:hover {
    color: #7c3aed;
    background: #f3f0ff;
}

/* --- 空状态 --- */
.pt-empty {
    text-align: center;
    padding: 48px 20px;
    color: #6b7280;
}

.pt-empty-icon {
    font-size: 40px;
    margin-bottom: 12px;
}

.pt-empty-text {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 8px;
}

.pt-empty-hint {
    font-size: 13px;
    color: #9ca3af;
}

.pt-empty-hint a {
    color: #6366f1;
    text-decoration: none;
}

.pt-empty-hint a:hover {
    text-decoration: underline;
}

/* --- 编辑器面板 --- */
.pt-editor {
    border: 2px solid #6366f1;
    border-radius: 16px;
    background: #fff;
    margin-top: 8px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.15);
}

/* 入场动画通过添加/移除此类触发（支持重复动画）*/
.pt-editor.pt-editor-visible {
    animation: ptEditorIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes ptEditorIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.pt-editor-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 18px;
    background: linear-gradient(135deg, #5b5bd6 0%, #7c3aed 55%, #a855f7 100%);
    color: #fff;
}

.pt-editor-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.pt-editor-name {
    font-size: 16px;
    font-weight: 700;
    flex-shrink: 0;
}

.pt-editor-desc {
    font-size: 13px;
    opacity: 0.85;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pt-editor-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.pt-editor-reset,
.pt-editor-save-custom {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.4);
    color: #fff;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.pt-editor-reset:hover,
.pt-editor-save-custom:hover {
    background: rgba(255,255,255,0.35);
}

.pt-editor-close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    line-height: 1;
}

.pt-editor-close:hover {
    background: rgba(255,255,255,0.35);
}

.pt-editor-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    min-height: 360px;
}

.pt-editor-left {
    padding: 16px;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.pt-editor-right {
    padding: 16px;
    display: flex;
    flex-direction: column;
}

/* --- Section 通用 --- */
.pt-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* 合并唯一的 .pt-section-label 定义（含 justify-content: space-between 适配预览区标题行） */
.pt-section-label {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.pt-section-hint {
    font-size: 11px;
    color: #9ca3af;
    font-weight: 400;
}

/* 编辑器左侧区域的标题行添加左边界颜色标识 */
.pt-editor-left .pt-section-label {
    padding-left: 8px;
    border-left: 3px solid #6366f1;
    border-radius: 1px;
}
.pt-template-textarea {
    width: 100%;
    min-height: 130px;
    padding: 10px 12px;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.65;
    resize: vertical;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
    color: #374151;
    background: #fafafa;
}

.pt-template-textarea:focus {
    border-color: #6366f1;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* --- 变量网格 --- */
.pt-vars-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.pt-var-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.pt-var-item.pt-var-full {
    grid-column: span 2;
}

.pt-var-label {
    font-size: 12px;
    font-weight: 500;
    color: #4b5563;
    display: flex;
    align-items: center;
    gap: 4px;
}

.pt-var-badge {
    font-size: 10px;
    color: #8b5cf6;
    background: #f3f0ff;
    padding: 1px 5px;
    border-radius: 6px;
}

.pt-var-input {
    padding: 8px 10px;
    border: 1.5px solid #e5e7eb;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
    box-sizing: border-box;
    font-family: inherit;
    background: #fafafa;
}

.pt-var-input:focus {
    border-color: #6366f1;
    background: #fff;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
}

.pt-var-textarea {
    min-height: 72px;
    resize: vertical;
    line-height: 1.5;
}

/* 变量输入框高亮（未填写时边框提示） */
.pt-var-input.pt-var-empty {
    border-color: #fbbf24;
    background: #fffdf0;
}

/* --- 预览区 --- */
.pt-preview-section {
    flex: 1;
}

.pt-preview-btns {
    display: flex;
    gap: 6px;
}

.pt-btn-copy,
.pt-btn-send {
    padding: 5px 14px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.pt-btn-copy {
    background: #6366f1;
    color: #fff;
    box-shadow: 0 2px 6px rgba(99, 102, 241, 0.3);
}

.pt-btn-copy:hover {
    background: #4f46e5;
    box-shadow: 0 3px 10px rgba(99, 102, 241, 0.4);
    transform: translateY(-1px);
}

.pt-btn-send {
    background: #10b981;
    color: #fff;
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
}

.pt-btn-send:hover {
    background: #059669;
    box-shadow: 0 3px 10px rgba(16, 185, 129, 0.4);
    transform: translateY(-1px);
}

.pt-preview-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f8faff;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    min-height: 200px;
    transition: border-color 0.3s, box-shadow 0.3s;
}

/* 所有变量均已填写时，预览框绿色边框 */
.pt-preview-wrap.pt-preview-complete {
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
    background: #f0fdf8;
}

.pt-preview-text {
    flex: 1;
    padding: 12px 14px;
    font-size: 13px;
    line-height: 1.7;
    color: #374151;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-y: auto;
    max-height: 480px;
}

/* 预览文本区自定义滚动条 */
.pt-preview-text::-webkit-scrollbar {
    width: 4px;
}
.pt-preview-text::-webkit-scrollbar-track {
    background: transparent;
}
.pt-preview-text::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 2px;
}
.pt-preview-text::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* 未填写的变量高亮 */
.pt-preview-text .pt-unfilled {
    color: #ef4444;
    background: #fef2f2;
    padding: 0 2px;
    border-radius: 3px;
    font-weight: 600;
}

/* 已填写的变量高亮 */
.pt-preview-text .pt-filled {
    color: #059669;
    background: #ecfdf5;
    padding: 0 2px;
    border-radius: 3px;
}

.pt-preview-count {
    padding: 6px 14px;
    font-size: 11px;
    color: #9ca3af;
    border-top: 1px solid #e5e7eb;
    background: #f3f4f6;
    text-align: right;
}

/* --- 自定义模板弹窗 --- */
.pt-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(2px);
}

.pt-modal {
    background: #fff;
    border-radius: 18px;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 24px 72px rgba(0,0,0,0.22);
    animation: ptModalIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes ptModalIn {
    from { opacity: 0; transform: scale(0.94) translateY(8px); }
    to   { opacity: 1; transform: scale(1)   translateY(0); }
}

.pt-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 14px;
    border-bottom: 1px solid #e5e7eb;
}

.pt-modal-header span {
    font-size: 16px;
    font-weight: 700;
    color: #1f2937;
}

.pt-modal-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: #6b7280;
    line-height: 1;
    padding: 0;
    transition: color 0.2s;
}

.pt-modal-close:hover {
    color: #1f2937;
}

.pt-modal-body {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.pt-modal-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pt-modal-field label {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}

.pt-required {
    color: #ef4444;
}

.pt-modal-input {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.pt-modal-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

.pt-modal-icon-input {
    width: 60px;
    text-align: center;
    font-size: 18px;
}

.pt-emoji-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.pt-emoji-presets {
    display: flex;
    gap: 6px;
}

.pt-emoji-opt {
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: background 0.15s;
}

.pt-emoji-opt:hover {
    background: #f3f4f6;
}

.pt-modal-tpl-hint {
    font-size: 12px;
    color: #6b7280;
    background: #f9fafb;
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.pt-modal-tpl-hint code {
    background: #e0e7ff;
    color: #4f46e5;
    padding: 0 4px;
    border-radius: 3px;
    font-family: monospace;
}

.pt-modal-textarea {
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.6;
    resize: vertical;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
    width: 100%;
    box-sizing: border-box;
}

.pt-modal-textarea:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

.pt-modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px 18px;
    border-top: 1px solid #e5e7eb;
}

/* 弹窗底部快捷键提示 */
.pt-modal-shortcut {
    flex: 1;
    font-size: 12px;
    color: #9ca3af;
    display: flex;
    align-items: center;
    gap: 4px;
}

.pt-modal-shortcut kbd {
    display: inline-flex;
    align-items: center;
    padding: 1px 5px;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 11px;
    font-family: monospace;
    color: #374151;
    box-shadow: 0 1px 0 #c8cdd5;
    line-height: 1.4;
}

.pt-modal-cancel {
    padding: 8px 18px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    color: #374151;
    transition: background 0.2s;
}

.pt-modal-cancel:hover {
    background: #e5e7eb;
}

.pt-modal-save {
    padding: 8px 20px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border: none;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    color: #fff;
    font-weight: 600;
    transition: opacity 0.2s;
}

.pt-modal-save:hover {
    opacity: 0.9;
}

/* --- Toast --- */
.pt-toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 20px;
    border-radius: 24px;
    font-size: 13px;
    font-weight: 500;
    z-index: 9999;
    pointer-events: none;
    white-space: nowrap;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    transition: opacity 0.3s;
}

.pt-toast-success {
    background: #10b981;
    color: #fff;
}

.pt-toast-warning {
    background: #f59e0b;
    color: #fff;
}

.pt-toast-error {
    background: #ef4444;
    color: #fff;
}

/* --- 响应式 1024px --- */
@media (max-width: 1024px) {
    .pt-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}

/* --- 响应式 768px --- */
@media (max-width: 768px) {
    .pt-editor-body {
        grid-template-columns: 1fr;
    }

    .pt-editor-left {
        border-right: none;
        border-bottom: 1px solid #e5e7eb;
    }

    .pt-vars-grid {
        grid-template-columns: 1fr;
    }

    .pt-var-item.pt-var-full {
        grid-column: span 1;
    }

    .pt-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }
}

/* --- 响应式 640px --- */
@media (max-width: 640px) {
    .pt-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .pt-add-btn {
        width: 100%;
        justify-content: center;
    }

    .pt-tabs {
        gap: 4px;
    }

    .pt-tab {
        padding: 5px 10px;
        font-size: 12px;
    }

    .pt-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .pt-editor-header {
        flex-wrap: wrap;
    }

    .pt-editor-desc {
        display: none;
    }

    .pt-stats-hint {
        display: none;
    }

    .pt-toast {
        width: calc(100% - 32px);
        text-align: center;
        white-space: normal;
    }
}
