/*
 * TXT 转 EPUB 工具样式
 * 纸感瑞士极简 + 莫兰迪护眼
 *
 * 规则：零渐变、零阴影、零毛玻璃、圆角 2-4px
 */

.epub-container {
    max-width: 900px;
    margin: 0 auto;
}

/* ========================================
   消息提示
   ======================================== */

.message {
    padding: 10px 12px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    display: none;
    font-size: 13px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-1);
}

.message.info {
    background: var(--bg-card);
    border-color: var(--border-strong);
    color: var(--text-2);
}

.message.error {
    background: var(--danger-soft);
    border-color: var(--danger);
    color: var(--danger);
}

.message.success {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent-hover);
}

/* ========================================
   卡片
   ======================================== */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.card h2 {
    margin: 0 0 16px 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-1);
}

/* ========================================
   文件上传区
   ======================================== */

.upload-area {
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    padding: 32px 16px;
    text-align: center;
    transition: background-color var(--t-fast), border-color var(--t-fast);
    cursor: pointer;
    background: var(--bg-page);
}

/* .dragover 由 JS 挂载，保留拖放高亮 */
.upload-area:hover,
.upload-area.dragover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.upload-hint {
    color: var(--text-2);
}

.upload-icon {
    font-size: 40px;
    display: block;
    margin-bottom: 10px;
    line-height: 1;
}

.upload-hint p {
    margin: 6px 0;
    font-size: 13px;
}

.upload-limit {
    font-family: var(--font-mono);
    font-size: 11px !important;
    letter-spacing: 0.02em;
    color: var(--text-3);
}

.file-input-wrapper {
    position: relative;
    display: inline-block;
    margin-top: 12px;
}

.file-input-button {
    height: 32px;
    background: var(--bg-card);
    color: var(--text-1);
    border: 1px solid var(--border);
    padding: 0 14px;
    border-radius: var(--radius);
    cursor: pointer;
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    transition: background-color var(--t-fast), border-color var(--t-fast);
}

.file-input-button:hover {
    background: var(--bg-hover);
    border-color: var(--border-strong);
}

.file-input-wrapper input[type="file"] {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* ========================================
   文件列表
   ======================================== */

.file-list {
    margin-top: 12px;
}

.file-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
    cursor: grab;
    transition: background-color var(--t-fast), border-color var(--t-fast);
}

.file-item:hover {
    border-color: var(--border-strong);
    background: var(--bg-hover);
}

/* .dragging 由 JS 在拖拽排序时挂载，保留 */
.file-item.dragging {
    opacity: 0.5;
    border-style: dashed;
}

.file-item .file-icon {
    font-size: 20px;
    margin-right: 12px;
    line-height: 1;
}

.file-item .file-info {
    flex: 1;
    min-width: 0;
}

.file-item .file-name {
    font-weight: 600;
    color: var(--text-1);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-item .file-size {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.02em;
    color: var(--text-3);
}

.file-item .file-actions {
    display: flex;
    gap: 8px;
}

.file-item .file-remove {
    background: none;
    border: none;
    color: var(--text-2);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 2px;
    transition: background-color var(--t-fast), color var(--t-fast);
}

.file-item .file-remove:hover {
    color: var(--danger);
    background: var(--danger-soft);
}

/* ========================================
   内容预览
   ======================================== */

.preview-controls {
    margin-bottom: 12px;
}

.preview-controls select {
    width: 100%;
    height: 32px;
    padding: 0 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-1);
    font-family: var(--font-ui);
    font-size: 13px;
}

.preview-controls select:focus {
    outline: none;
    border-color: var(--accent);
}

.preview-content {
    max-height: 300px;
    overflow-y: auto;
    padding: 12px;
    background: var(--bg-page);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    white-space: pre-wrap;
    word-break: break-all;
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--text-1);
}

/* ========================================
   章节设置
   ======================================== */

.chapter-options {
    margin-bottom: 12px;
}

.option-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.option-row label {
    color: var(--text-2);
    font-size: 13px;
    white-space: nowrap;
}

.option-row input[type="text"] {
    flex: 1;
    min-width: 200px;
    height: 32px;
    padding: 0 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-1);
    font-family: var(--font-ui);
    font-size: 13px;
}

.option-row input[type="text"]:focus,
.option-row select:focus {
    outline: none;
    border-color: var(--accent);
}

.option-row select {
    flex: 1;
    min-width: 200px;
    height: 32px;
    padding: 0 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-1);
    font-family: var(--font-ui);
    font-size: 13px;
}

.regex-hint {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.02em;
    color: var(--text-3);
    margin-top: 8px;
    white-space: pre-wrap;
}

.btn-small {
    height: 32px;
    padding: 0 12px;
    background: var(--bg-card);
    color: var(--text-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    transition: background-color var(--t-fast), border-color var(--t-fast), color var(--t-fast);
    white-space: nowrap;
}

.btn-small:hover {
    background: var(--bg-hover);
    border-color: var(--border-strong);
}

.btn-danger {
    color: var(--danger);
    border-color: var(--danger);
}

.btn-danger:hover {
    background: var(--danger-soft);
    border-color: var(--danger);
}

/* ========================================
   章节列表
   ======================================== */

.chapter-list {
    max-height: 300px;
    overflow-y: auto;
}

.chapter-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
    gap: 12px;
}

.chapter-item .chapter-index {
    color: var(--text-3);
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.02em;
    min-width: 40px;
}

.chapter-item input[type="text"] {
    flex: 1;
    height: 30px;
    padding: 0 10px;
    background: var(--bg-page);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-1);
    font-family: var(--font-ui);
    font-size: 13px;
}

.chapter-item input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
}

.chapter-item .chapter-remove {
    background: none;
    border: none;
    color: var(--text-2);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 2px;
    transition: background-color var(--t-fast), color var(--t-fast);
}

.chapter-item .chapter-remove:hover {
    color: var(--danger);
    background: var(--danger-soft);
}

.chapter-item .source-text {
    flex: 1;
    color: var(--text-3);
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ========================================
   元数据表单
   ======================================== */

.metadata-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.form-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.form-row label {
    color: var(--text-2);
    font-size: 13px;
    min-width: 70px;
}

.form-row label .required {
    color: var(--danger);
}

.form-row input[type="text"],
.form-row select {
    flex: 1;
    min-width: 200px;
    height: 32px;
    padding: 0 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-1);
    font-family: var(--font-ui);
    font-size: 13px;
}

.form-row input[type="text"]:focus,
.form-row select:focus {
    outline: none;
    border-color: var(--accent);
}

/* ========================================
   封面上传
   ======================================== */

.cover-row {
    align-items: flex-start;
}

.cover-upload {
    position: relative;
    width: 120px;
    height: 160px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    background: var(--bg-page);
    transition: background-color var(--t-fast), border-color var(--t-fast);
}

.cover-upload:hover {
    border-color: var(--accent);
    background: var(--bg-hover);
}

.cover-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-3);
    font-size: 11px;
    text-align: center;
    padding: 0 8px;
}

.cover-icon {
    font-size: 28px;
    margin-bottom: 8px;
    line-height: 1;
}

.cover-upload input[type="file"] {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.cover-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ========================================
   操作按钮
   ======================================== */

.action-row {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
}

.btn-primary,
.btn-secondary {
    height: 32px;
    padding: 0 20px;
    border-radius: var(--radius);
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: background-color var(--t-fast), border-color var(--t-fast), color var(--t-fast);
    min-width: 140px;
}

.btn-primary {
    background: var(--accent);
    color: #FFFFFF;
    border: 1px solid var(--accent);
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: #FFFFFF;
}

.btn-primary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-1);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--border-strong);
}

/* ========================================
   加载状态
   ======================================== */

.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 18px;
    height: 18px;
    margin: -9px 0 0 -9px;
    border: 2px solid var(--border-strong);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: epubSpin 0.8s linear infinite;
}

@keyframes epubSpin {
    to {
        transform: rotate(360deg);
    }
}

/* ========================================
   进度遮罩层
   ======================================== */

.progress-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--bg-page);
    background: color-mix(in srgb, var(--bg-page) 88%, transparent);
    display: flex;
    align-items: center;
    justify-content: center;
}

.progress-panel {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    min-width: 360px;
    max-width: 460px;
    text-align: center;
}

.progress-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-1);
    margin-bottom: 20px;
}

.progress-bar-track {
    width: 100%;
    height: 8px;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 140ms ease-out;
}

.progress-stats {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
}

.progress-percent {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

.progress-detail {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.02em;
    color: var(--text-3);
    text-align: right;
}

@media (max-width: 600px) {
    .progress-panel {
        min-width: unset;
        width: 90%;
        padding: 20px;
    }
}

/* ========================================
   响应式
   ======================================== */

@media (max-width: 600px) {
    .card {
        padding: 14px;
    }

    .form-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .form-row input[type="text"],
    .form-row select {
        width: 100%;
        min-width: unset;
    }

    .option-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .option-row input[type="text"] {
        width: 100%;
        min-width: unset;
    }

    .action-row {
        flex-direction: column;
    }

    .btn-primary,
    .btn-secondary {
        width: 100%;
    }
}
