/* ========================================
   TRPG 日志染色器 - 主样式表 v2
   ======================================== */

/* ========== 浅色模式（默认）========== */
:root {
    --primary-color: #5b5fc7;
    --primary-hover: #4a4eb8;
    --accent-color: #2563eb;
    --secondary-color: #64748b;
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e2e8f0;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --border-light: #cbd5e1;
    --success-color: #16a34a;
    --warning-color: #ca8a04;
    --error-color: #dc2626;
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --msg-name-color: #2563eb;
    --msg-text-color: #1e293b;
}

/* ========== 深色模式 ========== */
[data-theme="dark"] {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --accent-color: #4fc3f7;
    --secondary-color: #64748b;
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --card-bg: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #334155;
    --border-light: #475569;
    --success-color: #22c55e;
    --warning-color: #eab308;
    --error-color: #ef4444;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
    --msg-name-color: #4fc3f7;
    --msg-text-color: #f0f0f0;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* 顶部导航栏 */
.main-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-icon { font-size: 24px; }
.logo h1 { font-size: 16px; font-weight: 600; }

.main-nav {
    display: flex;
    gap: 4px;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    font-size: 14px;
    transition: all 0.2s;
}

.nav-link:hover {
    color: var(--text-primary);
    background-color: var(--bg-tertiary);
}

.nav-link.active {
    color: var(--primary-color);
    background-color: rgba(99, 102, 241, 0.15);
}

/* 按钮样式 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover { background-color: var(--primary-hover); }

.btn-secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

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

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    background-color: transparent;
    color: var(--text-secondary);
    font-size: 18px;
}

.btn-icon:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-tool {
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
}

.btn-tool:hover {
    background-color: var(--border-light);
    color: var(--text-primary);
}

.btn-close {
    background: transparent;
    color: var(--text-secondary);
    font-size: 24px;
    width: 32px;
    height: 32px;
    padding: 0;
}

.btn-close:hover { color: var(--text-primary); }

.btn-beautify-small {
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    color: white;
    font-weight: 600;
}

.btn-beautify-small:hover {
    transform: scale(1.02);
}

.btn-export {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-export:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* 开关样式 */
.toggle-switch {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.toggle-switch input {
    display: none;
}

.toggle-slider {
    width: 40px;
    height: 22px;
    background-color: var(--bg-tertiary);
    border-radius: 11px;
    position: relative;
    transition: background-color 0.2s;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    background-color: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary-color);
}

.toggle-switch input:checked + .toggle-slider::after {
    transform: translateX(18px);
}

.toggle-label {
    font-size: 13px;
    color: var(--text-secondary);
}

/* 主内容区 */
.main-content {
    min-height: calc(100vh - 60px);
}

.page {
    display: none;
}

.page.active {
    display: block;
}

/* 上传区域 */
.upload-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 24px 16px;
}

.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 48px 24px;
    text-align: center;
    transition: all 0.3s;
    cursor: pointer;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary-color);
    background-color: rgba(99, 102, 241, 0.05);
}

.upload-icon { font-size: 48px; margin-bottom: 16px; }
.upload-area h2 { font-size: 18px; margin-bottom: 8px; }
.upload-area p { color: var(--text-secondary); font-size: 14px; }
.upload-hint { margin: 16px 0; }

.upload-options {
    margin-top: 24px;
    padding: 20px;
    background-color: var(--bg-secondary);
    border-radius: var(--radius-lg);
}

.upload-options h3 {
    font-size: 14px;
    margin-bottom: 12px;
}

.upload-options textarea {
    width: 100%;
    height: 180px;
    padding: 12px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
    margin-bottom: 12px;
}

.upload-options textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* 本地存储状态 */
.storage-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    margin-top: 15px;
    border: 1px solid var(--border-color);
}

.storage-icon {
    font-size: 20px;
}

#storageInfo {
    flex: 1;
    font-size: 13px;
    color: var(--text-secondary);
}

.btn-danger {
    background: #ef4444;
    color: white;
    border: none;
}

.btn-danger:hover {
    background: #dc2626;
}

/* 侧边面板 */
.side-panel {
    position: fixed;
    top: 0;
    right: -320px;
    width: 320px;
    height: 100%;
    background-color: var(--bg-secondary);
    z-index: 200;
    transition: right 0.3s;
    display: flex;
    flex-direction: column;
}

.side-panel.active {
    right: 0;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.panel-header h3 { font-size: 16px; }

.panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.panel-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* 过滤器样式 */
.filter-section {
    margin-bottom: 20px;
}

.filter-section h4 {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    cursor: pointer;
    font-size: 14px;
}

.filter-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.filter-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.date-filter {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.date-filter input {
    flex: 1;
    padding: 8px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
}

.date-filter span {
    color: var(--text-muted);
    font-size: 12px;
}

.date-filter-actions {
    display: flex;
    gap: 8px;
}

.qq-filter-list {
    max-height: 200px;
    overflow-y: auto;
}

.qq-filter-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    cursor: pointer;
    font-size: 13px;
}

.qq-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.qq-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.qq-number {
    font-size: 11px;
    color: var(--text-muted);
}

.qq-count {
    font-size: 11px;
    color: var(--text-muted);
}

.filter-actions {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

/* 角色管理样式 */
.character-manage-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.character-manage-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.character-color-picker {
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.character-name-input {
    flex: 1;
    padding: 6px 10px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
}

.character-name-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.character-qq {
    font-size: 11px;
    color: var(--text-muted);
}

/* 遮罩层 */
.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 150;
}

.overlay.active {
    display: block;
}

/* 模态框 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: var(--bg-secondary);
    border-radius: var(--radius-lg);
    max-width: 90vw;
    max-height: 90vh;
    overflow: auto;
    width: 400px;
}

.theme-modal {
    width: 700px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 { font-size: 18px; }

.modal-body { padding: 16px; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

/* 表单样式 */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-select,
.form-textarea {
    width: 100%;
    padding: 10px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
    font-family: inherit;
}

.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.position-selector {
    display: flex;
    gap: 8px;
}

.position-btn {
    flex: 1;
}

.position-btn.active {
    background-color: var(--primary-color);
    color: white;
}

/* 主题选择网格 */
.theme-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.theme-card {
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
    text-align: center;
}

.theme-card:hover {
    border-color: var(--border-light);
}

.theme-card.selected {
    border-color: var(--primary-color);
}

.theme-preview {
    height: 80px;
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
}

.classic-preview { background: linear-gradient(180deg, #f8fafc 0%, #e2e8f0 100%); }
.novel-preview { background: linear-gradient(180deg, #fef3c7 0%, #fde68a 100%); }
.cthulhu-preview { background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%); }
.parchment-preview { background: linear-gradient(180deg, #f5e6d3 0%, #e6d5c3 100%); }
.chinese-preview { background: linear-gradient(180deg, #fef7ed 0%, #fde8d0 100%); }
.minimal-preview { background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%); }

.theme-card h3 { font-size: 14px; margin-bottom: 4px; }
.theme-card p { font-size: 11px; color: var(--text-muted); }

/* 预览区域 */
.preview-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 16px;
}

.preview-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding: 12px;
    background-color: var(--bg-secondary);
    border-radius: var(--radius-md);
    flex-wrap: wrap;
    gap: 12px;
}

.theme-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.theme-selector label { font-size: 13px; }

.theme-selector select {
    padding: 8px 12px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
}

.export-buttons {
    display: flex;
    gap: 8px;
}

.preview-area {
    background-color: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 24px;
    min-height: 400px;
}

/* 空状态 */
.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: var(--text-muted);
    font-size: 14px;
}

/* 帮助内容 */
.help-content h3 {
    margin-top: 16px;
    margin-bottom: 10px;
    font-size: 15px;
    color: var(--primary-color);
}

.help-content ol,
.help-content ul {
    padding-left: 20px;
}

.help-content li {
    margin-bottom: 6px;
    font-size: 13px;
}
