/* styles.css */
*{
  margin: 0;
  padding: 0;
}
body {
  font-family: Arial, sans-serif;
  background-color: #f5f5f5;
  margin: 0;
  padding: 20px;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  background-color: #fff;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  position: relative; /* Ensure container is the positioning context */
}

.upload-section {
  display: flex;
  flex-direction: column;
  margin-bottom: 20px;
}

#input-text {
  width: 100%;
  height: 100px;
  padding: 10px;
  margin-bottom: 10px;
  border-radius: 4px;
  border: 1px solid #ccc;
}

button {
  padding: 10px;
  border: none;
  border-radius: 4px;
  background-color: #007bff;
  color: white;
  cursor: pointer;
}

button:hover {
  background-color: #0056b3;
}

.compare-section {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
}

.compare-section > div {
  width: 48%;
}

#original-text, #split-text {
  max-height: 500px;
  overflow-y: auto;
  background-color: #f0f0f0;
  padding: 10px;
  border-radius: 4px;
  border: 1px solid #ccc;
  min-height: 100px;
  position: relative; /* For positioning pseudo-elements */
}

/* Floating controls at the bottom */
.controls.floating-controls {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(0, 123, 255, 0.9);
  padding: 10px 20px;
  border-radius: 20px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.controls.floating-controls button {
  background-color: rgba(255, 255, 255, 0.9);
  color: #007bff;
}

/* Pseudo-element styles for highlighting */
span.green-highlight {
  position: relative;
  z-index: 1;
}

span.green-highlight {
  border: 2px solid lightgreen;
}


.highlight-container.red-highlight {
  border: 2px solid lightcoral;
}

/* Change selection color to pink */
::selection {
  background: pink;
}
/* 新增：复选框样式 */
.control-group {
    margin-top: 10px;
    display: flex;
    align-items: center;
}

.control-group label {
    margin-left: 5px;
    font-size: 14px;
    color: #333;
}

/* 新增：快捷键绑定区域样式 */
.shortcut-binding-section {
    margin-top: 30px;
    padding: 15px;
    border: 1px dashed #ccc;
    border-radius: 4px;
    background-color: #f9f9f9;
}

.shortcut-binding-section h3 {
    margin-bottom: 10px;
    color: #007bff;
}

.shortcut-item {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.shortcut-item label {
    width: 200px;
    font-size: 14px;
    font-weight: bold;
}

.shortcut-item input[type="text"] {
    flex-grow: 1;
    padding: 8px;
    margin-right: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.shortcut-item button {
    width: 80px;
    padding: 8px;
    background-color: #28a745;
}

.shortcut-item button:hover {
    background-color: #1e7e34;
}

/* 确保红框内的文本仍为 inline 布局 */
.highlight-container.red-highlight {
    border: 2px solid lightcoral;
    display: inline; /* 关键：确保红框不独占一行 */
    padding: 2px;
    border-radius: 4px;
}

/* 标记已复制的文本 */
span.gray-text {
    color: #aaa;
    /* 可以在这里添加划掉线或其他标记 */
}

/* 修正绿框突出显示，直接作用于 span 元素 */
#split-text span.green-highlight {
    border: 2px solid lightgreen;
    padding: 0 2px; /* 增加一点内边距让边框更清晰 */
    border-radius: 4px;
}

/* 换行符的特殊处理，防止其独占一行 */
span.line-break-span {
    display: block; 
    height: 0;
    margin: 5px 0;
}
/* ... 原始样式 ... */

/* 修正：确保红框内的文本仍为 inline 布局 */
.highlight-container.red-highlight {
    border: 2px solid lightcoral;
    display: inline; /* 关键：确保红框不独占一行 */
    padding: 2px;
    border-radius: 4px;
}

/* 标记已复制的文本 */
span.gray-text {
    color: #aaa;
}

/* 修正绿框突出显示，直接作用于 span 元素 */
#split-text span.green-highlight {
    border: 2px solid lightgreen;
    padding: 0 2px; 
    border-radius: 4px;
}

/* 换行符的特殊处理 */
span.line-break-span {
    display: block !important; 
    height: 0;
    margin: 5px 0;
    /* 确保换行符span不被红框内的display:inline覆盖 */
}

/* 绑定输入框激活时的样式 */
.binding-active {
    background-color: #ffe0b2;
    border: 1px solid orange;
}
/* 气泡框容器定位 */
#shortcut-tooltips {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* 允许点击穿透 */
    z-index: 10;
}

/* 单个气泡框 */
.tooltip {
    position: absolute;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    color: white;
    white-space: nowrap;
    opacity: 0.9;
    transition: opacity 0.2s;
    pointer-events: none;
    transform: translateX(-50%); /* 水平居中 */
}

.tooltip.hidden {
    display: none;
}

/* 红色气泡 (整句) */
#sentence-tooltip {
    background-color: lightcoral;
}

/* 绿色气泡 (小句) */
#phrase-tooltip {
    background-color: lightgreen;
    color: #fff;
}

/* 按钮快捷键显示 */
.shortcut-display {
    font-weight: normal;
    font-size: 0.9em;
    margin-left: 5px;
    opacity: 0.8;
}
/* ... (保留所有之前的样式) ... */

#original-text, #split-text {
  max-height: 500px; /* 用户要求的高度 */
  overflow-y: auto; /* 用户要求的滚动 */
  background-color: #f0f0f0;
  padding: 10px;
  border-radius: 4px;
  border: 1px solid #ccc;
  min-height: 100px;
  position: relative; 
}


/* 气泡框容器定位 */
#shortcut-tooltips {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; 
    z-index: 10;
}

/* 单个气泡框 */
.tooltip {
    position: absolute;
    padding: 6px 12px;
    border-radius: 6px; /* 更圆润 */
    font-size: 13px;
    font-weight: 500;
    color: white;
    white-space: nowrap;
    opacity: 0.95;
    transition: opacity 0.2s, top 0.3s, left 0.3s;
    pointer-events: none;
    line-height: 1.5;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2); /* 添加阴影 */
    transform: translateX(-50%); /* 水平居中 */
}

.tooltip.hidden {
    display: none;
    opacity: 0;
}

/* 红色气泡 (整句) - 突出显示 Ctrl 键 */
#sentence-tooltip {
    background-color: #dc3545; /* 红色系 */
}

/* 绿色气泡 (小句) - 突出显示 Shift 键 */
#phrase-tooltip {
    background-color: #28a745; /* 绿色系 */
}

/* 气泡箭头 (可选) */
.tooltip::after {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    bottom: -6px; /* 定位到气泡底部 */
    left: 50%;
    transform: translateX(-50%);
}

#sentence-tooltip::after {
    border-top: 6px solid #dc3545;
}

#phrase-tooltip::after {
    border-top: 6px solid #28a745;
}

/* ... (保留所有之前的样式) ... */

/* --- 输入控制区域布局修正：按钮在一行 --- */
.input-controls {
    display: flex; /* 使用 Flexbox 布局 */
    gap: 10px;    /* 按钮之间保持间隔 */
    align-items: center; /* 垂直居中对齐 */
    margin-top: 10px; /* 在文本区域下方留出空间 */
}

/* 调整输入框操作按钮样式 (可选，如果之前没有) */
.input-controls .action-button {
    padding: 8px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    background-color: #6c757d; 
    color: white;
    font-weight: bold;
}
.input-controls .action-button:hover {
    background-color: #5a6268;
}

/* 确保分割按钮的样式也适用于新布局 (如果它使用了不同的 ID) */
#split-button {
    padding: 8px 15px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

/* 确保复选框和标签对齐 */
.punctuation-checkbox {
    margin-left: auto; /* 将复选框推到最右边 */
    display: flex;
    align-items: center;
}
.tooltip {
    /* ... (保持其他样式不变，如 padding, border-radius, color, box-shadow) ... */
    position: absolute;
    padding: 6px 12px;
    border-radius: 6px; 
    font-size: 13px;
    font-weight: 500;
    color: white;
    white-space: nowrap;
    opacity: 0.95;
    transition: opacity 0.2s, top 0.3s, left 0.3s;
    pointer-events: none;
    line-height: 1.5;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2); 
    
    /* 关键：使用 translateY(-50%) 确保气泡垂直居中 */
    transform: translateY(-50%); 
}

.tooltip.hidden {
    display: none;
    opacity: 0;
}

/* 气泡箭头：创建指向左侧的箭头 */
.tooltip::after {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    
    /* 箭头边框：确保上下透明 */
    border-top: 6px solid transparent !important; /* 强制覆盖 */
    border-bottom: 6px solid transparent !important; /* 强制覆盖 */
    
    /* 定位在气泡左侧中间 */
    left: -6px; 
    top: 50%;
    transform: translateY(-50%); 
}

/* 红色气泡 */
#sentence-tooltip {
    background-color: #dc3545;
}
#sentence-tooltip::after {
    /* 仅设置右侧边框，形成左指三角形 */
    border-right: 6px solid #dc3545 !important; 
    border-left: none !important;
}

/* 绿色气泡 */
#phrase-tooltip {
    background-color: #28a745;
    color: #fff;
}
#phrase-tooltip::after {
    /* 仅设置右侧边框，形成左指三角形 */
    border-right: 6px solid #28a745 !important;
    border-left: none !important;
}
.split-text-container {
    display: flex;
    align-items: flex-start; /* 顶部对齐 */
    position: relative;
    margin-top: 10px; 
}

/* 确保 split-text 拥有大部分空间，且是唯一可滚动的元素 */
#split-text {
    flex-grow: 1; 
    max-height: 500px;
    overflow-y: auto;
    /* ... (保留 padding, border-radius, background-color 等样式) ... */
    position: relative; 
}

/* 气泡框容器：固定在右侧，相对 split-text-container 定位 */
#shortcut-tooltips {
    position: absolute; 
    right: 0; /* 贴紧父容器右侧 */
    top: 0;
    height: 100%;
    width: 390px; /* 预留气泡显示的宽度 */
    pointer-events: none;
    z-index: 10;
}

/* 单个气泡框：相对于 #shortcut-tooltips 容器绝对定位 */
.tooltip {
    position: absolute;
    left: 400px; /* 气泡距离右侧边缘的距离 */
    padding: 6px 12px;
    border-radius: 6px; 
    font-size: 13px;
    font-weight: 500;
    color: white;
    white-space: nowrap;
    opacity: 0.95;
    transition: opacity 0.3s, top 0.3s; /* 仅过渡 top */
    pointer-events: none;
    line-height: 1.5;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2); 
    
    /* 垂直位置由 JS 控制，不需要 translateY(-50%) */
    transform: none; 
}

/* 气泡箭头：创建指向左侧的箭头 */
.tooltip::after {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    
    border-top: 6px solid transparent !important;
    border-bottom: 6px solid transparent !important;
    
    /* 定位在气泡左侧，垂直位置由 JS 覆盖 */
    left: -6px; 
    top: 50%;
    transform: translateY(-50%); 
}