/* ============================================
   MEMORY — SuperMemory Graph & Detail Views
   ============================================ */

/* ============================================
   MEMORY — SuperMemory Dashboard
   ============================================ */

.btn-memory {
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
    color: white;
    border: none;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-memory:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.4);
}

.btn-memory.active {
    background: linear-gradient(135deg, #0891b2 0%, #0e7490 100%);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15);
    transform: none;
}

[data-theme="dark"] .btn-memory {
    background: linear-gradient(135deg, #0891b2 0%, #0e7490 100%);
}

[data-theme="dark"] .btn-memory:hover {
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
}

.memory-dashboard {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    position: relative;
    background: var(--bg-card);
    border-radius: 8px;
    overflow: hidden;
}

.memory-header {
    flex: 0 0 auto;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-card);
}

.memory-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.memory-title {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.8px;
    color: var(--text-primary);
}

.memory-view-toggle {
    display: flex;
    gap: 2px;
    background: var(--tag-bg);
    border-radius: 6px;
    padding: 2px;
}

.memory-view-btn {
    background: transparent;
    border: none;
    padding: 5px 16px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.memory-view-btn.active {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.memory-close-btn {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

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

.memory-body {
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* Graph View */
.memory-graph-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
    background: #1a1b2e;
    overflow: hidden;
}

.memory-graph-wrapper canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Legend */
.memory-legend {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(26, 27, 46, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 14px;
    color: #e0e0e0;
    font-size: 11px;
    max-height: calc(100% - 24px);
    overflow-y: auto;
    min-width: 180px;
    backdrop-filter: blur(10px);
    z-index: 10;
}

.memory-legend h4 {
    font-size: 13px;
    letter-spacing: 0.5px;
    color: #fff;
    margin-bottom: 6px;
}

.memory-legend-title {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.2px;
    color: #888;
    margin-bottom: 3px;
    margin-top: 3px;
}

.memory-legend-section {
    margin-bottom: 10px;
}

.memory-legend-item {
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 2px 0;
    font-size: 11px;
    color: #ccc;
}

.memory-legend-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 3px 10px;
    font-size: 11px;
    color: #ccc;
}

.memory-legend-item.legend-clickable {
    cursor: pointer;
    padding: 2px 6px;
    margin: 1px -6px;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}

.memory-legend-item.legend-clickable:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.memory-legend-item.legend-active {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.legend-hint {
    font-size: 9px;
    color: #666;
    font-weight: 400;
    letter-spacing: 0;
}

.legend-clear {
    font-size: 10px;
    color: #ef4444;
    cursor: pointer;
    margin-left: auto;
    padding: 2px 6px;
    border-radius: 4px;
}

.legend-clear:hover {
    background: rgba(239, 68, 68, 0.2);
}

.memory-legend-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.memory-legend-arch {
    font-size: 10px;
    color: #888;
    font-family: monospace;
    margin: 0;
    display: inline;
}

.memory-legend-arch::after {
    content: ' · ';
    color: #555;
}

.memory-legend-arch:last-child::after {
    content: '';
}

/* Legend shapes */
.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-hex {
    width: 11px;
    height: 11px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    flex-shrink: 0;
}

.legend-hex-sm {
    width: 9px;
    height: 9px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    flex-shrink: 0;
}

.legend-square {
    width: 8px;
    height: 8px;
    border-radius: 1px;
    flex-shrink: 0;
}

.legend-diamond {
    width: 9px;
    height: 9px;
    transform: rotate(45deg);
    border-radius: 1px;
    flex-shrink: 0;
}

.legend-line {
    width: 18px;
    height: 2px;
    background: #666;
    flex-shrink: 0;
}

.legend-line-solid {
    width: 18px;
    height: 2px;
    flex-shrink: 0;
}

.legend-line-thick {
    width: 18px;
    height: 3px;
    flex-shrink: 0;
    border-radius: 1px;
}

.legend-line-dashed {
    width: 18px;
    height: 0;
    border-top: 2px dashed;
    flex-shrink: 0;
}

.legend-line-dotted {
    width: 18px;
    height: 0;
    border-top: 2px dotted;
    flex-shrink: 0;
}

/* Controls */
.memory-controls {
    position: absolute;
    bottom: 16px;
    left: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 10;
}

.memory-control-btn {
    width: 52px;
    height: 36px;
    background: rgba(26, 27, 46, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: #e0e0e0;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s ease;
}

.memory-control-btn:hover {
    background: rgba(40, 42, 65, 0.95);
    border-color: rgba(255, 255, 255, 0.25);
}

/* Tooltip */
.memory-tooltip {
    position: absolute;
    pointer-events: none;
    background: rgba(0, 0, 0, 0.88);
    color: #fff;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 11px;
    line-height: 1.5;
    z-index: 100;
    max-width: 260px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
}

/* Detail View */
.memory-detail-wrapper {
    display: grid;
    grid-template-columns: 200px 1fr;
    height: 100%;
    overflow: hidden;
}

.memory-agent-sidebar {
    border-right: 1px solid var(--border-light);
    overflow-y: auto;
    background: var(--bg-card);
}

.memory-agent-item {
    padding: 10px 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    transition: background 0.1s ease;
    border-bottom: 1px solid var(--border-subtle);
}

.memory-agent-item:hover {
    background: var(--tag-bg);
}

.memory-agent-item.active {
    background: var(--tag-bg);
    font-weight: 600;
    color: var(--text-primary);
}

.memory-agent-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.memory-agent-name {
    flex: 1;
}

.memory-agent-status {
    font-size: 10px;
}

.memory-agent-status.status-working {
    color: #10b981;
}

.memory-agent-status.status-offline {
    color: #666;
}

.memory-detail-content {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.memory-detail-header {
    flex: 0 0 auto;
    border-bottom: 1px solid var(--border-light);
}

.memory-detail-agent {
    padding: 12px 16px 0;
    font-size: 14px;
    font-weight: 700;
}

.memory-file-tabs {
    display: flex;
    padding: 0 16px;
}

.memory-file-tab {
    padding: 10px 16px 8px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    color: var(--text-muted);
    cursor: pointer;
    border: none;
    background: none;
    border-bottom: 2px solid transparent;
    transition: all 0.15s ease;
}

.memory-file-tab:hover {
    color: var(--text-secondary);
}

.memory-file-tab.active {
    color: var(--text-primary);
    border-bottom-color: var(--accent-orange);
}

.memory-detail-meta {
    display: flex;
    gap: 16px;
    padding: 8px 16px;
    font-size: 11px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-subtle);
}

.memory-block {
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 16px;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-y: auto;
    flex: 1;
    margin: 12px 16px;
}

.memory-editor {
    width: calc(100% - 32px);
    margin: 12px 16px;
    flex: 1;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 12px;
    line-height: 1.6;
    background: #1e1e1e;
    color: #d4d4d4;
    border: 2px solid #0891b2;
    border-radius: 8px;
    padding: 16px;
    resize: none;
    outline: none;
}

.memory-editor:focus {
    border-color: #06b6d4;
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15);
}

.memory-actions {
    display: flex;
    gap: 8px;
    padding: 10px 16px;
    border-top: 1px solid var(--border-light);
    flex: 0 0 auto;
}

.memory-action-btn {
    padding: 6px 16px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.memory-action-btn.edit {
    background: var(--tag-bg);
    color: var(--text-primary);
}

.memory-action-btn.edit:hover {
    background: #ddd;
}

.memory-action-btn.refresh {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-light);
}

.memory-action-btn.refresh:hover {
    border-color: var(--text-muted);
}

.memory-action-btn.save {
    background: #10b981;
    color: white;
}

.memory-action-btn.save:hover {
    background: #059669;
}

.memory-action-btn.cancel {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-light);
}

.memory-action-btn.cancel:hover {
    border-color: var(--text-muted);
}

[data-theme="dark"] .memory-action-btn.edit {
    background: #333;
    color: #eee;
}

[data-theme="dark"] .memory-action-btn.edit:hover {
    background: #444;
}

/* ==========================================
   MEMORY — All Agents View
   ========================================== */

.memory-all-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}

.memory-all-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.memory-all-scroll {
    overflow-y: auto;
    flex: 1;
    padding: 8px;
}

.memory-all-agent-section {
    border: 1px solid var(--border-light);
    border-radius: 8px;
    margin-bottom: 8px;
    overflow: hidden;
    background: var(--bg-secondary, #1a1b2e);
}

.memory-all-agent-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    cursor: pointer;
    background: rgba(255,255,255,0.03);
    transition: background 0.15s;
    user-select: none;
}

.memory-all-agent-header:hover {
    background: rgba(255,255,255,0.06);
}

.memory-all-agent-arrow {
    font-size: 10px;
    color: var(--text-muted);
    transition: transform 0.2s;
    width: 12px;
    text-align: center;
}

.memory-all-agent-arrow.collapsed {
    transform: rotate(-90deg);
}

.memory-all-agent-name {
    font-weight: 600;
    font-size: 13px;
    color: #fff;
}

.memory-all-agent-role {
    font-size: 11px;
    color: var(--text-muted);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.memory-all-agent-files {
    padding: 4px 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.memory-all-file-block {
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 6px;
    overflow: hidden;
}

.memory-all-file-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: rgba(255,255,255,0.02);
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.memory-all-file-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.memory-all-file-meta {
    display: flex;
    gap: 10px;
    font-size: 10px;
    color: var(--text-muted);
    flex: 1;
}

.memory-all-file-open {
    background: none;
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    transition: all 0.15s;
    flex-shrink: 0;
}

.memory-all-file-open:hover {
    background: rgba(255,255,255,0.08);
    color: #00d4aa;
    border-color: #00d4aa;
}

.memory-all-file-content {
    max-height: 300px;
    overflow-y: auto;
    font-size: 11px;
    line-height: 1.5;
    padding: 8px 10px;
    margin: 0;
    border-radius: 0;
}

.memory-all-file-content::-webkit-scrollbar {
    width: 4px;
}

.memory-all-file-content::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 2px;
}

.memory-agent-all .memory-agent-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
