/* ========================================
   高级感前端优化 - 深色主题统一风格
   ======================================== */

/* 全局深色背景协调 */
:root {
    --deep-navy: #0B0E14;
    --slate-800: #1E293B;
    --slate-700: #334155;
    --slate-600: #475569;
    --cyan-accent: #22D3EE;
    --orange-accent: #F97316;
    --teal-accent: #4FD1C5;
    --off-white: #F8FAFC;
    --slate-border: rgba(148, 163, 184, 0.12);
}

/* ===== 角色档案优化布局 ===== */
.characters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    max-height: 75vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px;
}

/* 优化滚动条 - 深色主题 */
.characters-grid::-webkit-scrollbar {
    width: 6px;
}

.characters-grid::-webkit-scrollbar-track {
    background: rgba(30, 41, 59, 0.3);
    border-radius: 3px;
}

.characters-grid::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #22D3EE 0%, #4FD1C5 100%);
    border-radius: 3px;
}

.characters-grid::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #06B6D4 0%, #14B8A6 100%);
}

/* 角色卡片 - 深色高级感 */
.character-card {
    background: linear-gradient(135deg, #1E293B 0%, #0F172A 100%);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 10px;
    padding: 20px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.character-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(34, 211, 238, 0.08) 0%, transparent 70%);
    pointer-events: none;
    transition: transform 0.6s ease;
}

.character-card:hover::before {
    transform: translate(-20px, 20px);
}

.character-card:hover {
    border-color: #22D3EE;
    box-shadow: 0 8px 24px rgba(34, 211, 238, 0.15);
    transform: translateY(-2px);
}

/* 角色头部 */
.character-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.character-avatar {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    background: linear-gradient(135deg, #22D3EE 0%, #4FD1C5 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0B0E14;
    font-size: 22px;
    font-weight: 800;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(34, 211, 238, 0.3);
    font-family: 'Inter', -apple-system, sans-serif;
}

.character-name-group {
    flex: 1;
    min-width: 0;
}

.character-name {
    font-size: 16px;
    font-weight: 700;
    color: #F8FAFC;
    margin-bottom: 5px;
    letter-spacing: -0.01em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.character-role {
    font-size: 11px;
    color: #22D3EE;
    background: rgba(34, 211, 238, 0.12);
    padding: 3px 9px;
    border-radius: 6px;
    display: inline-block;
    font-weight: 600;
    border: 1px solid rgba(34, 211, 238, 0.2);
}

/* 角色属性网格 - 紧凑布局 */
.character-attrs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 14px;
}

.character-attr-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: rgba(30, 41, 59, 0.5);
    padding: 10px;
    border-radius: 6px;
    border-left: 2px solid #4FD1C5;
}

.character-attr-label {
    font-size: 10px;
    color: #94A3B8;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.character-attr-value {
    font-size: 13px;
    color: #F8FAFC;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 角色描述 - 完整显示 */
.character-desc {
    font-size: 12px;
    line-height: 1.7;
    color: #CBD5E1;
    padding: 12px;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 6px;
    border-left: 3px solid #22D3EE;
    max-height: none;
    overflow: visible;
}

/* 角色标签 */
.character-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
}

.character-tag {
    font-size: 10px;
    padding: 4px 9px;
    background: rgba(79, 209, 197, 0.12);
    color: #4FD1C5;
    border-radius: 6px;
    font-weight: 600;
    border: 1px solid rgba(79, 209, 197, 0.2);
}

/* 角色名称编辑区域 */
.character-name-edit {
    margin-top: 12px;
    padding: 12px;
    background: rgba(30, 41, 59, 0.4);
    border-radius: 6px;
    border: 1px solid rgba(148, 163, 184, 0.1);
}

.character-name-edit select,
.character-name-edit input {
    width: 100%;
    padding: 8px 10px;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 6px;
    color: #F8FAFC;
    font-size: 13px;
    margin-bottom: 8px;
}

.character-name-edit select:focus,
.character-name-edit input:focus {
    outline: none;
    border-color: #22D3EE;
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.1);
}

.character-name-edit button {
    padding: 7px 14px;
    background: linear-gradient(135deg, #22D3EE 0%, #4FD1C5 100%);
    color: #0B0E14;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-right: 6px;
}

.character-name-edit button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(34, 211, 238, 0.3);
}

.character-name-edit button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ===== 世界设定优化 - 完整显示 ===== */
.outline-box {
    background: linear-gradient(135deg, #1E293B 0%, #0F172A 100%);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.outline-box h3,
.outline-box h4 {
    color: #F8FAFC;
    font-weight: 700;
    margin-bottom: 12px;
    letter-spacing: -0.01em;
}

.outline-box p,
.outline-box div {
    color: #CBD5E1;
    line-height: 1.7;
    font-size: 13px;
    max-height: none;
    overflow: visible;
}

.outline-box strong {
    color: #F8FAFC;
    font-weight: 600;
}

/* 展开区域优化 */
.outline-stage {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    transition: all 0.25s ease;
}

.outline-stage:hover {
    border-color: #22D3EE;
    box-shadow: 0 4px 12px rgba(34, 211, 238, 0.12);
}

.outline-stage-title {
    color: #F8FAFC;
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 10px;
}

.outline-stage-content {
    color: #CBD5E1;
    line-height: 1.7;
    font-size: 13px;
}

/* ===== 编辑大纲按钮优化 ===== */
.outline-edit-btn,
button[onclick*="editOutline"] {
    padding: 8px 16px;
    background: linear-gradient(135deg, #F97316 0%, #FB923C 100%);
    color: #ffffff;
    border: none;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 2px 8px rgba(249, 115, 22, 0.2);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.outline-edit-btn:hover,
button[onclick*="editOutline"]:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(249, 115, 22, 0.35);
}

.outline-edit-btn:active,
button[onclick*="editOutline"]:active {
    transform: translateY(0);
}

/* 统一图标风格 - 使用 Lucide icons 风格 */
.icon-edit::before {
    content: "✏️";
    font-size: 14px;
    margin-right: 4px;
}

.icon-save::before {
    content: "💾";
    font-size: 14px;
    margin-right: 4px;
}

.icon-generate::before {
    content: "✨";
    font-size: 14px;
    margin-right: 4px;
}

/* ===== 右侧工具栏优化 ===== */
.writer-tool-btn {
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(148, 163, 184, 0.15);
    color: #CBD5E1;
    transition: all 0.25s ease;
}

.writer-tool-btn:hover {
    background: rgba(34, 211, 238, 0.12);
    border-color: #22D3EE;
    color: #22D3EE;
}

.writer-tool-btn.selected {
    background: linear-gradient(135deg, #22D3EE 0%, #4FD1C5 100%);
    border-color: #22D3EE;
    color: #0B0E14;
    font-weight: 700;
}

/* ===== 响应式优化 ===== */
@media (max-width: 1024px) {
    .characters-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 16px;
    }
}

@media (max-width: 768px) {
    .characters-grid {
        grid-template-columns: 1fr;
        max-height: 65vh;
    }
    
    .character-attrs {
        grid-template-columns: 1fr;
    }
    
    .character-card {
        padding: 16px;
    }
}

/* ===== 主题提示框优化 ===== */
.theme-hint {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: rgba(34, 211, 238, 0.12);
    border: 1px solid rgba(34, 211, 238, 0.2);
    border-radius: 6px;
    color: #22D3EE;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 12px;
}

/* ===== 加载动画优化 ===== */
@keyframes shimmer {
    0% { background-position: -1000px 0; }
    100% { background-position: 1000px 0; }
}

.loading-skeleton {
    background: linear-gradient(
        90deg,
        rgba(30, 41, 59, 0.4) 0%,
        rgba(30, 41, 59, 0.6) 50%,
        rgba(30, 41, 59, 0.4) 100%
    );
    background-size: 1000px 100%;
    animation: shimmer 2s infinite;
    border-radius: 6px;
}

/* ===== 状态徽章统一 ===== */
.status-badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    border: 1px solid;
}

.status-badge.primary {
    background: rgba(34, 211, 238, 0.12);
    border-color: rgba(34, 211, 238, 0.2);
    color: #22D3EE;
}

.status-badge.warning {
    background: rgba(249, 115, 22, 0.12);
    border-color: rgba(249, 115, 22, 0.2);
    color: #F97316;
}

.status-badge.success {
    background: rgba(79, 209, 197, 0.12);
    border-color: rgba(79, 209, 197, 0.2);
    color: #4FD1C5;
}

/* ===== 高级卡片悬停效果 ===== */
.premium-card {
    position: relative;
    overflow: hidden;
}

.premium-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(34, 211, 238, 0.1),
        transparent
    );
    transition: left 0.5s ease;
}

.premium-card:hover::after {
    left: 100%;
}

/* ==================== 右侧工具面板优化 ==================== */

/* 工具面板标题区域 */
.writer-content-panel .writer-content-title,
.writer-geninfo-panel .writer-geninfo-title {
    padding: 18px 20px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.writer-content-panel .writer-content-title h3,
.writer-geninfo-panel .writer-geninfo-title h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 4px 0;
    letter-spacing: -0.01em;
}

.writer-content-panel .writer-content-subtitle,
.writer-geninfo-panel .writer-geninfo-subtitle {
    font-size: 11.5px;
    color: var(--muted);
    margin: 0;
}

/* 工具面板内容区域 */
.writer-content-panel .writer-content-body,
.writer-geninfo-panel .writer-geninfo-body {
    padding: 20px;
    overflow-y: auto;
}

/* 角色卡片网格 */
.writer-tool-character-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}

.writer-tool-character-card {
    position: relative;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

.writer-tool-character-card:hover {
    border-color: var(--brand);
    box-shadow: 0 4px 16px rgba(56, 189, 248, 0.15);
    transform: translateY(-2px);
}

/* 角色头像 */
.writer-character-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-soft) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(56, 189, 248, 0.25);
}

/* 角色信息 */
.writer-character-identity {
    margin-bottom: 10px;
}

.writer-character-identity strong {
    display: block;
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.writer-character-identity small {
    display: inline-block;
    padding: 3px 8px;
    background: var(--brand-soft);
    color: var(--brand);
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.writer-character-desc {
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--muted);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 世界设定展开面板 */
.writer-tool-setting-list details {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 10px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.writer-tool-setting-list details[open] {
    border-color: var(--brand);
}

.writer-tool-setting-list summary {
    padding: 14px 16px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.2s ease;
}

.writer-tool-setting-list summary:hover {
    background: var(--surface);
}

.writer-tool-setting-list details[open] summary {
    background: var(--brand-soft);
    color: var(--brand);
    border-bottom: 1px solid var(--border);
}

.writer-tool-setting-list .setting-content {
    padding: 16px;
    font-size: 13px;
    line-height: 1.7;
    color: var(--text);
}

/* 故事大纲摘要卡片 */
.writer-tool-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.writer-tool-summary > div {
    text-align: center;
}

.writer-tool-summary span {
    display: block;
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.writer-tool-summary strong {
    display: block;
    font-size: 22px;
    font-weight: 700;
    color: var(--brand);
}

/* 工具面板章节区块 */
.writer-tool-section {
    margin-bottom: 24px;
    padding: 18px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.writer-tool-section h3 {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 14px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.writer-tool-section p {
    font-size: 13px;
    line-height: 1.7;
    color: var(--text);
    margin: 0;
}

/* 标签列表 */
.writer-tool-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.writer-tool-tags span {
    display: inline-block;
    padding: 6px 12px;
    background: var(--brand-soft);
    color: var(--brand);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

/* 时间轴样式 */
.writer-tool-timeline {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.writer-tool-timeline article {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.writer-tool-step {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-soft) 100%);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(56, 189, 248, 0.3);
}

.writer-tool-stage-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.writer-tool-stage-head strong {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
}

.writer-tool-stage-head span {
    font-size: 11px;
    color: var(--muted);
    padding: 3px 8px;
    background: var(--surface);
    border-radius: 4px;
}

.writer-tool-timeline article p {
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--muted);
    margin: 0;
}

/* 右侧工具按钮统一样式 */
.writer-sidebar-right .writer-sidebar-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--muted);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 10px;
    font-size: 18px;
}

.writer-sidebar-right .writer-sidebar-icon:hover {
    background: var(--brand-soft);
    border-color: var(--brand);
    color: var(--brand);
    transform: translateX(-2px);
}

.writer-sidebar-right .writer-sidebar-icon.active {
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-soft) 100%);
    border-color: var(--brand);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(56, 189, 248, 0.3);
}

/* 编辑大纲按钮优化 */
.writer-edit-outline-btn,
button[onclick*="editOutline"] {
    padding: 8px 16px;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-soft) 100%);
    border: 1px solid var(--brand);
    border-radius: 6px;
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(56, 189, 248, 0.2);
}

.writer-edit-outline-btn:hover,
button[onclick*="editOutline"]:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.3);
}

.writer-edit-outline-btn:active,
button[onclick*="editOutline"]:active {
    transform: translateY(0);
}

/* 工具面板空状态 */
.writer-tool-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.writer-tool-empty-icon {
    font-size: 48px;
    color: var(--muted);
    margin-bottom: 16px;
    opacity: 0.5;
}

.writer-tool-empty strong {
    font-size: 14px;
    color: var(--text);
    font-weight: 600;
}

/* 大纲编辑器最终覆盖：避免旧增强样式产生大面积深灰卡片 */
#writerOutlineEditorBody {
    color: var(--text);
    background: var(--bg);
}

#writerOutlineEditorBody .inner-tab-content {
    background: transparent;
}

#writerOutlineEditorBody .outline-editor-character,
#writerOutlineEditorBody .edit-group {
    background: var(--card) !important;
    border: 1px solid var(--border) !important;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05) !important;
}

#writerOutlineEditorBody .outline-editor-character {
    color: var(--text);
}

#writerOutlineEditorBody .outline-editor-character p,
#writerOutlineEditorBody .outline-editor-character label,
#writerOutlineEditorBody .outline-editor-character small,
#writerOutlineEditorBody .edit-group p,
#writerOutlineEditorBody .edit-group li {
    color: var(--text-sub) !important;
}

#writerOutlineEditorBody .outline-editor-character strong,
#writerOutlineEditorBody .edit-group h4,
#writerOutlineEditorBody .edit-group strong {
    color: var(--text) !important;
}

#writerOutlineEditorBody .outline-editor-name-row,
#writerOutlineEditorBody .outline-editor-fields {
    background: transparent !important;
}

#writerOutlineEditorBody .outline-editor-name-row select,
#writerOutlineEditorBody .outline-editor-name-row input,
#writerOutlineEditorBody .outline-editor-fields input,
#writerOutlineEditorBody .outline-editor-fields textarea,
#writerOutlineEditorBody .edit-group .input-mini,
#writerOutlineEditorBody .edit-group .outline-textarea {
    background: var(--input-bg) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}

#writerOutlineEditorBody .outline-editor-name-row button {
    box-shadow: none !important;
}

#writerOutlineEditorBody .outline-editor-generate-name {
    background: transparent !important;
}

#writerOutlineEditorBody .outline-editor-character .edit-actions .btn-mini,
#writerOutlineEditorBody .edit-group .edit-actions .btn-mini {
    background: transparent !important;
    color: var(--text-sub) !important;
    border: 1px solid var(--border) !important;
}

#writerOutlineEditorBody .outline-editor-character .edit-actions .btn-mini:hover,
#writerOutlineEditorBody .edit-group .edit-actions .btn-mini:hover {
    color: var(--brand) !important;
    border-color: var(--brand) !important;
}

[data-theme="dark"] #writerOutlineEditorBody .outline-editor-character,
[data-theme="dark"] #writerOutlineEditorBody .edit-group {
    background: var(--card) !important;
    border-color: var(--border) !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18) !important;
}
