/* PaperAI 公共样式 */
:root {
    --primary: #6c5ce7;
    --primary-light: #a29bfe;
    --primary-bg: #f5f3ff;
    --sidebar-w: 220px;
}
[x-cloak] { display: none !important; }
* { box-sizing: border-box; }
body { font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; background: #f8f9fc; margin: 0; }
body.body-locked { overflow: hidden; }
.is-hidden { display: none !important; }

/* 重置 Bootstrap 对 aside 的影响 */
aside { display: block; margin: 0; padding: 0; }

/* Sidebar */
aside.sidebar { position: fixed !important; left: 0; top: 0; bottom: 0; width: var(--sidebar-w); background: #fff; border-right: 1px solid #eee; padding: 20px 0; z-index: 100; overflow-y: auto; display: block !important; }
aside.sidebar .logo { display: flex !important; align-items: center; gap: 10px; padding: 0 20px 24px; font-size: 18px; font-weight: 700; color: var(--primary); text-decoration: none; }
aside.sidebar .logo i { font-size: 28px; }
aside.sidebar .nav-item { display: flex !important; align-items: center; gap: 12px; padding: 12px 24px; color: #666; font-size: 14px; cursor: pointer; transition: all .15s; text-decoration: none; }
aside.sidebar .nav-item:hover { background: var(--primary-bg); color: var(--primary); }
aside.sidebar .nav-item.active { background: var(--primary-bg); color: var(--primary); font-weight: 600; border-right: 3px solid var(--primary); }
aside.sidebar .nav-item i { font-size: 18px; width: 22px; text-align: center; }

/* Top navbar */
.top-bar { position: fixed; top: 0; left: var(--sidebar-w); right: 0; height: 56px; background: #fff; border-bottom: 1px solid #eee; display: flex; align-items: center; justify-content: flex-end; padding: 0 24px; gap: 16px; z-index: 99; }
.top-bar .btn-outline-primary { border-color: var(--primary); color: var(--primary); font-size: 13px; }
.top-bar .btn-outline-primary:hover { background: var(--primary); color: #fff; }
.top-bar .btn-login { background: var(--primary); color: #fff; border: none; border-radius: 20px; padding: 6px 20px; font-size: 13px; cursor: pointer; }
.top-bar-icon { font-size: 18px; color: #888; cursor: pointer; }
.top-bar__user { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 8px; cursor: pointer; transition: background .15s; }
.top-bar__user:hover { background: #f5f5f5; }
.top-bar__avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.top-bar__nickname { font-size: 13px; font-weight: 500; color: #333; }
.recharge-item { padding: 16px; border: 2px solid #eee; border-radius: 10px; text-align: center; font-size: 20px; font-weight: 700; color: #333; cursor: pointer; transition: all .15s; }
.recharge-item { width: 100%; background: #fff; }
.recharge-item:hover, .recharge-item.active { border-color: var(--primary); color: var(--primary); background: var(--primary-bg); }

/* Main content */
.main { margin-left: var(--sidebar-w); margin-top: 56px; padding: 32px; min-height: calc(100vh - 56px); }
.app-loading { text-align: center; padding: 100px 20px; color: #888; }
.app-loading__icon { font-size: 48px; }
.app-loading__text { margin-top: 20px; }
.app-loading--error { color: #888; }
.app-loading__icon--error { color: #dc3545; }

/* Page header */
.page-title { text-align: center; margin-bottom: 8px; font-size: 24px; font-weight: 700; color: #333; }
.page-desc { text-align: center; color: #888; font-size: 14px; margin-bottom: 32px; line-height: 1.6; }

/* Content layout */
.content-row { display: flex; gap: 24px; }
.content-left { flex: 1; min-width: 0; }
.content-right { width: 340px; flex-shrink: 0; }

/* Card */
.card-box { background: #fff; border-radius: 12px; padding: 24px; box-shadow: 0 1px 4px rgba(0,0,0,.04); }

/* Section header */
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.section-title { font-size: 18px; font-weight: 600; color: #333; }
.section-hint { font-size: 12px; color: #999; margin-bottom: 16px; line-height: 1.6; }
.section-hint a { color: var(--primary); text-decoration: none; }

/* Pills */
.platform-row { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.platform-label { font-size: 14px; color: #666; white-space: nowrap; }
.pill { padding: 7px 20px; border-radius: 20px; border: 1px solid #ddd; font-size: 13px; cursor: pointer; transition: all .15s; background: #fff; color: #555; user-select: none; }
.pill:hover { border-color: var(--primary-light); color: var(--primary); }
.pill.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pill-outline { padding: 7px 16px; border-radius: 20px; border: 1px solid var(--primary-light); font-size: 12px; color: var(--primary); cursor: pointer; background: #fff; text-decoration: none; }
.pill-outline:hover { background: var(--primary-bg); }

/* Tabs */
.detect-tabs { display: flex; gap: 24px; border-bottom: 2px solid #f0f0f0; margin-bottom: 20px; }
.detect-tab { padding: 8px 0; font-size: 14px; color: #999; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .15s; }
.detect-tab:hover { color: #666; }
.detect-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }

/* Upload zone */
.upload-zone { border: 2px dashed #d9d9f0; border-radius: 12px; padding: 48px 20px; text-align: center; cursor: pointer; transition: all .2s; background: #fafaff; min-height: 200px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.upload-zone:hover, .upload-zone.dragover { border-color: var(--primary); background: var(--primary-bg); }
.upload-zone .icon { font-size: 28px; color: var(--primary); margin-bottom: 12px; }
.upload-zone .hint { color: #999; font-size: 12px; margin-top: 8px; }
.upload-zone .hint2 { color: #bbb; font-size: 12px; margin-top: 4px; }
.upload-zone a { color: var(--primary); text-decoration: none; }
.file-selected { margin-top: 12px; font-size: 13px; color: #333; }

/* Textarea */
.detect-textarea { width: 100%; min-height: 200px; border: 2px dashed #d9d9f0; border-radius: 12px; padding: 16px; font-size: 14px; resize: vertical; background: #fafaff; transition: border-color .2s; }
.detect-textarea:focus { outline: none; border-color: var(--primary); background: #fff; }

/* Form row */
.form-row { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.form-row label { font-size: 14px; color: #333; white-space: nowrap; min-width: 48px; text-align: right; }
.form-row label .req { color: #e74c3c; }
.form-row input { flex: 1; border: none; border-bottom: 1px solid #e8e8e8; padding: 8px 0; font-size: 14px; outline: none; background: transparent; }
.form-row input:focus { border-bottom-color: var(--primary); }
.form-row .char-count { font-size: 12px; color: #ccc; white-space: nowrap; }

/* Submit button */
.btn-submit { display: block; width: 100%; margin-top: 24px; padding: 12px; background: var(--primary); color: #fff; border: none; border-radius: 8px; font-size: 15px; cursor: pointer; transition: background .15s; }
.btn-submit:hover { background: #5b4bd5; }
.btn-submit:disabled { background: #ccc; cursor: not-allowed; }

/* Right info card */
.info-card { background: #fff; border-radius: 12px; padding: 24px; box-shadow: 0 1px 4px rgba(0,0,0,.04); }
.info-card .warn { display: flex; align-items: flex-start; gap: 8px; padding: 16px; background: #fff8f0; border-radius: 8px; margin-bottom: 20px; }
.warn-icon { color: #e74c3c; font-size: 18px; flex-shrink: 0; margin-top: 2px; }
.warn-title { font-size: 15px; font-weight: 600; color: #333; margin-bottom: 4px; }
.warn-text { font-size: 12px; color: #888; line-height: 1.6; }
.service-title { font-size: 16px; font-weight: 600; color: #333; margin-bottom: 16px; }
.service-item { display: flex; gap: 14px; margin-bottom: 20px; }
.service-icon { width: 48px; height: 48px; border-radius: 12px; background: linear-gradient(135deg, var(--primary-bg), #e8e4ff); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.service-icon i { font-size: 22px; color: var(--primary); }
.service-item h6 { font-size: 14px; font-weight: 600; color: #333; margin: 0 0 4px; }
.service-item p { font-size: 12px; color: #888; margin: 0; line-height: 1.5; }

/* Footer */
.footer { text-align: center; padding: 24px; color: #bbb; font-size: 12px; margin-top: 32px; }
.footer a { color: #999; text-decoration: none; margin: 0 8px; }
.footer a:hover { color: var(--primary); }

.editor-page-card {
    min-height: 500px;
}

.editor-page-toolbar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.editor-page-textarea {
    min-height: 400px;
}

.editor-page-submit {
    max-width: 300px;
    margin: 24px auto 0;
}

/* ===== 响应式布局 ===== */

/* 手机端菜单按钮 */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 12px;
    left: 16px;
    z-index: 101;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    width: 40px;
    height: 40px;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
}

/* 侧边栏遮罩层 */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 99;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .28s ease, visibility 0s linear .28s;
}
.sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity .28s ease;
}

/* 平板及以下：统一抽屉侧栏，避免窄侧栏挤压内容区 */
@media (max-width: 1023px) {
    :root { --sidebar-w: 0; }

    .mobile-menu-btn { display: block; }

    aside.sidebar {
        transform: translateX(-100%);
        transition: transform .34s cubic-bezier(.22, 1, .36, 1), box-shadow .34s ease;
        width: 280px;
        box-shadow: 2px 0 12px rgba(0,0,0,.1);
        z-index: 101;
        overflow-y: auto;
        will-change: transform;
        backface-visibility: hidden;
        -webkit-backface-visibility: hidden;
        transform-style: preserve-3d;
    }
    aside.sidebar.open { transform: translateX(0); }

    .top-bar {
        left: 0;
        padding: 0 16px 0 60px;
    }

    .main {
        margin-left: 0;
        padding: 24px 20px;
    }

    .content-row { flex-direction: column; }
    .content-right { width: 100%; }
}

/* 手机端：隐藏侧边栏，显示菜单按钮 (< 768px) */
@media (max-width: 767px) {
    :root { --sidebar-w: 0; }

    .mobile-menu-btn { display: block; }

    aside.sidebar {
        transform: translateX(-100%);
        transition: transform .34s cubic-bezier(.22, 1, .36, 1), box-shadow .34s ease;
        width: 280px;
        box-shadow: 2px 0 12px rgba(0,0,0,.1);
        z-index: 101;
        overflow-y: auto;
        will-change: transform;
        backface-visibility: hidden;
        -webkit-backface-visibility: hidden;
        transform-style: preserve-3d;
    }
    aside.sidebar.open { transform: translateX(0); }

    /* 侧边栏内容优化 */
    aside.sidebar .logo {
        padding: 0 16px 20px;
        font-size: 16px;
    }
    aside.sidebar .logo i { font-size: 24px; }
    aside.sidebar .nav-item {
        padding: 14px 20px;
        font-size: 15px;
    }
    aside.sidebar .nav-item i {
        font-size: 20px;
        width: 24px;
    }

    .top-bar {
        left: 0;
        padding: 0 12px 0 60px;
        gap: 6px;
        height: 56px;
    }

    /* 移动端隐藏"未登录"按钮，只保留充值和登录 */
    .top-bar .btn-outline-primary:first-child {
        display: none;
    }

    .top-bar .btn-outline-primary {
        font-size: 11px;
        padding: 4px 8px;
        white-space: nowrap;
    }
    .top-bar .btn-login {
        font-size: 11px;
        padding: 5px 12px;
    }
    .top-bar i.bi-bell {
        font-size: 16px;
    }

    .main {
        margin-left: 0;
        padding: 20px 12px;
    }

    .content-row { flex-direction: column; }
    .content-right { width: 100%; }

    .page-title { font-size: 20px; }
    .page-desc { font-size: 13px; }

    .card-box { padding: 16px; }

    /* Pills 优化 */
    .platform-row { gap: 8px; }
    .pill { padding: 6px 16px; font-size: 12px; }
    .pill-outline { padding: 6px 14px; font-size: 11px; }

    /* 上传区域 */
    .upload-zone { padding: 32px 16px; min-height: 160px; }
    .upload-zone .icon { font-size: 24px; }

    /* 表单行 */
    .form-row { flex-wrap: wrap; gap: 8px; }
    .form-row label { min-width: auto; text-align: left; width: 100%; }
    .form-row input, .form-row select { width: 100%; }

    /* 历史记录弹窗 */
    .history-popup {
        top: 60px;
        right: 16px;
        left: 16px;
        width: auto;
    }
}

/* Feature grid for placeholder pages */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 40px;
    max-width: 1000px;
    margin-left: auto;
    margin-right: auto;
}
.feature-card {
    background: #fff;
    border-radius: 12px;
    padding: 28px 24px;
    box-shadow: 0 1px 4px rgba(0,0,0,.04);
    transition: all .3s;
    text-align: center;
    border: 1px solid #f0f0f0;
}
.feature-card:hover {
    box-shadow: 0 4px 16px rgba(108, 92, 231, 0.12);
    transform: translateY(-4px);
    border-color: var(--primary-light);
}
.feature-card .fc-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary-bg), #e8e4ff);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}
.feature-card .fc-icon i {
    font-size: 26px;
    color: var(--primary);
}
.feature-card h5 {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin: 0 0 10px;
}
.feature-card p {
    font-size: 13px;
    color: #888;
    margin: 0;
    line-height: 1.6;
}

/* Coming soon badge */
.badge-soon { display: inline-block; padding: 3px 10px; border-radius: 10px; background: #fff3e0; color: #e67e22; font-size: 11px; font-weight: 500; }

/* ===== 历史记录样式 ===== */

/* 历史记录区域 */
.history-section { margin-top: 32px; }
.history-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.history-head h4 { font-size: 18px; font-weight: 600; color: #333; margin: 0; }
.history-head .refresh-btn { color: #999; cursor: pointer; font-size: 18px; }
.history-head .refresh-btn:hover { color: var(--primary); }
.history-empty { text-align: center; padding: 40px; color: #bbb; font-size: 14px; background: #fff; border-radius: 12px; }

/* 卡片列表容器 */
.history-cards { max-height: 420px; overflow-y: auto; padding-right: 4px; }
.history-cards::-webkit-scrollbar { width: 4px; }
.history-cards::-webkit-scrollbar-thumb { background: #ddd; border-radius: 4px; }

/* 段落历史卡片 */
.history-card-item {
    background: #fff; border-radius: 12px; padding: 16px 20px; margin-bottom: 12px;
    border: 1px solid #f0f0f0; transition: box-shadow .2s;
    display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
}
.history-card-item:hover { box-shadow: 0 2px 12px rgba(0,0,0,.06); }
.history-card-main { flex: 1; min-width: 0; }
.history-card-side { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; flex-shrink: 0; }
.hci-header { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.hci-time { font-size: 12px; color: #bbb; }
.hci-body { font-size: 13px; line-height: 1.8; }
.hci-input { color: #666; margin-bottom: 6px; }
.hci-output { color: var(--primary); }
.hci-label { font-weight: 600; color: #999; font-size: 12px; }
.hci-header .hci-time { margin-left: auto; }

/* 文件历史行 */
.history-file-item {
    display: flex; align-items: center; gap: 12px; padding: 14px 20px;
    background: #fff; border-radius: 12px; margin-bottom: 10px;
    border: 1px solid #f0f0f0; transition: box-shadow .2s; flex-wrap: wrap;
}
.history-file-item:hover { box-shadow: 0 2px 12px rgba(0,0,0,.06); }
.hfi-name { font-size: 14px; color: #333; font-weight: 500; flex: 1; min-width: 120px; }
.hfi-status { font-size: 12px; padding: 3px 10px; border-radius: 10px; font-weight: 500; }
.hfi-time { font-size: 12px; color: #bbb; }
.hfi-download { font-size: 13px; color: var(--primary); text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.hfi-download:hover { text-decoration: underline; }

/* 状态标签 */
.status-success { background: #e8f5e9; color: #2e7d32; }
.status-completed { background: #e8f5e9; color: #2e7d32; }
.status-processing { background: #fff3e0; color: #e65100; }
.status-pending { background: #f3e5f5; color: #7b1fa2; }
.status-failed { background: #ffebee; color: #c62828; }

/* 功能类型标签 */
.type-tag {
    display: inline-block; padding: 2px 10px; border-radius: 10px;
    font-size: 12px; font-weight: 500;
}
.type-1 { background: #e3f2fd; color: #1565c0; }
.type-2 { background: #f3e5f5; color: #7b1fa2; }
.type-3 { background: #fff3e0; color: #e65100; }
.type-4 { background: #e8f5e9; color: #2e7d32; }

/* 右上角弹出卡片 */
.history-popup {
    position: fixed; top: 72px; right: 32px; width: 340px;
    background: #fff; border-radius: 14px; box-shadow: 0 8px 32px rgba(0,0,0,.12);
    z-index: 300; overflow: hidden;
}
.hp-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px; border-bottom: 1px solid #f0f0f0;
}
.hp-header span:first-child { font-size: 16px; font-weight: 600; color: #333; }
.hp-sub { font-size: 12px; color: #bbb; }
.hp-body { max-height: 400px; overflow-y: auto; padding: 8px 0; }
.hp-body::-webkit-scrollbar { width: 4px; }
.hp-body::-webkit-scrollbar-thumb { background: #eee; border-radius: 4px; }
.hp-item { padding: 12px 20px; border-bottom: 1px solid #f8f8f8; cursor: pointer; transition: background .15s; }
.hp-item:hover { background: #fafbfc; }
.hp-item:last-child { border-bottom: none; }
.hp-item-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.hp-time { font-size: 11px; color: #ccc; }
.hp-item-text { font-size: 12px; color: #888; line-height: 1.6; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
