/**
 * Explorer Module Styles
 * Memory, Conversation, and Session Browser
 */

/* Explorer Container */
.explorer-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--bg-primary);
    overflow: hidden;
}

/* Explorer Header */
.explorer-header {
    padding: 1rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.explorer-tabs {
    display: flex;
    gap: 0.5rem;
}

.explorer-tab {
    padding: 0.5rem 1rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

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

.explorer-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* Search Bar */
.explorer-search {
    display: flex;
    gap: 0.5rem;
}

.explorer-search input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.9rem;
}

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

.explorer-search input::placeholder {
    color: var(--text-muted);
}

/* Explorer Main Content */
.explorer-main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.explorer-list {
    width: 350px;
    min-width: 250px;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    background: var(--bg-secondary);
}

.explorer-detail {
    flex: 1;
    overflow-y: auto;
    background: var(--bg-primary);
    padding: 1rem;
}

/* Explorer Content Sections */
.explorer-content {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.explorer-content.hidden {
    display: none;
}

/* Empty State */
.explorer-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    text-align: center;
    color: var(--text-muted);
}

.explorer-empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.explorer-empty-hint {
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

/* Session Items */
.explorer-session-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
}

.explorer-session-item:hover {
    background: var(--bg-tertiary);
}

.explorer-session-item.active {
    background: var(--primary);
    color: white;
}

.session-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}

.session-title {
    font-weight: 500;
    font-size: 0.95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 200px;
}

.session-meta {
    display: flex;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.explorer-session-item.active .session-meta {
    color: rgba(255, 255, 255, 0.8);
}

.session-companion {
    font-weight: 500;
}

.session-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.explorer-session-item.active .session-date {
    color: rgba(255, 255, 255, 0.7);
}

.session-actions {
    display: none;
    gap: 0.25rem;
    margin-top: 0.5rem;
}

.explorer-session-item:hover .session-actions {
    display: flex;
}

/* Privacy Badges */
.privacy-badge {
    padding: 0.125rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

.badge-ephemeral {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.badge-isolated {
    background: rgba(249, 115, 22, 0.15);
    color: #f97316;
}

.badge-anonymous {
    background: rgba(234, 179, 8, 0.15);
    color: #eab308;
}

.badge-normal {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.badge-public {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}

.privacy-indicator {
    font-size: 0.7rem;
}

/* Session Detail */
.session-detail-header {
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.session-detail-title {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.session-detail-title input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.session-detail-title input:hover {
    border-color: var(--border);
}

.session-detail-title input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-secondary);
}

.session-detail-meta {
    display: flex;
    gap: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.session-detail-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.session-detail-actions {
    display: flex;
    gap: 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* Messages in Explorer */
.explorer-message {
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
    border-radius: 8px;
    background: var(--bg-secondary);
}

.explorer-message.message-user {
    background: var(--bg-tertiary);
    border-left: 3px solid var(--primary);
}

.explorer-message.message-assistant {
    border-left: 3px solid var(--text-muted);
}

.message-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.message-role {
    font-weight: 600;
    color: var(--text-primary);
}

.message-content {
    color: var(--text-primary);
    line-height: 1.6;
}

.message-content.markdown-body {
    /* Markdown styles inherited from main.css */
}

.message-content pre {
    margin: 0.5rem 0;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: 6px;
    overflow-x: auto;
}

.message-content code {
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.85em;
}

.message-model {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* Memory Items */
.explorer-memory-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

.memory-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.memory-type {
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.badge-conversation { background: #3b82f6; color: white; }
.badge-fact { background: #8b5cf6; color: white; }
.badge-preference { background: #ec4899; color: white; }
.badge-event { background: #f59e0b; color: white; }

.memory-companion {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.memory-content {
    color: var(--text-primary);
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 0.5rem;
}

.memory-footer {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.memory-importance {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.importance-bar {
    width: 60px;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
}

.importance-fill {
    height: 100%;
    background: linear-gradient(90deg, #22c55e, #eab308, #ef4444);
    border-radius: 3px;
}

/* Storage Status */
.storage-overview {
    display: flex;
    gap: 2rem;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.storage-stat {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 600;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.storage-section {
    margin-bottom: 1.5rem;
}

.storage-section h4 {
    margin-bottom: 0.75rem;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.storage-breakdown {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.storage-item {
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: 6px;
}

.storage-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.storage-item-count {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.storage-bar {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.25rem;
}

.storage-bar-fill {
    height: 100%;
    border-radius: 4px;
    background: var(--primary);
    transition: width 0.3s ease;
}

.storage-bar-fill.badge-ephemeral { background: #ef4444; }
.storage-bar-fill.badge-isolated { background: #f97316; }
.storage-bar-fill.badge-anonymous { background: #eab308; }
.storage-bar-fill.badge-normal { background: #22c55e; }
.storage-bar-fill.badge-public { background: #3b82f6; }

.storage-item-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Sovereignty Exports */
.sovereignty-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.sovereignty-info {
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    margin-bottom: 1rem;
    border-left: 3px solid var(--primary);
}

.sovereignty-info p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.exports-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.export-item {
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-radius: 6px;
    border: 1px solid var(--border);
}

.export-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.export-cid {
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.export-tier {
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-ipfs { background: #3b82f6; color: white; }
.badge-filecoin { background: #22c55e; color: white; }
.badge-local { background: #6b7280; color: white; }

.export-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.export-actions {
    display: flex;
    gap: 0.25rem;
    margin-top: 0.5rem;
}

/* Search Results */
#explorerSearchResults {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0 0 8px 8px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.search-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.search-result-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s;
}

.search-result-item:hover {
    background: var(--bg-tertiary);
}

.result-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.25rem;
}

.result-session {
    font-weight: 500;
    color: var(--text-primary);
}

.result-companion {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.result-snippet {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 0.25rem;
}

.result-snippet mark {
    background: rgba(234, 179, 8, 0.3);
    color: inherit;
    padding: 0 0.125rem;
    border-radius: 2px;
}

.result-meta {
    display: flex;
    gap: 0.75rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Modal */
.explorer-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.explorer-modal-content {
    background: var(--bg-secondary);
    padding: 2rem;
    border-radius: 12px;
    max-width: 400px;
    text-align: center;
}

.explorer-modal-content h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.qr-placeholder {
    padding: 1.5rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
    margin-bottom: 1rem;
}

.cid-display {
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.8rem;
    word-break: break-all;
    padding: 0.75rem;
    background: var(--bg-primary);
    border-radius: 4px;
    margin: 1rem 0;
}

.qr-note {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* Buttons */
.btn-icon {
    padding: 0.25rem 0.5rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

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

.btn-icon.btn-danger:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: #ef4444;
}

.btn-primary {
    padding: 0.5rem 1rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-primary:hover {
    filter: brightness(1.1);
}

.btn-secondary {
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

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

.btn-danger {
    padding: 0.5rem 1rem;
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid #ef4444;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

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

.btn-load-more {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px dashed var(--border);
    border-radius: 6px;
    cursor: pointer;
    margin-top: 0.5rem;
}

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

/* Responsive */
@media (max-width: 768px) {
    .explorer-main {
        flex-direction: column;
    }

    .explorer-list {
        width: 100%;
        max-height: 40vh;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .storage-overview {
        flex-direction: column;
        gap: 1rem;
    }
}
