/* ============================================================================
 * Prompt 管理页面样式
 * Phase F · P2-B 渐进上线机制
 * 知音品牌色系 --primary: #F18D24, --secondary: #149EBB
 * ============================================================================ */

/* ==================== 主布局 ==================== */
.pm-container {
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
    background: #f5f6f8;
    min-height: calc(100vh - 60px);
}

.pm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.pm-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: #1f2937;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pm-header-actions {
    display: flex;
    gap: 8px;
}

.pm-header-stats {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: #6b7280;
}

.pm-header-stats span {
    background: #fff;
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid #e5e7eb;
}

/* ==================== 搜索 ==================== */
.pm-search {
    margin-bottom: 20px;
}

.pm-search input {
    width: 100%;
    max-width: 400px;
    padding: 10px 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 13px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.pm-search input:focus {
    outline: none;
    border-color: #f18d24;
    box-shadow: 0 0 0 3px rgba(241,141,36,0.1);
}

/* ==================== 场景卡片网格 ==================== */
.pm-scene-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
    gap: 16px;
}

.pm-scene-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border: 1px solid #e5e7eb;
    transition: box-shadow 0.2s, border-color 0.2s;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pm-scene-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.pm-scene-card.graying {
    border-color: #fcd34d;
    background: linear-gradient(135deg, #fff 0%, #fffbeb 100%);
}

.pm-scene-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.pm-scene-name {
    font-size: 15px;
    font-weight: 600;
    color: #1f2937;
}

.pm-scene-badges {
    display: flex;
    gap: 6px;
}

.pm-scene-version {
    font-size: 11px;
    color: #6b7280;
    background: #f3f4f6;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}

/* ==================== 灰度状态条 ==================== */
.pm-gray-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 8px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    transition: background 0.2s, border-color 0.2s;
}

.pm-gray-status.active {
    background: #fef3c7;
    border-color: #fcd34d;
}

.pm-gray-badge {
    font-size: 11px;
    font-weight: 500;
    padding: 2px 10px;
    border-radius: 10px;
    white-space: nowrap;
}

.pm-gray-badge.inactive {
    background: #d1fae5;
    color: #065f46;
}

.pm-gray-badge.active {
    background: #fbbf24;
    color: #78350f;
}

/* ==================== 灰度滑块 ==================== */
.pm-gray-slider {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.pm-gray-slider input[type="range"] {
    flex: 1;
    accent-color: #f18d24;
    height: 4px;
}

.pm-gray-value {
    font-size: 13px;
    font-weight: 600;
    color: #1f2937;
    min-width: 40px;
    text-align: right;
}

/* ==================== 操作按钮 ==================== */
.pm-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.pm-btn {
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    background: #fff;
    font-size: 12px;
    cursor: pointer;
    color: #374151;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.pm-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.pm-btn.primary {
    background: #f18d24;
    color: #fff;
    border-color: #f18d24;
}

.pm-btn.primary:hover {
    background: #d97706;
}

.pm-btn.danger {
    color: #dc2626;
    border-color: #fecaca;
}

.pm-btn.danger:hover {
    background: #fef2f2;
}

.pm-btn.success {
    color: #059669;
    border-color: #a7f3d0;
}

.pm-btn.success:hover {
    background: #ecfdf5;
}

.pm-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ==================== 编辑器布局 ==================== */
.pm-editor-container {
    display: flex;
    gap: 24px;
    height: calc(100vh - 150px);
    min-height: 500px;
}

.pm-editor-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.pm-editor-sidebar {
    width: 340px;
    flex-shrink: 0;
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border: 1px solid #e5e7eb;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pm-editor-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding: 12px 16px;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    flex-wrap: wrap;
    gap: 8px;
}

.pm-editor-toolbar .pm-editor-info {
    font-size: 13px;
    color: #6b7280;
}

.pm-editor-toolbar .pm-editor-info strong {
    color: #1f2937;
}

.pm-editor-textarea {
    flex: 1;
    width: 100%;
    min-height: 400px;
    padding: 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.6;
    resize: vertical;
    tab-size: 2;
}

.pm-editor-textarea:focus {
    outline: none;
    border-color: #f18d24;
    box-shadow: 0 0 0 3px rgba(241,141,36,0.1);
}

/* ==================== Diff 视图 ==================== */
.pm-diff-container {
    margin-top: 20px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
}

.pm-diff-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    font-size: 13px;
    color: #6b7280;
}

.pm-diff-header strong {
    color: #1f2937;
}

.pm-diff-content {
    background: #1e1e1e;
    padding: 16px;
    color: #d4d4d4;
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 12px;
    line-height: 1.8;
    max-height: 600px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

.pm-diff-add {
    color: #4ec9b0;
}

.pm-diff-remove {
    color: #f44747;
}

.pm-diff-same {
    color: #808080;
}

/* ==================== 版本列表 ==================== */
.pm-version-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.pm-version-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
    border: 1px solid transparent;
    margin-bottom: 4px;
}

.pm-version-item:hover {
    background: #f3f4f6;
}

.pm-version-item.selected {
    background: #fef3c7;
    border-color: #fcd34d;
}

.pm-version-num {
    font-weight: 600;
    font-size: 14px;
    color: #1f2937;
}

.pm-version-meta {
    font-size: 11px;
    color: #9ca3af;
}

.pm-version-tag {
    font-size: 10px;
    padding: 1px 8px;
    border-radius: 8px;
    font-weight: 500;
}

.pm-version-tag.gray {
    background: #fbbf24;
    color: #78350f;
}

.pm-version-tag.stable {
    background: #d1fae5;
    color: #065f46;
}

.pm-version-tag.latest {
    background: #dbeafe;
    color: #1e40af;
}

.pm-sidebar-title {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin: 0 0 4px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.pm-sidebar-section {
    padding-bottom: 12px;
    border-bottom: 1px solid #f3f4f6;
}

.pm-sidebar-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

/* ==================== 评测对比 ==================== */
.pm-eval-result {
    margin-top: 20px;
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    border: 1px solid #e5e7eb;
}

.pm-eval-scores {
    display: flex;
    gap: 24px;
    justify-content: center;
    margin: 16px 0;
    flex-wrap: wrap;
}

.pm-eval-score-card {
    text-align: center;
    padding: 16px 24px;
    border-radius: 10px;
    background: #f9fafb;
    border: 2px solid #e5e7eb;
    min-width: 140px;
}

.pm-eval-score-card .score {
    font-size: 32px;
    font-weight: 700;
    color: #1f2937;
}

.pm-eval-score-card .label {
    font-size: 12px;
    color: #6b7280;
    margin-top: 4px;
}

.pm-eval-score-card.winner {
    background: #d1fae5;
    border-color: #059669;
}

.pm-eval-score-card.loser {
    background: #fee2e2;
    border-color: #dc2626;
}

.pm-eval-verdict {
    text-align: center;
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 15px;
    margin-top: 16px;
}

.pm-eval-verdict.improved {
    background: #d1fae5;
    color: #065f46;
}

.pm-eval-verdict.degraded {
    background: #fee2e2;
    color: #991b1b;
}

/* ==================== 空状态 / 加载 ==================== */
.pm-empty {
    text-align: center;
    padding: 48px 24px;
    color: #9ca3af;
}

.pm-empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.pm-loading {
    text-align: center;
    padding: 48px 24px;
    color: #9ca3af;
}

/* ==================== 审计日志表格 ==================== */
.pm-audit-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.pm-audit-table th {
    text-align: left;
    padding: 8px 12px;
    border-bottom: 2px solid #e5e7eb;
    background: #f9fafb;
    color: #6b7280;
    font-weight: 500;
}

.pm-audit-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #f3f4f6;
    color: #374151;
}

.pm-audit-table tr:hover td {
    background: #f9fafb;
}

/* ==================== 一键回滚确认 ==================== */
.pm-rollback-dialog {
    padding: 16px;
    text-align: center;
}

.pm-rollback-dialog .warning-icon {
    font-size: 36px;
    margin-bottom: 12px;
}

.pm-rollback-dialog p {
    color: #6b7280;
    font-size: 14px;
    margin: 8px 0;
}

.pm-rollback-dialog .scene-name {
    font-weight: 600;
    color: #1f2937;
}

/* ==================== 阈值告警横幅 ==================== */
.pm-threshold-alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 20px;
    background: #fef2f2;
    border: 2px solid #f87171;
    border-radius: 10px;
    margin-bottom: 16px;
    animation: pmAlertPulse 0.6s ease;
}

.pm-threshold-alert-icon {
    font-size: 28px;
    flex-shrink: 0;
    line-height: 1;
}

.pm-threshold-alert-body {
    flex: 1;
}

.pm-threshold-alert-body strong {
    color: #991b1b;
    font-size: 15px;
}

.pm-threshold-alert-body p {
    margin: 4px 0 0;
    color: #b91c1c;
    font-size: 13px;
    line-height: 1.5;
}

@keyframes pmAlertPulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(248,113,113,0.4); }
    50% { transform: scale(1.01); box-shadow: 0 0 0 8px rgba(248,113,113,0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(248,113,113,0); }
}

/* ==================== F.6: 历史追溯面板 ==================== */

.pm-history-empty {
    text-align: center;
    padding: 48px 24px;
}

.pm-history-empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.pm-history-empty-title {
    font-size: 15px;
    font-weight: 600;
    color: #6b7280;
    margin: 0 0 8px;
}

.pm-history-empty-desc {
    font-size: 13px;
    color: #9ca3af;
    margin: 0;
    line-height: 1.6;
}

/* 最近版本对比 */
.pm-history-comparison {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 16px 20px;
    margin-bottom: 20px;
}

.pm-history-comp-title {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 12px;
}

.pm-history-comp-cards {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.pm-history-comp-card {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px 20px;
    text-align: center;
    min-width: 120px;
}

.pm-history-comp-ver {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 4px;
}

.pm-history-comp-score {
    font-size: 20px;
    font-weight: 700;
    color: #1f2937;
}

.pm-history-comp-trend {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    min-width: 80px;
}

.pm-history-comp-arrow {
    font-size: 20px;
    line-height: 1;
}

/* 趋势柱状图 */
.pm-history-chart-section {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 16px 20px;
    margin-bottom: 20px;
}

.pm-history-chart-title {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 16px;
}

.pm-history-chart {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 160px;
    padding: 0 8px;
    border-bottom: 1px solid #e5e7eb;
}

.pm-history-bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
    gap: 4px;
    min-width: 28px;
}

.pm-history-bar {
    width: 100%;
    max-width: 48px;
    border-radius: 4px 4px 0 0;
    min-height: 2px;
    transition: height 0.4s ease;
}

.pm-history-bar-val {
    font-size: 10px;
    color: #6b7280;
    font-weight: 500;
}

.pm-history-bar-label {
    font-size: 10px;
    color: #9ca3af;
    margin-top: 2px;
}

/* 版本详情表格 */
.pm-history-table-section {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 16px 20px;
}

.pm-history-table-title {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 12px;
}

.pm-history-table-wrap {
    overflow-x: auto;
}

.pm-history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.pm-history-table th {
    text-align: left;
    padding: 8px 12px;
    border-bottom: 2px solid #e5e7eb;
    background: #f9fafb;
    color: #6b7280;
    font-weight: 500;
    font-size: 12px;
    white-space: nowrap;
}

.pm-history-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f3f4f6;
    color: #374151;
}

.pm-history-row:hover td {
    background: #f9fafb;
}

.pm-history-cell-ver {
    font-weight: 600;
    color: #1f2937;
    white-space: nowrap;
}

.pm-history-cell-num {
    text-align: center;
    white-space: nowrap;
}

.pm-history-cell-summary {
    font-size: 12px;
    color: #6b7280;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ==================== 响应式 ==================== */
@media (max-width: 900px) {
    .pm-scene-grid {
        grid-template-columns: 1fr;
    }

    .pm-editor-container {
        flex-direction: column;
        height: auto;
    }

    .pm-editor-sidebar {
        width: 100%;
        max-height: 300px;
    }

    .pm-eval-scores {
        flex-direction: column;
        align-items: center;
    }

    .pm-history-comp-cards {
        flex-direction: column;
        align-items: center;
    }

    .pm-history-chart {
        height: 120px;
        gap: 4px;
    }

    .pm-history-bar-col {
        min-width: 20px;
    }
}

/* ==================== Toast ==================== */
.pm-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    animation: pmSlideIn 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.pm-toast.success {
    background: #059669;
    color: #fff;
}

.pm-toast.error {
    background: #dc2626;
    color: #fff;
}

.pm-toast.info {
    background: #149ebb;
    color: #fff;
}

@keyframes pmSlideIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}
