/* ===== 正则表达式测试工具样式 ===== */

/* Tab 导航 */
.rt-tabs {
    display: flex;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 24px;
    gap: 4px;
}

.rt-tab-btn {
    padding: 10px 28px;
    border: none;
    background: none;
    font-size: 15px;
    font-weight: 500;
    color: #718096;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    border-radius: 6px 6px 0 0;
    transition: all 0.2s ease;
}

.rt-tab-btn:hover {
    color: #667eea;
    background: #f0f4ff;
}

.rt-tab-btn.rt-active {
    color: #667eea;
    border-bottom-color: #667eea;
    background: linear-gradient(180deg, #fafbff 0%, #f0f4ff 100%);
}

/* Tab 内容区 */
.rt-tab-content {
    display: block;
}

/* 隐藏工具类 */
.rt-hidden {
    display: none;
}

/* 标签 */
.rt-label {
    display: block;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 8px;
    font-size: 15px;
}

/* 正则输入区 */
.rt-pattern-wrap {
    display: flex;
    align-items: center;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.rt-pattern-wrap:focus-within {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.rt-pattern-wrap.rt-error-border {
    border-color: #e53e3e;
    box-shadow: 0 0 0 3px rgba(229, 62, 62, 0.1);
}

.rt-delimiter {
    padding: 12px 10px;
    background: #f7fafc;
    color: #667eea;
    font-size: 20px;
    font-weight: bold;
    font-family: 'Courier New', monospace;
    border-right: 1px solid #e2e8f0;
    user-select: none;
    line-height: 1;
    flex-shrink: 0;
}

.rt-delimiter:last-of-type {
    border-right: none;
    border-left: 1px solid #e2e8f0;
}

.rt-pattern-input {
    flex: 1;
    border: none;
    outline: none;
    padding: 12px 14px;
    font-size: 16px;
    font-family: 'Courier New', Courier, monospace;
    color: #2d3748;
    background: transparent;
    min-width: 0;
}

.rt-replacement-input {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 15px;
    font-family: 'Courier New', Courier, monospace;
    color: #2d3748;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    box-sizing: border-box;
    outline: none;
}

.rt-replacement-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Flags 区 */
.rt-flags {
    display: flex;
    gap: 2px;
    padding: 6px 10px;
    background: #f7fafc;
    border-left: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.rt-flag-label {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    font-weight: 700;
    color: #a0aec0;
    width: 30px;
    height: 30px;
    border-radius: 5px;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    user-select: none;
}

.rt-flag-label:hover {
    background: #edf2f7;
    color: #667eea;
    border-color: #c7d2fe;
}

.rt-flag-label input {
    display: none;
}

.rt-flag-label.rt-flag-active {
    background: #667eea;
    color: #fff;
    border-color: #667eea;
}

/* 正则错误提示 */
.rt-pattern-error {
    margin-top: 6px;
    padding: 8px 14px;
    background: #fff5f5;
    border: 1px solid #feb2b2;
    border-radius: 6px;
    color: #c53030;
    font-size: 13px;
    font-family: 'Courier New', monospace;
}

/* 文本区 */
.rt-textarea {
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    resize: vertical;
}

/* 结果容器 */
.rt-result {
    background: #f8f9fa;
    border: 1px solid #e2e8f0;
    border-top: 3px solid #667eea;
    border-radius: 12px;
    padding: 20px 24px;
    margin: 16px 0;
    animation: rtFadeIn 0.3s ease;
}

@keyframes rtFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.rt-result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}

/* 徽标 */
.rt-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 18px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.2s ease, color 0.2s ease;
}

.rt-badge-success {
    background: #c6f6d5;
    color: #276749;
}

.rt-badge-zero {
    background: #e2e8f0;
    color: #718096;
}

/* 复制按钮 */
.rt-copy-btn {
    padding: 6px 18px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 13px;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.2s ease;
}

.rt-copy-btn:hover {
    background: #667eea;
    color: #fff;
    border-color: #667eea;
}

/* 分节标题 */
.rt-section-title {
    font-weight: 600;
    color: #718096;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin: 16px 0 8px 0;
}

/* 高亮预览区 */
.rt-highlighted {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    line-height: 1.9;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 260px;
    overflow-y: auto;
    color: #2d3748;
}

.rt-highlighted mark {
    color: inherit;
    border-radius: 3px;
    padding: 1px 2px;
    font-style: normal;
}

.rt-highlighted .rt-mark-1 { background: #fef08a; }
.rt-highlighted .rt-mark-2 { background: #bfdbfe; }
.rt-highlighted .rt-mark-3 { background: #bbf7d0; }
.rt-highlighted .rt-mark-4 { background: #fecdd3; }
.rt-highlighted .rt-mark-5 { background: #ddd6fe; }

/* 匹配详情列表 */
.rt-match-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 360px;
    overflow-y: auto;
    padding-right: 2px;
}

.rt-match-item {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-left: 3px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    transition: box-shadow 0.2s ease, border-left-color 0.15s ease;
}

.rt-match-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.rt-match-index {
    border-radius: 50%;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
    color: #fff;
}

.rt-match-index-1 { background: #667eea; }
.rt-match-index-2 { background: #48bb78; }
.rt-match-index-3 { background: #ed8936; }
.rt-match-index-4 { background: #e53e3e; }
.rt-match-index-5 { background: #9f7aea; }

.rt-match-info {
    flex: 1;
    min-width: 0;
}

.rt-match-value {
    font-family: 'Courier New', monospace;
    font-size: 14px;
    background: #fef9e7;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid #fde68a;
    word-break: break-all;
    display: inline-block;
    max-width: 100%;
}

.rt-match-meta {
    font-size: 12px;
    color: #a0aec0;
    margin-top: 5px;
}

.rt-match-groups {
    margin-top: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.rt-group-tag {
    background: #ebf4ff;
    border: 1px solid #bee3f8;
    color: #2b6cb0;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-family: 'Courier New', monospace;
}

.rt-more-hint {
    text-align: center;
    color: #a0aec0;
    font-size: 13px;
    padding: 8px;
    background: #f7fafc;
    border-radius: 6px;
    border: 1px dashed #e2e8f0;
}

/* 无匹配提示 */
.rt-no-match {
    text-align: center;
    padding: 40px;
    color: #a0aec0;
    font-size: 15px;
    background: #f7fafc;
    border-radius: 12px;
    border: 2px dashed #e2e8f0;
    margin: 16px 0;
}

/* 错误提示 */
.rt-error {
    background: #fff5f5;
    border: 1px solid #feb2b2;
    border-radius: 8px;
    padding: 14px 18px;
    color: #c53030;
    font-size: 14px;
    margin: 16px 0;
}

/* 替换结果输出 */
.rt-replace-output {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    line-height: 1.9;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 300px;
    overflow-y: auto;
    color: #2d3748;
}

/* 常用示例区 */
.rt-examples-title {
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 10px;
    font-size: 14px;
}

.rt-examples {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.rt-example-btn {
    padding: 5px 14px;
    background: #f0f4ff;
    border: 1px solid #c7d2fe;
    border-radius: 20px;
    font-size: 13px;
    color: #4c51bf;
    cursor: pointer;
    transition: all 0.2s ease;
}

.rt-example-btn:hover {
    background: #667eea;
    color: #fff;
    border-color: #667eea;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(102, 126, 234, 0.3);
}

/* 提示文本 */
.rt-hint {
    font-size: 12px;
    color: #a0aec0;
    font-weight: normal;
}

/* m5 间距 */
.m5 {
    margin: 0 0 16px 0;
}

/* 正则输入框清除按钮 */
.rt-clear-pattern {
    padding: 0 10px;
    background: none;
    border: none;
    color: #cbd5e0;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    align-self: stretch;
    display: flex;
    align-items: center;
    transition: color 0.2s ease;
    border-left: 1px solid #e2e8f0;
}

.rt-clear-pattern:hover {
    color: #e53e3e;
    background: #fff5f5;
}

/* 错误提示淡出动画 */
@keyframes rtErrorFade {
    from { opacity: 1; }
    to   { opacity: 0; }
}

.rt-error-fading {
    animation: rtErrorFade 0.3s ease forwards;
}

/* 替换原文高亮（被替换部分红色删除线） */
.rt-replace-origin-view mark {
    background: #fed7d7;
    color: #c53030;
    text-decoration: line-through;
    border-radius: 3px;
    padding: 1px 2px;
    font-style: normal;
}

/* 快捷键提示 */
.rt-shortcut-hint {
    font-size: 12px;
    color: #a0aec0;
    margin-left: 8px;
    margin-right: 4px;
    vertical-align: middle;
    user-select: none;
}

/* 匹配项左侧颜色边框（与序号徽标颜色对应） */
.rt-match-item-1 { border-left-color: #667eea; }
.rt-match-item-2 { border-left-color: #48bb78; }
.rt-match-item-3 { border-left-color: #ed8936; }
.rt-match-item-4 { border-left-color: #e53e3e; }
.rt-match-item-5 { border-left-color: #9f7aea; }

/* 键盘快捷键标签 */
kbd {
    display: inline-block;
    padding: 2px 7px;
    background: #f7fafc;
    border: 1px solid #cbd5e0;
    border-bottom: 2px solid #a0aec0;
    border-radius: 4px;
    font-size: 11px;
    font-family: inherit;
    color: #4a5568;
    line-height: 1.5;
    white-space: nowrap;
}

/* 无匹配状态图标 */
.rt-no-match::before {
    content: '🔍';
    display: block;
    font-size: 28px;
    margin-bottom: 8px;
    opacity: 0.7;
}

/* 自定义滚动条 */
.rt-highlighted::-webkit-scrollbar,
.rt-match-list::-webkit-scrollbar,
.rt-replace-output::-webkit-scrollbar {
    width: 5px;
}
.rt-highlighted::-webkit-scrollbar-track,
.rt-match-list::-webkit-scrollbar-track,
.rt-replace-output::-webkit-scrollbar-track {
    background: transparent;
}
.rt-highlighted::-webkit-scrollbar-thumb,
.rt-match-list::-webkit-scrollbar-thumb,
.rt-replace-output::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}
.rt-highlighted::-webkit-scrollbar-thumb:hover,
.rt-match-list::-webkit-scrollbar-thumb:hover,
.rt-replace-output::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* 输入框占位符颜色 */
.rt-pattern-input::placeholder,
.rt-replacement-input::placeholder {
    color: #c0cadb;
    font-style: italic;
}

.rt-textarea::placeholder {
    color: #c0cadb;
}

/* 正则输入框光标颜色 */
.rt-pattern-input {
    caret-color: #667eea;
}

/* 响应式布局 - 平板端 */
@media (max-width: 768px) {
    .rt-tab-btn {
        padding: 9px 20px;
        font-size: 14px;
    }
    .rt-result {
        padding: 16px 18px;
    }
    .rt-match-list {
        max-height: 280px;
    }
    .rt-highlighted {
        max-height: 220px;
    }
}

/* 响应式布局 - 手机端 */
@media (max-width: 640px) {
    .rt-tabs {
        margin-bottom: 16px;
        gap: 2px;
    }
    .rt-tab-btn {
        padding: 8px 14px;
        font-size: 13px;
    }
    .rt-pattern-input {
        padding: 10px 10px;
        font-size: 14px;
    }
    .rt-delimiter {
        padding: 10px 8px;
        font-size: 17px;
    }
    .rt-flag-label {
        width: 26px;
        height: 26px;
        font-size: 13px;
    }
    .rt-flags {
        gap: 1px;
        padding: 5px 8px;
    }
    .rt-result {
        padding: 14px;
        margin: 12px 0;
    }
    .rt-match-list {
        max-height: 240px;
    }
    .rt-highlighted {
        max-height: 180px;
        font-size: 13px;
    }
    .rt-example-btn {
        padding: 4px 10px;
        font-size: 12px;
    }
    .rt-match-item {
        padding: 10px 12px;
        gap: 10px;
    }
    .rt-match-index {
        width: 22px;
        height: 22px;
        font-size: 11px;
    }
    .rt-shortcut-hint {
        display: none;
    }
    .rt-no-match {
        padding: 28px 16px;
    }
}
