/**
 * 正则表达式在线测试工具 - 专用样式
 * 注意：info-card 样式完全依赖 tools-common.css，不可重复定义
 */

/* ==================== 输入区（单栏全宽） ==================== */
.regex-input-section {
    margin-bottom: 2rem;
}

/* ==================== 正则输入区 ==================== */
.regex-input-area {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.regex-pattern-card,
.regex-text-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.3s ease;
}

.regex-pattern-card:hover,
.regex-text-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.regex-pattern-card h3,
.regex-text-card h3 {
    margin: 0 0 1rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: #333;
}

/* 正则表达式输入组 */
.regex-input-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.regex-delimiter {
    font-size: 1.5rem;
    font-weight: 700;
    color: #666;
    font-family: 'Courier New', monospace;
}

.regex-input {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 1rem;
    font-family: 'Courier New', monospace;
    transition: border-color 0.3s ease;
}

.regex-input:focus {
    outline: none;
    border-color: #4285f4;
    box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.1);
}

/* 正则标志 */
.regex-flags {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.regex-flags label {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: #555;
    cursor: pointer;
    user-select: none;
}

.regex-flags input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* 正则状态提示 */
.regex-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.875rem;
}

.regex-status-info {
    background: #e3f2fd;
    color: #1976d2;
}

.regex-status-success {
    background: #e8f5e9;
    color: #388e3c;
}

.regex-status-error {
    background: #ffebee;
    color: #d32f2f;
}

.regex-status-warning {
    background: #fff3e0;
    color: #f57c00;
}

.status-icon {
    font-weight: 700;
    font-size: 1rem;
}

/* 测试文本区 */
.regex-textarea {
    width: 100%;
    min-height: 60px;
    padding: 0.75rem;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: 'Courier New', monospace;
    resize: vertical;
    transition: border-color 0.3s ease;
}

.regex-textarea:focus {
    outline: none;
    border-color: #4285f4;
    box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.1);
}

.regex-text-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: #666;
}

/* 操作按钮栏 */
.regex-action-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.regex-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: #555;
    cursor: pointer;
    user-select: none;
}

.regex-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* ==================== 帮助区（移至模板库后） ==================== */
.regex-help-section {
    margin-top: 2rem;
    margin-bottom: 2rem;
}

.regex-help-section h2 {
    margin: 0 0 1.5rem 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: #333;
}

.regex-syntax-card,
.regex-tips-card {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.regex-tips-card h3 {
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
}

.regex-tips-card ul {
    margin: 0;
    padding-left: 1.5rem;
    font-size: 0.95rem;
    color: #555;
    line-height: 1.7;
}

.regex-tips-card li {
    margin-bottom: 0.75rem;
}

.regex-tips-card code,
.regex-syntax-card code {
    background: #e8eaf6;
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    color: #3f51b5;
}

/* 语法速查表 */
.regex-syntax-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.regex-syntax-table tr {
    border-bottom: 1px solid #e0e0e0;
}

.regex-syntax-table tr:last-child {
    border-bottom: none;
}

.regex-syntax-table td {
    padding: 0.5rem 0;
}

.regex-syntax-table td:first-child {
    font-family: 'Courier New', monospace;
    font-weight: 700;
    color: #3f51b5;
    width: 35%;
}

.regex-syntax-table td:last-child {
    color: #555;
}

/* ==================== 匹配结果区 ==================== */
.regex-result-section {
    margin-top: 2rem;
    margin-bottom: 2rem;
}

/* 匹配统计 */
.regex-stats-card {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-item {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    padding: 1.25rem;
    text-align: center;
    color: #ffffff;
}

.stat-label {
    display: block;
    font-size: 0.875rem;
    opacity: 0.9;
    margin-bottom: 0.5rem;
}

.stat-value {
    display: block;
    font-size: 1.75rem;
    font-weight: 700;
}

/* 高亮显示卡片 */
.regex-highlight-card,
.regex-matches-card,
.regex-groups-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.regex-highlight-card h3,
.regex-matches-card h3,
.regex-groups-card h3 {
    margin: 0 0 1rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: #333;
}

/* 高亮显示文本 */
.regex-highlight-text {
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1rem;
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 400px;
    overflow-y: auto;
}

/* 匹配高亮样式 - 5种颜色循环 */
.match-highlight {
    font-weight: 600;
    padding: 2px 4px;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.match-highlight:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.match-color-0 {
    background: #fef3c7;
    color: #92400e;
    border-bottom: 2px solid #f59e0b;
}

.match-color-1 {
    background: #dbeafe;
    color: #1e40af;
    border-bottom: 2px solid #3b82f6;
}

.match-color-2 {
    background: #dcfce7;
    color: #166534;
    border-bottom: 2px solid #10b981;
}

.match-color-3 {
    background: #fce7f3;
    color: #9f1239;
    border-bottom: 2px solid #ec4899;
}

.match-color-4 {
    background: #e0e7ff;
    color: #3730a3;
    border-bottom: 2px solid #6366f1;
}

/* 当前选中的匹配项 */
.match-highlight.active {
    outline: 2px solid #4285f4;
    outline-offset: 2px;
}

/* 匹配详情列表 */
.regex-matches-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.match-item {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
    border-left: 4px solid #4285f4;
}

.match-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: #666;
}

.match-index {
    font-weight: 600;
    color: #4285f4;
}

.match-content {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 0.5rem;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    word-wrap: break-word;
}

.no-matches {
    text-align: center;
    color: #999;
    padding: 2rem;
    font-size: 0.95rem;
}

/* 捕获组展示 */
.group-match {
    margin-bottom: 1.5rem;
}

.group-match:last-child {
    margin-bottom: 0;
}

.group-match h4 {
    margin: 0 0 0.75rem 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: #555;
}

.group-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.group-list li {
    background: #f1f3f5;
    border-radius: 6px;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.group-index {
    font-size: 0.875rem;
    font-weight: 600;
    color: #666;
    min-width: 80px;
}

.group-content {
    flex: 1;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 0.5rem;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

.no-groups {
    text-align: center;
    color: #999;
    padding: 1rem;
}

/* ==================== 替换功能区 ==================== */
.regex-replace-section {
    margin-bottom: 2rem;
}

.regex-replace-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.regex-replace-card h3 {
    margin: 0 0 1rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: #333;
}

.regex-replace-input {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.regex-replace-input label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #555;
    min-width: 70px;
}

.regex-replace-result {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid #e0e0e0;
}

.regex-replace-result h4 {
    margin: 0 0 0.75rem 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: #333;
}

.regex-replace-result pre {
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1rem;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 0.75rem;
}

/* ==================== 模板库区域 ==================== */
.regex-templates-section {
    margin-bottom: 2rem;
}

.regex-templates-section h2 {
    margin: 0 0 1.5rem 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: #333;
}

/* 模板分类标签 */
.regex-template-tabs {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.template-tab {
    padding: 0.75rem 1.25rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: #ffffff;
    font-size: 0.95rem;
    font-weight: 600;
    color: #555;
    cursor: pointer;
    transition: all 0.3s ease;
}

.template-tab:hover {
    border-color: #4285f4;
    color: #4285f4;
}

.template-tab.active {
    background: #4285f4;
    border-color: #4285f4;
    color: #ffffff;
}

/* 模板网格 */
.regex-templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.25rem;
}

/* 模板卡片 */
.template-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 1.25rem;
    border: 2px solid #e0e0e0;
    transition: all 0.3s ease;
    cursor: pointer;
}

.template-card:hover {
    border-color: #4285f4;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.template-card h4 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: #333;
}

.template-desc {
    font-size: 0.875rem;
    color: #666;
    margin-bottom: 0.75rem;
    line-height: 1.5;
}

.template-pattern {
    background: #f8f9fa;
    border-radius: 6px;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    overflow-x: auto;
}

.template-pattern code {
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: #3f51b5;
    word-break: break-all;
}

.template-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 0.75rem;
    border-top: 1px solid #e0e0e0;
}

.template-example {
    font-size: 0.8rem;
    color: #999;
    font-family: 'Courier New', monospace;
}

.apply-template-btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    background: #4285f4;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.apply-template-btn:hover {
    background: #3367d6;
}

/* ==================== 响应式设计 ==================== */

/* 平板端 (768px - 1024px) */
@media (max-width: 1024px) {
    .regex-stats-card {
        gap: 0.75rem;
    }

    .stat-item {
        padding: 1rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .regex-help-section h2 {
        font-size: 1.3rem;
    }

    .regex-syntax-card,
    .regex-tips-card {
        padding: 1.25rem;
    }
}

/* 手机端 (< 768px) */
@media (max-width: 768px) {
    .regex-input-section {
        margin-bottom: 1.5rem;
    }

    .regex-input-group {
        flex-wrap: wrap;
    }

    .regex-help-section h2 {
        font-size: 1.25rem;
    }

    .regex-syntax-card,
    .regex-tips-card {
        padding: 1rem;
    }

    .regex-flags {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .regex-action-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .regex-action-bar .btn {
        width: 100%;
    }

    .regex-stats-card {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .regex-templates-grid {
        grid-template-columns: 1fr;
    }

    .template-tab {
        flex: 1;
        text-align: center;
    }

    .regex-replace-input {
        flex-direction: column;
        align-items: stretch;
    }

    .regex-replace-input label {
        min-width: auto;
    }

    .regex-template-tabs {
        gap: 0.5rem;
    }
}

/* 超小屏幕优化 (< 480px) */
@media (max-width: 480px) {
    .regex-pattern-card,
    .regex-text-card {
        padding: 1rem;
    }

    .regex-highlight-card,
    .regex-matches-card,
    .regex-groups-card,
    .regex-replace-card {
        padding: 1rem;
    }

    .regex-templates-section h2 {
        font-size: 1.25rem;
    }

    .template-card {
        padding: 1rem;
    }

    .stat-item {
        padding: 0.875rem;
    }

    .stat-value {
        font-size: 1.25rem;
    }
}
