/* =============================================
   生成点评意见 - feedback_generation.css
   参考 svg_editor 风格，三栏布局
   ============================================= */

/* ========== 主容器 ========== */
.fg-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
    min-height: 600px;
    background: #f8fafc;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

/* 全屏模式 */
.fg-container.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9999;
    border-radius: 0;
    margin: 0;
    min-height: unset;
}

/* ========== 顶部工具栏 ========== */
.fg-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    flex-wrap: wrap;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    flex-shrink: 0;
}

/* 工具栏标题 */
.fg-toolbar .toolbar-title {
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.92);
    letter-spacing: 0.5px;
    margin-right: 8px;
}

.toolbar-group {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
    min-height: 28px;
}

.toolbar-btn {
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.92);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: #667eea;
    transition: all 0.2s;
    white-space: nowrap;
}

.toolbar-btn:hover:not(:disabled) {
    background: #fff;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

.toolbar-btn:active:not(:disabled) {
    transform: translateY(0);
}

.toolbar-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* 主操作按钒（生成点评） */
.toolbar-btn-primary {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(249, 115, 22, 0.4);
}

.toolbar-btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #fb923c 0%, #f97316 100%);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.5);
    color: #fff;
}

/* ========== Shake 抖动动画（校验错误提示） ========== */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 50%, 90% { transform: translateX(-5px); }
    30%, 70% { transform: translateX(5px); }
}

.fg-input.shake,
.fg-select.shake,
.fg-textarea.shake {
    animation: shake 0.5s ease-in-out;
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12) !important;
}

/* ========== 主内容区：三栏 ========== */
.fg-main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    background: #f8fafc;
}

/* ========== 左栏：历史记录 ========== */
.fg-history-panel {
    width: 210px;
    flex-shrink: 0;
    background: #fff;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.history-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    background: linear-gradient(to bottom, #fafafa 0%, #f5f5f5 100%);
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.history-panel-header h3 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
}

/* 历史条数计数 */
.history-count {
    font-size: 11px;
    color: #94a3b8;
    font-weight: 400;
}

.history-clear-btn {
    background: #fff0f0;
    border: none;
    color: #ef4444;
    font-size: 11px;
    cursor: pointer;
    padding: 2px 7px;
    border-radius: 3px;
    transition: background 0.2s;
    white-space: nowrap;
}

.history-clear-btn:hover {
    background: #fde8e8;
}

.history-search {
    padding: 8px;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.history-search input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    font-size: 12px;
    outline: none;
    transition: all 0.2s;
    box-sizing: border-box;
    color: #374151;
}

.history-search input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
}

/* 自定义滚动条：宽度4px，hover轨道橙色 */
.history-list::-webkit-scrollbar {
    width: 4px;
}
.history-list::-webkit-scrollbar-track {
    background: transparent;
    transition: background 0.2s;
}
.history-list:hover::-webkit-scrollbar-track {
    background: #fff3e8;
}
.history-list::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 2px;
}
.history-list::-webkit-scrollbar-thumb:hover {
    background: #f97316;
}

.history-empty {
    text-align: center;
    color: #94a3b8;
    font-size: 12px;
    padding: 24px 8px;
    user-select: none;
}

.history-item {
    display: flex;
    flex-direction: column;
    padding: 9px 11px;
    margin: 3px 0;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    animation: hiFadeIn 0.2s ease;
}

@keyframes hiFadeIn {
    from { opacity: 0; transform: translateX(-4px); }
    to   { opacity: 1; transform: translateX(0); }
}

.history-item:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    transform: translateX(2px);
}

.history-item.active {
    background: #eef2ff;
    border-color: #818cf8;
    box-shadow: 0 1px 3px rgba(99, 102, 241, 0.18);
}

.history-item-del {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 18px;
    height: 18px;
    background: #fde8e8;
    color: #ef4444;
    border: none;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s;
    padding: 0;
    line-height: 1;
}

.history-item:hover .history-item-del {
    opacity: 1;
}

.history-item-del:hover {
    background: #ef4444;
    color: #fff;
}

.history-item-subject {
    font-size: 12px;
    font-weight: 600;
    color: #1e293b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 20px;
    margin-bottom: 2px;
}

.history-item-type {
    font-size: 11px;
    color: #667eea;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-item-time {
    font-size: 10px;
    color: #94a3b8;
}

/* ========== 中栏：表单输入 ========== */
.fg-input-panel {
    width: 380px;
    flex-shrink: 0;
    background: #fff;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ========== 右栏：结果展示 ========== */
.fg-result-panel {
    flex: 1;
    background: #fff;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 300px;
}

/* ========== 通用面板头部 ========== */
.panel-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: linear-gradient(to bottom, #fafafa 0%, #f5f5f5 100%);
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.panel-header h3 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    white-space: nowrap;
}

.panel-tip {
    font-size: 11px;
    color: #94a3b8;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.result-meta {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;     /* 允许在窄屏下收缩，防止溢出 */
    flex-shrink: 1;
    overflow: hidden;
}

.result-char-count {
    font-size: 11px;
    color: #94a3b8;
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 10px;
    transition: color 0.2s, background 0.2s;
}

/* 评价对象/场景标签 */
.result-meta-subject {
    font-size: 11px;
    color: #667eea;
    background: #eef2ff;
    padding: 2px 10px;
    border-radius: 10px;
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 1;
}

/* 生成时间标签 */
.result-time {
    font-size: 11px;
    color: #94a3b8;
    white-space: nowrap;
    flex-shrink: 0;
}

/* 多级色标预警：<4000蓝色，4000-8000橙色，>8000红色 */
.result-char-count.count-normal  { color: #3b82f6; background: #eff6ff; }
.result-char-count.count-warning { color: #f97316; background: #fff7ed; }
.result-char-count.count-danger  { color: #ef4444; background: #fef2f2; font-weight: 600; }

/* ========== 表单区域 ========== */
.fg-input-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* 表单滚动条 */
.fg-input-body::-webkit-scrollbar { width: 4px; }
.fg-input-body::-webkit-scrollbar-track { background: transparent; }
.fg-input-body:hover::-webkit-scrollbar-track { background: #fff3e8; }
.fg-input-body::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 2px; }
.fg-input-body::-webkit-scrollbar-thumb:hover { background: #f97316; }

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 5px;
}

.required-mark {
    color: #ef4444;
    margin-left: 2px;
}

.label-tip {
    font-size: 11px;
    font-weight: 400;
    color: #9ca3af;
}

.fg-input,
.fg-select,
.fg-textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    font-size: 13px;
    color: #374151;
    background: #fafafa;
    outline: none;
    transition: all 0.2s;
    box-sizing: border-box;
    font-family: inherit;
}

.fg-input:focus,
.fg-select:focus,
.fg-textarea:focus {
    border-color: #667eea;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* 输入框 hover 状态 */
.fg-input:hover:not(:focus),
.fg-select:hover:not(:focus),
.fg-textarea:hover:not(:focus) {
    border-color: #c7d2e0;
    background: #fff;
}

.fg-input::placeholder,
.fg-textarea::placeholder {
    color: #b0b7c3;
}

.fg-textarea {
    resize: vertical;
    min-height: 100px;
    line-height: 1.6;
}

/* Ctrl+Enter 快捷键提示 与 背景字数统计 */
.fg-textarea-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
}

.fg-textarea-hint {
    font-size: 11px;
    color: #b0b7c3;
    user-select: none;
}

.bg-char-count {
    font-size: 11px;
    color: #b0b7c3;
    transition: color 0.2s;
}

.bg-char-count.warn   { color: #f97316; font-weight: 600; }
.bg-char-count.danger { color: #ef4444; font-weight: 600; }

/* textarea 滚动条 */
.fg-textarea::-webkit-scrollbar { width: 4px; }
.fg-textarea::-webkit-scrollbar-track { background: transparent; }
.fg-textarea:hover::-webkit-scrollbar-track { background: #fff3e8; }
.fg-textarea::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 2px; }
.fg-textarea::-webkit-scrollbar-thumb:hover { background: #f97316; }

.fg-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239ca3af'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
}

.form-row {
    display: flex;
    gap: 10px;
}

.form-group-half {
    flex: 1;
    min-width: 0;
}

/* ========== 结果内容区域 增强视觉 ========== */
.fg-result-body {
    flex: 1;
    overflow-y: auto;
    position: relative;
    display: flex;
    flex-direction: column;
    background: #fff;
}

/* 结果区滚动条 */
.fg-result-body::-webkit-scrollbar { width: 4px; }
.fg-result-body::-webkit-scrollbar-track { background: transparent; }
.fg-result-body:hover::-webkit-scrollbar-track { background: #fff3e8; }
.fg-result-body::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 2px; }
.fg-result-body::-webkit-scrollbar-thumb:hover { background: #f97316; }

/* 占位提示 */
.result-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    text-align: center;
    color: #94a3b8;
    user-select: none;
}

.placeholder-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.placeholder-title {
    font-size: 15px;
    font-weight: 600;
    color: #64748b;
    margin: 0 0 8px;
}

.placeholder-desc {
    font-size: 13px;
    color: #94a3b8;
    margin: 4px 0;
    line-height: 1.6;
}

/* 加载动画 */
.result-loading {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    text-align: center;
}

.loading-dots {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
}

.loading-dots span {
    width: 10px;
    height: 10px;
    background: #667eea;
    border-radius: 50%;
    display: inline-block;
    animation: dotPulse 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
    40% { transform: scale(1.1); opacity: 1; }
}

.loading-text {
    font-size: 13px;
    color: #667eea;
    margin: 0;
}

/* 结果内容 */
.result-content {
    flex: 1;
    min-height: 0; /* 防止 flex 容器压缩内容被裁切 */
    padding: 24px 28px;
    font-size: 14px;
    line-height: 2.0;
    color: #374151;
    white-space: pre-wrap;
    word-break: break-word;
    animation: resultFadeIn 0.4s ease;
    border-left: 3px solid #818cf8; /* 加深为可见的 indigo 色调左边框 */
}

@keyframes resultFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* 错误状态下隐藏左边框，并改为 flex 列布局使错误块可垂直居中 */
.result-content.result-content--error {
    border-left: none;
    display: flex;
    flex-direction: column;
    padding: 0;
}

/* 错误状态展示块 */
.result-error-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    text-align: center;
    flex: 1;
}

.result-error-icon {
    font-size: 40px;
    margin-bottom: 16px;
    color: #f87171;
    line-height: 1;
}

.result-error-title {
    font-size: 14px;
    font-weight: 600;
    color: #dc2626;
    margin: 0 0 8px;
}

.result-error-hint {
    font-size: 12px;
    color: #9ca3af;
    margin: 0;
}

/* ========== 示例模态框 ========== */
.fg-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 100000;
    backdrop-filter: blur(2px);
}

.fg-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100001;
    width: 90%;
    max-width: 720px;
    max-height: 82vh;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalSlideIn 0.22s ease-out;
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: translate(-50%, calc(-50% - 16px)); }
    to   { opacity: 1; transform: translate(-50%, -50%); }
}

/* 模态框内容层：flex 列布局 + 充满高度，保证 header 和 body 正确分配空间 */
.fg-modal-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.fg-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.fg-modal-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

.fg-modal-close {
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fg-modal-close:hover {
    background: rgba(255,255,255,0.3);
}

.fg-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 12px;
    align-content: start;
}

/* 模态框滚动条 */
.fg-modal-body::-webkit-scrollbar { width: 4px; }
.fg-modal-body::-webkit-scrollbar-track { background: transparent; }
.fg-modal-body:hover::-webkit-scrollbar-track { background: #fff3e8; }
.fg-modal-body::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 2px; }
.fg-modal-body::-webkit-scrollbar-thumb:hover { background: #f97316; }

/* 示例卡片 */
.example-card {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 14px;
    cursor: pointer;
    transition: all 0.2s;
    background: #fafafa;
    position: relative;
    overflow: hidden;
}

.example-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    opacity: 0;
    transition: opacity 0.2s;
}

.example-card:hover {
    border-color: #818cf8;
    background: #faf5ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.12);
}

.example-card:hover::before {
    opacity: 1;
}

.example-card-title {
    font-size: 13px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.example-card-badge {
    font-size: 10px;
    font-weight: 500;
    background: #eef2ff;
    color: #667eea;
    padding: 1px 6px;
    border-radius: 10px;
    white-space: nowrap;
}

.example-card-desc {
    font-size: 12px;
    color: #64748b;
    line-height: 1.5;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.example-card-import {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 10px;
    font-size: 11px;
    font-weight: 600;
    color: #667eea;
    background: #eef2ff;
    border: none;
    border-radius: 4px;
    padding: 3px 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.example-card-import:hover {
    background: #667eea;
    color: #fff;
}

/* ========== 响应式布局 ========== */
@media (max-width: 1024px) {
    .fg-input-panel {
        width: 320px;
    }
    .panel-tip {
        display: none;
    }
}

@media (max-width: 768px) {
    .fg-main-content {
        flex-direction: column;
        overflow-y: auto;
    }
    .fg-history-panel {
        width: 100%;
        max-height: 160px;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
    }
    .fg-input-panel {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
        max-height: 400px;
    }
    .fg-result-panel {
        width: 100%;
        min-height: 300px;
    }
    .form-row {
        flex-direction: column;
    }
    .fg-modal-body {
        grid-template-columns: 1fr;
    }
}

/* ========== 打印样式 ========== */
@media print {
    .fg-toolbar,
    .fg-history-panel,
    .fg-input-panel,
    #resultPlaceholder,
    #resultLoading {
        display: none !important;
    }
    .fg-container,
    .fg-container.fullscreen {
        position: static !important;
        height: auto;
        box-shadow: none;
    }
    .fg-main-content {
        display: block;
    }
    .fg-result-panel {
        width: 100%;
    }
    .fg-result-body {
        overflow: visible;
    }
    .result-content {
        padding: 0;
    }
}
