/**
 * Liora - Sidebar 组件样式
 * 右侧操作面板 - 终端风格侧边栏
 */

/* ============================================
   侧边栏容器
   ============================================ */
.sidebar {
    width: clamp(300px, 28vw, 380px);
    min-width: 300px;
    max-width: 380px;
    display: flex;
    flex-direction: column;
    background-color: var(--color-bg);
    border-left: 1px solid var(--color-border);
    font-family: var(--font-mono);
}

/* ============================================
   选项卡 - 类终端标签
   ============================================ */
.tabs {
    display: flex;
    background: var(--color-bg-secondary);
    border-bottom: 1px solid var(--color-border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
    display: none;
}

.tab {
    flex: 1;
    padding: 10px 8px;
    border: none;
    border-right: 1px solid var(--color-border-light);
    background-color: transparent;
    cursor: pointer;
    font-size: 11px;
    font-family: var(--font-mono);
    font-weight: 500;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #000000;
}

.tab:last-child {
    border-right: none;
}

.tab.active {
    background-color: var(--color-bg);
    color: #000000;
    box-shadow: inset 0 2px 0 var(--color-memory);
}

.tab:not(.active):hover {
    background-color: rgba(0,0,0,0.02);
    color: #000000;
}

.tab:focus-visible {
    outline: 2px solid var(--color-memory);
    outline-offset: -2px;
    z-index: 1;
}

/* ============================================
   面板内容
   ============================================ */
.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.panel {
    display: none;
}

.panel.active {
    display: flex;
    flex-direction: column;
}

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

.form-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-secondary);
    margin-bottom: 8px;
}

.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border-light);
    font-family: var(--font-sans);
    font-size: 14px;
    background: var(--color-bg);
    transition: all 0.2s ease;
}

.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--color-memory);
    box-shadow: 0 0 0 3px var(--color-memory-light);
}

.form-textarea {
    min-height: 120px;
    resize: vertical;
    line-height: 1.6;
}

.char-count {
    font-weight: normal;
    color: var(--color-text-muted);
    text-transform: none;
}

/* ============================================
   文本域包装器
   ============================================ */
.textarea-wrapper {
    position: relative;
}

.mention-popup {
    position: absolute;
    bottom: 100%;
    left: 0;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-lg);
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

/* ============================================
   文件上传
   ============================================ */
.file-upload {
    display: block;
    padding: 20px;
    border: 2px dashed var(--color-border-light);
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.file-upload:hover {
    border-color: var(--color-memory);
    background: var(--color-bg-secondary);
}

.file-upload input[type="file"] {
    display: none;
}

.file-upload-hint {
    font-size: 13px;
    color: var(--color-text-muted);
}

.file-preview {
    margin-top: 12px;
    padding: 12px;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border-light);
}

/* ============================================
   按钮
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.btn-primary {
    width: 100%;
    background: var(--color-memory);
    color: white;
    border-color: var(--color-memory);
}

.btn-primary:hover {
    background: #6a5b7a;
}

.btn-send {
    padding: 8px;
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================
   记忆搜索
   ============================================ */
.memory-search {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.memory-search input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--color-border-light);
    font-family: var(--font-sans);
    font-size: 14px;
}

.memory-search button {
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
}

/* ============================================
   记忆列表
   ============================================ */
.memory-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ============================================
   记忆弹窗
   ============================================ */
.memory-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.memory-modal.show {
    display: flex;
}

.memory-modal-content {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
}

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

.memory-modal-title {
    font-weight: 600;
}

.memory-modal-close {
    border: none;
    background: transparent;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
}

.memory-modal-body {
    padding: 20px;
}

/* ============================================
   统计面板
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

/* 超小屏幕单列布局 */
@media (max-width: 360px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

.stat-card {
    padding: 16px;
    border: 1px solid var(--color-border-light);
    text-align: center;
}

.stat-card.primary {
    border-color: var(--color-memory);
    background: var(--color-memory-light);
}

.stat-number {
    font-size: 24px;
    font-weight: 600;
    color: var(--color-memory);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-secondary);
}

.stats-section {
    margin-bottom: 24px;
}

.stats-section-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.section-icon {
    font-size: 14px;
}

/* ============================================
   热力图
   ============================================ */
.heatmap-header {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--color-text-muted);
    margin-bottom: 8px;
}

.heatmap-container {
    display: grid;
    grid-template-columns: repeat(30, 1fr);
    gap: 2px;
    margin-bottom: 8px;
}

.heatmap-legend {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    font-size: 11px;
}

.legend-cell {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.legend-cell.level-0 { background: var(--color-bg-tertiary); }
.legend-cell.level-1 { background: #dcd5e3; }
.legend-cell.level-2 { background: #c0b5cc; }
.legend-cell.level-3 { background: #a295b0; }
.legend-cell.level-4 { background: var(--color-memory); }

/* ============================================
   情感条
   ============================================ */
.emotion-bars {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.emotion-bar-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.emotion-label {
    font-size: 13px;
    width: 60px;
}

.emotion-bar {
    flex: 1;
    height: 8px;
    background: var(--color-bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

.emotion-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.emotion-fill.positive { background: #1a936f; }
.emotion-fill.neutral { background: #999; }
.emotion-fill.negative { background: #c5283d; }

.emotion-count {
    font-size: 12px;
    color: var(--color-text-muted);
    width: 30px;
    text-align: right;
}

/* ============================================
   历史上的今天
   ============================================ */
.timetravel-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--color-border-light);
}

.timetravel-icon-large {
    font-size: 32px;
}

.timetravel-title {
    flex: 1;
}

.timetravel-main {
    font-size: 16px;
    font-weight: 600;
}

.timetravel-sub {
    font-size: 12px;
    color: var(--color-text-muted);
}

.timetravel-quote {
    font-style: italic;
    color: var(--color-text-secondary);
    padding: 12px;
    border-left: 3px solid var(--color-memory);
    background: var(--color-bg-secondary);
    margin-bottom: 20px;
}

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

.timetravel-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--color-text-muted);
}

.empty-icon {
    font-size: 32px;
    margin-bottom: 12px;
}

.empty-text {
    font-size: 14px;
    margin-bottom: 4px;
}

.empty-hint {
    font-size: 12px;
    opacity: 0.7;
}

/* ============================================
   探索面板
   ============================================ */
.explore-node-card {
    background: var(--color-bg);
    border: 1px solid var(--color-border-light);
    margin-bottom: 16px;
}

.node-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--color-bg-secondary);
    border-bottom: 1px solid var(--color-border-light);
}

.node-card-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--color-memory);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
}

.node-card-info {
    flex: 1;
}

.node-card-name {
    font-weight: 600;
    margin-bottom: 2px;
}

.node-card-type {
    font-size: 11px;
    color: var(--color-text-muted);
    text-transform: uppercase;
}

.node-card-body {
    padding: 12px 16px;
}

.node-meta-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--color-border-light);
}

.node-meta-row:last-child {
    border-bottom: none;
}

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

.meta-value {
    font-size: 12px;
    font-weight: 600;
}

/* ============================================
   探索聊天
   ============================================ */
.explore-chat-section {
    border: 1px solid var(--color-border-light);
    margin-bottom: 16px;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--color-bg-secondary);
    border-bottom: 1px solid var(--color-border-light);
    font-size: 12px;
    font-weight: 600;
}

.chat-messages {
    height: 200px;
    overflow-y: auto;
    padding: 12px;
}

.chat-empty {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--color-text-muted);
}

.chat-empty .empty-icon {
    margin-bottom: 8px;
}

.chat-empty .empty-text {
    font-size: 12px;
    line-height: 1.5;
}

.chat-input-area {
    display: flex;
    border-top: 1px solid var(--color-border-light);
}

.chat-input-area textarea {
    flex: 1;
    padding: 10px 12px;
    border: none;
    resize: none;
    font-family: var(--font-sans);
    font-size: 13px;
}

.chat-input-area textarea:focus {
    outline: none;
}

/* ============================================
   快捷提示
   ============================================ */
.explore-quick-prompts {
    margin-bottom: 16px;
}

.quick-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-secondary);
    margin-bottom: 8px;
}

.quick-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.quick-tag {
    padding: 6px 10px;
    border: 1px solid var(--color-border-light);
    background: var(--color-bg);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quick-tag:hover {
    border-color: var(--color-memory);
    background: var(--color-memory-light);
}

/* ============================================
   路径探索
   ============================================ */
.explore-path-finder {
    border: 1px solid var(--color-border-light);
    padding: 12px;
}

.path-finder-box {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
}

.path-from-to {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 12px;
    background: var(--color-bg-secondary);
    font-size: 13px;
}

.path-arrow {
    color: var(--color-memory);
    font-weight: 600;
}

.btn-find-path {
    padding: 10px;
    border: 1px solid var(--color-memory);
    background: var(--color-memory);
    color: white;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 12px;
    text-transform: uppercase;
}

.btn-find-path:hover {
    background: #6a5b7a;
}

.path-result {
    margin-top: 12px;
    padding: 12px;
    background: var(--color-bg-secondary);
    font-size: 13px;
}

/* ============================================
   记忆故事生成
   ============================================ */
.explore-story-gen {
    background: linear-gradient(135deg, var(--color-bg-secondary), var(--color-bg-tertiary));
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 16px;
    margin-top: 20px;
}

.explore-story-gen .quick-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-memory);
    margin-bottom: 12px;
}

.explore-story-gen .quick-title::before {
    content: '📖';
    font-size: 14px;
}

.btn-story {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--color-memory);
    background: var(--color-bg);
    color: var(--color-memory);
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 12px;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-story:hover {
    background: var(--color-memory);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(122, 107, 138, 0.2);
}

.btn-story:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.story-result {
    margin-top: 16px;
    padding: 20px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.8;
    display: none;
    animation: fadeInUp 0.4s ease;
}

.story-result.show {
    display: block;
}

.story-result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px dashed var(--color-border);
}

.story-result-title {
    font-family: var(--font-serif);
    font-size: 14px;
    font-weight: 600;
    color: var(--color-memory);
    letter-spacing: 1px;
}

.story-result-content {
    font-family: var(--font-serif);
    font-size: 15px;
    line-height: 1.9;
    color: var(--color-text);
    font-style: italic;
    text-align: justify;
}

.story-result-content p {
    margin-bottom: 12px;
}

.story-result-content p:last-child {
    margin-bottom: 0;
}

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

.story-result-brand {
    font-family: var(--font-serif);
    font-size: 12px;
    color: var(--color-text-muted);
    font-style: italic;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 加载动画 */
.loading-dots {
    position: relative;
}

.loading-dots::after {
    content: '...';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: ''; }
    40% { content: '.'; }
    60% { content: '..'; }
    80%, 100% { content: '...'; }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.story-error {
    color: #c62828;
    font-weight: 500;
    padding: 12px;
    background: rgba(198, 40, 40, 0.05);
    border-radius: 6px;
    border-left: 3px solid #c62828;
}

/* ============================================
   状态消息
   ============================================ */
.status-message {
    padding: 10px 12px;
    margin-bottom: 16px;
    font-size: 13px;
    display: none;
}

.status-message.success {
    display: block;
    background: rgba(26, 147, 111, 0.1);
    border: 1px solid #1a936f;
    color: #1a936f;
}

.status-message.error {
    display: block;
    background: rgba(197, 40, 61, 0.1);
    border: 1px solid #c5283d;
    color: #c5283d;
}
