@font-face {
    font-family: 'HarmonyOS Sans SC';
    src: url('fonts/HarmonyOS_Sans_SC_Regular.woff2') format('woff2');
    font-weight: 400;
}
@font-face {
    font-family: 'HarmonyOS Sans SC';
    src: url('fonts/HarmonyOS_Sans_SC_Medium.woff2') format('woff2');
    font-weight: 500;
}
@font-face {
    font-family: 'HarmonyOS Sans SC';
    src: url('fonts/HarmonyOS_Sans_SC_Bold.woff2') format('woff2');
    font-weight: 700;
}

:root {
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #059669;
    --success-hover: #047857;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --border: #e2e8f0;
    --warning-bg: #fffbeb;
    --warning-text: #b45309;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'HarmonyOS Sans SC', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    padding: 2rem;
}

/* 极大扩展了整体宽度，解决中间过窄的问题 */
.app-container {
    max-width: 1400px; 
    margin: 0 auto; 
    display: flex; 
    flex-direction: column; 
    gap: 1.5rem;
}

.app-header { text-align: center; padding: 1rem 0; }
.app-header h1 {
    font-size: 2.5rem; font-weight: 700; background: linear-gradient(135deg, #1e3a8a, #3b82f6);
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; margin-bottom: 0.5rem;
}
.app-header p { color: var(--text-muted); font-size: 1.1rem; }

/* 整体从两列改为一列上下叠放的宽阔结构 */
.app-main { display: flex; flex-direction: column; gap: 1.5rem; }

.card {
    background: var(--card-bg); border-radius: 1rem; padding: 2rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border);
}

.card h2 { font-size: 1.25rem; margin-bottom: 1.5rem; display: flex; align-items: center; gap: 0.5rem; color: var(--text-main); border-bottom: 2px solid #f1f5f9; padding-bottom: 0.75rem;}

/* 第一块配置区：内联为平铺网格，节约垂直高度 */
.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

label { display: block; font-size: 0.875rem; color: var(--text-main); margin-bottom: 0.5rem; font-weight: 500; }
input, textarea {
    width: 100%; padding: 0.75rem 1rem; background: #ffffff;
    border: 1px solid var(--border); border-radius: 0.5rem; color: var(--text-main); font-family: inherit; transition: all 0.2s;
}
input:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }

/* Cron和安全提示区采用二八分左右结构 */
.cron-info-row { display: grid; grid-template-columns: 2fr 1.2fr; gap: 1.5rem; }
@media(max-width: 900px) { .cron-info-row { grid-template-columns: 1fr; }}

.alert-info {
    background: #eff6ff; color: #1e40af; padding: 1.25rem; border-radius: 0.5rem; font-size: 0.875rem; border: 1px solid #bfdbfe;
}
.alert-info code { display: block; background: #dbeafe; padding: 0.5rem; border-radius: 0.25rem; margin-top: 0.5rem; word-break: break-all; font-weight: 600; color: #1e3a8a;}
.alert-warning {
    background: var(--warning-bg); color: var(--warning-text); padding: 1.25rem; border-radius: 0.5rem; font-size: 0.875rem; border: 1px solid #fcd34d;
}

/* 第二块文章构建区：左右两列（写文 / 调度） */
.add-article-layout {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 2.5rem;
}
@media(max-width: 900px) { .add-article-layout { grid-template-columns: 1fr; } }

.entry-zone { display: flex; flex-direction: column; gap: 1rem; }
.action-row { display: flex; gap: 1rem; }
.action-row .btn, .action-row label.btn { flex: 1; justify-content: center; height: 46px; box-sizing: border-box; display: inline-flex; align-items: center; }

.btn { display: inline-flex; align-items: center; justify-content: center; padding: 0.75rem 1.5rem; border-radius: 0.5rem; font-weight: 600; cursor: pointer; border: 1px solid transparent; font-size: 0.875rem; transition: transform 0.1s, box-shadow 0.2s; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); box-shadow: 0 4px 10px rgba(37,99,235,0.2) }
.btn-success { background: var(--success); color: white; border-color: var(--success); }
.btn-success:hover { background: var(--success-hover); border-color: var(--success-hover); box-shadow: 0 4px 10px rgba(5,150,105,0.2) }
.btn-warning { background: #f59e0b; color: white; border-color: #f59e0b; }
.btn-warning:hover { background: #d97706; border-color: #d97706; box-shadow: 0 4px 10px rgba(245,158,11,0.2) }
.btn-danger { background: transparent; border: 1px solid var(--danger); color: var(--danger); padding: 0.35rem 0.75rem; font-size: 0.75rem; border-radius: 0.35rem; }
.btn-danger:hover { background: var(--danger); color: white; }
.btn-sm { padding: 0.35rem 1rem; font-size: 0.8rem; }
.outline-btn { background: #f8fafc; border: 1px solid var(--border); color: var(--text-main); }
.outline-btn:hover { background: #e2e8f0; }

.queue-zone { display: flex; flex-direction: column; }
.queue-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; padding-bottom: 0.5rem; border-bottom: 2px solid #f1f5f9; }

.article-list { list-style: none; max-height: 450px; overflow-y: auto; padding-right: 0.5rem; }
.article-list::-webkit-scrollbar { width: 6px; }
.article-list::-webkit-scrollbar-track { background: #f1f5f9; border-radius: 3px; }
.article-list::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

.article-item {
    background: #f8fafc; border: 1px solid var(--border); border-radius: 0.5rem; padding: 1rem; margin-bottom: 0.75rem; display: flex; justify-content: space-between; align-items: center; 
}
.article-item:hover { background: #ffffff; border-color: #93c5fd; box-shadow: 0 2px 5px rgba(0,0,0,0.03); }
.article-info h4 { font-size: 0.95rem; margin-bottom: 0.35rem; font-weight: 500; cursor: pointer; transition: color 0.2s; }
.article-info h4:hover { color: var(--primary); }

.article-preview-expand {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: #f1f5f9;
    padding: 0.5rem 0.8rem;
    border-radius: 0.4rem;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
    line-height: 1.5;
    border-left: 3px solid #cbd5e1;
}

.status-badge { padding: 0.25rem 0.6rem; border-radius: 1rem; font-size: 0.7rem; font-weight: 600; }
.status-pending { background: #cbd5e1; color: #334155; }
.status-success { background: #d1fae5; color: #059669; }
.status-failed { background: #fee2e2; color: #dc2626; }

.console-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.log-console {
    background: #1e293b; border-radius: 0.5rem; padding: 1rem; height: 180px; overflow-y: auto; font-family: 'Consolas', monospace; font-size: 0.85rem; border: 1px solid var(--border);
}
.log-item { margin-bottom: 0.5rem; border-bottom: 1px dashed #334155; padding-bottom: 0.5rem; }
.log-item:last-child { border-bottom: none; }
.log-item.info { color: #e2e8f0; }
.log-item.info span.time { color: #94a3b8; }
.log-item.success { color: #34d399; }
.log-item.error { color: #f87171; }

/* select 下拉框样式 */
select {
    width: 100%; padding: 0.75rem 1rem;
    background: #ffffff; border: 1px solid var(--border);
    border-radius: 0.5rem; color: var(--text-main);
    font-family: inherit; font-size: 0.875rem;
    cursor: pointer; transition: all 0.2s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
}
select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }

/* AI Panel */
.ai-layout {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 2rem;
}
@media(max-width: 900px) { .ai-layout { grid-template-columns: 1fr; } }
.ai-inputs { display: flex; flex-direction: column; }

.ai-preview { display: flex; flex-direction: column; }
.ai-preview-header {
    display: flex; justify-content: space-between; align-items: center;
    padding-bottom: 0.5rem; margin-bottom: 0.75rem;
    border-bottom: 2px solid #f1f5f9; font-weight: 600; font-size: 0.9rem;
}

.ai-tabs-container {
    display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.75rem;
}
.ai-tab {
    padding: 0.2rem 0.6rem; border-radius: 0.25rem; font-size: 0.8rem; cursor: pointer;
    background: #f1f5f9; color: var(--text-muted); transition: all 0.2s; border: 1px solid transparent;
}
.ai-tab:hover { background: #e2e8f0; }
.ai-tab.active { background: #eff6ff; color: var(--primary); border-color: #bfdbfe; font-weight: 600; }

.ai-status-badge {
    padding: 0.2rem 0.65rem; border-radius: 1rem;
    font-size: 0.75rem; font-weight: 600;
    background: #e2e8f0; color: #64748b;
    transition: all 0.3s;
}
.ai-status-badge.running { background: #dbeafe; color: #1d4ed8; }
.ai-status-badge.done { background: #d1fae5; color: #059669; }

.conn-badge {
    padding: 0.2rem 0.6rem; border-radius: 1rem; font-size: 0.75rem; font-weight: 600;
}
.conn-badge.success { background: #d1fae5; color: #059669; }
.conn-badge.error { background: #fee2e2; color: #dc2626; }

.ai-preview-box {
    flex: 1; min-height: 220px; max-height: 340px;
    overflow-y: auto; background: #f8fafc;
    border: 1px solid var(--border); border-radius: 0.5rem;
    padding: 1rem; font-size: 0.875rem; color: var(--text-muted);
    line-height: 1.8; white-space: pre-wrap; word-break: break-word;
}
.ai-preview-box::-webkit-scrollbar { width: 6px; }
.ai-preview-box::-webkit-scrollbar-track { background: #f1f5f9; border-radius: 3px; }
.ai-preview-box::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* ============================================
   移动端完整响应式适配 (≤ 640px)
   ============================================ */
@media (max-width: 640px) {

    body {
        padding: 1rem;
    }

    .app-header h1 {
        font-size: 1.5rem;
    }
    .app-header p {
        font-size: 0.9rem;
    }

    .card {
        padding: 1.25rem;
        border-radius: 0.75rem;
    }

    /* 配置网格：手机强制单列 */
    .config-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
        margin-bottom: 1rem;
    }

    /* Cron 提示区：已有 900px 断点，手机再优化间距 */
    .cron-info-row {
        gap: 1rem;
    }

    /* 文章构建区：已有 900px 断点，手机上队列在写文下方 */
    .add-article-layout {
        gap: 1.5rem;
    }

    /* 操作按钮行：手机上纵向排列 */
    .action-row {
        flex-direction: column;
    }
    .action-row .btn,
    .action-row label.btn {
        width: 100%;
        height: auto;
        padding: 0.75rem 1rem;
    }

    /* 队列头部：文字和按钮纵向排列 */
    .queue-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    .queue-header .btn-success {
        width: 100%;
    }

    /* 文章条目：标题和删除按钮纵向 */
    .article-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    .article-actions {
        width: 100%;
    }
    .article-actions .btn-danger {
        width: 100%;
        text-align: center;
        padding: 0.5rem;
    }

    /* AI 面板：已有 900px 断点，手机间距优化 */
    .ai-layout {
        gap: 1.5rem;
    }
    .ai-preview-box {
        min-height: 160px;
    }

    /* 日志控制台：字号缩小 */
    .log-console {
        font-size: 0.78rem;
        height: 150px;
    }
}

/* 平板适配 (641px - 900px) */
@media (min-width: 641px) and (max-width: 900px) {
    body {
        padding: 1.5rem;
    }
    .config-grid {
        grid-template-columns: 1fr 1fr !important;
    }
    .app-header h1 {
        font-size: 2rem;
    }
}
