/* Knowledge Journal - Dark Mode CSS */

:root {
    --bg-primary: #0c0c0d;
    --bg-secondary: #1a1a1b;
    --bg-tertiary: #2a2a2b;
    --bg-hover: #3a3a3b;
    --text-primary: #ececec;
    --text-secondary: #a0a0a0;
    --text-muted: #707070;
    --border-color: #2d2d2d;
    --accent-color: #10a37f;
    --accent-hover: #0d8f6f;
    --user-msg-bg: #2a2a2b;
    --assistant-msg-bg: #1a1a1b;
    --input-bg: #2a2a2b;
    --sidebar-width: 260px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    position: relative;
}

/* Sidebar Styles */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    position: relative;
    z-index: 100;
}

.sidebar-header {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
}

.new-chat-btn {
    width: 100%;
    padding: 10px 12px;
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    transition: all 0.2s;
}

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

.sidebar-section {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--bg-hover) transparent;
}

.sidebar-section::-webkit-scrollbar {
    width: 6px;
}

.sidebar-section::-webkit-scrollbar-thumb {
    background-color: var(--bg-hover);
    border-radius: 3px;
}

.section-header {
    padding: 12px 16px 8px;
    position: sticky;
    top: 0;
    background-color: var(--bg-secondary);
    z-index: 10;
}

.section-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Category List */
.category-list {
    padding: 4px 8px;
}

.category-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
    margin-bottom: 2px;
}

.category-item:hover {
    background-color: var(--bg-hover);
}

.category-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.category-name {
    font-size: 14px;
    color: var(--text-primary);
}

/* Conversation List */
.conversation-list {
    padding: 4px 8px;
}

.conversation-item {
    position: relative;
    margin-bottom: 4px;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.conversation-item:hover {
    background-color: var(--bg-hover);
}

.conversation-item.active {
    background-color: var(--bg-tertiary);
}

.conversation-link,
.conversation-link:link,
.conversation-link:visited,
.conversation-link:hover,
.conversation-link:active {
    display: block;
    padding: 10px 12px;
    text-decoration: none;
    color: var(--text-primary) !important;
}

/* Override any link colors in conversation area */
.conversation-list a {
    color: var(--text-primary) !important;
}

.conversation-title {
    font-size: 14px;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

/* Summary Toggle and Display */
.summary-toggle {
    position: absolute;
    right: 8px;
    top: 12px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
}

.summary-toggle:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.conversation-summary {
    padding: 8px 12px;
    border-top: 1px solid var(--border-color);
    background-color: rgba(0, 0, 0, 0.2);
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
    }
    to {
        opacity: 1;
        max-height: 200px;
    }
}

.summary-content {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 8px;
}

.summary-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.category-tag {
    display: inline-block;
    padding: 2px 8px;
    background-color: var(--accent-color);
    color: white;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-primary);
    position: relative;
}

.mobile-header {
    display: none;
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
}

.menu-toggle {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 4px;
}

.mobile-title {
    font-size: 18px;
    font-weight: 600;
    margin-left: 12px;
    display: inline-block;
}

/* Chat Container */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 20px;
}

.messages-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

/* Welcome Message */
.welcome-message {
    text-align: center;
    padding: 60px 20px;
}

.welcome-message h2 {
    font-size: 32px;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.welcome-message p {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 40px;
    line-height: 1.6;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 40px;
}

.feature-card {
    background-color: var(--bg-secondary);
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.feature-icon {
    font-size: 32px;
    display: block;
    margin-bottom: 12px;
}

.feature-card h3 {
    font-size: 16px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.feature-card p {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
}

/* Messages */
.message {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    animation: fadeIn 0.3s ease;
}

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.user-message .message-avatar {
    background-color: var(--user-msg-bg);
}

.assistant-message .message-avatar {
    background-color: var(--accent-color);
}

.message-content {
    flex: 1;
    line-height: 1.6;
    font-size: 15px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.user-message .message-content {
    color: var(--text-primary);
}

.assistant-message .message-content {
    color: var(--text-primary);
}

/* Input Container */
.input-container {
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-primary);
    padding: 12px 20px 20px;
}

.input-wrapper {
    max-width: 800px;
    margin: 0 auto;
    position: relative;
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.message-input {
    flex: 1;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    padding: 12px 50px 12px 16px;
    font-size: 15px;
    resize: none;
    outline: none;
    min-height: 44px;
    max-height: 200px;
    font-family: inherit;
    line-height: 1.5;
}

.message-input:focus {
    border-color: var(--accent-color);
}

.send-button {
    position: absolute;
    right: 8px;
    bottom: 8px;
    background-color: var(--accent-color);
    border: none;
    border-radius: 6px;
    color: white;
    padding: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.send-button:hover:not(:disabled) {
    background-color: var(--accent-hover);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: var(--bg-secondary);
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
}

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

.modal-header h2 {
    font-size: 20px;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* Category View */
.category-summary {
    background-color: var(--bg-tertiary);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
}

.category-summary h3 {
    font-size: 16px;
    margin-bottom: 12px;
    color: var(--accent-color);
}

.category-entries {
    margin-top: 20px;
}

.entry-item {
    background-color: var(--bg-tertiary);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
    border-left: 3px solid var(--accent-color);
}

.entry-content {
    margin-bottom: 8px;
    line-height: 1.6;
}

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

/* Ember Outline */
.ember-outline {
    background-color: var(--bg-tertiary);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}

.ember-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--accent-color);
}

.chapter-item {
    margin-left: 20px;
    margin-bottom: 8px;
    padding: 8px;
    background-color: var(--bg-secondary);
    border-radius: 4px;
}

.chapter-title {
    font-weight: 500;
    margin-bottom: 4px;
}

.chapter-notes {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Loading Spinner */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    border-top-color: var(--accent-color);
    animation: spin 0.8s linear infinite;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        transform: translateX(-100%);
        z-index: 1000;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .mobile-header {
        display: flex;
        align-items: center;
    }
    
    .feature-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        width: 95%;
        max-height: 90vh;
    }
}

/* Ember Detail View */
.ember-detail-container {
    padding: 20px;
}

.ember-header {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.ember-icon {
    width: 60px;
    height: 60px;
    background: var(--accent-color);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ember-icon svg {
    width: 32px;
    height: 32px;
    stroke: white;
}

.ember-info h2 {
    margin: 0 0 8px 0;
    color: var(--text-primary);
}

.ember-description {
    color: var(--text-secondary);
    font-size: 14px;
}

.ember-preview {
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 4px;
}

.no-details {
    text-align: center;
    padding: 40px;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.no-details .hint {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 12px;
}

.ember-insights h3 {
    color: var(--accent-color);
    margin-bottom: 20px;
}

.insight-card {
    background: var(--bg-tertiary);
    border-left: 3px solid var(--accent-color);
    padding: 16px;
    margin-bottom: 16px;
    border-radius: 4px;
}

.insight-text {
    color: var(--text-primary);
    line-height: 1.6;
    margin-bottom: 12px;
}

.insight-source {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.insight-source a {
    color: var(--accent-color) !important;
    text-decoration: none;
}

.insight-source a:hover {
    text-decoration: underline;
}

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

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background-color: var(--bg-hover);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background-color: var(--text-muted);
}