/* ── 在线文本对比 工具页样式 ── */

/* ── 输入区域 ── */
.diff-input-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.diff-input-col {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.diff-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: #555;
}

.diff-textarea {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: 'Fira Code', 'Noto Sans SC', monospace;
    line-height: 1.6;
    resize: vertical;
    background: #fafafa;
    color: #333;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.diff-textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
    background: white;
}

/* ── 对比模式选择 ── */
.diff-mode-bar {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 1rem;
}

.diff-mode-label {
    font-size: 0.9rem;
    color: #555;
    font-weight: 500;
}

.diff-mode-group {
    display: flex;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
}

.diff-mode-btn {
    padding: 0.5rem 1rem;
    border: none;
    background: white;
    font-size: 0.85rem;
    font-family: inherit;
    color: #666;
    cursor: pointer;
    transition: all 0.2s;
    border-right: 1px solid #e0e0e0;
}

.diff-mode-btn:last-child {
    border-right: none;
}

.diff-mode-btn:hover {
    background: #f5f5f5;
}

.diff-mode-btn.active {
    background: #2563eb;
    color: white;
}

/* ── 对比统计 ── */
.diff-summary {
    display: flex;
    gap: 1rem;
    margin: 1rem 0;
    padding: 0.7rem 1rem;
    background: #f8f9fb;
    border: 1px solid #e8eaf0;
    border-radius: 8px;
    flex-wrap: wrap;
}

.diff-stat {
    font-size: 0.85rem;
    color: #666;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.diff-stat-add strong { color: #059669; }
.diff-stat-del strong { color: #dc2626; }
.diff-stat-eq strong { color: #666; }

.diff-stat::before {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.diff-stat-add::before { background: #d1fae5; border: 1px solid #059669; }
.diff-stat-del::before { background: #fee2e2; border: 1px solid #dc2626; }
.diff-stat-eq::before { background: #f0f0f0; border: 1px solid #ccc; }

/* ── 对比结果 ── */
.diff-result {
    margin-top: 1rem;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
}

.diff-result-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.diff-result-col {
    overflow-x: auto;
    font-family: 'Fira Code', monospace;
    font-size: 0.82rem;
    line-height: 1.6;
}

.diff-result-col:first-child {
    border-right: 1px solid #e0e0e0;
}

/* 行样式 */
.diff-line {
    display: flex;
    min-height: 1.6em;
    white-space: pre-wrap;
    word-break: break-all;
}

.diff-line-num {
    min-width: 36px;
    padding: 0 6px;
    text-align: right;
    color: #aaa;
    background: rgba(0,0,0,0.02);
    border-right: 1px solid #e8eaf0;
    user-select: none;
    flex-shrink: 0;
    font-size: 0.78rem;
}

.diff-line-text {
    padding: 0 8px;
    flex: 1;
}

/* 差异颜色 */
.diff-line.diff-add {
    background: #d1fae5;
}

.diff-line.diff-add .diff-line-num {
    background: #a7f3d0;
    color: #065f46;
}

.diff-line.diff-del {
    background: #fee2e2;
}

.diff-line.diff-del .diff-line-num {
    background: #fecaca;
    color: #991b1b;
}

.diff-line.diff-empty {
    background: #f5f5f5;
}

.diff-line.diff-empty .diff-line-num {
    background: #eee;
}

/* 行内差异高亮 */
.diff-inline-add {
    background: #6ee7b7;
    border-radius: 2px;
}

.diff-inline-del {
    background: #fca5a5;
    border-radius: 2px;
}

/* 按词/字符模式的 inline diff 展示 */
.diff-inline-wrap {
    padding: 1rem;
    font-family: 'Fira Code', 'Noto Sans SC', monospace;
    font-size: 0.88rem;
    line-height: 1.8;
    white-space: pre-wrap;
    word-break: break-all;
}

.diff-token-add {
    background: #d1fae5;
    color: #065f46;
    border-radius: 2px;
    padding: 0 1px;
}

.diff-token-del {
    background: #fee2e2;
    color: #991b1b;
    border-radius: 2px;
    padding: 0 1px;
    text-decoration: line-through;
}

/* ── Mobile ── */
@media (max-width: 640px) {
    .diff-input-grid {
        grid-template-columns: 1fr;
    }

    .diff-result-grid {
        grid-template-columns: 1fr;
    }

    .diff-result-col:first-child {
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
    }

    .diff-mode-bar {
        flex-direction: column;
        align-items: flex-start;
    }
}
