/* ============================================================
   小说下载工作区 - 完整样式（精简无重复版）
   ============================================================ */

/* ---------- 主容器 ---------- */
#txtwb_xz {
    display: none;
    flex-direction: column;
    position: relative !important;
    top: auto !important;
    left: auto !important;
    transform: none !important;
    width: 100% !important;
    height: 100% !important;
    background: #ffffff !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    z-index: auto !important;
    overflow: hidden;
}

/* ---------- 顶部工具栏 ---------- */
#txtwb_xz .header-bar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #f8f9fa;
    border-bottom: 2px solid #4f46e5;
    padding: 8px 16px;
    min-height: 52px;
    z-index: 10;
    flex-wrap: nowrap;
}

#txtwb-toolbar .toolbar-btn {
    height: 34px;
    padding: 0 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    white-space: nowrap;
    border: none;
    line-height: 1;
    background: #f1f5f9;
    color: #1e293b;
}
#txtwb-toolbar .toolbar-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
#txtwb-toolbar .toolbar-btn:active {
    transform: translateY(0);
    box-shadow: none;
}

#txtwb-toolbar .sidebar-toggle-btn {
    height: 34px;
    padding: 0 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #475569;
}
#txtwb-toolbar .sidebar-toggle-btn:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
}

/* ---------- 主体（flex 行） ---------- */
#txtwb_xz .txtwb-flex-row {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* ---------- 中间内容区 ---------- */
#txtwb_xz .txtwb-content-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fff;
    overflow: hidden;
    width: 100%;
}

#txtwb_xz .txtwb-content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: #fafbfc;
    border-bottom: 1px solid #eef2f7;
    flex-shrink: 0;
}

#txtwb_xz .txtwb-content-body {
    flex: 1;
    overflow-y: auto;
    background: #fff;
}

#crawlerContentPreview {
    width: 100%;
    height: 100%;
    padding: 20px;
    font-size: 15px;
    line-height: 2;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-y: auto;
    box-sizing: border-box;
}

#crawlerResultSection {
    display: none;
    padding: 20px;
    text-align: center;
    border-top: 1px solid #eef2f7;
    background: #f8fafc;
}
#crawlerResultSection.active {
    display: block;
}

/* ---------- 左侧工具箱（浮动） ---------- */
#txtwb_xz .txtwb-toolbox {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 380px;
    background: #f8fafc;
    border-right: 2px solid #eef2f7;
    transform: translateX(-100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 20;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
#txtwb_xz .txtwb-toolbox.open {
    transform: translateX(0);
}

#txtwb_xz .txtwb-toolbox .txtwb-toolbox-inner {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #f8fafc;
    overflow: hidden;
}

.txtwb-toolbox-header {
    padding: 12px 16px;
    background: #fff;
    border-bottom: 1px solid #eef2f7;
    flex-shrink: 0;
    font-weight: 600;
}

.txtwb-toolbox-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.txtwb-module {
    background: #fff;
    border-radius: 10px;
    padding: 12px;
    border: 1px solid #eef2f7;
}
.txtwb-module:hover {
    border-color: #e2e8f0;
}

/* ---------- 右侧章节侧边栏（浮动） ---------- */
#txtwb_xz .txtwb-chapter-sidebar {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 280px;
    background: #f8fafc;
    border-left: 2px solid #eef2f7;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 20;
    box-shadow: -2px 0 12px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
#txtwb_xz .txtwb-chapter-sidebar.open {
    transform: translateX(0);
}

#txtwb_xz .txtwb-chapter-sidebar .txtwb-chapter-sidebar-inner {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #f8fafc;
    overflow: hidden;
}

#txtwb_xz .txtwb-chapter-sidebar-header {
    padding: 12px 16px;
    background: #fff;
    border-bottom: 1px solid #eef2f7;
    flex-shrink: 0;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
}

#txtwb_xz .txtwb-chapter-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 10px;
}

.txtwb-chapter-list .crawler-chapter-item {
    padding: 6px 10px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    cursor: pointer;
}
.txtwb-chapter-list .crawler-chapter-item:hover {
    background: #f1f5f9;
}
.txtwb-chapter-list .crawler-chapter-status {
    font-size: 10px;
    padding: 0 8px;
    border-radius: 10px;
}
.txtwb-chapter-list .crawler-status-pending {
    background: #fef9c3;
    color: #854d0e;
}
.txtwb-chapter-list .crawler-status-current {
    background: #dbeafe;
    color: #1e40af;
}
.txtwb-chapter-list .crawler-status-done {
    background: #dcfce7;
    color: #166534;
}

/* ---------- 历史记录侧边栏内容 ---------- */
.history-book-item {
    padding: 8px 12px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    transition: background 0.2s;
    border-radius: 4px;
}
.history-book-item:hover {
    background: #f1f5f9;
}
.history-book-item .book-name {
    font-weight: 600;
    color: #0f172a;
}
.history-book-item .book-meta {
    font-size: 12px;
    color: #94a3b8;
}

.history-chapter-item {
    padding: 6px 12px 6px 20px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    font-size: 13px;
    color: #475569;
    border-radius: 4px;
    transition: background 0.2s;
}
.history-chapter-item:hover {
    background: #f1f5f9;
}
.history-chapter-item.active {
    background: #eef2ff;
    color: #4f46e5;
}

/* ---------- 工具箱内部样式（爬虫组件） ---------- */
#txtwb-toolbox .crawler-header {
    background: transparent;
    padding: 0;
    margin: 0;
    border: none;
    box-shadow: none;
}
#txtwb-toolbox .crawler-header p {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #0f172a;
}
#txtwb-toolbox .crawler-header .subtitle {
    font-size: 11px;
    color: #94a3b8;
    font-weight: 400;
    margin-top: 2px;
}

#txtwb-toolbox .crawler-user-info {
    font-size: 13px;
    color: #475569;
    padding: 4px 0;
}
#txtwb-toolbox .crawler-user-info span {
    color: #2563eb;
    font-weight: 600;
}

#txtwb-toolbox .crawler-config-panel {
    padding: 0;
}
#txtwb-toolbox .crawler-preset-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
#txtwb-toolbox .crawler-preset-btn {
    padding: 4px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    background: #fff;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: #475569;
    transition: all 0.2s;
}
#txtwb-toolbox .crawler-preset-btn:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}
#txtwb-toolbox .crawler-preset-btn.active {
    background: #eef2ff;
    border-color: #4f46e5;
    color: #4f46e5;
}

#txtwb-toolbox .crawler-advanced-config {
    display: none;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e2e8f0;
}
#txtwb-toolbox .crawler-advanced-config.visible {
    display: block;
}
#txtwb-toolbox .crawler-toggle-advanced {
    color: #4f46e5;
    cursor: pointer;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
}
#txtwb-toolbox .crawler-toggle-advanced:hover {
    text-decoration: underline;
}

#txtwb-toolbox .crawler-config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 12px;
}
#txtwb-toolbox .crawler-form-group label {
    font-size: 11px;
    color: #64748b;
    margin-bottom: 2px;
    display: block;
}
#txtwb-toolbox .crawler-form-group input,
#txtwb-toolbox .crawler-form-group select {
    width: 100%;
    padding: 4px 8px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 12px;
    background: #fff;
    color: #1e293b;
    outline: none;
    transition: border-color 0.2s;
}
#txtwb-toolbox .crawler-form-group input:focus,
#txtwb-toolbox .crawler-form-group select:focus {
    border-color: #4f46e5;
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.1);
}

#txtwb-toolbox .crawler-main-input {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}
#txtwb-toolbox .crawler-main-input input[type="text"] {
    flex: 1;
    min-width: 120px;
    padding: 6px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}
#txtwb-toolbox .crawler-main-input input[type="text"]:focus {
    border-color: #4f46e5;
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.08);
}
#txtwb-toolbox .crawler-input-group {
    display: flex;
    align-items: center;
    gap: 4px;
}
#txtwb-toolbox .crawler-input-group label {
    font-size: 12px;
    color: #64748b;
}
#txtwb-toolbox .crawler-chapter-count-input {
    width: 60px;
    padding: 6px 4px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    text-align: center;
    font-size: 13px;
}

#txtwb-toolbox #crawlerStartBtn {
    width: 100%;
    padding: 8px 0;
    background: #4f46e5;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
#txtwb-toolbox #crawlerStartBtn:hover {
    background: #4338ca;
}
#txtwb-toolbox #crawlerStartBtn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#txtwb-toolbox #crawlerProgressSection {
    display: none;
}
#txtwb-toolbox #crawlerProgressSection.active {
    display: block;
}
#txtwb-toolbox .crawler-progress-bar-container {
    background: #f1f5f9;
    height: 6px;
    border-radius: 4px;
    overflow: hidden;
    margin: 8px 0 12px;
}
#txtwb-toolbox .crawler-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #4f46e5, #7c3aed);
    width: 0%;
    transition: width 0.3s;
}
#txtwb-toolbox .crawler-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 6px;
}
#txtwb-toolbox .crawler-stat-card {
    background: #f8fafc;
    padding: 6px;
    border-radius: 6px;
    text-align: center;
}
#txtwb-toolbox .crawler-stat-value {
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
}
#txtwb-toolbox .crawler-stat-label {
    font-size: 10px;
    color: #94a3b8;
}

#txtwb-toolbox .crawler-log-container {
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 6px;
    padding: 8px 10px;
    height: 120px;
    overflow-y: auto;
    font-family: 'Consolas', monospace;
    font-size: 11px;
    line-height: 1.6;
}
#txtwb-toolbox .crawler-log-container .crawler-log-entry {
    opacity: 0.9;
}
#txtwb-toolbox .crawler-log-container .crawler-log-success {
    color: #4ade80;
}
#txtwb-toolbox .crawler-log-container .crawler-log-error {
    color: #f87171;
}
#txtwb-toolbox .crawler-log-container .crawler-log-warning {
    color: #fbbf24;
}
#txtwb-toolbox .crawler-log-container .crawler-log-info {
    color: #93c5fd;
}

#txtwb-toolbox #crawlerLogSection h3 {
    font-size: 13px;
    color: #a78bfa;
    margin-bottom: 6px;
    font-weight: 600;
}

/* ---------- 推荐网站弹窗（固定在 body 上） ---------- */
.recommend-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.2);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.recommend-modal.active {
    display: flex;
}
.recommend-content {
    background: #fff;
    border-radius: 16px;
    padding: 30px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}
.website-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.website-item {
    background: #f8fafc;
    padding: 10px;
    border-radius: 8px;
}
.website-name {
    font-weight: bold;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
}
.website-url {
    font-size: 12px;
    color: #64748b;
    word-break: break-all;
}

/* ---------- 全屏模式 ---------- */
#txtwb_xz.fullscreen-mode {
    transform: none !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    border: none !important;
    border-radius: 0 !important;
}

/* ---------- 指示器 ---------- */
.crawler-smart-indicator {
    display: inline-block;
    padding: 2px 8px;
    background: #dcfce7;
    color: #166534;
    border-radius: 10px;
    font-size: 11px;
    margin-left: 10px;
}
.crawler-selector-indicator {
    display: inline-block;
    padding: 2px 8px;
    background: #dbeafe;
    color: #1e40af;
    border-radius: 10px;
    font-size: 11px;
    margin-left: 10px;
}

/* ---------- 保存书籍模块 ---------- */
#saveBookModule input,
#saveBookModule select {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 13px;
    box-sizing: border-box;
    margin-bottom: 6px;
}
#saveBookModule button {
    padding: 6px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
}
#saveBookModule .btn-bai {
    background: #4f46e5;
    color: #fff;
}
#saveBookModule .btn-bai:hover {
    background: #4338ca;
}

/* ---------- 移动端适配 ---------- */
@media (max-width: 768px) {
    #txtwb_xz .header-bar {
        flex-wrap: wrap;
        gap: 4px;
        padding: 6px 10px;
        min-height: 44px;
    }
    #txtwb-toolbar .toolbar-btn,
    #txtwb-toolbar .sidebar-toggle-btn {
        font-size: 12px;
        height: 30px;
        padding: 0 10px;
    }

    #txtwb_xz .txtwb-toolbox {
        width: 85vw;
        max-width: 340px;
    }
    #txtwb_xz .txtwb-chapter-sidebar {
        width: 85vw;
        max-width: 280px;
    }

    #txtwb-toolbox .txtwb-toolbox-body {
        padding: 8px 10px 16px;
        gap: 8px;
    }
    #txtwb-toolbox .txtwb-module {
        padding: 10px 12px;
    }
    #txtwb-toolbox .crawler-config-grid {
        grid-template-columns: 1fr;
    }
    #txtwb-toolbox .crawler-stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    #txtwb-toolbox .crawler-main-input {
        flex-direction: column;
    }
    #txtwb-toolbox .crawler-main-input input[type="text"] {
        min-width: auto;
        width: 100%;
    }
    #txtwb-toolbox .crawler-input-group {
        justify-content: space-between;
    }
    #txtwb-toolbox .crawler-chapter-count-input {
        width: 80px;
    }
}

@media (max-width: 480px) {
    #txtwb-toolbar .toolbar-btn,
    #txtwb-toolbar .sidebar-toggle-btn {
        font-size: 11px;
        height: 28px;
        padding: 0 8px;
    }
    #txtwb-toolbar .toolbar-btn span:not(.icon) {
        display: none; /* 隐藏文字，只显示图标 */
    }
    #txtwb_xz .txtwb-toolbox {
        width: 92vw;
    }
    #txtwb_xz .txtwb-chapter-sidebar {
        width: 92vw;
    }
}