/* 颜色文本样式 */

/* 颜色文本基础样式 - 高优先级 */
.colored-text,
.detail-content .colored-text,
.post-content .colored-text,
.card .colored-text,
p .colored-text,
div .colored-text {
    font-weight: 500 !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1) !important;
    transition: opacity 0.2s ease, text-shadow 0.2s ease !important;
    display: inline !important;
    position: relative !important;
}

/* 确保颜色属性具有最高优先级 */
.colored-text[style*="color:"],
.detail-content .colored-text[style*="color:"],
.post-content .colored-text[style*="color:"],
.card .colored-text[style*="color:"],
p .colored-text[style*="color:"],
div .colored-text[style*="color:"] {
    color: inherit !important;
}

/* 强制覆盖所有可能的文本颜色规则 */
body .card .colored-text,
body .detail-content .colored-text,
body .post-content .colored-text,
body p .colored-text,
body div .colored-text,
html body .colored-text {
    color: var(--colored-text-color, inherit) !important;
}

/* 针对可能的白色文本覆盖 */
.colored-text {
    color: inherit !important;
}

/* 更强的优先级规则 */
body.detail-page .card .colored-text,
body.detail-page .detail-content .colored-text {
    color: inherit !important;
    opacity: 1 !important;
}

/* 最高优先级：覆盖所有可能的白色文本规则 */
body .card h1 .colored-text,
body .card h2 .colored-text,
body .card h3 .colored-text,
body .card h4 .colored-text,
body .card h5 .colored-text,
body .card h6 .colored-text,
body .card p .colored-text,
body .card span .colored-text,
body .card a .colored-text,
body .card .text-muted .colored-text,
body .card .card-title .colored-text,
body .card .card-text .colored-text,
html body .card .colored-text,
html body .detail-content .colored-text,
html body div .colored-text,
html body p .colored-text,
html body span .colored-text {
    color: var(--colored-text-color) !important;
}

/* 终极解决方案：直接覆盖所有可能的颜色规则 */
[class*="colored-text"]:not(.color-disabled) {
    color: var(--colored-text-color) !important;
}

/* 兼容方案：确保即使CSS变量不支持也能显示 */
.colored-text:not([style*="--colored-text-color"]) {
    filter: none !important;
}

/* 针对特定页面的强制规则 */
body.desktop-device .colored-text,
body.mobile-device .colored-text {
    color: var(--colored-text-color, inherit) !important;
}

/* 颜色文本悬停效果 */
.colored-text:hover {
    opacity: 0.8;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* 已处理的颜色文本容器标记 */
.color-text-processed {
    /* 用于标记已处理的元素，无视觉效果 */
}

/* 颜色预览容器 */
.color-preview {
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    margin: 10px 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.color-preview span {
    display: inline-block;
    margin: 2px 8px;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    font-size: 12px;
    transition: all 0.2s ease;
}

.color-preview span:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

/* 颜色文本帮助提示 */
.color-text-help {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 15px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    line-height: 1.6;
}

.color-text-help p {
    white-space: pre-line;
    word-wrap: break-word;
    margin: 0;
}

.color-text-help h4 {
    color: rgba(255, 255, 255, 0.95);
    margin-bottom: 10px;
    font-size: 16px;
}

.color-text-help .example {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    padding: 8px 12px;
    margin: 8px 0;
    font-family: 'Courier New', monospace;
    border-left: 3px solid #4CAF50;
}

.color-text-help .example-result {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    padding: 8px 12px;
    margin: 8px 0;
    border-left: 3px solid #2196F3;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .colored-text {
        font-weight: 600; /* 移动端稍微加粗以提高可读性 */
    }
    
    .color-preview {
        padding: 8px;
    }
    
    .color-preview span {
        margin: 1px 4px;
        padding: 1px 4px;
        font-size: 11px;
    }
    
    .color-text-help {
        padding: 12px;
        font-size: 13px;
    }
}

/* 深色主题适配 */
@media (prefers-color-scheme: dark) {
    .colored-text {
        text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    }
    
    .color-text-help {
        background: rgba(255, 255, 255, 0.05);
        border-color: rgba(255, 255, 255, 0.1);
    }
}

/* 打印样式 */
@media print {
    .colored-text {
        color: #000 !important;
        text-shadow: none !important;
        font-weight: bold !important;
    }
    
    .color-preview,
    .color-text-help {
        display: none;
    }
}

/* 高对比度模式 */
@media (prefers-contrast: high) {
    .colored-text {
        text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.8);
        font-weight: 700;
    }
    
    .colored-text:hover {
        text-shadow: 2px 2px 0 rgba(255, 255, 255, 0.9);
    }
}

/* 动效优化 - 减少动效用户 */
@media (prefers-reduced-motion: reduce) {
    .colored-text,
    .color-preview span {
        transition: none !important;
    }
    
    .color-preview span:hover {
        transform: none !important;
    }
}

/* 选中状态 */
.colored-text::selection {
    background: rgba(255, 255, 255, 0.3);
    color: inherit;
}

.colored-text::-moz-selection {
    background: rgba(255, 255, 255, 0.3);
    color: inherit;
}

/* 焦点状态（用于可聚焦元素） */
.colored-text:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 1px;
    border-radius: 2px;
}

/* 特殊效果：渐变背景（可选） */
.colored-text.gradient {
    background: linear-gradient(45deg, currentColor, rgba(255, 255, 255, 0.3));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* 特殊效果：发光效果（可选） */
.colored-text.glow {
    text-shadow: 0 0 10px currentColor, 0 0 20px currentColor, 0 0 30px currentColor;
}

/* 错误状态（颜色无法解析时） */
.colored-text.error {
    color: #ff6b7a !important;
    text-decoration: underline dotted;
}

/* 调试模式 */
.debug .colored-text {
    border: 1px dashed rgba(255, 0, 0, 0.3);
    background: rgba(255, 0, 0, 0.1);
}

.debug .colored-text::before {
    content: '[COLOR]';
    font-size: 8px;
    position: absolute;
    top: -12px;
    left: 0;
    color: #ff0000;
    font-weight: normal;
}
