/* ============================================= */
/* ========= 按需激活的容器调试系式 ============ */
/* ========= color.css - Debug System ========= */
/* ============================================= */

/* 
 * 本文件专注于容器边界、布局调试等可视化辅助功能
 * 调试面板默认不存在，只有按下 Ctrl+M 后才会创建
 * 职责分离：避免功能重复和代码冲突
 */

/* ===================================================== */
/* ========= 容器边界调试系统 ========================== */
/* ===================================================== */

/* 调试用边框显示，帮助定位布局问题 */
.debug-container .ebook-pages {
    border: 3px solid red !important;
    background: rgba(255, 0, 0, 0.1) !important;
}

.debug-container .page {
    border: 1px solid blue !important;
    background: rgba(0, 0, 255, 0.05) !important;
}

.debug-container .page::before {
    content: "Page " attr(data-page-index);
    position: absolute;
    top: 5px;
    left: 5px;
    background: yellow;
    padding: 2px 5px;
    font-size: 10px;
    z-index: 1000;
    pointer-events: none;
}

/* 容器边界调试 */
.debug-container .ebook-content-wrapper {
    border: 2px solid green !important;
    background: rgba(0, 255, 0, 0.05) !important;
}

.debug-container .page-wrapper {
    border: 2px solid orange !important;
    background: rgba(255, 165, 0, 0.05) !important;
}

/* 列表模式容器调试 */
.debug-container .thumbnail-view {
    border: 3px solid purple !important;
    background: rgba(128, 0, 128, 0.1) !important;
}

.debug-container .thumbnail-item {
    border: 1px solid cyan !important;
    background: rgba(0, 255, 255, 0.05) !important;
    position: relative !important;
}

.debug-container .thumbnail-item::before {
    content: "Item " attr(data-page-index);
    position: absolute;
    top: -20px;
    left: 0;
    background: purple;
    color: white;
    padding: 1px 4px;
    font-size: 10px;
    font-weight: bold;
    z-index: 1000;
    pointer-events: none;
    border-radius: 2px;
}

.debug-container .thumbnail-item img {
    border: 1px solid magenta !important;
    opacity: 0.9 !important;
}

/* ===================================================== */
/* ========= 临时调试边框系统 ========================== */
/* ===================================================== */

/* 临时调试边框 - 用于查看重叠问题 */
.debug-borders .ebook-container {
    border: 3px solid green !important;
}

.debug-borders .control-frame {
    border: 3px solid blue !important;
}

.debug-borders .ebook-info {
    border: 3px solid red !important;
}

.debug-borders .recommendations-container {
    border: 3px solid purple !important;
}

/* 列表模式边框调试 */
.debug-borders .thumbnail-view {
    border: 3px solid purple !important;
    background: rgba(128, 0, 128, 0.1) !important;
}

.debug-borders .thumbnail-item {
    border: 1px solid cyan !important;
    background: rgba(0, 255, 255, 0.05) !important;
}

/* ===================================================== */
/* ========= 全屏模式容器调试 ========================== */
/* ===================================================== */

/* 全屏模式下可能的定位问题调试 */
.debug-fullscreen-containers .fullscreen-mode .ebook-content-wrapper {
    border: 2px solid yellow !important;
}

.debug-fullscreen-containers .fullscreen-mode .page-wrapper {
    border: 2px solid green !important;
}

.debug-fullscreen-containers .fullscreen-mode .ebook-pages {
    border: 2px solid blue !important;
}

/* 全屏列表模式容器调试 */
.debug-fullscreen-containers .fullscreen-mode.list-mode .thumbnail-view {
    border: 4px solid purple !important;
    background: rgba(128, 0, 128, 0.15) !important;
}

.debug-fullscreen-containers .fullscreen-mode.list-mode .thumbnail-item {
    border: 2px solid cyan !important;
    background: rgba(0, 255, 255, 0.1) !important;
}

/* ===================================================== */
/* ========= 调试工具类 ================================ */
/* ===================================================== */

/* 调试工具类 - 可以通过JavaScript动态添加 */

/* 显示所有容器边界 */
.show-all-borders * {
    border: 1px solid rgba(255, 0, 0, 0.3) !important;
}

/* 显示flex容器 */
.show-flex-containers [style*="display: flex"],
.show-flex-containers .ebook-pages,
.show-flex-containers .control-upper {
    border: 2px solid cyan !important;
    background: rgba(0, 255, 255, 0.05) !important;
}

/* 显示grid容器 */
.show-grid-containers [style*="display: grid"],
.show-grid-containers .ebook-info,
.show-grid-containers .recommendations-list,
.show-grid-containers .thumbnail-view {
    border: 2px solid magenta !important;
    background: rgba(255, 0, 255, 0.05) !important;
}

/* 显示定位元素 */
.show-positioned-elements [style*="position: absolute"],
.show-positioned-elements [style*="position: fixed"],
.show-positioned-elements .fullscreen-btn,
.show-positioned-elements .orientation-btn {
    border: 2px solid orange !important;
    background: rgba(255, 165, 0, 0.1) !important;
}

/* ===================================================== */
/* ========= 调试信息显示面板（按需创建） ============== */
/* ===================================================== */

/* 调试信息面板样式 - 只有在JS创建后才生效 */
.debug-info-panel {
    position: fixed;
    top: 100px;
    left: 20px;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 15px;
    border-radius: 8px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 12px;
    z-index: 10001;
    max-width: 300px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    /* 默认隐藏，由JS控制显示 */
    display: none;
    /* 添加动画效果 */
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

/* 当面板被激活时的样式 */
.debug-info-panel[style*="display: block"] {
    opacity: 1;
    transform: translateY(0);
}

.debug-info-panel h3 {
    margin: 0 0 10px 0;
    color: #ff6b6b;
    font-size: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 5px;
}

.debug-info-panel .debug-item {
    margin: 5px 0;
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
}

.debug-info-panel .debug-label {
    color: #74c0fc;
}

.debug-info-panel .debug-value {
    color: #51cf66;
    font-weight: bold;
}

/* ===================================================== */
/* ========= 调试控制按钮（按需创建） ================== */
/* ===================================================== */

/* 调试控制按钮容器 */
.debug-controls {
    position: fixed;
    bottom: 20px;
    left: 20px;
    display: none; /* 默认隐藏，由JS控制 */
    flex-direction: column;
    gap: 8px;
    z-index: 10001;
    /* 添加入场动画 */
    opacity: 0;
    transform: translateX(-20px);
    transition: all 0.3s ease;
}

/* 当控制面板被激活时的样式 */
.debug-controls[style*="display: flex"] {
    opacity: 1;
    transform: translateX(0);
}

.debug-btn {
    background: rgba(106, 17, 203, 0.9);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    /* 添加悬停发光效果 */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.debug-btn:hover {
    background: rgba(106, 17, 203, 1);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(106, 17, 203, 0.3);
}

.debug-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.debug-btn.active {
    background: rgba(255, 107, 107, 0.9);
    box-shadow: 0 4px 8px rgba(255, 107, 107, 0.3);
}

/* ===================================================== */
/* ========= 性能调试工具 ============================== */
/* ===================================================== */

/* 慢动画调试 - 减慢所有动画便于观察 */
.debug-slow-animations * {
    animation-duration: 3s !important;
    transition-duration: 1s !important;
}

/* 禁用所有动画 - 用于性能测试 */
.debug-no-animations * {
    animation: none !important;
    transition: none !important;
}

/* 高亮重绘区域 */
.debug-repaint * {
    border: 1px solid red !important;
    background: rgba(255, 0, 0, 0.1) !important;
}

/* ===================================================== */
/* ========= 布局网格调试 ============================== */
/* ===================================================== */

/* 显示CSS Grid布局线 */
.debug-grid-lines .ebook-info {
    background-image: 
        linear-gradient(rgba(255, 0, 0, 0.3) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 0, 0, 0.3) 1px, transparent 1px);
    background-size: 20px 20px;
}

.debug-grid-lines .recommendations-list {
    background-image: 
        linear-gradient(rgba(0, 255, 0, 0.3) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 255, 0, 0.3) 1px, transparent 1px);
    background-size: 15px 15px;
}

/* 列表模式Grid网格线显示 */
.debug-grid-lines .thumbnail-view {
    background-image: 
        linear-gradient(rgba(128, 0, 128, 0.3) 1px, transparent 1px),
        linear-gradient(90deg, rgba(128, 0, 128, 0.3) 1px, transparent 1px);
    background-size: 25px 25px;
}

/* 显示Flexbox主轴和交叉轴 */
.debug-flex-axis .control-upper {
    position: relative;
}

.debug-flex-axis .control-upper::before {
    content: "主轴 →";
    position: absolute;
    top: -20px;
    left: 0;
    color: red;
    font-size: 12px;
    font-weight: bold;
    background: rgba(255, 255, 255, 0.9);
    padding: 2px 5px;
    border-radius: 3px;
}

.debug-flex-axis .control-upper::after {
    content: "↓ 交叉轴";
    position: absolute;
    top: 0;
    left: -60px;
    color: blue;
    font-size: 12px;
    font-weight: bold;
    writing-mode: vertical-lr;
    background: rgba(255, 255, 255, 0.9);
    padding: 5px 2px;
    border-radius: 3px;
}

/* ===================================================== */
/* ========= 响应式断点调试（按需激活） ================ */
/* ===================================================== */

/* 显示当前断点信息 - 默认隐藏 */
.debug-breakpoints::before {
    content: "Desktop Large (>1400px)";
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    z-index: 10002;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    border: 1px solid rgba(255, 255, 255, 0.2);
    /* 添加动画 */
    animation: debugBreakpointPulse 2s infinite;
}

@keyframes debugBreakpointPulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

@media (max-width: 1400px) {
    .debug-breakpoints::before {
        content: "Desktop (≤1400px)";
        background: rgba(0, 100, 200, 0.8);
    }
}

@media (max-width: 1000px) {
    .debug-breakpoints::before {
        content: "Tablet (≤1000px)";
        background: rgba(255, 140, 0, 0.8);
    }
}

@media (max-width: 768px) {
    .debug-breakpoints::before {
        content: "Mobile (≤768px)";
        background: rgba(255, 20, 147, 0.8);
    }
}

@media (max-width: 576px) {
    .debug-breakpoints::before {
        content: "Mobile Small (≤576px)";
        background: rgba(220, 20, 60, 0.8);
    }
}

/* ===================================================== */
/* ========= 移动端调试适配 ============================ */
/* ===================================================== */

/* 移动端调试面板适配 */
@media (max-width: 768px) {
    .debug-info-panel {
        top: 80px;
        left: 10px;
        right: 10px;
        max-width: none;
        font-size: 11px;
        padding: 12px;
    }
    
    .debug-controls {
        bottom: 15px;
        left: 10px;
        right: 10px;
        flex-direction: row;
        justify-content: space-between;
        gap: 5px;
        flex-wrap: wrap;
    }
    
    .debug-btn {
        flex: 1;
        min-width: 80px;
        padding: 6px 8px;
        font-size: 10px;
    }
    
    .debug-breakpoints::before {
        top: 5px;
        font-size: 11px;
        padding: 3px 8px;
    }
}

/* 超小屏幕调试优化 */
@media (max-width: 480px) {
    .debug-info-panel {
        font-size: 10px;
        padding: 10px;
        top: 60px;
    }
    
    .debug-controls {
        gap: 3px;
    }
    
    .debug-btn {
        padding: 5px 6px;
        font-size: 9px;
        min-width: 70px;
    }
    
    .debug-breakpoints::before {
        font-size: 10px;
        padding: 2px 6px;
    }
}

/* ===================================================== */
/* ========= 开发者模式激活指示器 ====================== */
/* ===================================================== */

/* 开发者模式激活时的全局样式 */
.developer-mode {
    /* 添加全局调试环境指示 */
}

/* 开发者模式下的特殊标记 */
.developer-mode::before {
    content: "🔧 开发者调试模式已激活";
    position: fixed;
    top: 0;
    left: 0;
    background: linear-gradient(45deg, #ff6b6b, #feca57);
    color: white;
    padding: 5px 15px;
    font-size: 12px;
    font-weight: bold;
    z-index: 10002;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    /* 添加动画效果 */
    animation: developerModeSlideIn 0.5s ease;
}

@keyframes developerModeSlideIn {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ===================================================== */
/* ========= 打印调试清理 ============================== */
/* ===================================================== */

/* 打印时隐藏所有调试元素 */
@media print {
    .debug-info-panel,
    .debug-controls,
    .debug-container .ebook-pages,
    .debug-container .page,
    .debug-container .ebook-content-wrapper,
    .debug-container .page-wrapper,
    .debug-container .thumbnail-view,
    .debug-container .thumbnail-item,
    .debug-borders .ebook-container,
    .debug-borders .control-frame,
    .debug-borders .ebook-info,
    .debug-borders .recommendations-container,
    .debug-borders .thumbnail-view,
    .debug-borders .thumbnail-item {
        display: none !important;
        border: none !important;
        background: transparent !important;
    }
    
    .debug-breakpoints::before,
    .developer-mode::before {
        display: none !important;
    }
    
    /* 清理所有调试背景 */
    .debug-grid-lines .ebook-info,
    .debug-grid-lines .recommendations-list,
    .debug-grid-lines .thumbnail-view {
        background-image: none !important;
    }
}

/* ===================================================== */
/* ========= 辅助调试工具（按需激活） ================== */
/* ===================================================== */

/* 显示元素尺寸信息 */
.debug-dimensions .ebook-container::after {
    content: attr(data-width) " × " attr(data-height);
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(255, 255, 0, 0.9);
    color: black;
    padding: 2px 5px;
    font-size: 10px;
    font-family: monospace;
    z-index: 1000;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.2);
}

/* 显示滚动位置 */
.debug-scroll::before {
    content: "Scroll: " attr(data-scroll-top) "px";
    position: fixed;
    top: 50px;
    right: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 5px 10px;
    font-size: 12px;
    font-family: monospace;
    z-index: 10001;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* 显示当前页面信息 */
.debug-page-info::after {
    content: "Page: " attr(data-current-page) " / " attr(data-total-pages);
    position: fixed;
    bottom: 50px;
    right: 20px;
    background: rgba(0, 100, 200, 0.9);
    color: white;
    padding: 5px 10px;
    font-size: 12px;
    font-family: monospace;
    z-index: 10001;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* ===================================================== */
/* ========= 颜色主题调试 ============================== */
/* ===================================================== */

/* 高对比度调试模式 */
.debug-high-contrast {
    filter: contrast(200%) brightness(1.2);
}

/* 灰度调试模式 */
.debug-grayscale {
    filter: grayscale(100%);
}

/* 色盲友好调试模式 */
.debug-colorblind {
    filter: hue-rotate(180deg) saturate(0.5);
}

/* ===================================================== */
/* ========= 调试模式隐藏控制 ========================== */
/* ===================================================== */

/* 当调试模式未激活时，确保所有调试元素都隐藏 */
body:not(.debug-mode) .debug-info-panel,
body:not(.debug-mode) .debug-controls {
    display: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* 当调试模式未激活时，清理所有调试类 */
body:not(.debug-mode) {
    /* 自动清理可能残留的调试类 */
}

body:not(.debug-mode) .debug-container,
body:not(.debug-mode) .debug-borders,
body:not(.debug-mode) .debug-grid-lines,
body:not(.debug-mode) .debug-breakpoints {
    /* 覆盖调试样式 */
}

/* 确保默认状态下没有任何调试视觉元素 */
.ebook-pages,
.page,
.ebook-content-wrapper,
.page-wrapper,
.ebook-container,
.control-frame,
.ebook-info,
.recommendations-container,
.thumbnail-view,
.thumbnail-item {
    /* 默认无调试边框 */
    border: none;
    background: transparent;
}