/* ==================== 基础重置 ==================== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --brand-green: #4EB341;
    --brand-blue: #005CAF;
    --brand-orange: #F07300;
    --bg-main: #f5f5f5;
    --bg-card: #ffffff;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-muted: #999999;
    --border-color: #e0e0e0;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

body {
    font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    font-size: 14px;
    height: 100vh;
    overflow: hidden;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* ==================== 顶部栏 ==================== */
.header {
    height: 56px;
    background: linear-gradient(135deg, var(--brand-green) 0%, #3a9c2d 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-left { display: flex; align-items: baseline; gap: 12px; }
.logo { font-size: 18px; font-weight: 700; }
.subtitle { font-size: 14px; opacity: 0.85; }
.header-right { display: flex; gap: 8px; }

/* ==================== 按钮通用 ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--brand-green); color: #fff; }
.btn-primary:hover { background: #3a9c2d; }
.btn-secondary { background: #e8e8e8; color: var(--text-primary); }
.btn-secondary:hover { background: #d0d0d0; }
.btn-success { background: var(--brand-blue); color: #fff; }
.btn-success:hover { background: #004a8f; }
.btn-icon { background: rgba(255,255,255,0.15); color: #fff; padding: 8px; border-radius: 6px; }
.btn-icon:hover { background: rgba(255,255,255,0.3); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ==================== 主布局 ==================== */
.main-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ==================== 左侧栏 ==================== */
.sidebar {
    width: 240px;
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-title {
    padding: 16px 20px 12px;
    font-size: 13px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.template-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 8px;
}

.template-item {
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    margin-bottom: 4px;
}
.template-item:hover { background: #f0f7ef; }
.template-item.active { background: #e8f5e8; border-left: 3px solid var(--brand-green); }
.template-item .tpl-name { font-size: 14px; font-weight: 500; color: var(--text-primary); }
.template-item .tpl-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.sidebar-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ccc;
}
.status-dot.connected { background: var(--brand-green); }
.status-dot.disconnected { background: #f5222d; }

/* ==================== 编辑区 ==================== */
.editor-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 24px 32px;
}

.field-area { margin-bottom: 16px; }
.field-placeholder {
    text-align: center;
    color: var(--text-muted);
    padding: 60px 0;
    font-size: 16px;
}

.field-group { margin-bottom: 14px; }
.field-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.field-input, .field-textarea, .field-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
    transition: border-color 0.2s;
}
.field-input:focus, .field-textarea:focus, .field-select:focus {
    outline: none;
    border-color: var(--brand-green);
    box-shadow: 0 0 0 2px rgba(78,179,65,0.1);
}
.field-textarea { min-height: 72px; resize: vertical; }

.extra-instruction {
    margin-top: 16px;
}
.extra-instruction textarea {
    width: 100%;
    min-height: 60px;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    resize: vertical;
}

/* ==================== 生成栏 ==================== */
.generate-bar {
    display: flex;
    align-items: center;
    gap: 20px;
    margin: 20px 0;
    padding: 16px 0;
    border-top: 1px solid var(--border-color);
}

.temperature-control {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}
.temperature-control input[type="range"] {
    width: 120px;
    accent-color: var(--brand-green);
}
#temperature-value { font-weight: 600; min-width: 30px; }

/* ==================== 标题 & 正文 ==================== */
.title-area { margin-bottom: 16px; }
.title-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--brand-green);
    border-radius: 8px;
    font-size: 18px;
    font-weight: 600;
    background: #fff;
}
.title-input:focus { outline: none; box-shadow: 0 0 0 3px rgba(78,179,65,0.15); }

.content-area { flex: 1; margin-bottom: 16px; }
.content-textarea {
    width: 100%;
    min-height: 400px;
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    line-height: 1.8;
    resize: vertical;
    background: #fff;
}
.content-textarea:focus { outline: none; border-color: var(--brand-green); }

/* ==================== 操作栏 ==================== */
.action-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 0;
    border-top: 1px solid var(--border-color);
}
.author-input {
    width: 140px;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
}
.author-input:focus { outline: none; border-color: var(--brand-green); }

/* ==================== 加载遮罩 ==================== */
.loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.45);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay p {
    color: #fff;
    margin-top: 16px;
    font-size: 16px;
}

/* ==================== 弹窗 ==================== */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}
.modal-content {
    background: #fff;
    border-radius: 12px;
    width: 480px;
    max-width: 90%;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}
.modal-header h2 { font-size: 18px; }
.btn-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
}
.btn-close:hover { color: var(--text-primary); }

.modal-body { padding: 24px; }
.form-group { margin-bottom: 20px; }
.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
}
.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
}
.form-input:focus { outline: none; border-color: var(--brand-green); }
.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}
.form-hint a { color: var(--brand-blue); }
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

/* ==================== 提示消息 ==================== */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(51,51,51,0.95);
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 2000;
    animation: fadeInUp 0.3s ease;
}
.toast.success { background: var(--brand-green); }
.toast.error { background: #f5222d; }
@keyframes fadeInUp {
    from { opacity: 0; transform: translate(-50%, 20px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* ==================== 滚动条 ==================== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #aaa; }

/* ==================== 顶部标签页 ==================== */
.top-tabs {
    display: flex;
    gap: 4px;
    margin-right: 8px;
    background: rgba(255,255,255,0.15);
    border-radius: 8px;
    padding: 3px;
}
.top-tab {
    border: none;
    background: transparent;
    color: rgba(255,255,255,0.85);
    font-size: 14px;
    font-weight: 500;
    padding: 6px 18px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s;
}
.top-tab:hover { color: #fff; }
.top-tab.active { background: #fff; color: var(--brand-green); font-weight: 600; }
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--brand-orange);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
}
.top-tab.active .badge { background: var(--brand-orange); color: #fff; }

/* ==================== 范文库页面 ==================== */
.samples-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px 32px;
}
.samples-container {
    display: flex;
    gap: 20px;
    max-width: 1400px;
    margin: 0 auto;
    align-items: flex-start;
}
.samples-left {
    width: 46%;
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex-shrink: 0;
}
.samples-right { flex: 1; min-width: 0; }

.card {
    background: var(--bg-card);
    border-radius: 10px;
    box-shadow: var(--shadow);
    padding: 18px 20px;
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.card-header h3 { font-size: 15px; font-weight: 600; }
.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}
.hint-text { font-size: 12px; color: var(--text-muted); }
.btn-sm { padding: 5px 14px; font-size: 13px; }

.profile-textarea {
    width: 100%;
    min-height: 180px;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.7;
    resize: vertical;
}
.profile-textarea:focus { outline: none; border-color: var(--brand-green); }

.sample-form .form-row {
    display: flex;
    gap: 12px;
}
.form-col { flex: 1; margin-bottom: 10px; }
.form-col-sm { flex: 0 0 140px; }
.form-col label, .sample-form label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.form-actions-left { margin-top: 4px; }

.url-import { display: flex; gap: 10px; }
.url-import .form-input { flex: 1; }

/* 范文列表 */
.list-card { min-height: 300px; }
.samples-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: calc(100vh - 160px);
    overflow-y: auto;
    padding-right: 4px;
}
.sample-item {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 14px;
    transition: border-color 0.15s;
}
.sample-item:hover { border-color: var(--brand-green); }
.sample-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}
.sample-title {
    font-size: 14px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}
.sample-tags { display: flex; gap: 6px; flex-shrink: 0; }
.tag {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}
.tag-category { background: #e8f5e8; color: #2d7a22; }
.tag-company { background: #e7f0fa; color: var(--brand-blue); }
.tag-web { background: #fdf0e3; color: var(--brand-orange); }
.sample-meta { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.sample-excerpt {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 6px;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.sample-ops { margin-top: 8px; display: flex; gap: 14px; }
.btn-link {
    border: none;
    background: none;
    color: var(--brand-blue);
    font-size: 12px;
    cursor: pointer;
    padding: 0;
}
.btn-link:hover { text-decoration: underline; }
.btn-link.btn-del { color: #e05555; }

.empty-tip {
    text-align: center;
    color: var(--text-muted);
    padding: 60px 0;
    font-size: 14px;
}

/* 生成栏：范文开关 */
.samples-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}
.samples-toggle input { accent-color: var(--brand-green); width: 15px; height: 15px; }

/* ==================== 顶级文章模块 ==================== */
.modal-wide { width: 640px; max-height: 85vh; overflow-y: auto; }

.angles-list { display: flex; flex-direction: column; gap: 12px; }

.angle-card {
    border: 2px solid var(--border-color);
    border-radius: 10px;
    padding: 14px 16px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.angle-card:hover { border-color: var(--brand-green); }
.angle-card.selected {
    border-color: var(--brand-green);
    background: #f2faf4;
}

.angle-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.angle-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px; height: 24px;
    border-radius: 50%;
    background: var(--brand-green);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
}
.angle-type {
    font-size: 12px;
    color: var(--brand-green);
    border: 1px solid var(--brand-green);
    border-radius: 10px;
    padding: 1px 8px;
    flex-shrink: 0;
}
.angle-title { font-size: 15px; font-weight: 600; color: var(--text-primary); }

.angle-view, .angle-approach, .angle-hook {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-top: 4px;
}
.angle-view strong, .angle-approach strong, .angle-hook strong { color: var(--text-primary); }
.angle-view { color: #1a5c2e; }

/* ==================== 公众号排版 ==================== */
.wechat-style-list { display: flex; gap: 12px; padding: 14px 20px 4px; }

.wechat-preview {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin: 12px 20px 0;
    padding: 28px 26px;
    min-height: 320px;
    max-height: 460px;
    overflow-y: auto;
}
.wechat-preview h1 { font-size: 20px; }
.wechat-preview .empty-tip { padding: 60px 0; }

.wechat-style-card {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    padding: 14px 16px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.wechat-style-card:hover { border-color: var(--brand-green); }
.wechat-style-card.selected {
    border-color: var(--brand-green);
    background: #f2faf4;
}

.style-dot {
    width: 26px; height: 26px;
    border-radius: 50%;
    flex-shrink: 0;
}
.style-name { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.style-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.component-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    flex-wrap: wrap;
}

/* ==================== 账号登录 ==================== */
#auth-login-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: linear-gradient(135deg, #0f5c36 0%, #178a4f 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}
#auth-login-overlay[style*="display: none"],
#auth-login-overlay[style*="display:none"] { display: none !important; }

.auth-login-card {
    background: #fff;
    border-radius: 14px;
    padding: 36px 40px;
    width: 360px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.25);
    text-align: center;
}
.auth-login-title { font-size: 21px; font-weight: 700; color: #0f5c36; }
.auth-login-sub { font-size: 14px; color: #888; margin-top: 6px; margin-bottom: 24px; }
.auth-login-form { display: flex; flex-direction: column; gap: 12px; }
.auth-login-form input {
    padding: 12px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 15px;
    outline: none;
    transition: border-color .2s;
}
.auth-login-form input:focus { border-color: #178a4f; }
.auth-login-form .btn-primary {
    padding: 12px;
    border: none;
    border-radius: 8px;
    background: #178a4f;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    transition: background .2s;
}
.auth-login-form .btn-primary:hover { background: #0f5c36; }
.auth-login-form .btn-primary:disabled { background: #9cc7ae; cursor: not-allowed; }
.auth-error { color: #e74c3c; font-size: 13px; text-align: left; }
.auth-login-tip { margin-top: 14px; font-size: 12px; color: #999; display: none; }

/* 顶部用户栏 */
.auth-userbar {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 14px;
    padding-left: 14px;
    border-left: 1px solid rgba(255,255,255,0.25);
}
.auth-username-label {
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.btn-auth-link {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.35);
    color: #fff;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background .2s;
}
.btn-auth-link:hover { background: rgba(255,255,255,0.15); }
.btn-auth-manage { border-color: #ffd54d; color: #ffd54d; }
.btn-auth-manage:hover { background: rgba(255,213,77,0.15); }

/* 账号管理弹窗 */
.auth-modal .modal-content { max-width: 720px; width: 92%; }
.auth-user-add {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 110px 80px;
    gap: 8px;
    margin-bottom: 14px;
}
.auth-user-add input, .auth-user-add select {
    padding: 9px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
}
.auth-user-add input:focus, .auth-user-add select:focus { border-color: #178a4f; }
.auth-user-list { max-height: 380px; overflow-y: auto; }
.auth-user-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 4px;
    border-bottom: 1px solid #f0f0f0;
}
.auth-user-info { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.auth-user-name { font-weight: 600; font-size: 14px; }
.auth-user-uname { color: #999; font-size: 13px; }
.auth-user-time { color: #bbb; font-size: 12px; }
.auth-role-admin {
    background: #fff3cd; color: #856404;
    font-size: 11px; padding: 2px 8px; border-radius: 10px;
}
.auth-role-staff {
    background: #e8f5e9; color: #2e7d32;
    font-size: 11px; padding: 2px 8px; border-radius: 10px;
}
.auth-user-ops { display: flex; gap: 6px; }
.btn-mini { font-size: 12px; padding: 4px 10px; border-radius: 6px; }
.btn-danger { background: #e74c3c; color: #fff; border: none; cursor: pointer; }
.btn-danger:hover { background: #c0392b; }
.auth-op-pwd {
    background: #fff; border: 1px solid #bbb; color: #555; cursor: pointer;
}
.auth-op-pwd:hover { border-color: #178a4f; color: #178a4f; }
.auth-user-item .muted { color: #bbb; }
