/* =========================================================
   在线Prompt优化工具 - online_prompt_optimization.css
   前缀：opo-
   ========================================================= */

@keyframes opo-fadein {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes opo-card-in {
    from { opacity: 0; transform: translateY(10px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes opo-spin {
    to { transform: rotate(360deg); }
}

/* Tab内容切换动画 */
.opo-tab-content {
    min-height: 0;
}
.opo-tab-anim {
    animation: opo-fadein 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

/* =========================================================
   容器
   ========================================================= */
.opo-container {
    padding: 16px 20px;
    min-height: 480px;
}

/* =========================================================
   Tab 导航
   ========================================================= */
.opo-tab-nav {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid #e5e7eb;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.opo-tab-btn {
    padding: 9px 20px;
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    border-radius: 6px 6px 0 0;
    transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

.opo-tab-btn:hover {
    color: #3b82f6;
    background: #eff6ff;
    transform: translateY(-1px);
}

.opo-tab-btn.active {
    color: #2563eb;
    border-bottom-color: #2563eb;
    background: linear-gradient(to bottom, #eff6ff, #dbeafe);
    font-weight: 600;
}

/* =========================================================
   表单通用
   ========================================================= */
.opo-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
}

.opo-form-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.opo-label {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}

.opo-required {
    color: #ef4444;
    margin-left: 2px;
}

.opo-optional {
    color: #9ca3af;
    font-size: 12px;
    font-weight: normal;
}

.opo-textarea {
    width: 100%;
    padding: 10px 13px;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    color: #1f2937;
    background: #fafafa;
    resize: vertical;
    min-height: 120px;
    box-sizing: border-box;
    font-family: inherit;
    line-height: 1.6;
    transition: border-color 0.22s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.22s cubic-bezier(0.4, 0, 0.2, 1),
                background 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

.opo-textarea:focus {
    outline: none;
    border-color: #3b82f6;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.13);
}

.opo-char-count {
    font-size: 12px;
    color: #9ca3af;
    text-align: right;
    margin-top: 2px;
    transition: color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.opo-char-count.opo-char-warn  { color: #d97706; font-weight: 600; }
.opo-char-count.opo-char-danger { color: #dc2626; font-weight: 600; }

/* =========================================================
   任务类型选择器
   ========================================================= */
.opo-task-types {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.opo-task-btn {
    padding: 6px 14px;
    font-size: 13px;
    color: #6b7280;
    background: #f3f4f6;
    border: 1.5px solid #e5e7eb;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    font-weight: 500;
}

.opo-task-btn:hover {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #2563eb;
}

.opo-task-btn.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.28);
}

/* =========================================================
   优化目标复选框
   ========================================================= */
.opo-goals {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.opo-goal-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    color: #374151;
    cursor: pointer;
    padding: 5px 12px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
}

.opo-goal-item:hover {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1d4ed8;
}

.opo-goal-item input[type="checkbox"] {
    accent-color: #2563eb;
    width: 14px;
    height: 14px;
    cursor: pointer;
}

/* =========================================================
   操作按钮区
   ========================================================= */
.opo-form-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    padding-top: 2px;
}

/* =========================================================
   加载中
   ========================================================= */
.opo-loading {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 28px;
    color: #6b7280;
    font-size: 14px;
    justify-content: center;
    margin: 8px 0;
    background: linear-gradient(135deg, #f0f9ff, #f9fafb);
    border: 1px dashed #bfdbfe;
    border-radius: 10px;
}

.opo-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: opo-spin 0.8s linear infinite;
    flex-shrink: 0;
}

/* =========================================================
   优化结果
   ========================================================= */
.opo-result {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.07), 0 1px 4px rgba(0, 0, 0, 0.04);
    animation: opo-card-in 0.32s cubic-bezier(0.4, 0, 0.2, 1);
    margin-top: 4px;
}

.opo-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 100%);
    border-bottom: 1px solid #e5e7eb;
}

.opo-result-title {
    font-size: 15px;
    font-weight: 600;
    color: #1f2937;
}

.opo-result-actions {
    display: flex;
    gap: 8px;
}

.opo-action-btn {
    padding: 5px 14px;
    font-size: 12px;
    color: #2563eb;
    background: #fff;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    font-weight: 500;
}

.opo-action-btn:hover {
    background: #dbeafe;
    border-color: #60a5fa;
    color: #1d4ed8;
}

/* 对比展示 */
.opo-compare {
    display: grid;
    grid-template-columns: 1fr 40px 1fr;
    gap: 0;
    padding: 16px 18px;
    border-bottom: 1px solid #f3f4f6;
    align-items: start;
}

.opo-compare-col {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.opo-compare-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 4px;
    display: inline-block;
    width: fit-content;
}

.opo-label-before {
    color: #92400e;
    background: #fef3c7;
}

.opo-label-after {
    color: #065f46;
    background: #d1fae5;
}

.opo-compare-text {
    font-size: 13px;
    color: #374151;
    line-height: 1.65;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 7px;
    padding: 10px 12px;
    white-space: pre-wrap;
    word-break: break-word;
    min-height: 60px;
}

.opo-text-after {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #1f2937;
}

.opo-compare-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #9ca3af;
    margin-top: 28px;
    font-weight: bold;
}

/* 优化说明 */
.opo-improvements {
    padding: 14px 18px;
    border-bottom: 1px solid #f3f4f6;
}

.opo-improvements-title {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
}

.opo-improvements-content {
    font-size: 13px;
    color: #4b5563;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
}

/* =========================================================
   原始AI回复
   ========================================================= */
.opo-raw-wrap {
    padding: 10px 18px 14px;
}

.opo-raw-toggle {
    background: transparent;
    border: none;
    font-size: 12px;
    color: #9ca3af;
    cursor: pointer;
    padding: 0;
    transition: color 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

.opo-raw-toggle:hover {
    color: #3b82f6;
}

.opo-raw {
    margin-top: 8px;
    padding: 10px 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 12px;
    color: #475569;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 200px;
    overflow-y: auto;
}

/* =========================================================
   快捷键提示栏
   ========================================================= */
.opo-shortcut-bar {
    display: flex;
    gap: 16px;
    padding: 6px 12px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 7px;
    margin-bottom: 12px;
    font-size: 12px;
    color: #6b7280;
    flex-wrap: wrap;
    align-items: center;
}

.opo-shortcut-item {
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.opo-kbd {
    display: inline-flex;
    align-items: center;
    padding: 1px 6px;
    background: #fff;
    border: 1px solid #d1d5db;
    border-bottom-width: 2px;
    border-radius: 4px;
    font-size: 11px;
    font-family: 'Consolas', 'Menlo', monospace;
    color: #374151;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

/* =========================================================
   Prompt模板
   ========================================================= */
.opo-templates-intro {
    padding: 12px 16px;
    background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 100%);
    border-radius: 8px;
    border: 1px solid #bfdbfe;
    margin-bottom: 14px;
    color: #374151;
    font-size: 13px;
    line-height: 1.55;
}

.opo-templates-intro p {
    margin: 0;
}

.opo-cat-bar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.opo-cat-btn {
    padding: 5px 14px;
    font-size: 13px;
    color: #6b7280;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
    white-space: nowrap;
}

.opo-cat-btn:hover {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #2563eb;
}

.opo-cat-btn.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

.opo-template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.opo-tpl-card {
    background: #fff;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    padding: 14px 16px;
    cursor: pointer;
    transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.opo-tpl-card:hover {
    border-color: #93c5fd;
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.14);
    transform: translateY(-3px);
}

.opo-tpl-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.opo-tpl-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.opo-tpl-name {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    flex: 1;
}

.opo-tpl-cat-tag {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    background: #eff6ff;
    color: #2563eb;
    white-space: nowrap;
    font-weight: 500;
}

.opo-tpl-desc {
    font-size: 12px;
    color: #6b7280;
    line-height: 1.55;
}

.opo-tpl-preview {
    font-size: 12px;
    color: #374151;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 8px 10px;
    line-height: 1.55;
    max-height: 70px;
    overflow: hidden;
    white-space: pre-wrap;
    word-break: break-word;
}

.opo-tpl-actions {
    display: flex;
    gap: 8px;
    margin-top: 2px;
}

.opo-tpl-use-btn {
    flex: 1;
    padding: 6px 0;
    font-size: 12px;
    color: #fff;
    background: #2563eb;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

.opo-tpl-use-btn:hover {
    background: #1d4ed8;
}

.opo-tpl-copy-btn {
    padding: 6px 14px;
    font-size: 12px;
    color: #374151;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

.opo-tpl-copy-btn:hover {
    background: #e5e7eb;
}

/* =========================================================
   深度分析
   ========================================================= */
.opo-analyze-result {
    animation: opo-card-in 0.32s cubic-bezier(0.4, 0, 0.2, 1);
    margin-top: 4px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* 评分面板 */
.opo-score-panel {
    background: linear-gradient(135deg, #fff 60%, #f0f9ff 100%);
    border: 1px solid #e0eeff;
    border-radius: 14px;
    padding: 16px 20px;
    display: flex;
    gap: 20px;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.opo-score-circle-wrap {
    position: relative;
    width: 100px;
    height: 100px;
    flex-shrink: 0;
}

.opo-score-svg {
    width: 100px;
    height: 100px;
    transform: rotate(-90deg);
}

.opo-score-track {
    fill: none;
    stroke: #f3f4f6;
    stroke-width: 10;
}

.opo-score-ring {
    fill: none;
    stroke: var(--opo-ring-color, #3b82f6);
    stroke-width: 10;
    stroke-linecap: round;
    stroke-dasharray: 251.2;
    stroke-dashoffset: var(--opo-ring-offset, 251.2);
    transition: stroke-dashoffset 0.7s cubic-bezier(0.4, 0, 0.2, 1),
                stroke 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.opo-score-inner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
}

.opo-score-num {
    font-size: 24px;
    font-weight: 700;
    color: #1f2937;
    line-height: 1;
}

.opo-score-sub {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 2px;
}

/* 评分颜色主题（高分绿/中分橙/低分红） */
.opo-score-good .opo-score-num   { color: #16a34a; }
.opo-score-warning .opo-score-num { color: #d97706; }
.opo-score-danger .opo-score-num  { color: #dc2626; }

/* 评分维度 */
.opo-score-dims {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 11px;
    min-width: 0;
}

.opo-dim-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.opo-dim-name {
    font-size: 12px;
    color: #6b7280;
    width: 60px;
    flex-shrink: 0;
    font-weight: 500;
}

.opo-dim-bar-wrap {
    flex: 1;
    height: 8px;
    background: #f3f4f6;
    border-radius: 6px;
    overflow: hidden;
    min-width: 0;
}

.opo-dim-bar {
    height: 100%;
    width: 100%;
    border-radius: 6px;
    background: var(--opo-dim-color, linear-gradient(90deg, #60a5fa, #3b82f6));
    transform: scaleX(var(--opo-dim-scale, 0));
    transform-origin: left center;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.opo-dim-val {
    font-size: 13px;
    font-weight: 600;
    color: #1f2937;
    width: 22px;
    text-align: right;
    flex-shrink: 0;
}

/* 发现问题 & 优化建议 */
.opo-section {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.04);
}

.opo-section-title {
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    background: linear-gradient(to bottom, #f9fafb, #f3f4f6);
    border-bottom: 1px solid #e5e7eb;
}

.opo-issues-list,
.opo-suggestions-list {
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.opo-issue-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 10px;
    background: #fff5f5;
    border: 1px solid #fecaca;
    border-radius: 7px;
    font-size: 13px;
    color: #7f1d1d;
    line-height: 1.55;
    animation: opo-fadein 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.opo-issue-icon {
    flex-shrink: 0;
    font-size: 14px;
    margin-top: 1px;
}

.opo-suggestion-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 10px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 7px;
    font-size: 13px;
    color: #14532d;
    line-height: 1.55;
    animation: opo-fadein 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.opo-suggestion-icon {
    flex-shrink: 0;
    font-size: 14px;
    margin-top: 1px;
}

/* 发送到优化区域 */
.opo-send-optimize {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0 4px;
    flex-wrap: wrap;
}

.opo-send-tip {
    font-size: 12px;
    color: #9ca3af;
}

/* =========================================================
   Toast 通知
   ========================================================= */
.opo-toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 11px 24px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    background: #1f2937;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.22);
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    max-width: 90vw;
    overflow: hidden;
    text-overflow: ellipsis;
}

.opo-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* 淡出状态：CSS class控制，逆向回到隐藏状态 */
.opo-toast.show.opo-toast-out {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
}

.opo-toast.toast-success { background: #16a34a; }
.opo-toast.toast-warning { background: #d97706; }
.opo-toast.toast-error   { background: #dc2626; }
.opo-toast.toast-info    { background: #2563eb; }

/* =========================================================
   响应式
   ========================================================= */
@media (max-width: 768px) {
    .opo-container {
        padding: 12px 14px;
    }

    .opo-shortcut-bar {
        display: none;
    }

    .opo-compare {
        grid-template-columns: 1fr;
    }

    .opo-compare-arrow {
        margin-top: 0;
        transform: rotate(90deg);
    }

    .opo-score-panel {
        flex-direction: column;
        align-items: center;
        gap: 18px;
    }

    .opo-score-dims {
        width: 100%;
    }

    .opo-result-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .opo-template-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .opo-tab-btn {
        padding: 7px 12px;
        font-size: 13px;
    }

    .opo-form-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .opo-form-actions .button,
    .opo-form-actions .secondary {
        width: 100%;
        text-align: center;
    }

    .opo-task-types {
        gap: 5px;
    }

    .opo-task-btn {
        padding: 5px 10px;
        font-size: 12px;
    }
}

/* 剪贴板辅助元素（不可见） */
.opo-clipboard-helper {
    position: fixed;
    top: -9999px;
    left: -9999px;
    opacity: 0;
    pointer-events: none;
}

/* 模板空状态提示 */
.opo-empty-tip {
    padding: 40px 24px;
    color: #9ca3af;
    font-size: 14px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.opo-empty-tip::before {
    content: '💭';
    font-size: 28px;
    opacity: 0.6;
}

/* =========================================================
   隐藏辅助类（必须置于最末尾）
   ========================================================= */
.opo-hidden {
    display: none;
}
