/**
 * TXT 文件行级批注系统样式
 * 复用 video_annotation.css 的主题系统
 */

/* ==================== 容器布局 ==================== */

.text-annotation-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.text-annotation-container .annotation-main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.text-annotation-container .annotation-left-panel {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.text-annotation-container .annotation-right-panel {
    width: 380px;
    flex-shrink: 0;
    border-left: 1px solid var(--border-color, rgba(255,255,255,0.08));
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ==================== 关闭按钮 ==================== */

.btn-close-annotation {
    background: var(--bg-muted, rgba(255, 255, 255, 0.08));
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.2));
    color: var(--text-secondary, #ccc);
    padding: 6px 16px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-close-annotation:hover {
    background: var(--bg-card-hover, rgba(255, 255, 255, 0.15));
    border-color: var(--border-color, rgba(255, 255, 255, 0.4));
    color: var(--text-primary, #fff);
}

.annotation-close-bar {
    padding: 8px 16px;
    display: flex;
    justify-content: flex-end;
    background: var(--bg-bar, rgba(0,0,0,0.2));
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.06));
}

/* ==================== 标题栏 ==================== */

.task-title-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-muted, rgba(255,255,255,0.04));
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.06));
}

.task-title-icon {
    font-size: 18px;
}

.task-title-text {
    font-size: 14px;
    color: var(--text-primary, #e0e0e0);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ==================== 文本内容区 ==================== */

.text-content-wrapper {
    flex: 1;
    overflow-y: auto;
    position: relative;
}

.text-content-wrapper::-webkit-scrollbar {
    width: 8px;
}

.text-content-wrapper::-webkit-scrollbar-track {
    background: var(--bg-muted, rgba(255,255,255,0.04));
}

.text-content-wrapper::-webkit-scrollbar-thumb {
    background: var(--scrollbar-color, rgba(255,255,255,0.15));
    border-radius: 4px;
}

.text-content-wrapper::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-hover, rgba(255,255,255,0.25));
}

/* 行号样式 */
.line-numbers {
    font-size: 13px;
    color: var(--text-tertiary, #555);
    user-select: none;
}

.line-numbers .line-number {
    padding: 0 8px 0 4px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    position: relative;
    min-height: 1.7em;
    line-height: 1.7em;
}

.line-numbers .line-number:hover {
    background: var(--bg-card-hover, rgba(255,255,255,0.06));
    color: var(--text-secondary, #aaa);
}

.line-numbers .line-number.selected {
    background: rgba(102, 126, 234, 0.3);
    color: #fff;
    font-weight: 600;
}

.line-numbers .line-number.has-annotation {
    color: var(--text-tertiary, #aaa);
}

/* 文本行样式 */
.text-lines .text-line {
    padding: 0 4px;
    min-height: 1.7em;
    line-height: 1.7em;
    border-radius: 2px;
    transition: background 0.15s;
}

.text-lines .text-line:hover {
    background: var(--bg-card-hover, rgba(255,255,255,0.03));
}

.text-lines .text-line.selected {
    background: rgba(102, 126, 234, 0.2);
}

/* ==================== 批注列表面板 ==================== */

.annotations-list-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--bg-panel, rgba(255,255,255,0.03));
}

.annotations-list-panel .panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.08));
}

.annotations-list-panel .panel-header h4 {
    margin: 0;
    font-size: 14px;
    color: var(--text-primary, #e0e0e0);
}

.panel-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.toggle-scroll-btn {
    background: var(--bg-muted, rgba(255,255,255,0.06));
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    color: var(--text-secondary, #aaa);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}

.toggle-scroll-btn:hover {
    background: var(--bg-card-hover, rgba(255,255,255,0.1));
    color: var(--text-primary, #fff);
}

.collapse-btn {
    background: var(--bg-muted, rgba(255,255,255,0.06));
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    color: var(--text-secondary, #aaa);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}

.collapse-btn:hover {
    background: var(--bg-card-hover, rgba(255,255,255,0.1));
    color: var(--text-primary, #fff);
}

/* 批注列表 */
.annotations-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.annotations-list::-webkit-scrollbar {
    width: 6px;
}

.annotations-list::-webkit-scrollbar-track {
    background: transparent;
}

.annotations-list::-webkit-scrollbar-thumb {
    background: var(--scrollbar-color, rgba(255,255,255,0.1));
    border-radius: 3px;
}

.empty-annotations {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-tertiary, #666);
    font-size: 13px;
}

/* 批注条目 */
.annotation-item {
    cursor: pointer;
}

.annotation-item:hover {
    background: var(--bg-card-hover, rgba(255,255,255,0.08)) !important;
}

/* 编辑/跳转按钮 */
.edit-annotation-btn {
    background: var(--bg-muted, rgba(255,255,255,0.06));
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    color: var(--text-secondary, #aaa);
    border-radius: 4px;
    cursor: pointer;
    padding: 2px 6px;
    font-size: 11px;
    transition: all 0.2s;
}

.edit-annotation-btn:hover {
    background: var(--bg-card-hover, rgba(255,255,255,0.15));
    color: var(--text-primary, #fff);
}

.goto-line-btn:hover {
    background: rgba(255,255,255,0.1) !important;
    color: #fff !important;
}

/* ==================== 主题切换器 ==================== */

.theme-switcher {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.06));
    background: var(--bg-muted, rgba(0,0,0,0.1));
}

.theme-label {
    font-size: 11px;
    color: var(--text-tertiary, #888);
    margin-right: 4px;
}

.theme-btn {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.theme-btn:hover {
    transform: scale(1.2);
}

.theme-btn.active {
    border-color: #fff;
    box-shadow: 0 0 6px rgba(255,255,255,0.4);
}

.theme-btn[data-theme="deep-space"] { background: linear-gradient(135deg, #0f172a, #1e293b); }
.theme-btn[data-theme="carbon-gray"] { background: linear-gradient(135deg, #2d3748, #4a5568); }
.theme-btn[data-theme="ink-purple"] { background: linear-gradient(135deg, #1a1a2e, #0f3460); }
.theme-btn[data-theme="minimal-white"] { background: linear-gradient(135deg, #f5f7fa, #e8ecf1); border: 1px solid #ccc; }

/* ==================== 评论区样式 ==================== */

.annotation-comments-section {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color, rgba(255,255,255,0.06));
}

.annotation-comment-item {
    padding: 3px 0;
    font-size: 12px;
    color: var(--text-secondary, #aaa);
    line-height: 1.5;
}

/* ==================== 底部状态栏 ==================== */

.text-status-bar {
    padding: 6px 16px;
    background: var(--bg-bar, rgba(0,0,0,0.3));
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 11px;
    color: var(--text-tertiary, #888);
    border-top: 1px solid var(--border-color, rgba(255,255,255,0.06));
}

/* ==================== 编辑器弹窗 ==================== */

.annotation-editor-overlay {
    animation: fadeIn 0.2s ease;
}

.annotation-editor-box {
    animation: slideUp 0.25s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 编辑器弹窗默认样式（深色主题） */
.annotation-editor-box {
    background: var(--bg-card, #1e293b);
    color: var(--text-primary, #e0e0e0);
}

.annotation-editor-box .editor-title {
    color: var(--text-primary, #fff);
}

.annotation-editor-box .editor-label {
    color: var(--text-tertiary, #aaa);
}

.annotation-editor-box .editor-input {
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    background: var(--bg-input, #2d3748);
    color: var(--text-primary, #fff);
}

.annotation-editor-box .editor-cancel-btn {
    border: 1px solid var(--border-color, rgba(255,255,255,0.2));
    background: transparent;
    color: var(--text-secondary, #aaa);
}

.btn-close-editor {
    color: var(--text-tertiary, #888);
}

.btn-close-editor:hover {
    color: var(--text-primary, #fff) !important;
}

/* ==================== 编辑器图片上传 ==================== */

.annotation-editor-box .image-upload-area {
    position: relative;
    border: 2px dashed var(--border-color, #d9d9d9);
    border-radius: 8px;
    padding: 16px;
    text-align: center;
    transition: all 0.3s;
    background: var(--bg-input, #fafafa);
    margin-bottom: 8px;
}

.annotation-editor-box .image-upload-area:hover {
    border-color: #1890ff;
    background: var(--bg-muted, #f0f7ff);
}

.annotation-editor-box .btn-upload-images {
    padding: 8px 16px;
    background: var(--bg-card-hover, #f0f0f0);
    border: 1px dashed var(--border-color, #d9d9d9);
    border-radius: 6px;
    color: var(--text-secondary, #666);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s linear;
}

.annotation-editor-box .btn-upload-images:hover {
    background: #e6f7ff;
    border-color: #1890ff;
    color: #1890ff;
}

.annotation-editor-box .image-preview-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}

.annotation-editor-box .image-preview-item {
    position: relative;
    width: 80px;
    height: 80px;
}

.annotation-editor-box .image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border-color, #d9d9d9);
}

.annotation-editor-box .remove-image-btn {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    background: #ff4d4f;
    border: 2px solid #fff;
    border-radius: 50%;
    color: #fff;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.annotation-editor-box .paste-hint {
    font-size: 12px;
    color: var(--text-tertiary, #999);
    margin-top: 8px;
}

/* 加载占位符 */
.text-loading-placeholder {
    color: var(--text-tertiary, #888);
}

/* ==================== 极简白主题覆盖 ==================== */

.theme-minimal-white {
    /* 覆盖 CSS 变量，让没有用变量的地方也能通过继承生效 */
    --text-primary: #2d3748;
    --text-secondary: #4a5568;
    --text-tertiary: #718096;
    --bg-card: rgba(0,0,0,0.04);
    --bg-card-hover: rgba(0,0,0,0.08);
    --bg-muted: rgba(0,0,0,0.05);
    --border-color: rgba(0,0,0,0.12);
    --bg-input: rgba(0,0,0,0.03);
    --bg-bar: rgba(0,0,0,0.04);
    --bg-panel: rgba(255,255,255,0.7);
    --scrollbar-color: rgba(0,0,0,0.15);
    --scrollbar-hover: rgba(0,0,0,0.25);
}

.theme-minimal-white .text-annotation-container {
    background: linear-gradient(135deg, #f5f7fa 0%, #e8ecf1 50%, #f5f7fa 100%);
    color: #2d3748;
}

.theme-minimal-white .annotation-close-bar {
    background: var(--bg-bar);
}

.theme-minimal-white .btn-close-annotation {
    background: rgba(0, 0, 0, 0.06);
    border-color: rgba(0, 0, 0, 0.15);
    color: #2d3748;
}

.theme-minimal-white .btn-close-annotation:hover {
    background: rgba(0, 0, 0, 0.12);
    border-color: rgba(0, 0, 0, 0.3);
}

.theme-minimal-white .task-title-bar {
    background: rgba(0,0,0,0.03);
    border-bottom-color: rgba(0,0,0,0.08);
}

.theme-minimal-white .task-title-text {
    color: #2d3748;
}

/* 工具栏 */
.theme-minimal-white .text-toolbar {
    background: rgba(0,0,0,0.03) !important;
    border-bottom-color: rgba(0,0,0,0.08) !important;
}

.theme-minimal-white .text-toolbar span,
.theme-minimal-white .text-toolbar label {
    color: #4a5568 !important;
}

.theme-minimal-white .text-toolbar #selectedLineInfo {
    color: #2d3748 !important;
}

/* 行号区域 */
.theme-minimal-white .line-numbers {
    background: rgba(0,0,0,0.03) !important;
    border-right-color: rgba(0,0,0,0.08) !important;
    color: #999 !important;
}

.theme-minimal-white .line-numbers .line-number {
    color: #999;
}

.theme-minimal-white .line-numbers .line-number:hover {
    background: rgba(0,0,0,0.05);
    color: #555;
}

.theme-minimal-white .line-numbers .line-number.selected {
    background: rgba(102, 126, 234, 0.15);
    color: #2d3748;
}

/* 文本内容 */
.theme-minimal-white .text-lines {
    color: #333 !important;
}

.theme-minimal-white .text-lines .text-line {
    color: #333;
}

.theme-minimal-white .text-lines .text-line.selected {
    background: rgba(102, 126, 234, 0.1);
}

/* 批注列表面板 */
.theme-minimal-white .annotations-list-panel,
.theme-minimal-white .annotation-history-panel {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
}

.theme-minimal-white .panel-header h4 {
    color: #2d3748;
}

.theme-minimal-white .panel-header {
    border-bottom-color: rgba(0,0,0,0.08);
}

.theme-minimal-white .collapse-btn,
.theme-minimal-white .toggle-scroll-btn {
    background: rgba(0,0,0,0.04);
    border-color: rgba(0, 0, 0, 0.15);
    color: #4a5568;
}

.theme-minimal-white .collapse-btn:hover,
.theme-minimal-white .toggle-scroll-btn:hover {
    background: rgba(0, 0, 0, 0.08);
    color: #2d3748;
}

/* 主题切换器 */
.theme-minimal-white .theme-switcher {
    background: rgba(0,0,0,0.03);
    border-bottom-color: rgba(0,0,0,0.08);
}

.theme-minimal-white .theme-label {
    color: #718096;
}

.theme-minimal-white .theme-btn.active {
    border-color: #4a5568;
    box-shadow: 0 0 6px rgba(0,0,0,0.2);
}

/* 批注条目 */
.theme-minimal-white .annotation-item {
    background: rgba(255, 255, 255, 0.7) !important;
    border-color: rgba(0,0,0,0.08) !important;
    color: #2d3748;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06) !important;
}

.theme-minimal-white .annotation-item:hover {
    background: rgba(255, 255, 255, 0.9) !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;
}

.theme-minimal-white .annotation-comment {
    color: rgba(0, 0, 0, 0.85);
}

.theme-minimal-white .empty-annotations {
    color: #999;
}

/* 评论区 */
.theme-minimal-white .annotation-comment-item {
    color: #4a5568;
}

.theme-minimal-white .annotation-comments-section {
    border-top-color: rgba(0,0,0,0.08);
}

/* 状态栏 */
.theme-minimal-white .text-status-bar {
    background: rgba(0,0,0,0.03);
    color: #718096;
    border-top-color: rgba(0,0,0,0.08);
}

/* 右侧面板边框 */
.theme-minimal-white .annotation-right-panel {
    border-left-color: rgba(0,0,0,0.08);
}

/* 编辑器弹窗 */
.theme-minimal-white .annotation-editor-box {
    background: #fff;
    color: #333;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.theme-minimal-white .annotation-editor-box .editor-title {
    color: #2d3748;
}

.theme-minimal-white .annotation-editor-box .editor-label {
    color: #718096;
}

.theme-minimal-white .annotation-editor-box .editor-input {
    background: #f5f5f5;
    border-color: #d9d9d9;
    color: #333;
}

.theme-minimal-white .annotation-editor-box .editor-cancel-btn {
    border-color: #d9d9d9;
    color: #666;
}

.theme-minimal-white .btn-close-editor {
    color: #999;
}

.theme-minimal-white .btn-close-editor:hover {
    color: #333 !important;
}

/* 未读角标 */
.theme-minimal-white #unreadTextAnnoBadge {
    color: #4a5568;
}

/* ==================== 【t1】拖拽分割线 ==================== */

.panel-resize-handle {
    position: relative;
    z-index: 10;
}

.panel-resize-handle::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 32px;
    background: var(--text-tertiary, #666);
    border-radius: 2px;
    opacity: 0.3;
    transition: opacity 0.2s, height 0.2s;
}

.panel-resize-handle:hover::before,
.panel-resize-handle:active::before {
    opacity: 0.8;
    height: 60px;
}

.panel-resize-handle:hover {
    background: rgba(102, 126, 234, 0.12);
}

.panel-resize-handle:active {
    background: rgba(102, 126, 234, 0.25);
}

/* ==================== 【t2】批注面板不透明 ==================== */

.text-annotation-container .annotation-right-panel {
    background: var(--bg-panel, #0f172a);
    backdrop-filter: none;
}

.text-annotation-container .annotations-list-panel {
    background: var(--bg-panel, #0f172a);
    backdrop-filter: none;
}

/* 极简白主题覆盖 */
.theme-minimal-white .annotation-right-panel,
.theme-minimal-white .annotations-list-panel {
    background: rgba(255, 255, 255, 0.95);
}

/* ==================== 【t3】批注选中文字高亮 ==================== */

.text-line .anno-selected-text {
    background: rgba(102, 126, 234, 0.3);
    border-radius: 2px;
    padding: 0 1px;
    cursor: pointer;
}

.text-line .anno-selected-text.type-error {
    background: rgba(255, 77, 79, 0.3);
}
.text-line .anno-selected-text.type-warning {
    background: rgba(250, 173, 20, 0.3);
}
.text-line .anno-selected-text.type-suggestion {
    background: rgba(82, 196, 26, 0.3);
}
.text-line .anno-selected-text.type-praise {
    background: rgba(24, 144, 255, 0.3);
}
.text-line .anno-selected-text.type-question {
    background: rgba(114, 46, 209, 0.3);
}

/* ==================== 【t4】Hover高亮 ==================== */

.text-line.annotation-hover-highlight {
    background: rgba(102, 126, 234, 0.12) !important;
}

.text-line .anno-hover-text {
    background: rgba(102, 126, 234, 0.45);
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(102, 126, 234, 0.6);
}

.text-line.annotation-hover-highlight .anno-selected-text {
    background: rgba(102, 126, 234, 0.5);
}
